detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  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="prizeInfo.prizeType != 'coin'">¥{{ $numberFormat(prizeInfo.value) }}</view>
  34. <view class="prize-price-present" v-else>{{ prizeInfo.value }}颗</view>
  35. <view class="prize-price-txt ells-one">{{ prizeInfo.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" v-if="info.originPrice != 0">原价:¥{{ $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" @click="toRollingGame"></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">共{{ prizeList.length }}款</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. prizeInfo: {}
  119. };
  120. },
  121. onLoad(opthios) {
  122. if (opthios.scene) {
  123. let sceneStr = decodeURIComponent(opthios.scene)
  124. this.sceneArr = sceneStr.split('&')
  125. this.boxId = this.sceneArr[0]
  126. uni.setStorageSync('shareUid', this.sceneArr[1])
  127. uni.setStorageSync('shareType', this.sceneArr[2])
  128. }
  129. if (opthios.boxId) {
  130. this.boxId = opthios.boxId
  131. }
  132. if (opthios.userId) {
  133. uni.setStorageSync('shareUid', opthios.userId)
  134. }
  135. if (opthios.type) {
  136. uni.setStorageSync('shareType', opthios.type)
  137. }
  138. },
  139. mounted() {
  140. let _this = this;
  141. let info = uni.createSelectorQuery().select(".prize");
  142. info.boundingClientRect(function(data) { //data - 各种参数
  143. _this.contnetHeight = data.height
  144. }).exec()
  145. },
  146. onPageScroll: function(e) {
  147. let _this = this;
  148. _this.btnFixed = _this.contnetHeight <= e.scrollTop;
  149. },
  150. onShow() {
  151. this.pagesNum = getCurrentPages().length
  152. if (this.boxId) {
  153. this.getDetail()
  154. }
  155. },
  156. methods: {
  157. changePrizeSwiper({ detail }) {
  158. this.prizeIndex = detail.current
  159. this.prizeInfo = this.prizeList[detail.current]
  160. },
  161. getDetail() {
  162. uni.showLoading({
  163. title: '加载中'
  164. });
  165. $http.post('/api/v1/mp/user/mall/ticket/detail', {
  166. boxId: this.boxId,
  167. noToken: true
  168. }).then(res => {
  169. uni.hideLoading();
  170. if (res.code == 0) {
  171. this.info = {
  172. ...res.data,
  173. picUrl: res.data.picUrl.split(',').map(item => env.filePublic + item + '?imageView2/2/w/375'),
  174. ticketAwardsLabelList: res.data.ticketAwardsLabelList.map(item => {
  175. return { ...item, picUrl: env.filePublic + item.picUrl }
  176. })
  177. }
  178. let prizeList = res.data.prizeList
  179. prizeList.forEach(item => {
  180. item.picUrl = env.filePublic + item.picUrl.split(',')[0] + '?imageView2/2/w/375'
  181. item.awardsLabelPicUrl = env.filePublic + item.awardsLabelPicUrl
  182. })
  183. this.prizeList = prizeList
  184. this.prizeInfo = this.prizeList[this.prizeIndex]
  185. }
  186. }).catch(() => {
  187. uni.hideLoading();
  188. })
  189. },
  190. getPageNum() {
  191. let pages = getCurrentPages();
  192. },
  193. close() {
  194. this.payShow = false
  195. },
  196. toProcess(id) {
  197. this.payShow = false
  198. uni.navigateTo({
  199. url: `/packagePrize/rolling/index?boxId=${ this.info.boxId }&orderId=${ id }&isTry=0`
  200. })
  201. },
  202. exchange() {
  203. let data = {
  204. userCouponIds: [],
  205. autoCoupon: 1,
  206. boxId: this.info.boxId,
  207. orderNum: 1
  208. }
  209. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  210. if (res.code == 0) {
  211. let info = {
  212. ...res.data,
  213. ...this.info,
  214. picUrl: this.info.picUrl[0],
  215. couponTitle: res.data && res.data.couponList && res.data.couponList.length && res
  216. .data.couponList[0].title,
  217. couponId: res.data && res.data.couponList && res.data.couponList.length && res.data
  218. .couponList[0].id
  219. }
  220. this.payInfo = info
  221. this.payShow = true
  222. }
  223. })
  224. },
  225. toRollingGame() {
  226. uni.navigateTo({
  227. url: `/packagePrize/rolling/index?boxId=${ this.info.boxId }&isTry=1`
  228. })
  229. },
  230. toShare() {
  231. if (!uni.getStorageSync('token')) {
  232. uni.navigateTo({
  233. url: "/pages/login/index"
  234. })
  235. return
  236. }
  237. uni.navigateTo({
  238. url: `/packageOperate/share/index?boxId=${ this.info.boxId }`
  239. })
  240. },
  241. toIndex() {
  242. uni.switchTab({
  243. url: '/pages/index/index'
  244. })
  245. },
  246. // 点击规则说明
  247. toRule() {
  248. uni.navigateTo({
  249. url: '/packageOther/rule/index'
  250. })
  251. },
  252. toPrizeGoods(item) {
  253. if (item.prizeType == "goods") {
  254. uni.navigateTo({
  255. url: `/packagePrize/goods/detail?id=${ item.refId }`
  256. })
  257. }
  258. //门店优惠券
  259. if (item.prizeType == "coupon" || item.prizeType == "coupon_pkg") {
  260. uni.navigateTo({
  261. url: `/packagePrize/goods/detail?id=425`
  262. })
  263. }
  264. // 盲豆
  265. if (item.prizeType == "coin") {
  266. uni.navigateTo({
  267. url: `/packagePrize/goods/detail?id=424`
  268. })
  269. }
  270. }
  271. }
  272. }
  273. </script>
  274. <style lang="scss" scoped>
  275. .ticket-wrap {
  276. background: #FFF3EB;
  277. padding-bottom: 100rpx;
  278. }
  279. .nav-left {
  280. &__code {
  281. margin-left: 10rpx;
  282. }
  283. }
  284. // 奖品轮播
  285. .prize {
  286. height: 71vh;
  287. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/detail_3.png) center center no-repeat;
  288. background-size: 100vw 71vh;
  289. margin-bottom: 14rpx;
  290. // 查看规则
  291. &-rule {
  292. display: flex;
  293. align-items: center;
  294. height: 34rpx;
  295. padding: 44rpx 0 0 34rpx;
  296. margin-bottom: 60rpx;
  297. &-content {
  298. image {
  299. width: 34rpx;
  300. height: 34rpx;
  301. margin-right: 14rpx;
  302. }
  303. text {
  304. font-size: 40rpx;
  305. font-family: 'YouSheBiaoTiHei';
  306. font-weight: 400;
  307. color: #FFFFFF;
  308. }
  309. }
  310. }
  311. // 奖品轮播
  312. &-swiper {
  313. height: 33vh;
  314. .swiper-item {
  315. width: 60vw;
  316. height: 80%;
  317. }
  318. .swiper-item-side {
  319. width: 60%;
  320. height: 60%;
  321. margin: 0;
  322. }
  323. &-item {
  324. height: 100%;
  325. .img {
  326. position: absolute;
  327. width: 100%;
  328. height: 80%;
  329. animation: prizeBig .3s;
  330. }
  331. .img-side {
  332. width: 60%;
  333. height: 60%;
  334. animation: prizeMini .3s;
  335. opacity: .5;
  336. }
  337. }
  338. }
  339. // 奖品价格
  340. &-price {
  341. flex-direction: column;
  342. justify-content: space-between;
  343. height: 14vh;
  344. margin-bottom: 30rpx;
  345. &-present {
  346. font-size: 26rpx;
  347. font-weight: bold;
  348. }
  349. &-txt {
  350. padding: 0 34rpx;
  351. font-size: 30rpx;
  352. font-weight: bold;
  353. }
  354. &__ticket-price {
  355. position: relative;
  356. height: 66rpx;
  357. image {
  358. width: 276rpx;
  359. height: 66rpx;
  360. }
  361. .txt {
  362. position: absolute;
  363. font-size: 40rpx;
  364. line-height: 66rpx;
  365. font-family: YouSheBiaoTiHei;
  366. font-weight: 400;
  367. color: #FFFFFF;
  368. }
  369. }
  370. &-past {
  371. font-size: 26rpx;
  372. font-weight: bold;
  373. text-decoration: line-through;
  374. color: #5E3909;
  375. }
  376. }
  377. // 开启盲票
  378. .ticket-btn {
  379. justify-content: space-between;
  380. height: 10vh;
  381. padding: 0 34rpx;
  382. &-game {
  383. width: 110rpx;
  384. height: 110rpx;
  385. }
  386. &-center {
  387. position: relative;
  388. height: 100%;
  389. image {
  390. height: 100%;
  391. width: 55vw;
  392. }
  393. &-txt {
  394. position: absolute;
  395. top: 30rpx;
  396. font-size: 72rpx;
  397. line-height: 72rpx;
  398. font-family: YouSheBiaoTiHei;
  399. font-weight: 400;
  400. color: #FFFFFF;
  401. }
  402. }
  403. &-share {
  404. width: 110rpx;
  405. height: 110rpx;
  406. }
  407. }
  408. }
  409. // 盲票奖品说明
  410. .explain {
  411. width: 100vw;
  412. position: relative;
  413. height: 40rpx;
  414. margin-bottom: 32rpx;
  415. .image-left {
  416. width: 18vw;
  417. height: 40rpx;
  418. }
  419. .image-right {
  420. width: 18vw;
  421. height: 40rpx;
  422. }
  423. &-title {
  424. font-size: 46rpx;
  425. line-height: 46rpx;
  426. font-family: YouSheBiaoTiHei;
  427. font-weight: 400;
  428. color: #5E3909;
  429. padding: 0 8rpx;
  430. }
  431. }
  432. // 盲票奖品数量、概率
  433. .prize-total {
  434. margin-bottom: 34rpx;
  435. &-num {
  436. font-size: 26rpx;
  437. text-align: center;
  438. font-weight: bold;
  439. color: #744111;
  440. margin-bottom: 24rpx;
  441. }
  442. &-chance {
  443. margin-bottom: 32rpx;
  444. &-content {
  445. margin-right: 40rpx;
  446. image {
  447. width: 56rpx;
  448. height: 50rpx;
  449. }
  450. text {
  451. font-size: 28rpx;
  452. font-family: YouSheBiaoTiHei;
  453. font-weight: 400;
  454. color: #622C06;
  455. }
  456. }
  457. &-content:last-child {
  458. margin: 0;
  459. }
  460. }
  461. &-txt {
  462. padding: 0 100rpx;
  463. font-size: 26rpx;
  464. font-weight: 500;
  465. color: #956B33;
  466. line-height: 42rpx;
  467. text-align: center;
  468. }
  469. }
  470. // 盲票奖品列表
  471. .prize-list {
  472. padding: 0 34rpx;
  473. &-item {
  474. position: relative;
  475. padding: 0 110rpx 0 84rpx;
  476. justify-content: flex-start;
  477. height: 264rpx;
  478. background: #FFFFFF;
  479. border-radius: 22rpx;
  480. margin-bottom: 26rpx;
  481. image {
  482. width: 166rpx;
  483. height: 166rpx;
  484. margin-right: 34rpx;
  485. }
  486. &-info {
  487. height: 166rpx;
  488. flex: 1;
  489. flex-direction: column;
  490. align-items: flex-start;
  491. justify-content: space-between;
  492. .title {
  493. font-size: 30rpx;
  494. font-weight: bold;
  495. line-height: 42rpx;
  496. }
  497. .price {
  498. font-size: 36rpx;
  499. font-weight: bold;
  500. color: #FF4208;
  501. line-height: 42rpx;
  502. }
  503. }
  504. &-grade {
  505. position: absolute;
  506. top: -12rpx;
  507. left: 0;
  508. image {
  509. width: 66rpx;
  510. height: 60rpx;
  511. }
  512. }
  513. }
  514. }
  515. // 滚动固定按钮
  516. .footer-fixed {
  517. position: fixed;
  518. bottom: var(--window-bottom);
  519. left: 0;
  520. right: 0;
  521. &-btn {
  522. height: 10vh;
  523. &-center {
  524. position: relative;
  525. height: 100%;
  526. image {
  527. height: 100%;
  528. width: 55vw;
  529. }
  530. &-txt {
  531. position: absolute;
  532. top: 30rpx;
  533. font-size: 72rpx;
  534. line-height: 72rpx;
  535. font-family: YouSheBiaoTiHei;
  536. font-weight: 400;
  537. color: #FFFFFF;
  538. }
  539. }
  540. }
  541. }
  542. // 奖品缩小动画
  543. @keyframes prizeMini
  544. {
  545. from {
  546. width: 100%;
  547. height: 80%;
  548. }
  549. to {
  550. width: 50%;
  551. height: 60%;
  552. }
  553. }
  554. // 奖品放大动画
  555. @keyframes prizeBig
  556. {
  557. from {
  558. width: 50%;
  559. height: 60%;
  560. }
  561. to {
  562. width: 100%;
  563. height: 80%;
  564. }
  565. }
  566. </style>