detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <template>
  2. <view class="ticket-wrap">
  3. <view v-if="pagesNum > 1">
  4. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="盲票详情"></u-navbar>
  5. </view>
  6. <view v-else>
  7. <u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" title="盲票详情">
  8. <view class="nav-left flex" slot="left" @click="toIndex">
  9. <u-icon name="home" size="20" color="#333"></u-icon>
  10. <view class="nav-left__code">首页</view>
  11. </view>
  12. </u-navbar>
  13. </view>
  14. <!-- 奖品轮播 -->
  15. <view class="prize">
  16. <!-- 查看规则 -->
  17. <view class="prize-rule" @click="toRule">
  18. <view class="prize-rule-content flex">
  19. <image src="../../static/index/index_tip.png" mode=""></image>
  20. <text>查看规则</text>
  21. </view>
  22. </view>
  23. <!-- 奖品 -->
  24. <swiper class="prize-swiper" previous-margin="100px" next-margin="100px" :interval="4000" :autoplay="true" :circular="true" @change="changePrizeSwiper">
  25. <swiper-item :class="prizeIndex == index ? 'swiper-item' : 'swiper-item-side'" v-for="(item, index) in prizeList.slice(0, 11)" :key="index">
  26. <view class="prize-swiper-item flex">
  27. <image :class="prizeIndex == index ? 'img' : 'img-side'" :src="item.picUrl" mode="aspectFit"></image>
  28. </view>
  29. </swiper-item>
  30. </swiper>
  31. <!-- 奖品价格 -->
  32. <view class="prize-price flex">
  33. <view class="prize-price-present" v-if="prizeList[prizeIndex].prizeType != 'coin'">¥{{ $numberFormat(prizeList[prizeIndex].value) }}</view>
  34. <view class="prize-price-present" v-else>{{ prizeList[prizeIndex].value }}颗</view>
  35. <view class="prize-price-txt ells-one">{{ prizeList[prizeIndex].title }}</view>
  36. <view class="prize-price__ticket-price flex">
  37. <image src="../../static/ticketBox/ticket_block.png" mode="scaleToFill"></image>
  38. <view class="txt">¥{{ $numberFormat(info.salePrice) }} /个</view>
  39. </view>
  40. <view class="prize-price-past">原价:¥{{ $numberFormat(info.originPrice) }}/个</view>
  41. </view>
  42. <!-- 开启盲票 -->
  43. <view class="ticket-btn flex">
  44. <image class="ticket-btn-game" src="../../static/ticketBox/ticket_game.png" mode="scaleToFill"></image>
  45. <view class="ticket-btn-center flex" @click="exchange">
  46. <image src="../../static/ticketBox/ticket_btn_center.png" mode="scaleToFill"></image>
  47. <view class="ticket-btn-center-txt">开启盲票</view>
  48. </view>
  49. <image class="ticket-btn-share" src="../../static/ticketBox/ticket_share.png" mode="scaleToFill"></image>
  50. </view>
  51. </view>
  52. <!-- 盲票奖品说明 -->
  53. <view class="explain flex">
  54. <image class="image-left" src="../../static/ticketBox/ticket_explain_left.png" mode="aspectFit"></image>
  55. <view class="explain-title">开票必出以下宝贝之一</view>
  56. <image class="image-right" src="../../static/ticketBox/ticket_explain_right.png" mode="aspectFit"></image>
  57. </view>
  58. <!-- 盲票奖品数量、概率 -->
  59. <view class="prize-total">
  60. <view class="prize-total-num">共90款</view>
  61. <!-- 中奖概率 -->
  62. <view class="prize-total-chance flex">
  63. <view class="prize-total-chance-content flex" v-for="(item, index) in info.ticketAwardsLabelList">
  64. <image :src="item.picUrl" mode="scaleToFill"></image>
  65. <text>{{ item.hitRate }}%</text>
  66. </view>
  67. </view>
  68. <!-- 文字说明 -->
  69. <view class="prize-total-txt">因概率对小数点后三位进行四舍五入处理,故存在总值不为100%的可能。商品抽奖存在概率性,付费请谨慎!未成年人请在家长监督下使用。</view>
  70. </view>
  71. <!-- 盲票奖品列表 -->
  72. <view class="prize-list">
  73. <view class="prize-list-item flex" v-for="(item, index) in prizeList" :key="index" @click="toPrizeGoods(item)">
  74. <image :src="item.picUrl" mode="aspectFit"></image>
  75. <view class="prize-list-item-info flex">
  76. <view class="title ells">{{ item.title }}</view>
  77. <view class="price" v-if="item.prizeType != 'coin'">¥{{ $numberFormat(item.value) }}</view>
  78. <view class="price" v-else>{{ item.value }}颗</view>
  79. </view>
  80. <view class="prize-list-item-grade">
  81. <image :src="item.awardsLabelPicUrl" />
  82. </view>
  83. </view>
  84. </view>
  85. <view class="footer-fixed" v-if="btnFixed">
  86. <view class="footer-fixed-btn flex">
  87. <view class="footer-fixed-btn-center flex" @click="exchange">
  88. <image src="../../static/ticketBox/ticket_btn_center.png" mode="scaleToFill"></image>
  89. <view class="footer-fixed-btn-center-txt">开启盲票</view>
  90. </view>
  91. </view>
  92. </view>
  93. <!-- 支付弹层 -->
  94. <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="toProcess" />
  95. </view>
  96. </template>
  97. <script>
  98. import env from '../../config/env.js'
  99. import $http from '@/utils/request.js'
  100. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  101. export default {
  102. components: {
  103. PayPopup
  104. },
  105. data() {
  106. return {
  107. boxId: '',
  108. picUrlArr: [],
  109. info: {},
  110. prizeList: [],
  111. payShow: false,
  112. payInfo: {},
  113. pagesNum: null,
  114. sceneArr: null,
  115. prizeIndex: 0,
  116. contnetHeight: 0,
  117. btnFixed: false,
  118. };
  119. },
  120. onLoad(opthios) {
  121. if (opthios.scene) {
  122. let sceneStr = decodeURIComponent(opthios.scene)
  123. this.sceneArr = sceneStr.split('&')
  124. this.boxId = this.sceneArr[0]
  125. uni.setStorageSync('shareUid', this.sceneArr[1])
  126. uni.setStorageSync('shareType', this.sceneArr[2])
  127. }
  128. if (opthios.boxId) {
  129. this.boxId = opthios.boxId
  130. }
  131. if (opthios.userId) {
  132. uni.setStorageSync('shareUid', opthios.userId)
  133. }
  134. if (opthios.type) {
  135. uni.setStorageSync('shareType', opthios.type)
  136. }
  137. },
  138. mounted() {
  139. let _this = this;
  140. let info = uni.createSelectorQuery().select(".prize");
  141. info.boundingClientRect(function(data) { //data - 各种参数
  142. _this.contnetHeight = data.height
  143. }).exec()
  144. },
  145. onPageScroll: function(e) {
  146. let _this = this;
  147. _this.btnFixed = _this.contnetHeight <= e.scrollTop;
  148. },
  149. onShow() {
  150. this.pagesNum = getCurrentPages().length
  151. if (this.boxId) {
  152. this.getDetail()
  153. }
  154. },
  155. methods: {
  156. changePrizeSwiper({ detail }) {
  157. this.prizeIndex = detail.current
  158. },
  159. getDetail() {
  160. uni.showLoading({
  161. title: '加载中'
  162. });
  163. $http.post('/api/v1/mp/user/mall/ticket/detail', {
  164. boxId: this.boxId,
  165. noToken: true
  166. }).then(res => {
  167. uni.hideLoading();
  168. if (res.code == 0) {
  169. this.info = {
  170. ...res.data,
  171. picUrl: res.data.picUrl.split(',').map(item => env.filePublic + item + '?imageView2/2/w/375'),
  172. ticketAwardsLabelList: res.data.ticketAwardsLabelList.map(item => {
  173. return { ...item, picUrl: env.filePublic + item.picUrl }
  174. })
  175. }
  176. console.log(this.info);
  177. let prizeList = res.data.prizeList
  178. prizeList.forEach(item => {
  179. item.picUrl = env.filePublic + item.picUrl.split(',')[0] + '?imageView2/2/w/170'
  180. item.awardsLabelPicUrl = env.filePublic + item.awardsLabelPicUrl
  181. })
  182. this.prizeList = prizeList
  183. }
  184. }).catch(() => {
  185. uni.hideLoading();
  186. })
  187. },
  188. getPageNum() {
  189. let pages = getCurrentPages();
  190. },
  191. close() {
  192. this.payShow = false
  193. },
  194. toProcess(id) {
  195. this.payShow = false
  196. uni.navigateTo({
  197. url: `/packageOperate/process/index?id=${ id }`
  198. })
  199. },
  200. exchange() {
  201. let data = {
  202. userCouponIds: [],
  203. autoCoupon: 1,
  204. boxId: this.info.boxId,
  205. orderNum: 1
  206. }
  207. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  208. if (res.code == 0) {
  209. let info = {
  210. ...res.data,
  211. ...this.info,
  212. picUrl: this.info.picUrl[2],
  213. couponTitle: res.data && res.data.couponList && res.data.couponList.length && res
  214. .data.couponList[0].title,
  215. couponId: res.data && res.data.couponList && res.data.couponList.length && res.data
  216. .couponList[0].id
  217. }
  218. this.payInfo = info
  219. this.payShow = true
  220. }
  221. })
  222. },
  223. toShare() {
  224. if (!uni.getStorageSync('token')) {
  225. uni.navigateTo({
  226. url: "/pages/login/index"
  227. })
  228. return
  229. }
  230. uni.navigateTo({
  231. url: `/packageOperate/share/index?boxId=${ this.info.boxId }`
  232. })
  233. },
  234. toIndex() {
  235. uni.switchTab({
  236. url: '/pages/index/index'
  237. })
  238. },
  239. // 点击规则说明
  240. toRule() {
  241. uni.navigateTo({
  242. url: '/packageOther/rule/index'
  243. })
  244. },
  245. toPrizeGoods(item) {
  246. if (item.prizeType == "goods") {
  247. uni.navigateTo({
  248. url: `/packagePrize/goods/detail?id=${ item.refId }`
  249. })
  250. }
  251. //门店优惠券
  252. if (item.prizeType == "coupon" || item.prizeType == "coupon_pkg") {
  253. // if (item.couponType == "1") {
  254. // uni.navigateTo({
  255. // url: `/packagePrize/goods/detail?id=426`
  256. // })
  257. // }
  258. // if (item.couponType == "2") {
  259. // uni.navigateTo({
  260. // url: `/packagePrize/goods/detail?id=425`
  261. // })
  262. // }
  263. uni.navigateTo({
  264. url: `/packagePrize/goods/detail?id=425`
  265. })
  266. }
  267. // 盲豆
  268. if (item.prizeType == "coin") {
  269. uni.navigateTo({
  270. url: `/packagePrize/goods/detail?id=424`
  271. })
  272. }
  273. }
  274. }
  275. }
  276. </script>
  277. <style lang="scss" scoped>
  278. .ticket-wrap {
  279. background: #FFF3EB;
  280. padding-bottom: 100rpx;
  281. }
  282. .nav-left {
  283. &__code {
  284. margin-left: 10rpx;
  285. }
  286. }
  287. // 奖品轮播
  288. .prize {
  289. height: 71vh;
  290. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/detail_3.png) center center no-repeat;
  291. background-size: 100vw 71vh;
  292. margin-bottom: 14rpx;
  293. // 查看规则
  294. &-rule {
  295. display: flex;
  296. align-items: center;
  297. height: 34rpx;
  298. padding: 44rpx 0 0 34rpx;
  299. margin-bottom: 60rpx;
  300. &-content {
  301. image {
  302. width: 34rpx;
  303. height: 34rpx;
  304. margin-right: 14rpx;
  305. }
  306. text {
  307. font-size: 40rpx;
  308. font-family: 'YouSheBiaoTiHei';
  309. font-weight: 400;
  310. color: #FFFFFF;
  311. }
  312. }
  313. }
  314. // 奖品轮播
  315. &-swiper {
  316. height: 33vh;
  317. .swiper-item {
  318. width: 60vw;
  319. height: 80%;
  320. }
  321. .swiper-item-side {
  322. width: 60%;
  323. height: 60%;
  324. margin: 0;
  325. }
  326. &-item {
  327. height: 100%;
  328. .img {
  329. position: absolute;
  330. width: 58vw;
  331. height: 80%;
  332. animation: prizeBig .3s;
  333. }
  334. .img-side {
  335. width: 60%;
  336. height: 60%;
  337. animation: prizeMini .3s;
  338. opacity: .5;
  339. }
  340. }
  341. }
  342. // 奖品价格
  343. &-price {
  344. flex-direction: column;
  345. justify-content: space-between;
  346. height: 14vh;
  347. margin-bottom: 30rpx;
  348. &-present {
  349. font-size: 26rpx;
  350. font-weight: bold;
  351. }
  352. &-txt {
  353. padding: 0 34rpx;
  354. font-size: 30rpx;
  355. font-weight: bold;
  356. }
  357. &__ticket-price {
  358. position: relative;
  359. height: 66rpx;
  360. image {
  361. width: 276rpx;
  362. height: 66rpx;
  363. }
  364. .txt {
  365. position: absolute;
  366. font-size: 40rpx;
  367. line-height: 66rpx;
  368. font-family: YouSheBiaoTiHei;
  369. font-weight: 400;
  370. color: #FFFFFF;
  371. }
  372. }
  373. &-past {
  374. font-size: 26rpx;
  375. font-weight: bold;
  376. text-decoration: line-through;
  377. color: #5E3909;
  378. }
  379. }
  380. // 开启盲票
  381. .ticket-btn {
  382. justify-content: space-between;
  383. height: 10vh;
  384. padding: 0 34rpx;
  385. &-game {
  386. width: 110rpx;
  387. height: 110rpx;
  388. }
  389. &-center {
  390. position: relative;
  391. height: 100%;
  392. image {
  393. height: 100%;
  394. width: 55vw;
  395. }
  396. &-txt {
  397. position: absolute;
  398. top: 30rpx;
  399. font-size: 72rpx;
  400. line-height: 72rpx;
  401. font-family: YouSheBiaoTiHei;
  402. font-weight: 400;
  403. color: #FFFFFF;
  404. }
  405. }
  406. &-share {
  407. width: 110rpx;
  408. height: 110rpx;
  409. }
  410. }
  411. }
  412. // 盲票奖品说明
  413. .explain {
  414. width: 100vw;
  415. position: relative;
  416. height: 40rpx;
  417. margin-bottom: 32rpx;
  418. .image-left {
  419. width: 18vw;
  420. height: 40rpx;
  421. }
  422. .image-right {
  423. width: 18vw;
  424. height: 40rpx;
  425. }
  426. &-title {
  427. font-size: 46rpx;
  428. line-height: 46rpx;
  429. font-family: YouSheBiaoTiHei;
  430. font-weight: 400;
  431. color: #5E3909;
  432. padding: 0 8rpx;
  433. }
  434. }
  435. // 盲票奖品数量、概率
  436. .prize-total {
  437. margin-bottom: 34rpx;
  438. &-num {
  439. font-size: 26rpx;
  440. text-align: center;
  441. font-weight: bold;
  442. color: #744111;
  443. margin-bottom: 24rpx;
  444. }
  445. &-chance {
  446. margin-bottom: 32rpx;
  447. &-content {
  448. margin-right: 40rpx;
  449. image {
  450. width: 56rpx;
  451. height: 50rpx;
  452. }
  453. text {
  454. font-size: 28rpx;
  455. font-family: YouSheBiaoTiHei;
  456. font-weight: 400;
  457. color: #622C06;
  458. }
  459. }
  460. &-content:last-child {
  461. margin: 0;
  462. }
  463. }
  464. &-txt {
  465. padding: 0 100rpx;
  466. font-size: 26rpx;
  467. font-weight: 500;
  468. color: #956B33;
  469. line-height: 42rpx;
  470. text-align: center;
  471. }
  472. }
  473. // 盲票奖品列表
  474. .prize-list {
  475. padding: 0 34rpx;
  476. &-item {
  477. position: relative;
  478. padding: 0 110rpx 0 84rpx;
  479. justify-content: flex-start;
  480. height: 264rpx;
  481. background: #FFFFFF;
  482. border-radius: 22rpx;
  483. margin-bottom: 26rpx;
  484. image {
  485. width: 166rpx;
  486. height: 166rpx;
  487. margin-right: 34rpx;
  488. }
  489. &-info {
  490. height: 166rpx;
  491. flex: 1;
  492. flex-direction: column;
  493. align-items: flex-start;
  494. justify-content: space-between;
  495. .title {
  496. font-size: 30rpx;
  497. font-weight: bold;
  498. line-height: 42rpx;
  499. }
  500. .price {
  501. font-size: 36rpx;
  502. font-weight: bold;
  503. color: #FF4208;
  504. line-height: 42rpx;
  505. }
  506. }
  507. &-grade {
  508. position: absolute;
  509. top: -12rpx;
  510. left: 0;
  511. image {
  512. width: 66rpx;
  513. height: 60rpx;
  514. }
  515. }
  516. }
  517. }
  518. // 滚动固定按钮
  519. .footer-fixed {
  520. position: fixed;
  521. bottom: var(--window-bottom);
  522. left: 0;
  523. right: 0;
  524. &-btn {
  525. height: 10vh;
  526. &-center {
  527. position: relative;
  528. height: 100%;
  529. image {
  530. height: 100%;
  531. width: 55vw;
  532. }
  533. &-txt {
  534. position: absolute;
  535. top: 30rpx;
  536. font-size: 72rpx;
  537. line-height: 72rpx;
  538. font-family: YouSheBiaoTiHei;
  539. font-weight: 400;
  540. color: #FFFFFF;
  541. }
  542. }
  543. }
  544. }
  545. // 奖品缩小动画
  546. @keyframes prizeMini
  547. {
  548. from {
  549. width: 60vw;
  550. height: 80%;
  551. }
  552. to {
  553. width: 50%;
  554. height: 60%;
  555. }
  556. }
  557. // 奖品放大动画
  558. @keyframes prizeBig
  559. {
  560. from {
  561. width: 50%;
  562. height: 60%;
  563. }
  564. to {
  565. width: 60vw;
  566. height: 80%;
  567. }
  568. }
  569. </style>