Browse Source

抽奖页面

DESKTOP-O04BTUJ\muzen 3 years atrás
parent
commit
34dd038cdf
2 changed files with 16 additions and 21 deletions
  1. 9 5
      src/pages/lottery/detail.vue
  2. 7 16
      src/pages/lottery/index.vue

+ 9 - 5
src/pages/lottery/detail.vue

@@ -1,6 +1,6 @@
 <template>
   <view class="app-container">
-    <view class="nav" :style="{'margin-top': statusBarHeight}">
+    <view class="nav" :style="{'margin-top': '44rpx'}">
       <uni-icons type="back" style="font-size: 48rpx" @click="getBack" />
       <text class="title">积分抽奖</text>
     </view>
@@ -28,7 +28,8 @@ import { receive } from '@/api/lottery.js'
 export default {
   data() {
     return {
-      statusBarHeight: 0,
+      // 用户信息
+      userInfo: {},
       // 表单
       form: {},
       // 防重复点击
@@ -36,8 +37,11 @@ export default {
     }
   },
   onLoad(e) {
-    this.form = e
-    this.statusBarHeight = uni.getWindowInfo().statusBarHeight + 'px'
+    this.form = {
+      resultGoodId: e.resultGoodId,
+      lotteryCode: e.lotteryCode
+    }
+    this.userInfo = JSON.parse(e.userInfo)
   },
   methods: {
     // 返回
@@ -66,7 +70,7 @@ export default {
         })
       } else {
         this.disabled = true
-        receive(this.form).then(res => {
+        receive(this.userInfo, this.form).then(res => {
           if (res.data.code === 0) {
             uni.showToast({
               title: '提交成功!',

+ 7 - 16
src/pages/lottery/index.vue

@@ -85,15 +85,14 @@ export default {
     getUserInfo.postMessage('获取用户信息')
     // 暴露setUserInfo方法给APP
     window['setUserInfo'] = res => {
-      this.setUserInfo(res)
-      console.log(res);
+      this.userInfo = res
+      this.setUserInfo()
     }
   },
   methods: {
-    setUserInfo(e) {
-      
+    setUserInfo() {
       this.prizes = []
-      page(JSON.parse(e)).then(res => {
+      page(JSON.parse(this.userInfo)).then(res => {
         if (res.data.code === 0) {
           const j = res.data.data
           // 可用积分
@@ -136,9 +135,7 @@ export default {
           this.$refs.lucky.play()
           if (this.disabled) {
             this.disabled = false
-            result({
-              userId: this.userId
-            }).then(res => {
+            result(JSON.parse(this.userInfo)).then(res => {
               if (res.data.code === 0) {
                 setTimeout(() => {
                   this.$refs.lucky.stop(res.data.data.resultGoodSort - 1)
@@ -185,9 +182,8 @@ export default {
     getSubmit() {
       if (this.disabled) {
         this.disabled = false
-        receive({
+        receive(JSON.parse(this.userInfo), {
           prizeId: this.form.resultGoodId,
-          userId: this.form.userId,
           lotteryCode: this.form.lotteryCode
         }).then(res => {
           if (res.data.code === 0) {
@@ -206,7 +202,7 @@ export default {
     // 填写收货信息
     getDetail() {
       uni.navigateTo({
-        url: `/pages/lottery/detail?userId=${this.userId}&prizeId=${this.form.resultGoodId}&lotteryCode=${this.form.lotteryCode}`
+        url: `/pages/lottery/detail?userInfo=${this.userInfo}&prizeId=${this.form.resultGoodId}&lotteryCode=${this.form.lotteryCode}`
       })
     }
   }
@@ -214,10 +210,6 @@ export default {
 </script>
 
 <style lang="scss" scoped>
-page{
-  height: none;
-}
-
 .app-container {
   position: relative;
   background: url('@/static/lottery/bg.png');
@@ -225,7 +217,6 @@ page{
   background-repeat: no-repeat;
   width: 100%;
   height: 1880rpx;
-  margin-top: 44rpx;
 
   .nav {
     height: 88rpx;