index.vue 17 KB

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