index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <template>
  2. <view>
  3. <view class="lucky"></view>
  4. <u-overlay :show="luckyShow" :opacity="0.8" 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="../../static/lucky/lucky_bg.png" mode=""></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=""></image>
  13. </view>
  14. <view class="luck-info-content-img">
  15. <view class="luck-info-content-img-word">
  16. <image class="img" src="../../static/lucky/lucky_tu.png" mode=""></image>
  17. <view class="luck-info-content-img-word__content">
  18. <text>{{ info.awardsName }}</text>
  19. </view>
  20. <image class="imgtwo" src="../../static/lucky/lucky_xiaoguo.png" mode="" v-if="infoimg">
  21. </image>
  22. <image class="img" src="../../static/lucky/lucky_guajiangqu.png" mode="" v-if="info.status == 1">
  23. <image class="imgone" src="../../static/lucky/lucky_yidong.png" v-else-if="info.status == 2"></image>
  24. </view>
  25. </view>
  26. <view class="luck-info-content-ticket">
  27. <image src="../../static/lucky/lucky_piaohao.png" mode=""></image>
  28. <view class="luck-info-content-ticket-info flex">
  29. <view class="title" :class="{ 'action': info.status == 2 }">{{ info.title }}</view>
  30. <view class="serialNo" :class="{ 'action': info.status == 2 }">盲票序列号:{{ info.serialNo }}
  31. </view>
  32. </view>
  33. </view>
  34. <view class="luck-info-content-btn" @click="pay" v-if="info.status == 1 && info.salePrice != 0">
  35. 支付{{ info.salePrice / 100 }}元 立即刮开盲票</view>
  36. <view class="luck-info-content-btn" @click="payDetail"
  37. v-else-if="info.status == 1 && info.salePrice == 0">收下盲票,立即刮开盲票</view>
  38. <view class=" code" v-else>开奖啦!</view>
  39. </view>
  40. <view class="luck-info-close flex">
  41. <navigator open-type="exit" target="miniProgram" hover-class="none"
  42. class="luck-info-close-content flex">
  43. <u-icon name="close" color="#fff" size="20"></u-icon>
  44. </navigator>
  45. </view>
  46. </view>
  47. </view>
  48. </u-overlay>
  49. <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="getDetailInfo" v-if="payShow" />
  50. <u-popup :show="showNull" :round="10" mode="center" :safeAreaInsetBottom="false" overlayOpacity="0.8"
  51. @touchmove.prevent.stop>
  52. <view class="null-prize">
  53. <view class="title">该盲票已兑奖</view>
  54. <view class="btn" @click="toUser">确认</view>
  55. </view>
  56. </u-popup>
  57. <u-popup :show="tipShow" :round="10" mode="center" :safeAreaInsetBottom="false" overlayOpacity="0.8"
  58. @touchmove.prevent.stop>
  59. <view class="null-prize">
  60. <view class="title">该盲票已被他人买走了</view>
  61. <view class="btn" @click="toUser">确认</view>
  62. </view>
  63. </u-popup>
  64. <u-popup :show="showAction" :round="10" mode="center" :safeAreaInsetBottom="false" overlayOpacity="0.8"
  65. @touchmove.prevent.stop>
  66. <view class="null-prize">
  67. <view class="title">该盲票未激活</view>
  68. <navigator open-type="exit" target="miniProgram" hover-class="none" class="btn">确认</navigator>
  69. </view>
  70. </u-popup>
  71. </view>
  72. </template>
  73. <script>
  74. import env from '../../config/env.js'
  75. import $http from '@/utils/request.js'
  76. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  77. import {
  78. urlParameter
  79. } from '@/utils/util.js'
  80. export default {
  81. components: {
  82. PayPopup
  83. },
  84. data() {
  85. return {
  86. serialNo: '',
  87. info: '',
  88. payInfo: {},
  89. payShow: false,
  90. payLookFlag: true,
  91. showNull: false,
  92. luckyShow: false,
  93. status: 2,
  94. showAction: false,
  95. infoimg: false,
  96. };
  97. },
  98. onLoad(options) {
  99. if (options.id) {
  100. this.serialNo = options.id
  101. this.getDetail()
  102. }
  103. if (options.q) {
  104. let obj = urlParameter(decodeURIComponent(options.q))
  105. this.serialNo = obj.id
  106. this.getDetail()
  107. }
  108. },
  109. methods: {
  110. getDetail() {
  111. uni.showLoading({
  112. title: '加载中'
  113. });
  114. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  115. serialNo: this.serialNo,
  116. noToken: true
  117. }).then(res => {
  118. uni.hideLoading();
  119. if (res.code == 0) {
  120. if (res.data.status == 1) {
  121. this.info = res.data
  122. this.luckyShow = true
  123. } else if (res.data.status == 2) {
  124. this.info = res.data
  125. if (uni.getStorageSync('token')) {
  126. uni.redirectTo({
  127. url: `/packagePrize/choice/index?id=${ res.data.ticketId }&type=offLine`
  128. })
  129. } else {
  130. this.luckyShow = true
  131. uni.showModal({
  132. title: '提示',
  133. content: '您未登录或登录失效!',
  134. confirmText: '去登录',
  135. showCancel: false,
  136. success(res) {
  137. if (res.confirm) {
  138. uni.navigateTo({
  139. url: "/pages/login/index"
  140. })
  141. }
  142. }
  143. })
  144. }
  145. } else {
  146. this.showNull = true
  147. this.luckyShow = false
  148. }
  149. } else if (res.code == 1023) {
  150. this.showAction = true
  151. this.luckyShow = false
  152. } else {
  153. uni.$u.toast('该盲票不存在!');
  154. setTimeout(() => {
  155. uni.switchTab({
  156. url: '/pages/index/index'
  157. })
  158. }, 1000)
  159. }
  160. }).catch(() => {
  161. uni.hideLoading();
  162. })
  163. },
  164. getDetailInfo() {
  165. let _this = this
  166. _this.payShow = false
  167. uni.showLoading({
  168. title: '加载中'
  169. });
  170. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  171. serialNo: _this.serialNo,
  172. noToken: true
  173. }).then(res => {
  174. uni.hideLoading();
  175. if (res.code == 0) {
  176. if (res.data.status == 2) {
  177. _this.info = res.data
  178. setTimeout(() => {
  179. this.infoimg = true
  180. setTimeout(() => {
  181. uni.redirectTo({
  182. url: `/packagePrize/choice/index?id=${ res.data.ticketId }&type=offLine`
  183. })
  184. }, 500)
  185. }, 500)
  186. } else {
  187. let num = 0
  188. let time = setInterval(() => {
  189. num++
  190. uni.showLoading({
  191. title: '加载中'
  192. });
  193. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  194. serialNo: _this.serialNo,
  195. noToken: true
  196. }).then(ele => {
  197. if (ele.data.status == 2) {
  198. uni.hideLoading();
  199. clearInterval(time)
  200. _this.info = res.data
  201. setTimeout(() => {
  202. this.infoimg = true
  203. setTimeout(() => {
  204. uni.redirectTo({
  205. url: `/packagePrize/choice/index?id=${ res.data.ticketId }&type=offLine`
  206. })
  207. }, 500)
  208. }, 500)
  209. }
  210. })
  211. if (num == 10) {
  212. uni.hideLoading();
  213. clearInterval(time)
  214. }
  215. }, 1000)
  216. }
  217. }
  218. }).catch(() => {
  219. uni.hideLoading();
  220. })
  221. },
  222. close() {
  223. this.payShow = false
  224. },
  225. payDetail() {
  226. let data = {
  227. ticketId: this.info.ticketId,
  228. autoCoupon: 0,
  229. userCouponIds: [],
  230. orderNum: 1
  231. }
  232. uni.showLoading();
  233. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  234. uni.hideLoading();
  235. if (res.code == 0) {
  236. if (res.data.payAmt == 0) {
  237. $http.post('/api/v1/mp/user/ticket/order/submit', {
  238. suid: uni.getStorageSync('shareUid'),
  239. type: uni.getStorageSync('shareType')
  240. }).then(res => {
  241. uni.hideLoading();
  242. if (res.code == 0) {
  243. this.getDetailInfo()
  244. } else {
  245. this.tipShow = true
  246. this.luckyShow = false
  247. }
  248. }).catch(() => {
  249. uni.hideLoading();
  250. })
  251. }
  252. }
  253. }).catch(() => {
  254. uni.hideLoading();
  255. })
  256. },
  257. pay() {
  258. let data = {
  259. ticketId: this.info.ticketId,
  260. autoCoupon: 1,
  261. userCouponIds: [],
  262. orderNum: 1
  263. }
  264. this.payLookFlag = false
  265. uni.showLoading({
  266. title: '加载中'
  267. });
  268. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  269. uni.hideLoading();
  270. if (res.code == 0) {
  271. let info = {
  272. ...res.data,
  273. ...this.info,
  274. picUrl: env.filePublic + res.data.picUrl,
  275. couponTitle: res.data && res.data.couponList && res.data.couponList.length && res
  276. .data.couponList[0].title,
  277. couponId: res.data && res.data.couponList && res.data.couponList.length && res.data
  278. .couponList[0].id,
  279. }
  280. this.payInfo = info
  281. this.payShow = true
  282. }
  283. }).catch(() => {
  284. uni.hideLoading();
  285. })
  286. },
  287. toUser() {
  288. uni.switchTab({
  289. url: '/pages/user/index'
  290. })
  291. },
  292. saveImg() {
  293. this.$refs.hchPoster.posterShow()
  294. },
  295. }
  296. }
  297. </script>
  298. <style lang="scss" scoped>
  299. .luck-warp {
  300. height: 100%;
  301. .luck-info {
  302. position: relative;
  303. width: 87vw;
  304. height: 60vh;
  305. &-bg {
  306. position: absolute;
  307. top: 0;
  308. image {
  309. width: 87vw;
  310. height: 60vh;
  311. }
  312. }
  313. &-content {
  314. flex-direction: column;
  315. justify-content: flex-start;
  316. position: absolute;
  317. top: 0;
  318. z-index: 10;
  319. width: 100%;
  320. height: 100%;
  321. &-num {
  322. position: relative;
  323. width: 422rpx;
  324. height: 8vh;
  325. margin-top: 16vh;
  326. margin-bottom: 3vh;
  327. image {
  328. position: absolute;
  329. top: 0;
  330. width: 100%;
  331. height: 100%;
  332. }
  333. }
  334. &-img {
  335. position: relative;
  336. width: 73%;
  337. height: 10vh;
  338. background-color: #fff;
  339. border-radius: 12rpx;
  340. &-word {
  341. position: absolute;
  342. top: 15%;
  343. left: 5%;
  344. width: 90%;
  345. height: 85%;
  346. overflow: hidden;
  347. .img {
  348. position: absolute;
  349. width: 100%;
  350. height: 82.6%;
  351. }
  352. .imgtwo {
  353. position: absolute;
  354. width: 20%;
  355. height: 82%;
  356. left: -20%;
  357. animation: shadowTwoMove 0.5s linear infinite;
  358. animation-iteration-count: 1;
  359. }
  360. .imgone {
  361. position: absolute;
  362. left: 100%;
  363. width: 100%;
  364. height: 100%;
  365. animation: shadowMove 0.5s linear infinite;
  366. animation-iteration-count: 1;
  367. }
  368. &__content {
  369. position: absolute;
  370. top: 25%;
  371. text-align: center;
  372. width: 100%;
  373. height: 100%;
  374. font-size: 36rpx;
  375. font-family: YouSheBiaoTiHei;
  376. font-weight: 400;
  377. color: #fff;
  378. }
  379. }
  380. }
  381. &-title {
  382. font-size: 40rpx;
  383. line-height: 40rpx;
  384. color: #FEFEFE;
  385. margin-bottom: 1vh;
  386. }
  387. &-tip {
  388. width: 80%;
  389. font-size: 26rpx;
  390. line-height: 35rpx;
  391. text-align: center;
  392. color: #fff;
  393. }
  394. &-ticket {
  395. position: relative;
  396. width: 73%;
  397. height: 10vh;
  398. margin-top: 2vh;
  399. image {
  400. position: absolute;
  401. top: 0;
  402. width: 100%;
  403. height: 95%;
  404. }
  405. &-info {
  406. width: 90%;
  407. height: 75%;
  408. left: 5%;
  409. position: absolute;
  410. top: 0;
  411. z-index: 5;
  412. flex-direction: column;
  413. .title {
  414. font-size: 30rpx;
  415. line-height: 30rpx;
  416. color: #FF6D2C;
  417. margin-top: 1vh;
  418. margin-bottom: 1vh;
  419. }
  420. .serialNo {
  421. font-size: 24rpx;
  422. color: #FF6D2C;
  423. }
  424. .action {
  425. color: #FFCBAA;
  426. }
  427. }
  428. }
  429. &-btn {
  430. padding: 0 8%;
  431. height: 7vh;
  432. line-height: 7vh;
  433. background: linear-gradient(0deg, #FF4924, #F9D448);
  434. box-shadow: 0px 6px 9px 0px rgba(135, 19, 3, 0.49);
  435. border-radius: 4vh;
  436. text-align: center;
  437. color: #FEFEFE;
  438. font-size: 40rpx;
  439. margin-top: 1vh;
  440. }
  441. .code {
  442. padding: 0 20%;
  443. height: 7vh;
  444. line-height: 10vh;
  445. text-align: center;
  446. color: #FEFEFE;
  447. font-family: YouSheBiaoTiHei;
  448. font-size: 38rpx
  449. }
  450. }
  451. &-close {
  452. width: 100%;
  453. position: absolute;
  454. bottom: -140rpx;
  455. &-content {
  456. width: 70rpx;
  457. height: 70rpx;
  458. border-radius: 50%;
  459. border: 1px solid #fff;
  460. }
  461. }
  462. }
  463. }
  464. .lucky {
  465. width: 100%;
  466. height: 100vh;
  467. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/hit_bkg.png) center center no-repeat;
  468. background-size: 100vw 100vh;
  469. }
  470. .null-prize {
  471. display: flex;
  472. flex-direction: column;
  473. align-items: center;
  474. justify-content: center;
  475. width: 80vw;
  476. height: 320rpx;
  477. background-color: #FFFFFF;
  478. border: 1px solid rgba(187, 187, 187, 100);
  479. .btn {
  480. margin-top: 60rpx;
  481. width: 160rpx;
  482. height: 60rpx;
  483. line-height: 60rpx;
  484. border-radius: 8rpx;
  485. background-color: rgba(235, 112, 9, 100);
  486. color: rgba(255, 255, 255, 100);
  487. font-size: 28rpx;
  488. text-align: center;
  489. }
  490. }
  491. // 支付后移动动画
  492. @keyframes shadowMove {
  493. 0% {
  494. left: 0%;
  495. }
  496. 100% {
  497. left: 100%;
  498. }
  499. }
  500. // 支付后移动动画
  501. @keyframes shadowTwoMove {
  502. 0% {
  503. left: -20%;
  504. }
  505. 100% {
  506. left: 100%;
  507. }
  508. }
  509. </style>