lottery_comment.vue 9.2 KB

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