lottery_comment.vue 8.8 KB

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