index.vue 15 KB

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