payLottery.vue 10 KB

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