index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  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" @touchmove.prevent.stop>
  78. <view class="null-prize">
  79. <view class="title">该盲票已兑奖</view>
  80. <navigator open-type="exit" target="miniProgram" hover-class="none" class="btn">确认</navigator>
  81. </view>
  82. </u-popup>
  83. <hch-poster ref="hchPoster" @cancel="handleCancel" :posterData.sync="posterData" @previewImage='previewImage'
  84. @canvasConfirm="toIndex" />
  85. </view>
  86. </template>
  87. <script>
  88. import env from '../../config/env.js'
  89. import $http from '@/utils/request.js'
  90. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  91. import HchPoster from "../../components/hch-poster/hch-poster.vue"
  92. export default {
  93. components: {
  94. PayPopup,
  95. HchPoster
  96. },
  97. data() {
  98. return {
  99. serialNo: '',
  100. info: '',
  101. payInfo: {},
  102. payShow: false,
  103. payLookFlag: true,
  104. showNull: false,
  105. posterData: {},
  106. luckyShow: true,
  107. status: 2,
  108. boxId: '',
  109. picUrlArr: [],
  110. boxInfo: {},
  111. prizeList: [],
  112. };
  113. },
  114. onLoad(options) {
  115. if (options.id) {
  116. this.serialNo = options.id
  117. }
  118. if (options.q) {
  119. let url = JSON.stringify(options.q)
  120. this.serialNo = url.substring(url.length - 22, url.length - 1)
  121. }
  122. },
  123. onShow() {
  124. if (this.serialNo && this.payLookFlag) {
  125. this.getDetail()
  126. }
  127. },
  128. methods: {
  129. getDetail() {
  130. uni.showLoading({
  131. title: '加载中'
  132. });
  133. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  134. serialNo: this.serialNo,
  135. noToken: true
  136. }).then(res => {
  137. uni.hideLoading();
  138. if (res.code == 0) {
  139. this.getBoxDetail(res.data.boxId)
  140. if (res.data.status == 1) {
  141. this.info = res.data
  142. } else if (res.data.status == 2) {
  143. if (uni.getStorageSync('token')) {
  144. uni.redirectTo({
  145. url: `/pages/choice/index?id=${ res.data.ticketId }`
  146. })
  147. } else {
  148. uni.showModal({
  149. title: '提示',
  150. content: '您未登录或登录失效!',
  151. confirmText: '去登录',
  152. showCancel: false,
  153. success(res) {
  154. if (res.confirm) {
  155. uni.navigateTo({
  156. url: "/pages/login/index"
  157. })
  158. }
  159. }
  160. })
  161. }
  162. } else {
  163. this.showNull = true
  164. this.luckyShow = false
  165. }
  166. } else {
  167. uni.$u.toast('该盲票不存在!');
  168. setTimeout(() => {
  169. uni.switchTab({
  170. url: '/pages/index/index'
  171. })
  172. }, 1000)
  173. }
  174. }).catch(() => {
  175. uni.hideLoading();
  176. })
  177. },
  178. getDetailInfo() {
  179. this.payShow = false
  180. uni.showLoading({
  181. title: '加载中'
  182. });
  183. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  184. serialNo: this.serialNo,
  185. noToken: true
  186. }).then(res => {
  187. uni.hideLoading();
  188. if (res.code == 0) {
  189. this.info = res.data
  190. let num = res.data.plainLuckyNum
  191. this.posterData.num.text =
  192. this.posterData = {
  193. poster: {
  194. //根据屏幕大小自动生成图片背景大小
  195. url: env.filePublic + this.info.picUrl, //图片地址
  196. r: 10, //圆角半径
  197. w: 300, //图片宽度
  198. h: 480, //图片高度
  199. p: 20 //图片内边距padding
  200. },
  201. square3: {
  202. x: 100,
  203. y: 100,
  204. r: 0, //圆角半径
  205. w: 240, //宽度
  206. h: 180, //高度
  207. mt: 65
  208. },
  209. title: {
  210. text: "幸运数字", //文本
  211. fontSize: 20, //字体大小
  212. color: "#000", //颜色
  213. lineHeight: 25, //行高
  214. mt: 20, //margin-top
  215. align: 'center'
  216. },
  217. num: {
  218. text: num + '', //文本
  219. fontSize: 40, //字体大小
  220. color: "#fff", //颜色
  221. lineHeight: 25, //行高
  222. mt: 20, //margin-top
  223. align: 'center'
  224. },
  225. txt: {
  226. text: res.data.title, //文本
  227. fontSize: 16, //字体大小
  228. color: "#000", //颜色
  229. lineHeight: 25, //行高
  230. mt: 20, //margin-top
  231. align: 'center'
  232. },
  233. }
  234. }
  235. }).catch(() => {
  236. uni.hideLoading();
  237. })
  238. },
  239. getBoxDetail(id) {
  240. uni.showLoading({
  241. title: '加载中'
  242. });
  243. $http.post('/api/v1/mp/user/mall/ticket/detail', {
  244. boxId: id,
  245. noToken: true
  246. }).then(res => {
  247. uni.hideLoading();
  248. if (res.code == 0) {
  249. this.boxInfo = res.data
  250. let picUrlArr = res.data.picUrl.split(',')
  251. picUrlArr.forEach(item => {
  252. this.picUrlArr.push(env.filePublic + item)
  253. })
  254. let prizeList = res.data.prizeList
  255. prizeList.forEach(item => {
  256. let picUrlArr = item.picUrl.split(',')
  257. item.picUrl = env.filePublic + picUrlArr[0]
  258. })
  259. this.prizeList = prizeList
  260. }
  261. }).catch(() => {
  262. uni.hideLoading();
  263. })
  264. },
  265. close() {
  266. this.payShow = false
  267. },
  268. pay() {
  269. let data = {
  270. ticketId: this.info.ticketId,
  271. autoCoupon: 1
  272. }
  273. this.payLookFlag = false
  274. uni.showLoading({
  275. title: '加载中'
  276. });
  277. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  278. uni.hideLoading();
  279. if (res.code == 0) {
  280. let info = {
  281. ...res.data,
  282. ...this.info,
  283. picUrl: env.filePublic + res.data.picUrl,
  284. }
  285. this.payInfo = info
  286. this.payShow = true
  287. }
  288. }).catch(() => {
  289. uni.hideLoading();
  290. })
  291. },
  292. screen() {
  293. },
  294. toIndex() {
  295. uni.switchTab({
  296. url: '/pages/index/index'
  297. })
  298. },
  299. previewImage() {
  300. },
  301. saveImg() {
  302. this.$refs.hchPoster.posterShow()
  303. },
  304. handleCancel() {
  305. },
  306. toIndex() {
  307. // uni.switchTab({
  308. // url: '/pages/index/index'
  309. // })
  310. },
  311. }
  312. }
  313. </script>
  314. <style lang="scss" scoped>
  315. .luck-warp {
  316. height: 100%;
  317. .luck-info {
  318. position: relative;
  319. width: 85%;
  320. border-radius: 40rpx;
  321. background-color: #fff;
  322. .luck-info-image {
  323. margin-bottom: 30rpx;
  324. .image1 {
  325. width: 400rpx;
  326. height: 400rpx;
  327. margin-top: -200rpx;
  328. }
  329. .image2 {
  330. width: 450rpx;
  331. height: 450rpx;
  332. margin-top: -286rpx;
  333. // padding-bottom: 50rpx;
  334. }
  335. }
  336. .luck-info-tip {
  337. .tip {
  338. width: 460rpx;
  339. height: 100rpx;
  340. line-height: 50rpx;
  341. font-size: 24rpx;
  342. padding: 0 26rpx;
  343. color: #666666;
  344. text-align: center;
  345. background: rgba(255, 109, 28, 0.2);
  346. }
  347. }
  348. .luck-info-content {
  349. flex-direction: column;
  350. .title {
  351. line-height: 68rpx;
  352. font-size: 48rpx;
  353. margin-bottom: 36rpx;
  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: -56rpx;
  390. width: 100%;
  391. font-size: 80rpx;
  392. color: #FFFFFF;
  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>