index.vue 15 KB

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