payLottery.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. <template>
  2. <view>
  3. <view class="header" v-show="lotteryShow">
  4. <view class="pay-status">
  5. <text class="iconfont icon-gou"></text>
  6. <view class="pay-status-r">
  7. <text class="pay-status-text">
  8. 支付成功
  9. </text>
  10. <text>
  11. 支付金额:¥{{totalPrice}}
  12. </text>
  13. </view>
  14. </view>
  15. <view class="jump">
  16. <view class="jump-det" @click="orderDetails">
  17. 查看订单
  18. </view>
  19. <view v-if="orderInfo.pink_id" class="jump-index" @click="goPink(orderInfo.pink_id)">
  20. {{orderInfo.pinkStatus==2?'查看拼团':'邀请参团'}}
  21. </view>
  22. <view v-else class="jump-index" @click="goIndex">
  23. 返回首页
  24. </view>
  25. </view>
  26. </view>
  27. <view class="grids-top" v-show="lotteryShow">
  28. <image src="../static/pay-lottery-l.png" mode=""></image>
  29. <view class="grids-title">
  30. <view>恭喜您,</view>
  31. <view class="grids-frequency">获得{{lottery_num}}次</view>
  32. <view>抽奖机会</view>
  33. </view>
  34. <image src="../static/pay-lottery-r.png" mode=""></image>
  35. </view>
  36. <view class='termValidity acea-row row-center-wrapper' v-show="lotteryShow">
  37. <view class='timeItem acea-row row-center-wrapper'>
  38. <view>距有效期仅剩</view>
  39. <countDown :is-day="false" :tip-text="' '" :day-text="' '" :hour-text="' : '"
  40. :minute-text="' : '" :second-text="' '" :datatime="datatime"
  41. style="margin-top: 4rpx;"></countDown>
  42. </view>
  43. </view>
  44. <view class="grids" v-show="lotteryShow">
  45. <image class="grids-bag" :src="imgHost + '/statics/images/pay-lottery-bag.png'" mode=""></image>
  46. <view class="grids-box">
  47. <gridsLottery class="" :prizeData="prize" @get_winingIndex='getWiningIndex'
  48. @luck_draw_finish='luck_draw_finish' :lotteryType='1' :datatime="datatime">
  49. </gridsLottery>
  50. </view>
  51. </view>
  52. <lotteryAleart :aleartStatus="aleartStatus" @close="closeLottery" :alData="alData" :aleartType="aleartType">
  53. </lotteryAleart>
  54. <view class="mask" v-if="aleartStatus || addressModel"></view>
  55. <userAddress v-if="addressModel" :aleartStatus="addressModel" @getAddress="getAddress" @close="()=>{addressModel = false}">
  56. </userAddress>
  57. <!-- #ifdef MP -->
  58. <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize>
  59. <!-- #endif -->
  60. </view>
  61. </template>
  62. <script>
  63. import countDown from '@/components/countDown';
  64. import gridsLottery from '../components/lottery/index.vue'
  65. import lotteryAleart from '../components/lotteryAleart/index.vue'
  66. import userAddress from '../components/userAddress/index.vue'
  67. import {getOrderDetail} from '@/api/order.js';
  68. import {openOrderSubscribe} from '@/utils/SubscribeMessage.js';
  69. import {toLogin} from '@/libs/login.js';
  70. import {
  71. getLotteryData,
  72. startLottery,
  73. receiveLottery
  74. } from '@/api/lottery.js'
  75. import {
  76. mapGetters
  77. } from "vuex";
  78. import {HTTP_REQUEST_URL} from '@/config/app';
  79. export default {
  80. components: {
  81. gridsLottery,
  82. lotteryAleart,
  83. userAddress,
  84. countDown
  85. },
  86. props: {
  87. options: {
  88. type: Object
  89. },
  90. orderPayInfo: {
  91. type: Object
  92. }
  93. },
  94. data() {
  95. return {
  96. lotteryShow: false,
  97. addressModel: false,
  98. lottery_num: 0,
  99. aleartType: 0,
  100. aleartStatus: false,
  101. lottery_draw_param: {
  102. startIndex: 3, //开始抽奖位置,从0开始
  103. totalCount: 3, //一共要转的圈数
  104. winingIndex: 1, //中奖的位置,从0开始
  105. speed: 100 //抽奖动画的速度 [数字越大越慢,默认100]
  106. },
  107. alData: {},
  108. type: '',
  109. prize: [],
  110. orderId: '',
  111. order_pay_info: {
  112. paid: 1,
  113. _status: {}
  114. },
  115. isAuto: false, //没有授权的不会自动授权
  116. isShowAuth: false, //是否隐藏授权
  117. couponsHidden: true,
  118. couponList: [],
  119. totalPrice: 0,
  120. datatime:0,
  121. orderInfo:{},
  122. imgHost:HTTP_REQUEST_URL
  123. };
  124. },
  125. computed: mapGetters(['isLogin']),
  126. watch: {
  127. isLogin: {
  128. handler: function(newV, oldV) {
  129. if (newV) {}
  130. },
  131. deep: true
  132. },
  133. options: {
  134. handler: function(newV, oldV) {
  135. if (newV) {
  136. this.orderId = newV.order_id;
  137. this.totalPrice = newV.totalPrice;
  138. this.type = newV.type
  139. if(this.isLogin){
  140. this.getLotteryData(newV.type)
  141. }else{
  142. //#ifndef MP
  143. toLogin();
  144. //#endif
  145. //#ifdef MP
  146. this.isShowAuth = true;
  147. //#endif
  148. }
  149. }
  150. },
  151. deep: true
  152. },
  153. orderPayInfo: {
  154. handler: function(newV, oldV) {
  155. if (newV) {
  156. this.orderInfo = newV
  157. }
  158. },
  159. deep: true
  160. },
  161. },
  162. created(options) {
  163. // #ifdef H5 || APP-PLUS
  164. this.orderId = this.options.order_id;
  165. this.totalPrice = this.options.totalPrice;
  166. this.type = this.options.type;
  167. // #endif
  168. },
  169. mounted(){
  170. // #ifdef H5 || APP-PLUS
  171. if (this.isLogin) {
  172. this.getLotteryData(this.type)
  173. } else {
  174. toLogin();
  175. }
  176. // #endif
  177. },
  178. methods: {
  179. onLoadFun(){
  180. this.getLotteryData(this.type)
  181. this.isShowAuth = false;
  182. },
  183. // 授权关闭
  184. authColse: function(e) {
  185. this.isShowAuth = e
  186. },
  187. // 去参团页面;
  188. goPink: function(id) {
  189. uni.navigateTo({
  190. url: '/pages/activity/goods_combination_status/index?id=' + id
  191. });
  192. },
  193. openTap() {
  194. this.$set(this, 'couponsHidden', !this.couponsHidden);
  195. },
  196. orderDetails() {
  197. this.$emit('orderDetails')
  198. },
  199. getWiningIndex(callback) {
  200. this.aleartType = 0
  201. startLottery({
  202. id: this.id
  203. }).then(res => {
  204. this.prize.forEach((item, index) => {
  205. if (res.data.id === item.id) {
  206. this.alData = res.data
  207. this.lottery_draw_param.winingIndex = index;
  208. callback(this.lottery_draw_param);
  209. }
  210. })
  211. }).catch(err => {
  212. this.$util.Tips({
  213. title: err
  214. });
  215. })
  216. // //props修改在小程序和APP端不成功,所以在这里使用回调函数传参,
  217. },
  218. /**
  219. * 去首页关闭当前所有页面
  220. */
  221. goIndex: function(e) {
  222. uni.switchTab({
  223. url: '/pages/index/index'
  224. });
  225. },
  226. /**
  227. *
  228. * 去订单详情页面
  229. */
  230. goOrderDetails: function(e) {
  231. // #ifdef MP
  232. uni.showLoading({
  233. title: '正在加载',
  234. })
  235. openOrderSubscribe().then(res => {
  236. uni.hideLoading();
  237. uni.navigateTo({
  238. url: '/pages/goods/order_details/index?order_id=' + this.orderId
  239. });
  240. }).catch(() => {
  241. nui.hideLoading();
  242. });
  243. // #endif
  244. },
  245. getLotteryData(type) {
  246. getLotteryData(type).then(res => {
  247. this.factor_num = res.data.lottery.factor_num
  248. this.id = res.data.lottery.id
  249. this.prize = res.data.lottery.prize
  250. this.lottery_num = res.data.lottery_num
  251. this.prize.push({
  252. a: 1
  253. })
  254. this.$emit('lotteryShow', true)
  255. this.lotteryShow = true
  256. this.datatime = parseInt(res.data.cache_time);
  257. }).catch(err => {
  258. this.$emit('lotteryShow', false)
  259. this.lotteryShow = false
  260. })
  261. },
  262. closeLottery(status) {
  263. this.aleartStatus = false
  264. this.getLotteryData(this.type)
  265. if (this.alData.type === 6) {
  266. this.addressModel = true
  267. }
  268. },
  269. getAddress(data) {
  270. let addData = data
  271. addData.id = this.alData.lottery_record_id
  272. addData.address = data.address.province + data.address.city + data.address.district + data.detail
  273. receiveLottery(addData).then(res => {
  274. this.$util.Tips({
  275. title: '领取成功'
  276. });
  277. this.addressModel = false
  278. }).catch(err => {
  279. this.$util.Tips({
  280. title: err
  281. });
  282. })
  283. },
  284. getWiningIndex(callback) {
  285. this.aleartType = 0
  286. startLottery({
  287. id: this.id
  288. }).then(res => {
  289. this.prize.forEach((item, index) => {
  290. if (res.data.id === item.id) {
  291. this.alData = res.data
  292. this.lottery_draw_param.winingIndex = index;
  293. callback(this.lottery_draw_param);
  294. }
  295. })
  296. }).catch(err => {
  297. this.$util.Tips({
  298. title: err
  299. });
  300. })
  301. // //props修改在小程序和APP端不成功,所以在这里使用回调函数传参,
  302. },
  303. // 抽奖完成
  304. luck_draw_finish(param) {
  305. this.aleartType = 2
  306. this.aleartStatus = true
  307. },
  308. }
  309. }
  310. </script>
  311. <style lang="scss" scoped>
  312. /deep/.timeItem .time .styleAll{
  313. padding: 0 4rpx;
  314. font-size: 26rpx;
  315. color: #fff;
  316. background-color: #ff3d3d;
  317. }
  318. /deep/.timeItem .time .red{
  319. color: #ff3d3d;
  320. }
  321. .termValidity{
  322. margin-top: 10rpx;
  323. }
  324. .header {
  325. color: #fff;
  326. background-color: #E93323;
  327. display: flex;
  328. align-items: center;
  329. justify-content: center;
  330. flex-direction: column;
  331. padding: 80rpx 0;
  332. .pay-status {
  333. display: flex;
  334. align-items: center;
  335. .iconfont {
  336. font-size: 74rpx;
  337. background: rgba(#000, 0.08);
  338. border-radius: 50%;
  339. margin-right: 30rpx;
  340. padding: 9rpx;
  341. }
  342. .pay-status-r {
  343. display: flex;
  344. flex-direction: column;
  345. .pay-status-text {
  346. font-size: 38rpx;
  347. font-weight: bold;
  348. padding-bottom: 10rpx;
  349. }
  350. }
  351. }
  352. .grids /deep/ .grid_wrap .lottery_wrap .lottery_grid li:nth-of-type(9) {
  353. background: rgba(#fff, 0.2) !important;
  354. }
  355. .jump {
  356. display: flex;
  357. padding-top: 40rpx;
  358. .jump-det {
  359. background: #FFFFFF;
  360. opacity: 1;
  361. border-radius: 22px;
  362. color: #E93323;
  363. padding: 10rpx 38rpx;
  364. margin-right: 30rpx;
  365. }
  366. .jump-index {
  367. border: 1px solid #FEFFFF;
  368. opacity: 1;
  369. padding: 10rpx 38rpx;
  370. border-radius: 22px;
  371. }
  372. }
  373. }
  374. .grids-top {
  375. display: flex;
  376. justify-content: center;
  377. padding: 30rpx 0 0 0;
  378. image {
  379. width: 40rpx;
  380. height: 40rpx;
  381. }
  382. .grids-title {
  383. display: flex;
  384. justify-content: center;
  385. font-size: 20px;
  386. color: #E93323;
  387. z-index: 999;
  388. padding: 0 14rpx;
  389. font-weight: bold;
  390. .grids-frequency {}
  391. }
  392. }
  393. /deep/ .lottery_grid {
  394. background-color: #E93323;
  395. border-radius: 12rpx;
  396. }
  397. .grids {
  398. width: 100%;
  399. // height: 800rpx;
  400. display: flex;
  401. flex-direction: column;
  402. justify-content: center;
  403. align-items: center;
  404. margin-top: 20rpx;
  405. position: relative;
  406. padding: 30rpx;
  407. .grids-bag {
  408. position: absolute;
  409. top: 0;
  410. left: 0;
  411. // #ifdef MP
  412. width: 95%;
  413. height: 95%;
  414. // #endif
  415. // #ifdef H5 || APP-PLUS
  416. width: 750rpx;
  417. height: 750rpx;
  418. // #endif
  419. padding: 20rpx;
  420. display: flex;
  421. justify-content: center;
  422. align-items: center;
  423. }
  424. .grids-box {
  425. width: 700rpx;
  426. height: 700rpx;
  427. // z-index: 10000;
  428. padding: 20rpx;
  429. background-color: #E74435;
  430. }
  431. .winning-tips-list {
  432. display: flex;
  433. align-items: center;
  434. justify-content: center;
  435. width: 50%;
  436. font-size: 20rpx;
  437. line-height: 40rpx;
  438. height: 40rpx;
  439. font-weight: 400;
  440. color: #FFF8F8;
  441. margin: 30rpx 0;
  442. z-index: 999;
  443. background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.3) 51%, rgba(255, 255, 255, 0) 100%);
  444. .iconfont {
  445. font-size: 20rpx;
  446. margin-right: 10rpx;
  447. }
  448. }
  449. }
  450. .mask {
  451. position: fixed;
  452. top: 0;
  453. left: 0;
  454. right: 0;
  455. bottom: 0;
  456. background-color: rgba(0, 0, 0, 0.8);
  457. z-index: 9;
  458. }
  459. </style>