index.vue 15 KB

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