detail.vue 16 KB

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