index.vue 13 KB

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