lottery_comment.vue 9.7 KB

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