detail.vue 14 KB

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