index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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_not_num.png" mode="" v-if="info.status == 1"></image>
  13. <image src="../../static/lucky/lucky_ok_num.png" mode="" v-else></image>
  14. <view class="luck-info-content-num__content flex" v-if="info.status == 2">
  15. <text>{{ info.plainLuckyNum }}</text>
  16. </view>
  17. </view>
  18. <view class="luck-info-content-title" v-if="info.status == 1">- 幸运数字 -</view>
  19. <view class="luck-info-content-tip" v-else>请刮开纸质票面的数字,与此幸运数字相同的就是所中奖项</view>
  20. <view class="luck-info-content-ticket">
  21. <image src="../../static/lucky/lucky_not.png" mode="" v-if="info.status == 1"></image>
  22. <image src="../../static/lucky/lucky_ok.png" mode="" v-else></image>
  23. <view class="luck-info-content-ticket-info flex">
  24. <view class="title" :class="{ 'action': info.status == 2 }">{{ info.title }}</view>
  25. <view class="serialNo" :class="{ 'action': info.status == 2 }">盲票序列号:{{ info.serialNo }}</view>
  26. </view>
  27. </view>
  28. <view class="luck-info-content-btn" @click="pay" v-if="info.status == 1">支付{{ info.salePrice / 100 }}元 立即查看</view>
  29. <view class="luck-info-content-btn code" @click="scanCode" v-else>扫码兑奖</view>
  30. </view>
  31. <view class="luck-info-close flex">
  32. <navigator open-type="exit" target="miniProgram" hover-class="none" class="luck-info-close-content flex">
  33. <u-icon name="close" color="#fff" size="20"></u-icon>
  34. </navigator>
  35. </view>
  36. </view>
  37. </view>
  38. </u-overlay>
  39. <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="getDetailInfo" v-if="payShow" />
  40. <u-popup :show="showNull" :round="10" mode="center" :safeAreaInsetBottom="false" overlayOpacity="0.8"
  41. @touchmove.prevent.stop>
  42. <view class="null-prize">
  43. <view class="title">该盲票已兑奖</view>
  44. <!-- <navigator open-type="exit" target="miniProgram" hover-class="none" class="btn">确认</navigator> -->
  45. <view class="btn" @click="toUser">确认</view>
  46. </view>
  47. </u-popup>
  48. <u-popup :show="showAction" :round="10" mode="center" :safeAreaInsetBottom="false" overlayOpacity="0.8"
  49. @touchmove.prevent.stop>
  50. <view class="null-prize">
  51. <view class="title">该盲票未激活</view>
  52. <navigator open-type="exit" target="miniProgram" hover-class="none" class="btn">确认</navigator>
  53. </view>
  54. </u-popup>
  55. </view>
  56. </template>
  57. <script>
  58. import env from '../../config/env.js'
  59. import $http from '@/utils/request.js'
  60. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  61. export default {
  62. components: {
  63. PayPopup
  64. },
  65. data() {
  66. return {
  67. serialNo: '',
  68. info: '',
  69. payInfo: {},
  70. payShow: false,
  71. payLookFlag: true,
  72. showNull: false,
  73. luckyShow: false,
  74. status: 2,
  75. showAction: false,
  76. };
  77. },
  78. onLoad(options) {
  79. if (options.id) {
  80. this.serialNo = options.id
  81. this.getDetail()
  82. }
  83. if (options.q) {
  84. let url = JSON.stringify(options.q)
  85. this.serialNo = url.substring(url.length - 22, url.length - 1)
  86. this.getDetail()
  87. }
  88. },
  89. methods: {
  90. scanCode() {
  91. let _this = this
  92. uni.scanCode({
  93. scanType: ['qrCode'],
  94. success(res) {
  95. let url = res.result
  96. _this.serialNo = url.substring(url.length - 21, url.length)
  97. _this.getDetail()
  98. },
  99. fail() {
  100. uni.$u.toast('请扫二维码');
  101. }
  102. });
  103. },
  104. getDetail() {
  105. uni.showLoading({
  106. title: '加载中'
  107. });
  108. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  109. serialNo: this.serialNo,
  110. noToken: true
  111. }).then(res => {
  112. uni.hideLoading();
  113. if (res.code == 0) {
  114. if (res.data.status == 1) {
  115. this.info = res.data
  116. this.luckyShow = true
  117. } else if (res.data.status == 2) {
  118. this.info = res.data
  119. if (uni.getStorageSync('token')) {
  120. uni.redirectTo({
  121. url: `/packagePrize/choice/index?id=${ res.data.ticketId }&type=offLine`
  122. })
  123. } else {
  124. this.luckyShow = true
  125. uni.showModal({
  126. title: '提示',
  127. content: '您未登录或登录失效!',
  128. confirmText: '去登录',
  129. showCancel: false,
  130. success(res) {
  131. if (res.confirm) {
  132. uni.navigateTo({
  133. url: "/pages/login/index"
  134. })
  135. }
  136. }
  137. })
  138. }
  139. } else {
  140. this.showNull = true
  141. this.luckyShow = false
  142. }
  143. } else if (res.code == 1023) {
  144. this.showAction = true
  145. this.luckyShow = false
  146. } else {
  147. uni.$u.toast('该盲票不存在!');
  148. setTimeout(() => {
  149. uni.switchTab({
  150. url: '/pages/index/index'
  151. })
  152. }, 1000)
  153. }
  154. }).catch(() => {
  155. uni.hideLoading();
  156. })
  157. },
  158. getDetailInfo() {
  159. let _this = this
  160. _this.payShow = false
  161. uni.showLoading({
  162. title: '加载中'
  163. });
  164. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  165. serialNo: _this.serialNo,
  166. noToken: true
  167. }).then(res => {
  168. uni.hideLoading();
  169. if (res.code == 0) {
  170. if (res.data.status == 2) {
  171. _this.info = res.data
  172. let num = res.data.plainLuckyNum
  173. } else {
  174. let num = 0
  175. let time = setInterval(() => {
  176. num++
  177. uni.showLoading({
  178. title: '加载中'
  179. });
  180. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  181. serialNo: _this.serialNo,
  182. noToken: true
  183. }).then(ele => {
  184. if (ele.data.status == 2) {
  185. uni.hideLoading();
  186. clearInterval(time)
  187. _this.info = res.data
  188. let num = res.data.plainLuckyNum
  189. }
  190. })
  191. if (num == 10) {
  192. uni.hideLoading();
  193. clearInterval(time)
  194. }
  195. }, 1000)
  196. }
  197. }
  198. }).catch(() => {
  199. uni.hideLoading();
  200. })
  201. },
  202. close() {
  203. this.payShow = false
  204. },
  205. pay() {
  206. let data = {
  207. ticketId: this.info.ticketId,
  208. autoCoupon: 1,
  209. userCouponIds: [],
  210. orderNum: 1
  211. }
  212. this.payLookFlag = false
  213. uni.showLoading({
  214. title: '加载中'
  215. });
  216. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  217. uni.hideLoading();
  218. if (res.code == 0) {
  219. let info = {
  220. ...res.data,
  221. ...this.info,
  222. picUrl: env.filePublic + res.data.picUrl,
  223. couponTitle: res.data && res.data.couponList && res.data.couponList.length && res
  224. .data.couponList[0].title,
  225. couponId: res.data && res.data.couponList && res.data.couponList.length && res.data
  226. .couponList[0].id,
  227. }
  228. this.payInfo = info
  229. this.payShow = true
  230. }
  231. }).catch(() => {
  232. uni.hideLoading();
  233. })
  234. },
  235. toUser() {
  236. uni.switchTab({
  237. url: '/pages/user/index'
  238. })
  239. },
  240. saveImg() {
  241. this.$refs.hchPoster.posterShow()
  242. },
  243. }
  244. }
  245. </script>
  246. <style lang="scss" scoped>
  247. .luck-warp {
  248. height: 100%;
  249. .luck-info {
  250. position: relative;
  251. width: 87vw;
  252. height: 60vh;
  253. // background-color: #fff;
  254. &-bg {
  255. position: absolute;
  256. top: 0;
  257. image {
  258. width: 87vw;
  259. height: 60vh;
  260. }
  261. }
  262. &-content {
  263. flex-direction: column;
  264. justify-content: flex-start;
  265. position: absolute;
  266. top: 0;
  267. z-index: 10;
  268. width: 100%;
  269. height: 100%;
  270. &-num {
  271. position: relative;
  272. width: 60%;
  273. height: 10vh;
  274. margin-top: 17vh;
  275. margin-bottom: 2vh;
  276. image {
  277. position: absolute;
  278. top: 0;
  279. width: 100%;
  280. height: 100%;
  281. }
  282. &__content {
  283. position: absolute;
  284. top: 0;
  285. width: 100%;
  286. height: 100%;
  287. z-index: 5;
  288. font-size: 120rpx;
  289. font-family: YouSheBiaoTiHei;
  290. font-weight: 400;
  291. color: #FD3331;
  292. }
  293. }
  294. &-title {
  295. font-size: 40rpx;
  296. line-height: 40rpx;
  297. color: #FEFEFE;
  298. margin-bottom: 1vh;
  299. }
  300. &-tip {
  301. width: 80%;
  302. font-size: 26rpx;
  303. line-height: 35rpx;
  304. text-align: center;
  305. color: #fff;
  306. }
  307. &-ticket {
  308. position: relative;
  309. width: 96%;
  310. height: 14vh;
  311. margin-bottom: 2vh;
  312. image {
  313. position: absolute;
  314. top: 0;
  315. width: 100%;
  316. height: 100%;
  317. }
  318. &-info {
  319. width: 100%;
  320. height: 100%;
  321. position: absolute;
  322. top: 0;
  323. z-index: 5;
  324. flex-direction: column;
  325. .title {
  326. font-size: 36rpx;
  327. line-height: 36rpx;
  328. font-weight: bold;
  329. color: #FF6D2C;
  330. margin-bottom: 2vh;
  331. }
  332. .serialNo {
  333. font-size: 26rpx;
  334. color: #FF6D2C;
  335. }
  336. .action {
  337. color: #FFCBAA;
  338. }
  339. }
  340. }
  341. &-btn {
  342. padding: 0 13%;
  343. height: 8vh;
  344. line-height: 8vh;
  345. background: linear-gradient(0deg, #FF4924, #F9D448);
  346. box-shadow: 0px 6px 9px 0px rgba(135, 19, 3, 0.49);
  347. border-radius: 4vh;
  348. text-align: center;
  349. color: #FEFEFE;
  350. font-size: 40rpx;
  351. }
  352. .code {
  353. padding: 0 20%;
  354. }
  355. }
  356. &-close {
  357. width: 100%;
  358. position: absolute;
  359. bottom: -140rpx;
  360. &-content {
  361. width: 70rpx;
  362. height: 70rpx;
  363. border-radius: 50%;
  364. border: 1px solid #fff;
  365. }
  366. }
  367. }
  368. }
  369. .lucky {
  370. width: 100%;
  371. height: 100vh;
  372. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/v2/hit_bkg.png) center center no-repeat;
  373. background-size: 100vw 100vh;
  374. }
  375. .null-prize {
  376. display: flex;
  377. flex-direction: column;
  378. align-items: center;
  379. justify-content: center;
  380. width: 80vw;
  381. height: 320rpx;
  382. background-color: #FFFFFF;
  383. border: 1px solid rgba(187, 187, 187, 100);
  384. .btn {
  385. margin-top: 60rpx;
  386. width: 160rpx;
  387. height: 60rpx;
  388. line-height: 60rpx;
  389. border-radius: 8rpx;
  390. background-color: rgba(235, 112, 9, 100);
  391. color: rgba(255, 255, 255, 100);
  392. font-size: 28rpx;
  393. text-align: center;
  394. }
  395. }
  396. </style>