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