index.vue 17 KB

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