lottery_comment.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <view :style="colorStyle">
  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. {{$t(`评价完成`)}}
  9. </text>
  10. <text class="date">
  11. {{$util.getNowTime()}}
  12. </text>
  13. </view>
  14. </view>
  15. <view class="jump">
  16. <view class="jump-index" @click="goIndex">
  17. {{$t(`返回首页`)}}
  18. </view>
  19. </view>
  20. </view>
  21. <view class="grids-top" v-show="lotteryShow">
  22. <image src="../static/pay-lottery-l.png" mode=""></image>
  23. <view class="grids-title">
  24. <view>{{$t(`恭喜您`)}},{{$t(`获得`)}} {{lottery_num}} {{$t(`机会`)}}</view>
  25. </view>
  26. <image src="../static/pay-lottery-r.png" mode=""></image>
  27. </view>
  28. <view class="grids" v-show="lotteryShow">
  29. <image class="grids-bag" src="../static/pay-lottery-bag.png" mode=""></image>
  30. <view class="grids-box">
  31. <gridsLottery class="" :lotteryNum="lottery_num" :prizeData="prize" @get_winingIndex='getWiningIndex'
  32. @luck_draw_finish='luck_draw_finish'>
  33. </gridsLottery>
  34. </view>
  35. </view>
  36. <lotteryAleart :aleartStatus="aleartStatus" @close="closeLottery" :alData="alData" :aleartType="aleartType">
  37. </lotteryAleart>
  38. <view class="mask" v-if="aleartStatus || addressModel" @click="lotteryAleartClose"></view>
  39. <userAddress :aleartStatus="addressModel" @getAddress="getAddress" @close="()=>{addressModel = false}">
  40. </userAddress>
  41. </view>
  42. </template>
  43. <script>
  44. import gridsLottery from '../components/lottery/index.vue'
  45. import lotteryAleart from './components/lotteryAleart.vue'
  46. import userAddress from './components/userAddress.vue'
  47. import {
  48. openOrderSubscribe
  49. } from '@/utils/SubscribeMessage.js';
  50. import {
  51. getNowTime
  52. } from '@/utils/util.js'
  53. import {
  54. toLogin
  55. } from '@/libs/login.js';
  56. import {
  57. getLotteryData,
  58. startLottery,
  59. receiveLottery
  60. } from '@/api/lottery.js'
  61. import {
  62. mapGetters
  63. } from "vuex";
  64. // #ifdef MP
  65. import authorize from '@/components/Authorize';
  66. // #endif
  67. import colors from '@/mixins/color.js';
  68. export default {
  69. mixins: [colors],
  70. components: {
  71. // #ifdef MP
  72. authorize,
  73. // #endif
  74. gridsLottery,
  75. lotteryAleart,
  76. userAddress
  77. },
  78. computed: mapGetters(['isLogin']),
  79. data() {
  80. return {
  81. lotteryShow: false,
  82. addressModel: false,
  83. lottery_num: 0,
  84. aleartType: 0,
  85. aleartStatus: false,
  86. lottery_draw_param: {
  87. startIndex: 3, //开始抽奖位置,从0开始
  88. totalCount: 3, //一共要转的圈数
  89. winingIndex: 1, //中奖的位置,从0开始
  90. speed: 100 //抽奖动画的速度 [数字越大越慢,默认100]
  91. },
  92. alData: {},
  93. type: '',
  94. date: '',
  95. prize: [],
  96. orderId: '',
  97. order_pay_info: {
  98. paid: 1,
  99. _status: {}
  100. },
  101. isAuto: false, //没有授权的不会自动授权
  102. isShowAuth: false, //是否隐藏授权
  103. couponsHidden: true,
  104. couponList: []
  105. };
  106. },
  107. computed: mapGetters(['isLogin']),
  108. watch: {
  109. isLogin: {
  110. handler: function(newV, oldV) {
  111. if (newV) {
  112. // this.getOrderPayInfo();
  113. }
  114. },
  115. deep: true
  116. }
  117. },
  118. onLoad(options) {
  119. this.orderId = options.order_id;
  120. this.type = options.type;
  121. // this.date = this.set_time(options.date);
  122. if (this.isLogin) {
  123. // this.getOrderPayInfo();
  124. this.getLotteryData(this.type)
  125. } else {
  126. toLogin();
  127. }
  128. // #ifdef H5
  129. document.addEventListener('visibilitychange', (e) => {
  130. let state = document.visibilityState
  131. if (state == 'hidden') {}
  132. if (state == 'visible') {
  133. // this.getOrderPayInfo();
  134. }
  135. });
  136. // #endif
  137. },
  138. methods: {
  139. set_time(str) {
  140. var n = parseInt(str);
  141. var D = new Date(n);
  142. var year = D.getFullYear(); //四位数年份
  143. var month = D.getMonth() + 1; //月份(0-11),0为一月份
  144. month = month < 10 ? ('0' + month) : month;
  145. var day = D.getDate(); //月的某一天(1-31)
  146. day = day < 10 ? ('0' + day) : day;
  147. var hours = D.getHours(); //小时(0-23)
  148. hours = hours < 10 ? ('0' + hours) : hours;
  149. var minutes = D.getMinutes(); //分钟(0-59)
  150. minutes = minutes < 10 ? ('0' + minutes) : minutes;
  151. // var seconds = D.getSeconds();//秒(0-59)
  152. // seconds = seconds<10?('0'+seconds):seconds;
  153. // var week = D.getDay();//周几(0-6),0为周日
  154. // var weekArr = ['周日','周一','周二','周三','周四','周五','周六'];
  155. var now_time = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes;
  156. return now_time;
  157. },
  158. openTap() {
  159. this.$set(this, 'couponsHidden', !this.couponsHidden);
  160. },
  161. getWiningIndex(callback) {
  162. startLottery({
  163. id: this.id
  164. }).then(res => {
  165. this.prize.forEach((item, index) => {
  166. if (res.data.id === item.id) {
  167. this.alData = res.data
  168. this.lottery_draw_param.winingIndex = index;
  169. callback(this.lottery_draw_param);
  170. }
  171. })
  172. this.aleartType = 0
  173. }).catch(err => {
  174. this.$util.Tips({
  175. title: err
  176. });
  177. })
  178. },
  179. /**
  180. * 去首页关闭当前所有页面
  181. */
  182. goIndex: function(e) {
  183. uni.switchTab({
  184. url: '/pages/index/index'
  185. });
  186. },
  187. getLotteryData(type) {
  188. getLotteryData(type).then(res => {
  189. this.lotteryShow = true
  190. this.factor_num = res.data.lottery.factor_num
  191. this.id = res.data.lottery.id
  192. this.prize = res.data.lottery.prize
  193. this.lottery_num = res.data.lottery_num
  194. this.prize.push({
  195. a: 1
  196. })
  197. }).catch(err => {
  198. uni.redirectTo({
  199. url: '/pages/goods/order_details/index?order_id=' + this.orderId
  200. })
  201. })
  202. },
  203. closeLottery(status) {
  204. this.aleartStatus = false
  205. this.getLotteryData(this.type)
  206. if (this.alData.type === 6) {
  207. this.addressModel = true
  208. }
  209. },
  210. getAddress(data) {
  211. let addData = data
  212. addData.id = this.alData.lottery_record_id
  213. addData.address = data.address.province + data.address.city + data.address.district + data.detail
  214. receiveLottery(addData).then(res => {
  215. this.$util.Tips({
  216. title: this.$t(`领取成功`)
  217. });
  218. this.addressModel = false
  219. }).catch(err => {
  220. this.$util.Tips({
  221. title: err
  222. });
  223. })
  224. },
  225. getWiningIndex(callback) {
  226. this.aleartType = 0
  227. startLottery({
  228. id: this.id
  229. }).then(res => {
  230. this.prize.forEach((item, index) => {
  231. if (res.data.id === item.id) {
  232. this.alData = res.data
  233. this.lottery_draw_param.winingIndex = index;
  234. callback(this.lottery_draw_param);
  235. }
  236. })
  237. }).catch(err => {
  238. this.$util.Tips({
  239. title: err
  240. });
  241. })
  242. // //props修改在小程序和APP端不成功,所以在这里使用回调函数传参,
  243. },
  244. // 抽奖完成
  245. luck_draw_finish(param) {
  246. this.aleartType = 2
  247. this.aleartStatus = true
  248. },
  249. }
  250. }
  251. </script>
  252. <style lang="scss" scoped>
  253. .header {
  254. color: #fff;
  255. background-color: var(--view-theme);
  256. display: flex;
  257. align-items: center;
  258. justify-content: center;
  259. flex-direction: column;
  260. padding: 80rpx 0;
  261. .pay-status {
  262. display: flex;
  263. align-items: center;
  264. .iconfont {
  265. font-size: 74rpx;
  266. background: rgba(#000, 0.08);
  267. border-radius: 50%;
  268. margin-right: 30rpx;
  269. padding: 9rpx;
  270. }
  271. .pay-status-r {
  272. display: flex;
  273. flex-direction: column;
  274. .pay-status-text {
  275. font-size: 38rpx;
  276. font-weight: bold;
  277. padding-bottom: 10rpx;
  278. }
  279. }
  280. }
  281. .grids /deep/ .grid_wrap .lottery_wrap .lottery_grid li:nth-of-type(9) {
  282. background: rgba(#fff, 0.2) !important;
  283. }
  284. .jump {
  285. display: flex;
  286. padding-top: 40rpx;
  287. .jump-det {
  288. background: #FFFFFF;
  289. opacity: 1;
  290. border-radius: 22px;
  291. color: #E93323;
  292. padding: 10rpx 38rpx;
  293. margin-right: 30rpx;
  294. }
  295. .jump-index {
  296. border: 1px solid #FEFFFF;
  297. opacity: 1;
  298. padding: 10rpx 38rpx;
  299. border-radius: 22px;
  300. }
  301. }
  302. }
  303. .grids-top {
  304. display: flex;
  305. justify-content: center;
  306. padding: 30rpx 0 0 0;
  307. image {
  308. width: 40rpx;
  309. height: 40rpx;
  310. }
  311. .grids-title {
  312. display: flex;
  313. flex-wrap: wrap;
  314. justify-content: flex-start;
  315. font-size: 20px;
  316. color: #E93323;
  317. z-index: 999;
  318. padding: 0 14rpx;
  319. font-weight: bold;
  320. .grids-frequency {}
  321. }
  322. }
  323. /deep/ .lottery_grid {
  324. background-color: #E93323;
  325. border-radius: 12rpx;
  326. }
  327. .date {
  328. font-size: 26rpx;
  329. color: #fff;
  330. }
  331. .grids {
  332. width: 100%;
  333. // height: 800rpx;
  334. display: flex;
  335. flex-direction: column;
  336. justify-content: center;
  337. align-items: center;
  338. margin-top: 20rpx;
  339. position: relative;
  340. padding: 30rpx;
  341. .grids-bag {
  342. position: absolute;
  343. top: 0;
  344. left: 0;
  345. width: 750rpx;
  346. height: 750rpx;
  347. padding: 20rpx;
  348. display: flex;
  349. justify-content: center;
  350. align-items: center;
  351. }
  352. .grids-box {
  353. width: 700rpx;
  354. height: 700rpx;
  355. // z-index: 10000;
  356. padding: 20rpx;
  357. background-color: #E74435;
  358. }
  359. .winning-tips-list {
  360. display: flex;
  361. align-items: center;
  362. justify-content: center;
  363. width: 50%;
  364. font-size: 20rpx;
  365. line-height: 40rpx;
  366. height: 40rpx;
  367. font-weight: 400;
  368. color: #FFF8F8;
  369. margin: 30rpx 0;
  370. z-index: 999;
  371. background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.3) 51%, rgba(255, 255, 255, 0) 100%);
  372. .iconfont {
  373. font-size: 20rpx;
  374. margin-right: 10rpx;
  375. }
  376. }
  377. }
  378. </style>