index.vue 16 KB

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