index.vue 10.0 KB

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