index.vue 13 KB

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