index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. <template>
  2. <view>
  3. <u-navbar leftIconSize="0" title="盲票详情" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
  4. <view class="detail">
  5. <view class="detail-top">
  6. <u-swiper :list="picUrlArr" height="320" radius="0" :indicator="true" :circular="true"></u-swiper>
  7. </view>
  8. <view class="flex detail-info">
  9. <view class="detail-info__left">
  10. <text class="title">{{ boxInfo.title }}</text>
  11. <view class="flex num">
  12. <u-icon name="gift" size="25" color="#EB7009"></u-icon>
  13. <text>100%抽中,奖品多多</text>
  14. </view>
  15. <view class="tip">图片仅供参考,请以实物为准</view>
  16. </view>
  17. <view class="detail-info__right">
  18. <text class="money">¥{{ $numberFormat(boxInfo.salePrice) }}</text>
  19. <text>销量 {{ boxInfo.saleQty }}</text>
  20. </view>
  21. </view>
  22. <view class="detail-goods">
  23. <view class="detail-goods-title">可获得奖品</view>
  24. <view class="detail-goods-list">
  25. <!-- <navigator :url="`/pages/prizeGoods/detail?id=${ item.prizeId }`" class="detail-goods-list-item"
  26. hover-class="navigator-hover" v-for="(item, index) in prizeList" :key="index"> -->
  27. <view class="detail-goods-list-item" v-for="(item, index) in prizeList" :key="index">
  28. <view class="detail-goods-list-item__value">
  29. <view class="flex image-wrap">
  30. <image :src="item.picUrl" mode="scaleToFill"></image>
  31. </view>
  32. <view class="info">
  33. <text class="title">{{ item.title }}</text>
  34. <text class="num"
  35. v-if="item.prizeType != 'coin'">价值:¥{{ $numberFormat(item.value) }}</text>
  36. <text class="num" v-else>数量:{{ item.value }}个</text>
  37. <text class="num">概率:{{ item.hitRate }}%</text>
  38. </view>
  39. <view class="name">{{ item.name }}</view>
  40. </view>
  41. </view>
  42. <!-- </navigator> -->
  43. </view>
  44. </view>
  45. </view>
  46. <u-overlay :show="luckyShow" :opacity="0.8" zIndex="100">
  47. <view class="flex luck-warp" @touchmove.prevent.stop>
  48. <view class="luck-info">
  49. <view class="flex luck-info-image">
  50. <image class="image1" src="../../static/icon/lucky_bg.png" mode="" v-if="info.status == 1">
  51. </image>
  52. <image class="image2" src="../../static/icon/lucky_bg2.png" mode="" v-else></image>
  53. </view>
  54. <view
  55. :class="{ 'flex luck-info-content mat': info.status == 1, 'flex luck-info-content mat2': info.status != 1 }">
  56. <view class="title">幸运数字</view>
  57. <view class="name">{{ info.title }}</view>
  58. <view class="num">盲票序列号:{{ info.serialNo }}</view>
  59. </view>
  60. <view class="flex luck-info-tip" v-if="info.status == 2">
  61. <view class="tip">请刮开纸质票面的数字,与此幸运数字相同的就是所中奖项</view>
  62. </view>
  63. <view class="flex luck-info-btn">
  64. <view class="btn" @click="pay" v-if="info.status == 1">支付{{ info.salePrice / 100 }}元 立即查看</view>
  65. <view class="btn" @click="scanCode" v-else>扫码兑奖</view>
  66. </view>
  67. <view class="flex luck-info-num" v-if="info.status == 2">{{ info.plainLuckyNum }}</view>
  68. <view class="flex luck-info-close">
  69. <navigator open-type="exit" target="miniProgram" hover-class="none" class="flex">
  70. <u-icon name="close" color="#333" size="20"></u-icon>
  71. </navigator>
  72. </view>
  73. </view>
  74. </view>
  75. </u-overlay>
  76. <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="getDetailInfo" />
  77. <u-popup :show="showNull" :round="10" mode="center" :safeAreaInsetBottom="false" overlayOpacity="0.8"
  78. @touchmove.prevent.stop>
  79. <view class="null-prize">
  80. <view class="title">该盲票已兑奖</view>
  81. <navigator open-type="exit" target="miniProgram" hover-class="none" class="btn">确认</navigator>
  82. </view>
  83. </u-popup>
  84. <u-popup :show="showAction" :round="10" mode="center" :safeAreaInsetBottom="false" overlayOpacity="0.8"
  85. @touchmove.prevent.stop>
  86. <view class="null-prize">
  87. <view class="title">该盲票未激活</view>
  88. <navigator open-type="exit" target="miniProgram" hover-class="none" class="btn">确认</navigator>
  89. </view>
  90. </u-popup>
  91. <hch-poster ref="hchPoster" :posterData.sync="posterData" />
  92. </view>
  93. </template>
  94. <script>
  95. import env from '../../config/env.js'
  96. import $http from '@/utils/request.js'
  97. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  98. import HchPoster from "../../components/hch-poster/hch-poster.vue"
  99. export default {
  100. components: {
  101. PayPopup,
  102. HchPoster
  103. },
  104. data() {
  105. return {
  106. serialNo: '',
  107. info: '',
  108. payInfo: {},
  109. payShow: false,
  110. payLookFlag: true,
  111. showNull: false,
  112. posterData: {},
  113. luckyShow: true,
  114. status: 2,
  115. boxId: '',
  116. picUrlArr: [],
  117. boxInfo: {},
  118. prizeList: [],
  119. showAction: false,
  120. };
  121. },
  122. onLoad(options) {
  123. if (options.id) {
  124. console.log(options.id);
  125. this.serialNo = options.id
  126. }
  127. if (options.q) {
  128. let url = JSON.stringify(options.q)
  129. console.log(url);
  130. this.serialNo = url.substring(url.length - 22, url.length - 1)
  131. }
  132. },
  133. onShow() {
  134. if (this.serialNo && this.payLookFlag) {
  135. this.getDetail()
  136. }
  137. },
  138. methods: {
  139. scanCode() {
  140. let _this = this
  141. uni.scanCode({
  142. scanType: ['qrCode'],
  143. success(res) {
  144. let url = res.result
  145. _this.serialNo = url.substring(url.length - 21, url.length)
  146. _this.getDetail()
  147. },
  148. fail(){
  149. uni.$u.toast('请扫二维码');
  150. }
  151. });
  152. },
  153. getDetail() {
  154. uni.showLoading({
  155. title: '加载中'
  156. });
  157. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  158. serialNo: this.serialNo,
  159. noToken: true
  160. }).then(res => {
  161. uni.hideLoading();
  162. if (res.code == 0) {
  163. this.getBoxDetail(res.data.boxId)
  164. if (res.data.status == 1) {
  165. this.info = res.data
  166. } else if (res.data.status == 2) {
  167. this.info = res.data
  168. if (uni.getStorageSync('token')) {
  169. uni.redirectTo({
  170. url: `/pages/choice/index?id=${ res.data.ticketId }`
  171. })
  172. } else {
  173. uni.showModal({
  174. title: '提示',
  175. content: '您未登录或登录失效!',
  176. confirmText: '去登录',
  177. showCancel: false,
  178. success(res) {
  179. if (res.confirm) {
  180. uni.navigateTo({
  181. url: "/pages/login/index"
  182. })
  183. }
  184. }
  185. })
  186. }
  187. } else {
  188. this.showNull = true
  189. this.luckyShow = false
  190. }
  191. } else if (res.code == 1023) {
  192. this.showAction = true
  193. this.luckyShow = false
  194. } else {
  195. uni.$u.toast('该盲票不存在!');
  196. setTimeout(() => {
  197. uni.switchTab({
  198. url: '/pages/index/index'
  199. })
  200. }, 1000)
  201. }
  202. }).catch(() => {
  203. uni.hideLoading();
  204. })
  205. },
  206. getDetailInfo() {
  207. let _this = this
  208. _this.payShow = false
  209. uni.showLoading({
  210. title: '加载中'
  211. });
  212. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  213. serialNo: _this.serialNo,
  214. noToken: true
  215. }).then(res => {
  216. uni.hideLoading();
  217. if (res.code == 0) {
  218. if (res.data.status == 2) {
  219. _this.info = res.data
  220. let num = res.data.plainLuckyNum
  221. } else {
  222. let num = 0
  223. let time = setInterval(() => {
  224. num++
  225. uni.showLoading({
  226. title: '加载中'
  227. });
  228. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  229. serialNo: _this.serialNo,
  230. noToken: true
  231. }).then(ele => {
  232. if (ele.data.status == 2) {
  233. uni.hideLoading();
  234. clearInterval(time)
  235. _this.info = res.data
  236. let num = res.data.plainLuckyNum
  237. }
  238. })
  239. if (num == 10) {
  240. uni.hideLoading();
  241. clearInterval(time)
  242. }
  243. }, 1000)
  244. }
  245. }
  246. }).catch(() => {
  247. uni.hideLoading();
  248. })
  249. },
  250. getBoxDetail(id) {
  251. uni.showLoading({
  252. title: '加载中'
  253. });
  254. $http.post('/api/v1/mp/user/mall/ticket/detail', {
  255. boxId: id,
  256. noToken: true
  257. }).then(res => {
  258. uni.hideLoading();
  259. if (res.code == 0) {
  260. this.boxInfo = res.data
  261. let picUrlArr = res.data.picUrl.split(',')
  262. picUrlArr.forEach(item => {
  263. this.picUrlArr.push(env.filePublic + item)
  264. })
  265. let prizeList = res.data.prizeList
  266. prizeList.forEach(item => {
  267. let picUrlArr = item.picUrl.split(',')
  268. item.picUrl = env.filePublic + picUrlArr[0]
  269. })
  270. this.prizeList = prizeList
  271. }
  272. }).catch(() => {
  273. uni.hideLoading();
  274. })
  275. },
  276. close() {
  277. this.payShow = false
  278. },
  279. pay() {
  280. let data = {
  281. ticketId: this.info.ticketId,
  282. autoCoupon: 1
  283. }
  284. this.payLookFlag = false
  285. uni.showLoading({
  286. title: '加载中'
  287. });
  288. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  289. uni.hideLoading();
  290. if (res.code == 0) {
  291. let info = {
  292. ...res.data,
  293. ...this.info,
  294. picUrl: env.filePublic + res.data.picUrl,
  295. }
  296. this.payInfo = info
  297. this.payShow = true
  298. }
  299. }).catch(() => {
  300. uni.hideLoading();
  301. })
  302. },
  303. saveImg() {
  304. this.$refs.hchPoster.posterShow()
  305. },
  306. }
  307. }
  308. </script>
  309. <style lang="scss" scoped>
  310. .luck-warp {
  311. height: 100%;
  312. .luck-info {
  313. position: relative;
  314. width: 85%;
  315. border-radius: 40rpx;
  316. background-color: #fff;
  317. .luck-info-image {
  318. // margin-bottom: 30rpx;
  319. .image1 {
  320. width: 400rpx;
  321. height: 400rpx;
  322. margin-top: -200rpx;
  323. }
  324. .image2 {
  325. width: 700rpx;
  326. height: 700rpx;
  327. margin-top: -446rpx;
  328. // padding-bottom: 50rpx;
  329. }
  330. }
  331. .luck-info-tip {
  332. .tip {
  333. width: 460rpx;
  334. height: 100rpx;
  335. line-height: 50rpx;
  336. font-size: 24rpx;
  337. padding: 0 26rpx;
  338. color: #666666;
  339. text-align: center;
  340. border-radius: 10rpx;
  341. background: rgba(255, 109, 28, 0.2);
  342. }
  343. }
  344. .luck-info-content {
  345. flex-direction: column;
  346. .title {
  347. line-height: 68rpx;
  348. font-size: 48rpx;
  349. color: #FA6401;
  350. font-size: 60rpx;
  351. font-weight: bold;
  352. margin-bottom: 72rpx;
  353. }
  354. .name {
  355. font-size: 40rpx;
  356. line-height: 56rpx;
  357. margin-bottom: 20rpx;
  358. }
  359. .num {
  360. font-size: 32rpx;
  361. color: #666666;
  362. line-height: 44rpx;
  363. }
  364. }
  365. .mat {
  366. margin-bottom: 140rpx;
  367. }
  368. .mat2 {
  369. margin-bottom: 20rpx;
  370. }
  371. .luck-info-btn {
  372. margin-top: 20rpx;
  373. .btn {
  374. width: 530rpx;
  375. height: 100rpx;
  376. line-height: 100rpx;
  377. color: #FFFFFF;
  378. font-size: 48rpx;
  379. text-align: center;
  380. border-radius: 200rpx;
  381. background: linear-gradient(180deg, #FFB266 0%, #FFB266 0%, #FF843A 100%, #FF843A 100%);
  382. box-shadow: 0px 4px 10px 0px rgba(182, 85, 24, 0.6);
  383. margin-bottom: 72rpx;
  384. }
  385. }
  386. .luck-info-num {
  387. position: absolute;
  388. top: -280rpx;
  389. width: 100%;
  390. font-size: 260rpx;
  391. font-family: LucidaSans-Demi, LucidaSans;
  392. color: #FFBD4E;
  393. text-shadow: 1px 1px rgba(255, 255, 255, .7);
  394. font-weight: bold;
  395. }
  396. .luck-info-close {
  397. position: absolute;
  398. width: 70rpx;
  399. height: 70rpx;
  400. background-color: #b9b9b9;
  401. border-radius: 50%;
  402. right: 10rpx;
  403. top: -80rpx;
  404. }
  405. }
  406. }
  407. .detail {
  408. padding-bottom: 100rpx;
  409. &-top {
  410. margin-bottom: 20rpx;
  411. }
  412. &-info {
  413. justify-content: space-between;
  414. box-sizing: border-box;
  415. padding: 24rpx 16rpx;
  416. background-color: #fff;
  417. margin: 10rpx 10rpx 20rpx;
  418. border-radius: 10rpx;
  419. &__left {
  420. display: flex;
  421. flex-direction: column;
  422. justify-content: space-between;
  423. text {
  424. line-height: 24rpx;
  425. display: inline-block;
  426. }
  427. .title {
  428. color: rgba(16, 16, 16, 100);
  429. font-size: 32rpx;
  430. line-height: 32rpx;
  431. font-weight: bold;
  432. }
  433. .num {
  434. color: $uni-text-color;
  435. font-size: 28rpx;
  436. justify-content: flex-start;
  437. margin: 20rpx 0;
  438. }
  439. .tip {
  440. font-size: 24rpx;
  441. }
  442. }
  443. &__right {
  444. display: flex;
  445. flex-direction: column;
  446. align-items: flex-end;
  447. justify-content: space-between;
  448. height: 162rpx;
  449. text {
  450. color: rgba(157, 157, 157, 100);
  451. font-size: 14px;
  452. }
  453. .money {
  454. font-size: 40rpx;
  455. font-weight: bold;
  456. line-height: 40rpx;
  457. font-weight: bold;
  458. color: $uni-text-color;
  459. margin-bottom: 40rpx;
  460. }
  461. }
  462. }
  463. &-sku {
  464. background-color: #fff;
  465. border-radius: 10rpx;
  466. margin: 10rpx 10rpx 20rpx;
  467. &-title {
  468. padding: 24rpx 16rpx 12rpx;
  469. }
  470. &-item {
  471. padding-bottom: 10rpx;
  472. view {
  473. padding-left: 50rpx;
  474. line-height: 50rpx;
  475. }
  476. }
  477. }
  478. &-goods {
  479. margin: 10rpx 10rpx 20rpx;
  480. &-title {
  481. margin-bottom: 20rpx;
  482. }
  483. &-list {
  484. padding-bottom: 100rpx;
  485. &-item {
  486. position: relative;
  487. background-color: #FFFFFF;
  488. margin-bottom: 30rpx;
  489. border-radius: 10rpx;
  490. padding: 30rpx 20rpx;
  491. &__value {
  492. display: flex;
  493. }
  494. image {
  495. width: 200rpx;
  496. height: 200rpx;
  497. }
  498. .name {
  499. position: absolute;
  500. left: 0rpx;
  501. top: 0rpx;
  502. line-height: 28rpx;
  503. padding: 10rpx 40rpx;
  504. color: #FFFFFF;
  505. border-top-left-radius: 10rpx;
  506. border-bottom-right-radius: 40rpx;
  507. background-color: $uni-bg-color;
  508. }
  509. .info {
  510. display: flex;
  511. flex-direction: column;
  512. justify-content: space-between;
  513. font-size: 30rpx;
  514. padding-left: 50rpx;
  515. .title {
  516. font-weight: bold;
  517. }
  518. .num {
  519. color: #848484;
  520. }
  521. }
  522. }
  523. &-item:last-child {
  524. border: none;
  525. }
  526. }
  527. }
  528. }
  529. .null-prize {
  530. display: flex;
  531. flex-direction: column;
  532. align-items: center;
  533. justify-content: center;
  534. width: 80vw;
  535. height: 320rpx;
  536. background-color: #FFFFFF;
  537. border: 1px solid rgba(187, 187, 187, 100);
  538. .btn {
  539. margin-top: 60rpx;
  540. width: 160rpx;
  541. height: 60rpx;
  542. line-height: 60rpx;
  543. border-radius: 8rpx;
  544. background-color: rgba(235, 112, 9, 100);
  545. color: rgba(255, 255, 255, 100);
  546. font-size: 28rpx;
  547. text-align: center;
  548. }
  549. }
  550. </style>