index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. <template>
  2. <view>
  3. <view class="lucky"></view>
  4. <u-overlay :show="luckyShow" :opacity="0.3" zIndex="100">
  5. <view class="flex luck-warp" @touchmove.prevent.stop>
  6. <view class="luck-info">
  7. <view class="luck-info-bg">
  8. <image src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/lucky1_prize.jpg" mode="scaleToFill"></image>
  9. </view>
  10. <view class="luck-info-content flex">
  11. <view class="luck-info-content-num">
  12. <!-- <image src="../../static/lucky/lucky_gkmp.png" mode="aspectFit" v-if="info.salePrice == 0">
  13. </image> -->
  14. <!-- <view v-if="info.salePrice == 0"> -->
  15. <view class="luck-info-content-num-word" v-if="info.salePrice == 0">
  16. <text>共富体验</text>
  17. <text style="font-size: 66rpx;">开启我的
  18. <text style="color: #FF0000;">共富</text>
  19. 时刻</text>
  20. </view>
  21. <image src="../../static/lucky/zioff.png" mode="aspectFit" v-else></image>
  22. </view>
  23. <view class="luck-info-content-img" v-if="info.status != 1">
  24. <view class="luck-info-content-img-word">
  25. <image class="img" src="../../static/lucky/lucky_tu.png" mode="scaleToFill"></image>
  26. <view class="luck-info-content-img-word__content">
  27. <text>{{ info.awardsName }}</text>
  28. </view>
  29. <image class="imgtwo" src="../../static/lucky/lucky_xiaoguo.png" mode="scaleToFill"
  30. v-if="infoimg">
  31. </image>
  32. <image class="img" src="../../static/lucky/lucky_guajiangqu.png" mode="scaleToFill"
  33. v-if="info.status == 1"></image>
  34. <image class="imgone" src="../../static/lucky/lucky_yidong.png"
  35. v-else-if="info.status == 2"></image>
  36. </view>
  37. </view>
  38. <view class="luck-info-content-ticket">
  39. <image src="https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/static/lucky_background3.png" mode="scaleToFill"></image>
  40. <view class="luck-info-content-ticket-info flex">
  41. <view class="title" :class="{ 'action': info.status == 2 }">{{ info.title }}</view>
  42. <view class="serialNo" :class="{ 'action': info.status == 2 }">序列号:{{ info.serialNo }}
  43. </view>
  44. </view>
  45. </view>
  46. <view class="luck-info-content-nearby" v-if="info.status == 1 ">
  47. 附近已有<view class="num" style="display: inline-block; padding: 0 2px;">{{ nearbyNum }}</view>人刮开<view class="dots"><view>.</view><view>.</view><view>.</view></view>
  48. </view>
  49. <view class="luck-info-content-btn" style="width: 500rpx;" @click="pay"
  50. v-if="info.status == 1 && info.salePrice != 0">
  51. 点击支付</view>
  52. <view class="luck-info-content-btn" style="width: 500rpx;" @click="payDetail"
  53. v-else-if="info.status == 1 && info.salePrice == 0">立即刮奖</view>
  54. <!-- <view class=" code" v-else>开奖啦!</view> -->
  55. <view class="luck-info-content-btn" style="width: 500rpx;" @click="toChoice" v-if="Choice">领取奖品
  56. </view>
  57. </view>
  58. <view class="luck-info-close flex">
  59. <navigator open-type="exit" target="miniProgram" hover-class="none"
  60. class="luck-info-close-content flex">
  61. <u-icon name="close" color="#fff" size="20"></u-icon>
  62. </navigator>
  63. </view>
  64. </view>
  65. </view>
  66. </u-overlay>
  67. <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="getDetailInfo" v-if="payShow" />
  68. <u-popup :show="showNull" :round="10" mode="center" :safeAreaInsetBottom="false" overlayOpacity="0.8"
  69. @touchmove.prevent.stop>
  70. <view class="null-prize">
  71. <view class="title">该盲票已兑奖</view>
  72. <view class="btn" @click="toUser">确认</view>
  73. </view>
  74. </u-popup>
  75. <u-popup :show="showStop" :round="10" mode="center" :safeAreaInsetBottom="false" overlayOpacity="0.8"
  76. @touchmove.prevent.stop>
  77. <view class="null-prize">
  78. <view class="title">该盲票已停售</view>
  79. <view class="btn" @click="toUser">确认</view>
  80. </view>
  81. </u-popup>
  82. <u-popup :show="tipShow" :round="10" mode="center" :safeAreaInsetBottom="false" overlayOpacity="0.8"
  83. @touchmove.prevent.stop>
  84. <view class="null-prize">
  85. <view class="title">该盲票已被他人买走了</view>
  86. <view class="btn" @click="toUser">确认</view>
  87. </view>
  88. </u-popup>
  89. <u-popup :show="showAction" :round="10" mode="center" :safeAreaInsetBottom="false" overlayOpacity="0.8"
  90. @touchmove.prevent.stop>
  91. <view class="null-prize">
  92. <view class="title">该盲票未激活</view>
  93. <navigator open-type="exit" target="miniProgram" hover-class="none" class="btn">确认</navigator>
  94. </view>
  95. </u-popup>
  96. </view>
  97. </template>
  98. <script>
  99. import env from '../../config/env.js'
  100. import $http from '@/utils/request.js'
  101. import appId from '@/config/appId.js'
  102. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  103. import {
  104. urlParameter
  105. } from '@/utils/util.js'
  106. export default {
  107. components: {
  108. PayPopup
  109. },
  110. data() {
  111. return {
  112. serialNo: '',
  113. info: '',
  114. payInfo: {},
  115. payShow: false,
  116. payLookFlag: true,
  117. showNull: false,
  118. showStop: false,
  119. luckyShow: false,
  120. status: 2,
  121. showAction: false,
  122. infoimg: false,
  123. Choice: false,
  124. ChoiceData: '',
  125. nearbyNum: 0,
  126. };
  127. },
  128. onLoad(options) {
  129. if (options.id) {
  130. this.serialNo = options.id
  131. this.getDetail()
  132. }
  133. if (options.q) {
  134. let obj = urlParameter(decodeURIComponent(options.q))
  135. this.serialNo = obj.id
  136. this.getDetail()
  137. }
  138. if(uni.getStorageSync('code')){
  139. this.serialNo = uni.getStorageSync('code')
  140. }
  141. this.jumpNumber()
  142. },
  143. onShow() {
  144. if(uni.getStorageSync('code')){
  145. this.serialNo = uni.getStorageSync('code')
  146. this.getDetail()
  147. }
  148. },
  149. methods: {
  150. getDetail() {
  151. uni.showLoading({
  152. title: '加载中'
  153. });
  154. let data = {
  155. serialNo: this.serialNo,
  156. noToken: true
  157. }
  158. // #ifdef MP-WEIXIN
  159. data.appSource = 1
  160. // #endif
  161. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', data).then(res => {
  162. uni.hideLoading();
  163. if (res.code == 0) {
  164. if (res.data.status == 1) {
  165. this.info = res.data
  166. this.luckyShow = true
  167. } else if (res.data.status == 2) {
  168. this.info = res.data
  169. if (uni.getStorageSync('token')) {
  170. uni.redirectTo({
  171. url: `/packagePrize/choice/index?id=${ res.data.ticketId }&type=offline`
  172. })
  173. } else {
  174. this.luckyShow = true
  175. uni.showModal({
  176. title: '提示',
  177. content: '您未登录或登录失效!',
  178. confirmText: '去登录',
  179. showCancel: false,
  180. success(res) {
  181. if (res.confirm) {
  182. uni.navigateTo({
  183. url: "/pages/login/index"
  184. })
  185. }
  186. }
  187. })
  188. }
  189. } else if(res.data.status == 5){
  190. this.showStop = true
  191. this.luckyShow = false
  192. } else {
  193. this.showNull = true
  194. this.luckyShow = false
  195. }
  196. } else if (res.code == 1023) {
  197. this.showAction = true
  198. this.luckyShow = false
  199. } else if (res.code == 1027){
  200. this.showStop = true
  201. this.luckyShow = false
  202. } else {
  203. uni.$u.toast('该盲票不存在!');
  204. setTimeout(() => {
  205. uni.switchTab({
  206. url: '/pages/index/index'
  207. })
  208. }, 1000)
  209. }
  210. }).catch(() => {
  211. uni.hideLoading();
  212. })
  213. },
  214. getDetailInfo() {
  215. let _this = this
  216. _this.payShow = false
  217. uni.showLoading({
  218. title: '加载中'
  219. });
  220. let data = {
  221. serialNo: _this.serialNo,
  222. noToken: true
  223. }
  224. // #ifdef MP-WEIXIN
  225. data.appSource = 1
  226. // #endif
  227. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', data).then(res => {
  228. uni.hideLoading();
  229. if (res.code == 0) {
  230. if (res.data.status == 2) {
  231. _this.info = res.data
  232. setTimeout(() => {
  233. this.infoimg = true
  234. setTimeout(() => {
  235. this.ChoiceData = res.data.ticketId
  236. this.Choice = true
  237. }, 500)
  238. }, 500)
  239. } else {
  240. let num = 0
  241. let time = setInterval(() => {
  242. num++
  243. uni.showLoading({
  244. title: '加载中'
  245. });
  246. let data = {
  247. serialNo: _this.serialNo,
  248. noToken: true
  249. }
  250. // #ifdef MP-WEIXIN
  251. data.appSource = 1
  252. // #endif
  253. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', data ).then(ele => {
  254. if (ele.data.status == 2) {
  255. uni.hideLoading();
  256. clearInterval(time)
  257. _this.info = res.data
  258. setTimeout(() => {
  259. this.infoimg = true
  260. setTimeout(() => {
  261. this.ChoiceData = res.data.ticketId
  262. this.Choice = true
  263. }, 500)
  264. }, 500)
  265. }
  266. })
  267. if (num == 10) {
  268. uni.hideLoading();
  269. clearInterval(time)
  270. }
  271. }, 1000)
  272. }
  273. }
  274. }).catch(() => {
  275. uni.hideLoading();
  276. })
  277. },
  278. jumpNumber() {
  279. this.nearbyNum = 0 //起始数据
  280. let endNum = Math.floor(Math.random()*10+1) //最终数据
  281. let step = 0 //累加步长
  282. let time = 200 //动画时间
  283. const timer = setInterval(() => {
  284. if(this.nearbyNum < (endNum - step)) {
  285. step++
  286. //小数
  287. this.nearbyNum = step
  288. } else {
  289. clearInterval(timer)
  290. this.nearbyNum = endNum
  291. }
  292. }, time)
  293. },
  294. //跳转奖品页
  295. toChoice() {
  296. uni.redirectTo({
  297. url: `/packagePrize/choice/index?id=${ this.ChoiceData }&type=offline`
  298. })
  299. },
  300. close() {
  301. this.payShow = false
  302. },
  303. payDetail() {
  304. let data = {
  305. ticketId: this.info.ticketId,
  306. autoCoupon: 0,
  307. userCouponIds: [],
  308. orderNum: 1,
  309. appSource: appId
  310. }
  311. uni.showLoading();
  312. let suid = uni.getStorageSync('shareUid')
  313. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  314. uni.hideLoading();
  315. if (res.code == 0) {
  316. if (res.data.payAmt == 0) {
  317. $http.post('/api/v1/mp/user/ticket/order/submit', {
  318. suid: suid !== 'undefined' && suid !== undefined ? suid : null,
  319. type: uni.getStorageSync('shareType')
  320. }).then(res => {
  321. uni.hideLoading();
  322. if (res.code == 0) {
  323. this.getDetailInfo()
  324. } else {
  325. this.tipShow = true
  326. this.luckyShow = false
  327. }
  328. }).catch(() => {
  329. uni.hideLoading();
  330. })
  331. }
  332. }
  333. }).catch(() => {
  334. uni.hideLoading();
  335. })
  336. },
  337. pay() {
  338. let data = {
  339. ticketId: this.info.ticketId,
  340. autoCoupon: 1,
  341. userCouponIds: [],
  342. orderNum: 1,
  343. appSource: appId
  344. }
  345. this.payLookFlag = false
  346. uni.showLoading({
  347. title: '加载中'
  348. });
  349. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  350. uni.hideLoading();
  351. if (res.code == 0) {
  352. let info = {
  353. ...res.data,
  354. ...this.info,
  355. picUrl: env.filePublic + res.data.picUrl,
  356. couponTitle: res.data && res.data.couponList && res.data.couponList.length && res
  357. .data.couponList[0].title,
  358. couponId: res.data && res.data.couponList && res.data.couponList.length && res.data
  359. .couponList[0].id,
  360. }
  361. this.payInfo = info
  362. this.payShow = true
  363. }
  364. }).catch(() => {
  365. uni.hideLoading();
  366. })
  367. },
  368. toUser() {
  369. uni.switchTab({
  370. url: '/pages/user/index'
  371. })
  372. },
  373. saveImg() {
  374. this.$refs.hchPoster.posterShow()
  375. },
  376. }
  377. }
  378. </script>
  379. <style lang="scss" scoped>
  380. .luck-warp {
  381. height: 100%;
  382. .luck-info {
  383. position: relative;
  384. // width: 87vw;
  385. width: 100%;
  386. height: 60vh;
  387. &-bg {
  388. position: absolute;
  389. top: 0;
  390. width: 100%;
  391. image {
  392. // width: 87vw;
  393. width: 100%;
  394. height: 70vh;
  395. }
  396. }
  397. &-content {
  398. flex-direction: column;
  399. justify-content: flex-start;
  400. position: absolute;
  401. top: 0;
  402. z-index: 10;
  403. width: 100%;
  404. height: 100%;
  405. &-num {
  406. position: relative;
  407. // width: 480rpx;
  408. height: 8vh;
  409. margin-top: 16vh;
  410. margin-bottom: 3vh;
  411. image {
  412. position: absolute;
  413. top: 0rpx;
  414. width: 100%;
  415. height: 100%;
  416. }
  417. &-word {
  418. display: flex;
  419. flex-direction: column;
  420. align-items: center;
  421. justify-content: center;
  422. font-size: 81rpx;
  423. font-family: YouSheBiaoTiHei;
  424. font-weight: 400;
  425. color: #7231F1;
  426. // line-height: 164rpx;
  427. }
  428. }
  429. &-img {
  430. position: relative;
  431. width: 73%;
  432. height: 8vh;
  433. background-color: #fff;
  434. border-radius: 12rpx;
  435. &-word {
  436. position: absolute;
  437. // top: 15%;
  438. // left: 5%;
  439. width: 100%;
  440. height: 100%;
  441. overflow: hidden;
  442. .img {
  443. position: absolute;
  444. width: 100%;
  445. height: 100%;
  446. }
  447. .imgtwo {
  448. position: absolute;
  449. width: 20%;
  450. height: 100%;
  451. left: -20%;
  452. animation: shadowTwoMove 0.5s linear infinite;
  453. animation-iteration-count: 1;
  454. }
  455. .imgone {
  456. position: absolute;
  457. left: 100%;
  458. width: 100%;
  459. height: 100%;
  460. animation: shadowMove 0.5s linear infinite;
  461. animation-iteration-count: 1;
  462. }
  463. &__content {
  464. position: absolute;
  465. // top: 25%;
  466. line-height: 8vh;
  467. text-align: center;
  468. width: 100%;
  469. height: 100%;
  470. font-size: 36rpx;
  471. font-family: YouSheBiaoTiHei;
  472. font-weight: 400;
  473. color: #fff;
  474. }
  475. }
  476. }
  477. &-title {
  478. font-size: 40rpx;
  479. line-height: 40rpx;
  480. color: #FEFEFE;
  481. margin-bottom: 1vh;
  482. }
  483. &-tip {
  484. width: 80%;
  485. font-size: 26rpx;
  486. line-height: 35rpx;
  487. text-align: center;
  488. color: #fff;
  489. }
  490. &-ticket {
  491. position: relative;
  492. width: 70%;
  493. height: 10vh;
  494. margin-top: 3vh;
  495. image {
  496. position: absolute;
  497. top: 0;
  498. width: 100%;
  499. height: 95%;
  500. }
  501. &-info {
  502. text-align: center;
  503. width: 90%;
  504. height: 75%;
  505. left: 5%;
  506. position: absolute;
  507. top: 0;
  508. z-index: 5;
  509. margin-top: 10rpx;
  510. flex-direction: column;
  511. .title {
  512. font-size: 28rpx;
  513. font-weight: 500;
  514. line-height: 28rpx;
  515. color: #fff;
  516. margin-top: 1vh;
  517. margin-bottom: 1vh;
  518. width: 90%;
  519. white-space: nowrap;
  520. overflow: hidden;
  521. text-overflow: ellipsis;
  522. }
  523. .serialNo {
  524. font-size: 26rpx;
  525. color: #fff;
  526. font-weight: 400;
  527. }
  528. // .action {
  529. // color: #FFCBAA;
  530. // }
  531. }
  532. }
  533. &-nearby {
  534. position: relative;
  535. text-align: center;
  536. width: 73%;
  537. // height: 6vh;
  538. margin-top: 4vh;
  539. font-size: 30rpx;
  540. color: #666;
  541. .num {
  542. font-size: 46rpx;
  543. }
  544. .dots {
  545. display: inline-block;
  546. view {
  547. display: inline-block;
  548. }
  549. }
  550. .dots view {
  551. animation: dots-1 2s infinite steps(1);
  552. -webkit-animation: dots-1 2s infinite steps(1);
  553. }
  554. .dots view:first-child+view {
  555. animation-name: dots-2;
  556. -webkit-animation-name: dots-2;
  557. }
  558. .dots view:first-child+view+view {
  559. animation-name: dots-3;//第三个点的动画名称
  560. -webkit-animation-name: dots-3;
  561. }
  562. }
  563. &-btn {
  564. padding: 0 8%;
  565. height: 8vh;
  566. line-height: 7vh;
  567. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/static/lucky_button.png) no-repeat center center;
  568. background-size: 100% 100%;
  569. // background: linear-gradient(0deg, #FF4924, #F9D448);
  570. // box-shadow: 0px 6px 9px 0px rgba(135, 19, 3, 0.49);
  571. // border-radius: 4vh;
  572. text-align: center;
  573. font-size: 32rpx;
  574. font-weight: 500;
  575. margin-top: 2vh;
  576. }
  577. .code {
  578. padding: 0 20%;
  579. height: 7vh;
  580. line-height: 10vh;
  581. text-align: center;
  582. color: #FEFEFE;
  583. font-family: YouSheBiaoTiHei;
  584. font-size: 38rpx
  585. }
  586. }
  587. &-close {
  588. width: 100%;
  589. position: absolute;
  590. bottom: -140rpx;
  591. &-content {
  592. width: 70rpx;
  593. height: 70rpx;
  594. border-radius: 50%;
  595. border: 1px solid #fff;
  596. }
  597. }
  598. }
  599. }
  600. .lucky {
  601. width: 100%;
  602. height: 100vh;
  603. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/static/lucky_background.png) center center no-repeat;
  604. background-size: 100vw 100vh;
  605. }
  606. .null-prize {
  607. display: flex;
  608. flex-direction: column;
  609. align-items: center;
  610. justify-content: center;
  611. width: 80vw;
  612. height: 320rpx;
  613. background-color: #FFFFFF;
  614. border: 1px solid rgba(187, 187, 187, 100);
  615. .btn {
  616. margin-top: 60rpx;
  617. width: 160rpx;
  618. height: 60rpx;
  619. line-height: 60rpx;
  620. border-radius: 8rpx;
  621. background-color: $uni-bg-color;
  622. color: rgba(255, 255, 255, 100);
  623. font-size: 28rpx;
  624. text-align: center;
  625. }
  626. }
  627. // 支付后移动动画
  628. @keyframes shadowMove {
  629. 0% {
  630. left: 0%;
  631. }
  632. 100% {
  633. left: 100%;
  634. }
  635. }
  636. // 支付后移动动画
  637. @keyframes shadowTwoMove {
  638. 0% {
  639. left: -20%;
  640. }
  641. 100% {
  642. left: 100%;
  643. }
  644. }
  645. //动态省略号
  646. @keyframes dots-1 {
  647. from {
  648. opacity: 0
  649. }
  650. 25% {
  651. opacity: 1
  652. }
  653. }
  654. @keyframes dots-2 {
  655. from {
  656. opacity: 0
  657. }
  658. 50% {
  659. opacity: 1
  660. }
  661. }
  662. @keyframes dots-3 {
  663. from {
  664. opacity: 0
  665. }
  666. 75% {
  667. opacity: 1
  668. }
  669. }
  670. @-webkit-keyframes dots-1 {
  671. from {
  672. opacity: 0
  673. }
  674. 25% {
  675. opacity: 1
  676. }
  677. }
  678. @-webkit-keyframes dots-2 {
  679. from {
  680. opacity: 0
  681. }
  682. 50% {
  683. opacity: 1
  684. }
  685. }
  686. @-webkit-keyframes dots-3 {
  687. from {
  688. opacity: 0
  689. }
  690. 75% {
  691. opacity: 1
  692. }
  693. }
  694. </style>