lottery_comment.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="w-full fixed-lt z-99 bg-gradient" :style="{'padding-top': sysHeight + 'px'}">
  4. <view class="w-full px-20 pl-20 h-80 flex-between-center">
  5. <text class="iconfont icon-ic_leftarrow fs-40 text--w111-fff"></text @tap="goIndex">
  6. <text class="fs-34 fw-500 text--w111-fff">评价抽奖</text>
  7. <text></text>
  8. </view>
  9. <view class="flex-col flex-center mt-50">
  10. <view class="flex-y-center">
  11. <text class="iconfont icon-ic-complete1 fs-52 text--w111-fff"></text>
  12. <text class="fs-40 fw-500 text--w111-fff pl-16">评价完成</text>
  13. </view>
  14. <view class="flex-center mt-30">
  15. <view class="w-192 h-64 rd-40rpx flex-center fs-24 text--w111-fff white-border" @tap="goBack">返回订单</view>
  16. <view class="w-192 h-64 rd-40rpx flex-center fs-24 text--w111-fff white-border ml-32" @tap="goIndex">返回首页</view>
  17. </view>
  18. </view>
  19. <view class="h-216"></view>
  20. </view>
  21. <view class="relative content bg--w111-fff w-full pt-32 pl-20 pr-20" :style="{'top': 164 + sysHeight + 'px'}">
  22. <view class="card bg--w111-fff rd-24rpx h-544 pt-32 pl-20 pr-20"
  23. v-show="lotteryShow">
  24. <gridsLottery
  25. :prizeData="prize"
  26. :lotteryNum="lottery_num"
  27. :lotteryType='1'
  28. :datatime="datatime"
  29. @get_winingIndex='getWiningIndex'
  30. @luck_draw_finish='luck_draw_finish' >
  31. </gridsLottery>
  32. </view>
  33. </view>
  34. <lotteryAleart
  35. :aleartStatus="aleartStatus"
  36. theme
  37. :alData="alData"
  38. :aleartType="aleartType"
  39. @close="closeLottery" >
  40. </lotteryAleart>
  41. <view class="mask" v-if="aleartStatus" @tap="lotteryAleartClose"></view>
  42. </view>
  43. </template>
  44. <script>
  45. let sysHeight = uni.getSystemInfoSync().statusBarHeight;
  46. import countDown from '@/components/countDown';
  47. import gridsLottery from '../components/lottery/payLottery.vue'
  48. import lotteryAleart from '../components/lotteryAleart/index.vue'
  49. import colors from "@/mixins/color";
  50. import {
  51. openOrderSubscribe
  52. } from '@/utils/SubscribeMessage.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 { postCartAdd } from '@/api/store.js';
  62. import {
  63. mapGetters
  64. } from "vuex";
  65. import {HTTP_REQUEST_URL} from '@/config/app';
  66. export default {
  67. components: {
  68. gridsLottery,
  69. lotteryAleart,
  70. countDown
  71. },
  72. mixins: [colors],
  73. computed: mapGetters(['isLogin']),
  74. data() {
  75. return {
  76. sysHeight:sysHeight,
  77. lotteryShow: false,
  78. addressModel: false,
  79. lottery_num: 0,
  80. aleartType: 0,
  81. aleartStatus: false,
  82. lottery_draw_param: {
  83. startIndex: 3, //开始抽奖位置,从0开始
  84. totalCount: 3, //一共要转的圈数
  85. winingIndex: 1, //中奖的位置,从0开始
  86. speed: 100 //抽奖动画的速度 [数字越大越慢,默认100]
  87. },
  88. alData: {},
  89. type: '',
  90. prize: [],
  91. orderId: '',
  92. order_pay_info: {
  93. paid: 1,
  94. _status: {}
  95. },
  96. isAuto: false, //没有授权的不会自动授权
  97. isShowAuth: false, //是否隐藏授权
  98. couponsHidden: true,
  99. couponList: [],
  100. datatime:0,
  101. imgHost:HTTP_REQUEST_URL
  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. if (this.isLogin) {
  119. // this.getOrderPayInfo();
  120. this.getLotteryData(this.type)
  121. }
  122. // #ifdef H5
  123. document.addEventListener('visibilitychange', (e) => {
  124. let state = document.visibilityState
  125. if (state == 'hidden') {
  126. }
  127. if (state == 'visible') {
  128. // this.getOrderPayInfo();
  129. }
  130. });
  131. // #endif
  132. },
  133. onShow() {
  134. uni.removeStorageSync('form_type_cart');
  135. if(!this.isLogin){
  136. toLogin()
  137. }
  138. },
  139. methods: {
  140. getWiningIndex(callback) {
  141. this.aleartType = 0
  142. startLottery({
  143. id: this.id
  144. }).then(res => {
  145. this.prize.forEach((item, index) => {
  146. if (res.data.id === item.id) {
  147. this.alData = res.data
  148. this.lottery_draw_param.winingIndex = index;
  149. callback(this.lottery_draw_param);
  150. }
  151. })
  152. }).catch(err => {
  153. this.$util.Tips({
  154. title: err
  155. });
  156. })
  157. },
  158. /**
  159. * 去首页关闭当前所有页面
  160. */
  161. goIndex: function(e) {
  162. uni.switchTab({
  163. url: '/pages/index/index'
  164. });
  165. },
  166. goBack(){
  167. uni.navigateBack()
  168. },
  169. getLotteryData(type) {
  170. getLotteryData(type).then(res => {
  171. this.lotteryShow = true
  172. this.factor_num = res.data.lottery.factor_num
  173. this.id = res.data.lottery.id
  174. this.prize = res.data.lottery.prize
  175. this.lottery_num = res.data.lottery_num
  176. this.prize.push({
  177. a: 1
  178. })
  179. this.datatime = parseInt(res.data.cache_time);
  180. }).catch(err => {
  181. uni.redirectTo({
  182. url: '/pages/goods/order_details/index?order_id=' + this.orderId
  183. })
  184. })
  185. },
  186. closeLottery(status) {
  187. this.aleartStatus = false
  188. this.getLotteryData(this.type)
  189. if (this.alData.type === 6) {
  190. this.addressModel = true
  191. postCartAdd({
  192. cartNum: 1,
  193. new: 1,
  194. is_new: 1,
  195. productId: this.alData.product_id,
  196. uniqueId: this.alData.unique,
  197. luckRecordId: this.alData.lottery_record_id,
  198. }).then(res => {
  199. uni.navigateTo({
  200. url: `/pages/goods/order_confirm/index?new=1&luckRecordId=${this.alData.lottery_record_id}&cartId=${res.data.cartId}&product_id=${this.alData.product_id}`
  201. });
  202. }).catch(err => {
  203. this.$util.Tips({
  204. title: `${err},请联系客服`
  205. });
  206. });
  207. }
  208. },
  209. getWiningIndex(callback) {
  210. this.aleartType = 0
  211. startLottery({
  212. id: this.id
  213. }).then(res => {
  214. this.prize.forEach((item, index) => {
  215. if (res.data.id === item.id) {
  216. this.alData = res.data
  217. this.lottery_draw_param.winingIndex = index;
  218. callback(this.lottery_draw_param);
  219. }
  220. })
  221. }).catch(err => {
  222. this.$util.Tips({
  223. title: err
  224. });
  225. })
  226. // //props修改在小程序和APP端不成功,所以在这里使用回调函数传参,
  227. },
  228. // 抽奖完成
  229. luck_draw_finish(param) {
  230. this.aleartType = 2
  231. this.aleartStatus = true
  232. },
  233. }
  234. }
  235. </script>
  236. <style lang="scss" scoped>
  237. .fs-52{
  238. font-size:52rpx;
  239. }
  240. .white-border{
  241. border: 1px solid #fff;
  242. }
  243. .ml-48{
  244. margin-left: 48rpx;
  245. }
  246. .h-216{
  247. height:216rpx;
  248. }
  249. .h-544{
  250. height:544rpx;
  251. }
  252. .content{
  253. background: #f5f5f5;
  254. border-radius: 40rpx 40rpx 0 0;
  255. left:0;
  256. min-height:500rpx;
  257. }
  258. .card ~ .card{
  259. margin-top: 20rpx;
  260. }
  261. .h-76{
  262. height:76rpx;
  263. }
  264. .cell ~ .cell {
  265. border-top: 1px solid #eee;
  266. }
  267. .card_btn{
  268. width: 114rpx;
  269. height: 52rpx;
  270. border-radius: 26rpx;
  271. border: 1px solid #E93323;
  272. }
  273. </style>