lottery_comment.vue 9.1 KB

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