index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. <template>
  2. <view>
  3. <u-popup :show="tipShow" :round="10" mode="center" :safeAreaInsetBottom="false">
  4. <view class="null-prize">
  5. <view class="title">该盲票已被他人买走了</view>
  6. <!-- <navigator open-type="exit" target="miniProgram" hover-class="none" class="btn">确认</navigator> -->
  7. <view class="btn" @click="toUser">确认</view>
  8. </view>
  9. </u-popup>
  10. <view class="choice">
  11. <!-- 返回 -->
  12. <view class="choice-navLeft flex" :style="{ top: statusHeight + 'px' }" @click="back">
  13. <u-icon size="19" color="#fff" name="arrow-left"></u-icon>
  14. </view>
  15. <!-- 标题 -->
  16. <view class="choice-title flex">
  17. <image src="../../packagePrize/static/rolling_title.png" mode="scaleToFill" v-if="!comfirmShow"></image>
  18. <image src="../../packagePrize/static/choice_title.png" mode="scaleToFill" v-else></image>
  19. </view>
  20. <!-- 提示 -->
  21. <view class="choice-tip flex" v-if="!comfirmShow">
  22. <view class="choice-tip-content">以下奖品任选一件</view>
  23. </view>
  24. <!-- 奖品列表 -->
  25. <view class="choice-list" v-if="!comfirmShow">
  26. <view class="choice-list-item flex" v-for="(item, index) in prizeList" :key="index">
  27. <view class="checkbox flex" :class="{ 'checkbox-action': actionIndex == index }" @click="selectPrize(index)">
  28. <u-icon name="checkmark" color="#fff" size="14"></u-icon>
  29. </view>
  30. <view class="info flex" @click="selectPrize(index)">
  31. <image :src="item.picUrl" mode="aspectFill"></image>
  32. <view class="info-content flex">
  33. <view class="info-content__title ells-one" v-if="item.prizeType && item.prizeType.value != 'coin'">{{ item.title }}</view>
  34. <view class="info-content__title ells-one" v-else>盲豆</view>
  35. <view class="info-content__price" v-if="item.prizeType && item.prizeType.value != 'coin'">¥{{ $numberFormat(item.value) }}</view>
  36. <view class="info-content__price" v-else>{{ item.value }}个</view>
  37. </view>
  38. </view>
  39. <view class="detail" @click="toPrizeGoods(item)">查看</view>
  40. </view>
  41. </view>
  42. <!-- 按钮 -->
  43. <view class="footer-fixed flex" v-if="!comfirmShow">
  44. <view class="footer-fixed-btn flex" @click="confirmPrize">
  45. <image src="../../packagePrize/static/rolling_btn.png" mode="aspectFit"></image>
  46. <view class="footer-fixed-btn-txt">确认</view>
  47. </view>
  48. </view>
  49. <view class="choice-box flex" v-if="comfirmShow">
  50. <view class="choice-box-popup flex">
  51. <view class="choice-box-popup__image flex">
  52. <image :src="actionInfo.picUrl" mode="aspectFit"></image>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="choice-info flex" v-if="comfirmShow">
  57. <view class="choice-info-content">
  58. <view class="choice-info-content-price" v-if="actionInfo.prizeType && actionInfo.prizeType.value != 'coin'"><text>¥</text>{{ $numberFormat(actionInfo.value) }}</view>
  59. <view class="choice-info-content-price" v-else>{{ actionInfo.value }}个</view>
  60. <view class="choice-info-content-title ells-one" v-if="actionInfo.prizeType && actionInfo.prizeType.value != 'coin'">{{ actionInfo.title }}</view>
  61. <view class="choice-info-content-title" v-else>盲豆</view>
  62. <view class="choice-info-content-btn flex">
  63. <view class="choice-info-content-btn-content flex" @click="toPrize(actionInfo.prizeType)">
  64. <image src="../../packagePrize/static/rolling_btn.png" mode="aspectFit"></image>
  65. <view class="choice-info-content-btn-content-txt" v-if="actionInfo.prizeType && actionInfo.prizeType.value != 'coin'">哇,去瞅瞅我的宝贝</view>
  66. <view class="choice-info-content-btn-content-txt" v-else>哇,去商城兑换商品</view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="choice-tip flex" @click="again" v-if="comfirmShow">
  72. <view class="txt">再来一张</view>
  73. </view>
  74. </view>
  75. <!-- 详情 -->
  76. <u-popup :show="detailShow" :round="11" mode="bottom" @close="detailShow = false" :closeable="true">
  77. <view class="prize-detail flex">
  78. <view class="prize-detail-title">奖品详情</view>
  79. <view class="prize-detail-content">
  80. <u-parse :content="description" :selectable="true"></u-parse>
  81. </view>
  82. </view>
  83. </u-popup>
  84. </view>
  85. </template>
  86. <script>
  87. import env from '../../config/env.js'
  88. import $http from '@/utils/request.js'
  89. import { formatRichText } from '@/utils/util.js'
  90. export default {
  91. data() {
  92. return {
  93. ticketId: '',
  94. prizeList: [],
  95. total: 0,
  96. actionIndex: 0,
  97. tipShow: false,
  98. comfirmShow: false,
  99. actionInfo: {},
  100. type: '',
  101. statusHeight: 30,
  102. detailShow: false,
  103. description: '',
  104. };
  105. },
  106. onLoad(options) {
  107. this.ticketId = options.id
  108. this.type = options.type
  109. // #ifdef MP-WEIXIN
  110. const res = uni.getMenuButtonBoundingClientRect()
  111. this.statusHeight = res.top //胶囊距离顶部
  112. // #endif
  113. this.getPrizeList()
  114. },
  115. methods: {
  116. getPrizeList() {
  117. uni.showLoading({
  118. title: '加载中'
  119. });
  120. let data = {
  121. ticketId: this.ticketId
  122. }
  123. $http.post('/api/v1/mp/user/ticket/queryHitPrizeList', data).then(res => {
  124. uni.hideLoading();
  125. if (res.code == 0) {
  126. res.data.prizeList.forEach(item => {
  127. let picUrlArr = item.picUrl.split(',')
  128. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/340'
  129. item.prizeType = JSON.parse(item.prizeType)
  130. })
  131. this.prizeList = res.data.prizeList
  132. if(this.prizeList.length == 1) {
  133. let item = this.prizeList[this.actionIndex]
  134. this.actionInfo = item
  135. $http.post('/api/v1/mp/user/ticket/cashPrize', {
  136. ticketId: this.ticketId,
  137. awardsId: item.awardsId,
  138. prizeId: item.prizeId
  139. }).then(res => {
  140. if (res.code == 0) {
  141. this.comfirmShow = true
  142. }
  143. })
  144. }
  145. this.ticketId = res.data.ticketId
  146. this.total = this.prizeList.length
  147. } else if (res.code == 1018) {
  148. this.tipShow = true
  149. } else {
  150. this.tipShow = true
  151. }
  152. }).catch(() => {
  153. uni.hideLoading();
  154. })
  155. },
  156. selectPrize(index) {
  157. this.actionIndex = index
  158. },
  159. confirmPrize() {
  160. let _this = this
  161. let item = _this.prizeList[_this.actionIndex]
  162. _this.actionInfo = item
  163. if (_this.prizeList.length > 1) {
  164. uni.showModal({
  165. title: '提示',
  166. content: '确定选择该奖品吗?',
  167. success(res) {
  168. if (res.confirm) {
  169. $http.post('/api/v1/mp/user/ticket/cashPrize', {
  170. ticketId: _this.ticketId,
  171. awardsId: item.awardsId,
  172. prizeId: item.prizeId
  173. }).then(res => {
  174. if (res.code == 0) {
  175. _this.comfirmShow = true
  176. }
  177. })
  178. }
  179. }
  180. })
  181. } else {
  182. $http.post('/api/v1/mp/user/ticket/cashPrize', {
  183. ticketId: _this.ticketId,
  184. awardsId: item.awardsId,
  185. prizeId: item.prizeId
  186. }).then(res => {
  187. if (res.code == 0) {
  188. _this.comfirmShow = true
  189. }
  190. })
  191. }
  192. },
  193. toIndex() {
  194. uni.switchTab({
  195. url: '/pages/index/index'
  196. })
  197. },
  198. back() {
  199. let pages = getCurrentPages();
  200. if (pages.length > 1) {
  201. uni.navigateBack({
  202. delta: 1
  203. })
  204. } else {
  205. uni.switchTab({
  206. url: '/pages/core/index'
  207. })
  208. }
  209. },
  210. toPrize(data) {
  211. if (data.value == 'goods') {
  212. uni.redirectTo({
  213. url: '/packagePrize/prize/index'
  214. })
  215. }
  216. if (data.value == 'coupon') {
  217. uni.redirectTo({
  218. url: '/packagePrize/prize/index?coupon=1'
  219. })
  220. }
  221. if (data.value == 'coupon_pkg') {
  222. uni.redirectTo({
  223. url: '/packagePrize/prize/index?coupon=1'
  224. })
  225. }
  226. if (data.value == 'coin') {
  227. uni.switchTab({
  228. url: '/pages/core/index'
  229. })
  230. }
  231. },
  232. toPrizeGoods(item) {
  233. if (item.prizeType.value == "goods") {
  234. this.getGoodsDetail(item.refId)
  235. }
  236. //门店优惠券
  237. if (item.prizeType.value == "coupon" || item.prizeType.value == "coupon_pkg") {
  238. this.getGoodsDetail(425)
  239. }
  240. // 盲豆
  241. if (item.prizeType.value == "coin") {
  242. this.getGoodsDetail(424)
  243. }
  244. },
  245. toUser() {
  246. uni.switchTab({
  247. url: '/pages/user/index'
  248. })
  249. },
  250. getGoodsDetail(id) {
  251. uni.showLoading({
  252. title: '加载中'
  253. });
  254. $http.post('/api/v1/mp/user/exchange/goods/detail', {
  255. noToken: true,
  256. goodsId: id
  257. }).then(res => {
  258. uni.hideLoading();
  259. if (res.code == 0) {
  260. this.detailShow = true
  261. // 处理富文本
  262. const description = res.data.description.replaceAll(".jpg\"", ".jpg?imageView2/2/w/750\"")
  263. .replaceAll(".jpeg\"", ".jpeg?imageView2/2/w/750\"").replaceAll(".png\"",
  264. ".png?imageView2/2/w/750\"");
  265. this.description = formatRichText(description);
  266. }
  267. }).catch(() => {
  268. uni.hideLoading();
  269. })
  270. },
  271. again() {
  272. let _this = this
  273. if(this.type == 'onLine') {
  274. uni.switchTab({
  275. url: '/pages/index/index'
  276. })
  277. } else {
  278. uni.scanCode({
  279. scanType: ['qrCode'],
  280. success(res) {
  281. const url = res.result
  282. let serialNo = url.substring(url.length - 21, url.length)
  283. uni.redirectTo({
  284. url: `/pages/lucky/index?id=${ serialNo }&type=offLine`
  285. })
  286. },
  287. fail() {
  288. uni.$u.toast('请扫二维码');
  289. }
  290. });
  291. }
  292. },
  293. }
  294. }
  295. </script>
  296. <style lang="scss" scoped>
  297. .choice {
  298. display: flex;
  299. flex-direction: column;
  300. position: relative;
  301. width: 100%;
  302. height: 100vh;
  303. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/offline_prize_bkg.png) center center no-repeat;
  304. background-size: 100vw 100vh;
  305. overflow: hidden;
  306. // 返回
  307. &-navLeft {
  308. position: absolute;
  309. left: 34rpx;
  310. width: 66rpx;
  311. height: 66rpx;
  312. background-color: rgba(255, 255, 255, .36);
  313. border-radius: 50%;
  314. }
  315. // 标题
  316. &-title {
  317. padding-top: 15vh;
  318. margin-bottom: 72rpx;
  319. image {
  320. width: 484rpx;
  321. height: 108rpx;
  322. }
  323. }
  324. // 提示
  325. &-tip {
  326. &-content {
  327. width: 50vw;
  328. height: 56rpx;
  329. line-height: 56rpx;
  330. background: rgba(255, 211, 157, .44);
  331. border-radius: 24rpx;
  332. color: #FB900B;
  333. font-size: 30rpx;
  334. text-align: center;
  335. }
  336. }
  337. // 奖品列表
  338. &-list {
  339. flex: 1;
  340. margin: 72rpx 48rpx 0;
  341. padding-bottom: 200rpx;
  342. overflow-y: auto;
  343. &-item {
  344. justify-content: space-between;
  345. background-color: #fff;
  346. border-radius: 12rpx;
  347. padding: 38rpx 24rpx;
  348. margin-bottom: 54rpx;
  349. .checkbox {
  350. width: 46rpx;
  351. height: 46rpx;
  352. border: 1px solid #F56D1B;
  353. border-radius: 50%;
  354. }
  355. .checkbox-action {
  356. background: #F56D1B;
  357. }
  358. .info {
  359. margin: 0 30rpx;
  360. flex: 1;
  361. justify-content: flex-start;
  362. image {
  363. width: 110rpx;
  364. height: 110rpx;
  365. margin-right: 34rpx;
  366. }
  367. &-content {
  368. height: 110rpx;
  369. flex: 1;
  370. align-items: flex-start;
  371. flex-direction: column;
  372. justify-content: space-between;
  373. &__title {
  374. width: 100%;
  375. font-size: 30rpx;
  376. }
  377. &__price {
  378. font-weight: bold;
  379. }
  380. }
  381. }
  382. .detail {
  383. color: #F56D1B;
  384. }
  385. }
  386. }
  387. &-box {
  388. margin-bottom: 34rpx;
  389. &-popup {
  390. flex-direction: column;
  391. width: 75vw;
  392. height: 38vh;
  393. background-color: #FFFFFF;
  394. border-radius: 22rpx;
  395. &__image {
  396. width: 65%;
  397. height: 65%;
  398. image {
  399. width: 100%;
  400. height: 100%;
  401. }
  402. }
  403. }
  404. }
  405. &-info {
  406. margin-bottom: 40rpx;
  407. &-content {
  408. width: 70vw;
  409. &-price {
  410. text-align: center;
  411. font-size: 40rpx;
  412. line-height: 40rpx;
  413. font-family: PingFang SC;
  414. font-weight: bold;
  415. color: #FFFFFF;
  416. margin-bottom: 20rpx;
  417. text {
  418. font-size: 28rpx;
  419. }
  420. }
  421. &-title {
  422. height: 36rpx;
  423. overflow: hidden;
  424. text-align: center;
  425. font-size: 36rpx;
  426. line-height: 36rpx;
  427. color: #FFFFFF;
  428. margin-bottom: 40rpx;
  429. }
  430. &-btn {
  431. &-content {
  432. position: relative;
  433. width: 70vw;
  434. image {
  435. width: 70vw;
  436. height: 112rpx;
  437. }
  438. &-txt {
  439. position: absolute;
  440. top: 0;
  441. height: 112rpx;
  442. line-height: 112rpx;
  443. font-size: 30rpx;
  444. text-align: center;
  445. color: #FFFFFF;
  446. }
  447. }
  448. }
  449. }
  450. }
  451. &-tip {
  452. .txt {
  453. width: 332rpx;
  454. height: 66rpx;
  455. line-height: 66rpx;
  456. text-align: center;
  457. background: rgba(255, 211, 157, .3);
  458. border-radius: 34rpx;
  459. font-size: 34rpx;
  460. font-weight: 500;
  461. color: #FB930D;
  462. }
  463. }
  464. }
  465. // 按钮
  466. .footer-fixed {
  467. position: fixed;
  468. bottom: var(--window-bottom);
  469. left: 0;
  470. right: 0;
  471. z-index: 11;
  472. // 设置ios刘海屏底部横线安全区域
  473. padding-bottom: constant(safe-area-inset-bottom);
  474. padding-bottom: env(safe-area-inset-bottom);
  475. &-btn {
  476. padding: 0 0 20rpx;
  477. position: relative;
  478. width: 70vw;
  479. image {
  480. width: 70vw;
  481. height: 112rpx;
  482. }
  483. &-txt {
  484. position: absolute;
  485. top: 0;
  486. height: 112rpx;
  487. line-height: 112rpx;
  488. font-size: 30rpx;
  489. text-align: center;
  490. color: #FFFFFF;
  491. }
  492. }
  493. .btn {
  494. padding: 20rpx 0;
  495. /deep/ button {
  496. width: 640rpx;
  497. height: 90rpx;
  498. line-height: 90rpx;
  499. font-size: 36rpx;
  500. color: #fff;
  501. background-color: $uni-bg-color;
  502. border: none;
  503. border-radius: 20rpx;
  504. }
  505. }
  506. }
  507. .prize-detail {
  508. flex-direction: column;
  509. height: 60vh;
  510. &-title {
  511. padding: 40rpx 0;
  512. text-align: center;
  513. font-size: 34rpx;
  514. line-height: 34rpx;
  515. font-weight: bold;
  516. }
  517. &-content {
  518. width: 100vw;
  519. flex: 1;
  520. overflow-y: auto;
  521. }
  522. }
  523. .null-prize {
  524. display: flex;
  525. flex-direction: column;
  526. align-items: center;
  527. justify-content: center;
  528. width: 80vw;
  529. height: 320rpx;
  530. background-color: #FFFFFF;
  531. border: 1px solid rgba(187, 187, 187, 100);
  532. .btn {
  533. margin-top: 60rpx;
  534. width: 160rpx;
  535. height: 60rpx;
  536. line-height: 60rpx;
  537. border-radius: 8rpx;
  538. background-color: rgba(235, 112, 9, 100);
  539. color: rgba(255, 255, 255, 100);
  540. font-size: 28rpx;
  541. text-align: center;
  542. }
  543. }
  544. .confirm-prize {
  545. display: flex;
  546. flex-direction: column;
  547. align-items: center;
  548. justify-content: center;
  549. width: 80vw;
  550. padding: 40rpx 0;
  551. &-info {
  552. width: 80%;
  553. margin-bottom: 60rpx;
  554. justify-content: space-around;
  555. image {
  556. width: 150rpx;
  557. height: 200rpx;
  558. }
  559. .title {
  560. flex: 1;
  561. padding-left: 40rpx;
  562. }
  563. }
  564. &-tip {
  565. text-align: center;
  566. margin-bottom: 60rpx;
  567. text {
  568. padding-left: 24rpx;
  569. color: rgba(32, 163, 242, 100);
  570. }
  571. }
  572. &-btn {
  573. width: 80%;
  574. justify-content: space-around;
  575. .back {
  576. width: 160rpx;
  577. height: 60rpx;
  578. line-height: 60rpx;
  579. border-radius: 8rpx;
  580. color: rgba(235, 112, 9, 100);
  581. font-size: 28rpx;
  582. text-align: center;
  583. font-family: Microsoft Yahei;
  584. border: 1px solid rgba(235, 112, 9, 100);
  585. }
  586. .confirm {
  587. width: 160rpx;
  588. height: 60rpx;
  589. line-height: 60rpx;
  590. border-radius: 8rpx;
  591. background-color: rgba(235, 112, 9, 100);
  592. color: rgba(253, 253, 253, 100);
  593. font-size: 28rpx;
  594. text-align: center;
  595. }
  596. }
  597. }
  598. </style>