detail.vue 15 KB

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