detail.vue 15 KB

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