index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  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. this.serialNo = options.id
  125. }
  126. if (options.q) {
  127. let url = JSON.stringify(options.q)
  128. this.serialNo = url.substring(url.length - 22, url.length - 1)
  129. }
  130. },
  131. onShow() {
  132. if (this.serialNo && this.payLookFlag) {
  133. this.getDetail()
  134. }
  135. },
  136. methods: {
  137. scanCode() {
  138. let _this = this
  139. uni.scanCode({
  140. scanType: ['qrCode'],
  141. success(res) {
  142. let url = res.result
  143. _this.serialNo = url.substring(url.length - 21, url.length)
  144. _this.getDetail()
  145. },
  146. fail(){
  147. uni.$u.toast('请扫二维码');
  148. }
  149. });
  150. },
  151. getDetail() {
  152. uni.showLoading({
  153. title: '加载中'
  154. });
  155. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  156. serialNo: this.serialNo,
  157. noToken: true
  158. }).then(res => {
  159. uni.hideLoading();
  160. if (res.code == 0) {
  161. this.getBoxDetail(res.data.boxId)
  162. if (res.data.status == 1) {
  163. this.info = res.data
  164. } else if (res.data.status == 2) {
  165. this.info = res.data
  166. if (uni.getStorageSync('token')) {
  167. uni.redirectTo({
  168. url: `/pages/choice/index?id=${ res.data.ticketId }&type=offLine`
  169. })
  170. } else {
  171. uni.showModal({
  172. title: '提示',
  173. content: '您未登录或登录失效!',
  174. confirmText: '去登录',
  175. showCancel: false,
  176. success(res) {
  177. if (res.confirm) {
  178. uni.navigateTo({
  179. url: "/pages/login/index"
  180. })
  181. }
  182. }
  183. })
  184. }
  185. } else {
  186. this.showNull = true
  187. this.luckyShow = false
  188. }
  189. } else if (res.code == 1023) {
  190. this.showAction = true
  191. this.luckyShow = false
  192. } else {
  193. uni.$u.toast('该盲票不存在!');
  194. setTimeout(() => {
  195. uni.switchTab({
  196. url: '/pages/index/index'
  197. })
  198. }, 1000)
  199. }
  200. }).catch(() => {
  201. uni.hideLoading();
  202. })
  203. },
  204. getDetailInfo() {
  205. let _this = this
  206. _this.payShow = false
  207. uni.showLoading({
  208. title: '加载中'
  209. });
  210. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  211. serialNo: _this.serialNo,
  212. noToken: true
  213. }).then(res => {
  214. uni.hideLoading();
  215. if (res.code == 0) {
  216. if (res.data.status == 2) {
  217. _this.info = res.data
  218. let num = res.data.plainLuckyNum
  219. } else {
  220. let num = 0
  221. let time = setInterval(() => {
  222. num++
  223. uni.showLoading({
  224. title: '加载中'
  225. });
  226. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  227. serialNo: _this.serialNo,
  228. noToken: true
  229. }).then(ele => {
  230. if (ele.data.status == 2) {
  231. uni.hideLoading();
  232. clearInterval(time)
  233. _this.info = res.data
  234. let num = res.data.plainLuckyNum
  235. }
  236. })
  237. if (num == 10) {
  238. uni.hideLoading();
  239. clearInterval(time)
  240. }
  241. }, 1000)
  242. }
  243. }
  244. }).catch(() => {
  245. uni.hideLoading();
  246. })
  247. },
  248. getBoxDetail(id) {
  249. uni.showLoading({
  250. title: '加载中'
  251. });
  252. $http.post('/api/v1/mp/user/mall/ticket/detail', {
  253. boxId: id,
  254. noToken: true
  255. }).then(res => {
  256. uni.hideLoading();
  257. if (res.code == 0) {
  258. this.boxInfo = res.data
  259. let picUrlArr = res.data.picUrl.split(',')
  260. picUrlArr.forEach(item => {
  261. this.picUrlArr.push(env.filePublic + item)
  262. })
  263. let prizeList = res.data.prizeList
  264. prizeList.forEach(item => {
  265. let picUrlArr = item.picUrl.split(',')
  266. item.picUrl = env.filePublic + picUrlArr[0]
  267. })
  268. this.prizeList = prizeList
  269. }
  270. }).catch(() => {
  271. uni.hideLoading();
  272. })
  273. },
  274. close() {
  275. this.payShow = false
  276. },
  277. pay() {
  278. let data = {
  279. ticketId: this.info.ticketId,
  280. autoCoupon: 1
  281. }
  282. this.payLookFlag = false
  283. uni.showLoading({
  284. title: '加载中'
  285. });
  286. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  287. uni.hideLoading();
  288. if (res.code == 0) {
  289. let info = {
  290. ...res.data,
  291. ...this.info,
  292. picUrl: env.filePublic + res.data.picUrl,
  293. }
  294. this.payInfo = info
  295. this.payShow = true
  296. }
  297. }).catch(() => {
  298. uni.hideLoading();
  299. })
  300. },
  301. saveImg() {
  302. this.$refs.hchPoster.posterShow()
  303. },
  304. }
  305. }
  306. </script>
  307. <style lang="scss" scoped>
  308. .luck-warp {
  309. height: 100%;
  310. .luck-info {
  311. position: relative;
  312. width: 85%;
  313. border-radius: 40rpx;
  314. background-color: #fff;
  315. .luck-info-image {
  316. // margin-bottom: 30rpx;
  317. .image1 {
  318. width: 400rpx;
  319. height: 400rpx;
  320. margin-top: -200rpx;
  321. }
  322. .image2 {
  323. width: 700rpx;
  324. height: 700rpx;
  325. margin-top: -446rpx;
  326. // padding-bottom: 50rpx;
  327. }
  328. }
  329. .luck-info-tip {
  330. .tip {
  331. width: 460rpx;
  332. height: 100rpx;
  333. line-height: 50rpx;
  334. font-size: 24rpx;
  335. padding: 0 26rpx;
  336. color: #666666;
  337. text-align: center;
  338. border-radius: 10rpx;
  339. background: rgba(255, 109, 28, 0.2);
  340. }
  341. }
  342. .luck-info-content {
  343. flex-direction: column;
  344. .title {
  345. line-height: 68rpx;
  346. font-size: 48rpx;
  347. color: #FA6401;
  348. font-size: 60rpx;
  349. font-weight: bold;
  350. margin-bottom: 72rpx;
  351. }
  352. .name {
  353. font-size: 40rpx;
  354. line-height: 56rpx;
  355. margin-bottom: 20rpx;
  356. }
  357. .num {
  358. font-size: 32rpx;
  359. color: #666666;
  360. line-height: 44rpx;
  361. }
  362. }
  363. .mat {
  364. margin-bottom: 140rpx;
  365. }
  366. .mat2 {
  367. margin-bottom: 20rpx;
  368. }
  369. .luck-info-btn {
  370. margin-top: 20rpx;
  371. .btn {
  372. width: 530rpx;
  373. height: 100rpx;
  374. line-height: 100rpx;
  375. color: #FFFFFF;
  376. font-size: 48rpx;
  377. text-align: center;
  378. border-radius: 200rpx;
  379. background: linear-gradient(180deg, #FFB266 0%, #FFB266 0%, #FF843A 100%, #FF843A 100%);
  380. box-shadow: 0px 4px 10px 0px rgba(182, 85, 24, 0.6);
  381. margin-bottom: 72rpx;
  382. }
  383. }
  384. .luck-info-num {
  385. position: absolute;
  386. top: -280rpx;
  387. width: 100%;
  388. font-size: 260rpx;
  389. font-family: LucidaSans-Demi, LucidaSans;
  390. color: #FFBD4E;
  391. text-shadow: 1px 1px rgba(255, 255, 255, .7);
  392. font-weight: bold;
  393. }
  394. .luck-info-close {
  395. position: absolute;
  396. width: 70rpx;
  397. height: 70rpx;
  398. background-color: #b9b9b9;
  399. border-radius: 50%;
  400. right: 10rpx;
  401. top: -80rpx;
  402. }
  403. }
  404. }
  405. .detail {
  406. padding-bottom: 100rpx;
  407. &-top {
  408. margin-bottom: 20rpx;
  409. }
  410. &-info {
  411. justify-content: space-between;
  412. box-sizing: border-box;
  413. padding: 24rpx 16rpx;
  414. background-color: #fff;
  415. margin: 10rpx 10rpx 20rpx;
  416. border-radius: 10rpx;
  417. &__left {
  418. display: flex;
  419. flex-direction: column;
  420. justify-content: space-between;
  421. text {
  422. line-height: 24rpx;
  423. display: inline-block;
  424. }
  425. .title {
  426. color: rgba(16, 16, 16, 100);
  427. font-size: 32rpx;
  428. line-height: 32rpx;
  429. font-weight: bold;
  430. }
  431. .num {
  432. color: $uni-text-color;
  433. font-size: 28rpx;
  434. justify-content: flex-start;
  435. margin: 20rpx 0;
  436. }
  437. .tip {
  438. font-size: 24rpx;
  439. }
  440. }
  441. &__right {
  442. display: flex;
  443. flex-direction: column;
  444. align-items: flex-end;
  445. justify-content: space-between;
  446. height: 162rpx;
  447. text {
  448. color: rgba(157, 157, 157, 100);
  449. font-size: 14px;
  450. }
  451. .money {
  452. font-size: 40rpx;
  453. font-weight: bold;
  454. line-height: 40rpx;
  455. font-weight: bold;
  456. color: $uni-text-color;
  457. margin-bottom: 40rpx;
  458. }
  459. }
  460. }
  461. &-sku {
  462. background-color: #fff;
  463. border-radius: 10rpx;
  464. margin: 10rpx 10rpx 20rpx;
  465. &-title {
  466. padding: 24rpx 16rpx 12rpx;
  467. }
  468. &-item {
  469. padding-bottom: 10rpx;
  470. view {
  471. padding-left: 50rpx;
  472. line-height: 50rpx;
  473. }
  474. }
  475. }
  476. &-goods {
  477. margin: 10rpx 10rpx 20rpx;
  478. &-title {
  479. margin-bottom: 20rpx;
  480. }
  481. &-list {
  482. padding-bottom: 100rpx;
  483. &-item {
  484. position: relative;
  485. background-color: #FFFFFF;
  486. margin-bottom: 30rpx;
  487. border-radius: 10rpx;
  488. padding: 30rpx 20rpx;
  489. &__value {
  490. display: flex;
  491. }
  492. image {
  493. width: 200rpx;
  494. height: 200rpx;
  495. }
  496. .name {
  497. position: absolute;
  498. left: 0rpx;
  499. top: 0rpx;
  500. line-height: 28rpx;
  501. padding: 10rpx 40rpx;
  502. color: #FFFFFF;
  503. border-top-left-radius: 10rpx;
  504. border-bottom-right-radius: 40rpx;
  505. background-color: $uni-bg-color;
  506. }
  507. .info {
  508. display: flex;
  509. flex-direction: column;
  510. justify-content: space-between;
  511. font-size: 30rpx;
  512. padding-left: 50rpx;
  513. .title {
  514. font-weight: bold;
  515. }
  516. .num {
  517. color: #848484;
  518. }
  519. }
  520. }
  521. &-item:last-child {
  522. border: none;
  523. }
  524. }
  525. }
  526. }
  527. .null-prize {
  528. display: flex;
  529. flex-direction: column;
  530. align-items: center;
  531. justify-content: center;
  532. width: 80vw;
  533. height: 320rpx;
  534. background-color: #FFFFFF;
  535. border: 1px solid rgba(187, 187, 187, 100);
  536. .btn {
  537. margin-top: 60rpx;
  538. width: 160rpx;
  539. height: 60rpx;
  540. line-height: 60rpx;
  541. border-radius: 8rpx;
  542. background-color: rgba(235, 112, 9, 100);
  543. color: rgba(255, 255, 255, 100);
  544. font-size: 28rpx;
  545. text-align: center;
  546. }
  547. }
  548. </style>