detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  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" />
  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. uni.navigateTo({
  236. url: `/packagePrize/rolling/index?boxId=${ this.info.boxId }&isTry=1`
  237. })
  238. },
  239. toShare() {
  240. this.getBaseInfo()
  241. // if (!uni.getStorageSync('token')) {
  242. // uni.navigateTo({
  243. // url: "/pages/login/index"
  244. // })
  245. // return
  246. // }
  247. // uni.navigateTo({
  248. // url: `/packageOperate/share/index?boxId=${ this.info.boxId }`
  249. // })
  250. },
  251. toIndex() {
  252. uni.switchTab({
  253. url: '/pages/index/index'
  254. })
  255. },
  256. // 点击规则说明
  257. toRule() {
  258. uni.navigateTo({
  259. url: '/packageOther/rule/index'
  260. })
  261. },
  262. toPrizeGoods(item) {
  263. if (item.prizeType == "goods") {
  264. uni.navigateTo({
  265. url: `/packagePrize/goods/detail?id=${ item.refId }`
  266. })
  267. }
  268. //门店优惠券
  269. if (item.prizeType == "coupon" || item.prizeType == "coupon_pkg") {
  270. uni.navigateTo({
  271. url: `/packagePrize/goods/detail?id=425&type=not`
  272. })
  273. }
  274. // 盲豆
  275. if (item.prizeType == "coin") {
  276. uni.navigateTo({
  277. url: `/packagePrize/goods/detail?id=424&type=not`
  278. })
  279. }
  280. },
  281. getBaseInfo() {
  282. $http.post('/api/v1/mp/user/getLoginUserinfo', {}).then(res => {
  283. uni.hideLoading();
  284. if (res.code == 0) {
  285. this.userInfo = res.data
  286. }
  287. })
  288. },
  289. },
  290. onShareAppMessage(res) {
  291. return {
  292. title: '一起来刮盲票吧',
  293. path: `/pages/ticketBox/detail?boxId=${ this.info.boxId }&userId=${ this.userInfo.userId }&type=1`,
  294. type: 2,
  295. }
  296. }
  297. }
  298. </script>
  299. <style lang="scss" scoped>
  300. .ticket-wrap {
  301. background: #FFF3EB;
  302. padding-bottom: 100rpx;
  303. }
  304. .nav-left {
  305. &__code {
  306. margin-left: 10rpx;
  307. }
  308. }
  309. // 奖品轮播
  310. .prize {
  311. height: 71vh;
  312. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/detail_3.png) center center no-repeat;
  313. background-size: 100vw 71vh;
  314. margin-bottom: 14rpx;
  315. // 查看规则
  316. &-rule {
  317. display: flex;
  318. align-items: center;
  319. height: 34rpx;
  320. padding: 44rpx 0 0 34rpx;
  321. margin-bottom: 60rpx;
  322. &-content {
  323. image {
  324. width: 34rpx;
  325. height: 34rpx;
  326. margin-right: 14rpx;
  327. }
  328. text {
  329. font-size: 40rpx;
  330. font-family: 'YouSheBiaoTiHei';
  331. font-weight: 400;
  332. color: #FFFFFF;
  333. }
  334. }
  335. }
  336. // 奖品轮播
  337. &-swiper {
  338. height: 33vh;
  339. .swiper-item {
  340. width: 60vw;
  341. height: 80%;
  342. }
  343. .swiper-item-side {
  344. width: 60%;
  345. height: 60%;
  346. margin: 0;
  347. }
  348. &-item {
  349. height: 100%;
  350. .img {
  351. position: absolute;
  352. width: 100%;
  353. height: 80%;
  354. animation: prizeBig .3s;
  355. }
  356. .img-side {
  357. width: 60%;
  358. height: 60%;
  359. animation: prizeMini .3s;
  360. opacity: .5;
  361. }
  362. }
  363. }
  364. // 奖品价格
  365. &-price {
  366. flex-direction: column;
  367. justify-content: space-between;
  368. height: 14vh;
  369. margin-bottom: 30rpx;
  370. &-present {
  371. font-size: 26rpx;
  372. font-weight: bold;
  373. }
  374. &-txt {
  375. padding: 0 34rpx;
  376. font-size: 30rpx;
  377. font-weight: bold;
  378. }
  379. &__ticket-price {
  380. position: relative;
  381. height: 66rpx;
  382. image {
  383. width: 276rpx;
  384. height: 66rpx;
  385. }
  386. .txt {
  387. position: absolute;
  388. font-size: 40rpx;
  389. line-height: 66rpx;
  390. font-family: YouSheBiaoTiHei;
  391. font-weight: 400;
  392. color: #FFFFFF;
  393. }
  394. }
  395. &-past {
  396. font-size: 26rpx;
  397. font-weight: bold;
  398. text-decoration: line-through;
  399. color: #5E3909;
  400. }
  401. }
  402. // 开启盲票
  403. .ticket-btn {
  404. justify-content: space-between;
  405. height: 10vh;
  406. padding: 0 34rpx;
  407. &-game {
  408. width: 110rpx;
  409. height: 110rpx;
  410. }
  411. &-center {
  412. position: relative;
  413. height: 100%;
  414. image {
  415. height: 100%;
  416. width: 55vw;
  417. }
  418. &-txt {
  419. position: absolute;
  420. top: 30rpx;
  421. font-size: 72rpx;
  422. line-height: 72rpx;
  423. font-family: YouSheBiaoTiHei;
  424. font-weight: 400;
  425. color: #FFFFFF;
  426. }
  427. }
  428. &-share {
  429. position: relative;
  430. width: 110rpx;
  431. height: 110rpx;
  432. image {
  433. position: absolute;
  434. width: 110rpx;
  435. height: 110rpx;
  436. }
  437. /deep/ button {
  438. position: absolute;
  439. z-index: 5;
  440. width: 110rpx;
  441. height: 110rpx;
  442. background: none;
  443. border: none !important;
  444. }
  445. /deep/ uni-button:after {
  446. border: none !important;
  447. }
  448. /deep/ button:after {
  449. border: none !important;
  450. }
  451. }
  452. }
  453. }
  454. // 盲票奖品说明
  455. .explain {
  456. width: 100vw;
  457. position: relative;
  458. height: 40rpx;
  459. margin-bottom: 32rpx;
  460. .image-left {
  461. width: 18vw;
  462. height: 40rpx;
  463. }
  464. .image-right {
  465. width: 18vw;
  466. height: 40rpx;
  467. }
  468. &-title {
  469. font-size: 46rpx;
  470. line-height: 46rpx;
  471. font-family: YouSheBiaoTiHei;
  472. font-weight: 400;
  473. color: #5E3909;
  474. padding: 0 8rpx;
  475. }
  476. }
  477. // 盲票奖品数量、概率
  478. .prize-total {
  479. margin-bottom: 34rpx;
  480. &-num {
  481. font-size: 26rpx;
  482. text-align: center;
  483. font-weight: bold;
  484. color: #744111;
  485. margin-bottom: 24rpx;
  486. }
  487. &-chance {
  488. margin-bottom: 32rpx;
  489. &-content {
  490. margin-right: 40rpx;
  491. image {
  492. width: 56rpx;
  493. height: 50rpx;
  494. }
  495. text {
  496. font-size: 28rpx;
  497. font-family: YouSheBiaoTiHei;
  498. font-weight: 400;
  499. color: #622C06;
  500. }
  501. }
  502. &-content:last-child {
  503. margin: 0;
  504. }
  505. }
  506. &-txt {
  507. padding: 0 100rpx;
  508. font-size: 26rpx;
  509. font-weight: 500;
  510. color: #956B33;
  511. line-height: 42rpx;
  512. text-align: center;
  513. }
  514. }
  515. // 盲票奖品列表
  516. .prize-list {
  517. padding: 0 34rpx;
  518. &-item {
  519. position: relative;
  520. padding: 0 110rpx 0 84rpx;
  521. justify-content: flex-start;
  522. height: 264rpx;
  523. background: #FFFFFF;
  524. border-radius: 22rpx;
  525. margin-bottom: 26rpx;
  526. image {
  527. width: 166rpx;
  528. height: 166rpx;
  529. margin-right: 34rpx;
  530. }
  531. &-info {
  532. height: 166rpx;
  533. flex: 1;
  534. flex-direction: column;
  535. align-items: flex-start;
  536. justify-content: space-between;
  537. .title {
  538. font-size: 30rpx;
  539. font-weight: bold;
  540. line-height: 42rpx;
  541. }
  542. .price {
  543. font-size: 36rpx;
  544. font-weight: bold;
  545. color: #FF4208;
  546. line-height: 42rpx;
  547. }
  548. }
  549. &-grade {
  550. position: absolute;
  551. top: -12rpx;
  552. left: 0;
  553. image {
  554. width: 66rpx;
  555. height: 60rpx;
  556. }
  557. }
  558. }
  559. }
  560. // 滚动固定按钮
  561. .footer-fixed {
  562. position: fixed;
  563. bottom: var(--window-bottom);
  564. left: 0;
  565. right: 0;
  566. &-btn {
  567. height: 10vh;
  568. &-center {
  569. position: relative;
  570. height: 100%;
  571. image {
  572. height: 100%;
  573. width: 55vw;
  574. }
  575. &-txt {
  576. position: absolute;
  577. top: 30rpx;
  578. font-size: 72rpx;
  579. line-height: 72rpx;
  580. font-family: YouSheBiaoTiHei;
  581. font-weight: 400;
  582. color: #FFFFFF;
  583. }
  584. }
  585. }
  586. }
  587. // 奖品缩小动画
  588. @keyframes prizeMini
  589. {
  590. from {
  591. width: 100%;
  592. height: 80%;
  593. }
  594. to {
  595. width: 50%;
  596. height: 60%;
  597. }
  598. }
  599. // 奖品放大动画
  600. @keyframes prizeBig
  601. {
  602. from {
  603. width: 50%;
  604. height: 60%;
  605. }
  606. to {
  607. width: 100%;
  608. height: 80%;
  609. }
  610. }
  611. </style>