index.vue 17 KB

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