Sfoglia il codice sorgente

完成代理商接口对接,未完成代理商页面确认

yerong 4 anni fa
parent
commit
0d556ae11f

+ 1 - 1
dist/wx

@@ -1 +1 @@
-Subproject commit fb362463d164cf7fdcf6268a497bd3b9f694b7cb
+Subproject commit 9dac92edb2074eef8003c6928bea5a2e26e07c38

+ 1 - 0
src/app.json

@@ -2,6 +2,7 @@
   "pages": [
     "pages/index/main",
     "pages/start/main",
+    "pages/none/main",
     "pages/report/main",
     "pages/game_record/main",
     "pages/user_center/main",

+ 34 - 29
src/components/device/toy/connecting.vue

@@ -187,36 +187,41 @@ export default {
         device_id: $this.deviceId,
         access_token: wx.getStorageSync('token')
       }
-      gameStart($params).then((res) => {
-        let $data = res.data
-        let $res = $data.data
-        console.log('游戏开始返回', $data)
-        if ($data.code == 0) {
-          // if ($data.code) {
-          Toast.success({
-            message: $data.errmsg,
-            onClose() {
-              //调用父级得方法游戏开始得方法
-              $this.$emit('game_start')
-              //设置游戏中
-              $this.connect_toy = 4
-              //设置游戏模式
-              game_store.commit('setMode', $event)
-              // 设置游戏状态为游戏中
-              game_store.commit('setGameStatus', 1)
-              // 设置游戏记录id
-              game_store.commit('setGameRecordId', $res['game_record_id'])
-              //设置游戏时间长
-              game_store.commit('setPlayTime', $res['play_time'])
-              mpvue.navigateTo({
-                url: "/pages/start/main"
-              })
-            }
-          })
-        } else {
-          Toast.fail($data.errmsg)
+      gameStart($params).then(
+        (res) => {
+          let $data = res.data
+          let $res = $data.data
+          console.log('游戏开始返回', $data)
+          if ($data.code == 0) {
+            // if ($data.code) {
+            Toast.success({
+              message: $data.errmsg,
+              onClose() {
+                //调用父级得方法游戏开始得方法
+                $this.$emit('game_start')
+                //设置游戏中
+                $this.connect_toy = 4
+                //设置游戏模式
+                game_store.commit('setMode', $event)
+                // 设置游戏状态为游戏中
+                game_store.commit('setGameStatus', 1)
+                // 设置游戏记录id
+                game_store.commit('setGameRecordId', $res['game_record_id'])
+                //设置游戏时间长
+                game_store.commit('setPlayTime', $res['play_time'])
+                mpvue.navigateTo({
+                  url: "/pages/start/main"
+                })
+              }
+            })
+          } else {
+            Toast.fail($data.errmsg)
+          }
+        },
+        (err) => {
+          console.log(err)
         }
-      })
+      )
 
     },
     //点击隐藏

+ 0 - 1
src/components/device/unconnect.vue

@@ -18,7 +18,6 @@
 </template>
 
 <script>
-import Toast from '../../../static/vant/toast/toast';
 
 var $this
 export default {

+ 21 - 19
src/components/index/login.vue

@@ -52,29 +52,31 @@ export default {
         Toast.fail('该用户已绑定邀请码')
       }
       //本地存储没有邀请码
-      if (!$_code) {
-        //校验邀请码
-        userCheckInvite($code).then((res) => {
-          let $res = res.data;
-          if ($res.code != 0) {
-            Toast.fail({
-              message: $res.errmsg,
-              duration: 3,
-              onClose() {
-                $this.$emit('changeStatus', 'scan')
-              }
-            })
-          }
-        })
-      }
+      // if (!$_code) {
+      //   //校验邀请码
+      //   userCheckInvite($code).then((res) => {
+      //     let $res = res.data;
+      //     if ($res.code != 0) {
+      //       Toast.fail({
+      //         message: $res.errmsg,
+      //         duration: 0
+      //         // onClose() {
+      //         //   $this.$emit('changeStatus', 'scan')
+      //         // }
+      //       })
+      //     }
+      //   })
+      // }
 
 
     }
     // 测试注释
-    // else {
-    //   // 跳转到关于水母页面
-    //   this.$emit('changeStatus', 'scan')
-    // }
+    else {
+      // 跳转到关于水母页面
+      mpvue.reLaunch({
+        url: "/pages/none/main"
+      })
+    }
   }
 }
 </script>

+ 20 - 31
src/components/index/personal.vue

@@ -105,7 +105,7 @@
             </div>
             <div>
               <text class="subtitle">
-                2020.09.21 13:00之前领取有效
+                新人有效
               </text>
             </div>
 
@@ -154,6 +154,7 @@ import {userDetail} from "../../requests/user";
 import {couponReceiveFirst} from "../../requests/coupons";
 import Toast from '../../../static/vant/toast/toast';
 import {formatTime} from "../../utils";
+import {reload_userinfo} from "../../utils/user";
 
 var $this
 export default {
@@ -161,17 +162,7 @@ export default {
   data() {
     return {
       userinfo: {
-        portrait: 'https://img.shuimuai.com/weixintouxiang.png',
-        user_name: "小疯兔屁屁",
-        phone: "15627202057",
-        experience: "0",
-        playtime: 0,
-        validity_time: "0",
-        coupon: "0",
-        level: 0,
-        nick_name: ""
         //判断是否第一次进入小程序 1为是第一次 0为非第一次
-
       },
       first: 0,
       pop_show: false
@@ -184,7 +175,7 @@ export default {
         if ($res.code == 0) {
           $this.first = false
           Toast.success($res.errmsg)
-        }else{
+        } else {
           Toast.fail($res.errmsg)
         }
       })
@@ -204,30 +195,28 @@ export default {
         url: "/pages/user_center/main"
       })
     },
-    to_coupons(){
+    to_coupons() {
       mpvue.navigateTo({
         url: "/pages/coupons/main"
       })
-    }
+    },
   },
   mounted() {
-    //获取用户信息
-    //获取用户信息
-    userDetail().then((res) => {
-      let $data = res.data
-      //判断如果是第一次登录就 弹出领取体验卡
-      $this.userinfo = $data.data
-      $this.userinfo['validity_time'] = formatTime($this.userinfo['validity_time'])
-      if ($this.userinfo.login_time == 0) {
-        $this.first = true
-      } else if ($this.userinfo.play_time == 0) {
-        $this.pop_show = true
-      }
-      $this.$store.commit('set_userinfo', $data.data);
-    })
-
-
-  },
+    reload_userinfo($this)
+    $this.userinfo = wx.getStorageSync('userinfo')
+    if ($this.userinfo.login_time == 0) {
+      $this.first = true
+    } else if ($this.userinfo.play_time == 0) {
+      $this.pop_show = true
+    }
+    $this.userinfo.play_time = Math.ceil($this.userinfo.play_time / 60)
+  }
+  ,
+  onShow() {
+    console.log(1)
+    reload_userinfo($this)
+  }
+  ,
   created() {
     $this = this
   }

+ 0 - 54
src/components/index/scan.vue

@@ -1,54 +0,0 @@
-<template>
-  <div id="index_login_container" class="animation-slide-right">
-    <view class=" text-xl padding text-center">
-      <text class=" text-bold title_color">欢迎来到水母星球!</text>
-    </view>
-    <view class="text-df text-center slogen">在此你将会体验到操控专注力的神奇感觉</view>
-    <div class="sub_slogen_sm text-center sub_slogen_ext">
-      <span class="text-center">水母星球小程序需要会员卡或者邀请卡使用 </span><br>
-      <span class="text-center">如你手上已有会员卡或邀请卡,请扫卡上的二维码</span>
-    </div>
-
-    <div class="text-center padding">
-      <button class="cu-btn lg cu-btn-primary text-white text-center">关于水母星球</button>
-    </div>
-    <view class="text-center text-xs">
-      <text class="text-gray">如果您在我们的实体店,请在店员的指导下链接脑环</text>
-    </view>
-  </div>
-</template>
-<script>
-var $this
-export default {
-  name: 'scan_container',
-  data() {
-    return {
-      username: ""
-    }
-  },
-  methods: {
-    open_scan() {
-      wx.scanCode({
-        onlyFromCamera: true
-      })
-    },
-    inputChange(e) {
-      console.log(e.mp.detail)
-      $this.username = e.mp.detail
-    },
-    toLogin() {
-    }
-  },
-  mounted() {
-    console.log()
-  },
-  created() {
-    $this = this
-  }
-}
-</script>
-<style>
-.sub_slogen_ext {
-  width: 290px;
-}
-</style>

+ 1 - 1
src/components/user_center/order_list.vue

@@ -39,7 +39,7 @@
           </div>
           <div>
             <text class="text-gray">实付款&nbsp;</text>
-            <text class="text-gray text-xxl">{{ order.total_price }}</text>
+            <text class="text-gray text-xxl">{{ order.price }}</text>
           </div>
 
         </div>

+ 5 - 2
src/pages/game_record/index.vue

@@ -87,8 +87,11 @@ export default {
       let $date = $event.mp.detail
       console.log($date)
     },
-    to_report($event){
-      console.log($event)
+    to_report($event) {
+
+      mpvue.navigateTo({
+        url: "/pages/game_record/main?id=" + $event
+      })
     }
   },
   mounted() {

+ 1 - 4
src/pages/index/index.vue

@@ -9,8 +9,6 @@
                        @changeStatus="change_status"
                        @changeTitle="change_title"
       ></login_container>
-      <!--      关于水母-->
-      <scan_container v-if="status == 'scan'"></scan_container>
       <!--      注册窗口-->
       <regist_container v-if="status == 'regist'"
                         @changeStatus='change_status'
@@ -46,7 +44,6 @@
 <script>
 import banner from '@/components/banner'
 import login_container from '@/components/index/login'
-import scan_container from '@/components/index/scan'
 import regist_container from '@/components/index/regist'
 import personal_container from "@/components/index/personal";
 import device_container from "@/components/device/device";
@@ -57,7 +54,7 @@ var $this
 export default {
   name: "index_container",
   components: {
-    banner, login_container, scan_container, regist_container, personal_container, device_container
+    banner, login_container, regist_container, personal_container, device_container
   },
   data() {
     return {

+ 0 - 0
src/pages/none/index.css


+ 16 - 0
src/pages/none/index.vue

@@ -0,0 +1,16 @@
+<template>
+  <div id="index_login_container" class="animation-slide-right">
+    <img src="https://img.shuimuai.com/web/none_page.png" alt="" class="cover">
+  </div>
+</template>
+<script>
+export default {
+  name: 'scan_container',
+}
+</script>
+<style scoped>
+.cover{
+  width: 100%;
+  height: 667px;
+}
+</style>

+ 12 - 0
src/pages/none/main.js

@@ -0,0 +1,12 @@
+import Vue from 'vue'
+import App from './index'
+
+// add this to handle exception
+Vue.config.errorHandler = function (err) {
+  if (console && console.error) {
+    console.error(err)
+  }
+}
+
+const app = new Vue(App)
+app.$mount()

+ 12 - 0
src/pages/none/main.json

@@ -0,0 +1,12 @@
+{
+  "usingComponents": {
+    "van-row": "../../../static/vant/row/index",
+    "van-col": "../../../static/vant/col/index",
+    "van-popup": "../../../static/vant/popup/index",
+    "van-overlay": "../../../static/vant/overlay/index",
+    "van-toast": "../../../static/vant/toast/index",
+    "van-field": "../../../static/vant/field/index",
+        "van-count-down":"../../../static/vant/count-down/index"
+
+  }
+}

+ 8 - 3
src/pages/report/index.vue

@@ -5,19 +5,19 @@
     <view class="user">
       <view class="up">
         <view class="left">
-          <img src="https://img.shuimuai.com/weixintouxiang.png"/>
+          <img :src="userinfo.portrait"/>
           <view>
             <text>{{ record.user_name }}</text>
             <text>{{ userinfo.level_name }}</text>
           </view>
         </view>
-        <view class="right">
+        <view class="right" @click="to_game_records">
           <img src="https://img.shuimuai.com/m_icon_chengji%402x.png"/>
           <text>成绩记录</text>
         </view>
       </view>
       <view class="down">
-        <view>41.59</view>
+        <view>{{ record.att_average }}</view>
         <view>专注力得分</view>
       </view>
     </view>
@@ -122,6 +122,11 @@ export default {
         let $res = res.data;
         $this.record = $res.data
       })
+    },
+    to_game_records(){
+      mpvue.navigateTo({
+        url:"/pages/game_record/main"
+      })
     }
   }
   ,

+ 9 - 3
src/pages/start/index.vue

@@ -247,7 +247,7 @@ export default {
       $this.game_finished()
     },
     to_report() {
-      mpvue.navigateTo({
+      mpvue.reLaunch({
         url: "/pages/report/main"
       })
     },
@@ -338,7 +338,9 @@ export default {
         //连接玩具
         console.log('玩具hexStr', hexStr)
         let $flag = bluetooth.connect_toy(hexStr, $this._deviceId, $this._serviceId, $this._characteristicId)
-        if ($flag) {
+        //连接不上设备
+        if ($flag == false) {
+          // $this.game_finished()
           console.log('info', $this._deviceId, $this._serviceId, $this._characteristicId)
         }
       })
@@ -392,6 +394,10 @@ export default {
     game_over() {
       let $current_time = $this.timeData.minutes * 60 + $this.timeData.seconds
       let $play_time = $this.play_time - $current_time
+      if ($this.mode == 2) {
+        let $userinfo = wx.getStorageSync('userinfo')
+        $play_time = $userinfo['play_time'] - $current_time
+      }
       let $params = {
         record_id: game_store.getters.getGameRecordId,
         type: $this.mode,
@@ -423,7 +429,7 @@ export default {
     //获取用户游玩时间
     let $play_time = $this.play_time = game_store.getters.getPlayTime
     $this.mode_list.forEach(($val, $index) => {
-      $val['time'] = $play_time * 1000
+      $val['time'] = $play_time * 60 * 1000
       if ($val['id'] == $this.mode) {
         $this.mode_item = $val
       }

+ 2 - 10
src/pages/user_center/orders/index.vue

@@ -1,14 +1,6 @@
 <template>
   <div class="uc_orders_container">
-    <van-tabs :active="0" color="#4B3AB0">
-      <van-tab title="全部">
-        <order_list :orders="orders"></order_list>
-      </van-tab>
-      <van-tab title="待支付">
-      </van-tab>
-      <van-tab title="已支付">
-      </van-tab>
-    </van-tabs>
+    <order_list :orders="orders"></order_list>
   </div>
 </template>
 
@@ -44,7 +36,7 @@ export default {
     get_order_list() {
       orderList().then((res) => {
         let $data = res.data
-        // $this.orders = $data.data
+        $this.orders = $data.data
         $this.orders.forEach(($val, $index) => {
           $this.orders[$index]['create_time'] = formatTime($val['create_time'] * 1000)
         })

+ 1 - 1
src/pages/user_center/recharge/index.css

@@ -73,7 +73,7 @@
 }
 
 .order_price_container {
-  margin-top: 140px;
+  margin-top: 110px;
 }
 
 /*充值按钮*/

+ 67 - 30
src/pages/user_center/recharge/index.vue

@@ -157,9 +157,14 @@
           <br>
 
         </view>
+
+        <view v-if="selection_card.discount">
+          <text class="text-sm text-gray">折扣&emsp;{{ selection_card.discount }}</text>
+          <br>
+        </view>
         <view class="order_price_container">
           <text class="text-sm text-gray">实付(元)&emsp;</text>
-          <text class="mine_min">{{ selection_card.price }}</text>
+          <text class="mine_min">{{ selection_card.price * selection_card.discount }}</text>
         </view>
         <button class="cu-btn bg-primary lg text-white recharge_button" @click="success_pay">立即充值</button>
       </div>
@@ -198,7 +203,7 @@
         <div class="button_group flex justify-around">
           <!--          <button class="cu-btn bg-gray text-white lg" @click="close_success_pop">以后再填</button>-->
           <!--          <button class="cu-btn  bg-primary text-white lg" @click="to_write_address">填写地址</button>-->
-          <button class="cu-btn  bg-primary text-white lg" @click="to_index">充值成功</button>
+          <button class="cu-btn  bg-primary text-white lg" @click="to_orderlist">充值成功</button>
         </div>
       </div>
     </van-popup>
@@ -228,7 +233,9 @@ export default {
       //用户信息
       userinfo: {},
       //  选中的充值卡
-      selection_card: {}
+      selection_card: {},
+      //支付信息
+      payment_info: {}
     }
   },
   watch: {},
@@ -260,10 +267,31 @@ export default {
     },
     //再次付款
     repay() {
-
+      let $payment = $this.payment_info
+      wx.requestPayment({
+        timeStamp: $payment.timeStamp,
+        nonceStr: $payment.nonceStr,
+        package: $payment.package,
+        signType: $payment.signType,
+        paySign: $payment.sign,
+        success(res) {
+          //支付成功
+          console.log('success', res)
+          //关闭确认订单窗口
+          $this.close_order_confirm()
+          $this.close_success_pop()
+          //打开成功充值窗口
+          $this.open_success_window()
+        },
+        fail(res) {
+          console.log('fail', res)
+          $this.close_order_confirm()
+          $this.err_show = true
+        }
+      })
     },
     to_index() {
-      mpvue.navigateTo({
+      mpvue.reLaunch({
         url: "/pages/index/main"
       })
     },
@@ -275,29 +303,35 @@ export default {
         buy_num: 1
       }
       createOrder($params).then((res) => {
-        let $data = res.data
-        let $payment = $data.data
-        wx.requestPayment({
-          timeStamp: $payment.timeStamp,
-          nonceStr: $payment.nonceStr,
-          package: $payment.package,
-          signType: $payment.signType,
-          paySign: $payment.sign,
-          success(res) {
-            //支付成功
-            console.log('success', res)
-            //关闭确认订单窗口
-            $this.close_order_confirm()
-            //打开成功充值窗口
-            $this.open_success_window()
-          },
-          fail(res) {
-            console.log('fail', res)
-            $this.close_order_confirm()
-            $this.err_show = true
-          }
-        })
-      })
+          let $data = res.data
+          let $payment = $data.data
+          $this.payment_info = $payment
+          wx.requestPayment({
+            timeStamp: $payment.timeStamp,
+            nonceStr: $payment.nonceStr,
+            package: $payment.package,
+            signType: $payment.signType,
+            paySign: $payment.sign,
+            success(res) {
+              //支付成功
+              console.log('success', res)
+              //关闭确认订单窗口
+              $this.close_order_confirm()
+              $this.close_success_pop()
+              //打开成功充值窗口
+              $this.open_success_window()
+            },
+            fail(res) {
+              console.log('fail', res)
+              $this.close_order_confirm()
+              $this.err_show = true
+            }
+          })
+        },
+        (err) => {
+          console.log(err)
+        }
+      )
       //  接收回调方法后弹出支付成功
     },
     //跳转填写地址
@@ -323,9 +357,9 @@ export default {
         })
       })
     },
-    to_orderlist(){
+    to_orderlist() {
       mpvue.navigateTo({
-        url:"/pages/user_center/orders/main"
+        url: "/pages/user_center/orders/main"
       })
     }
   }
@@ -338,6 +372,9 @@ export default {
     $this = this;
   },
   onLoad() {
+  },
+  onUnload() {
+    $this.close_success_pop()
   }
 }
 </script>

+ 1 - 1
src/requests/user.js

@@ -59,7 +59,7 @@ export function userChangeBirthday($params) {
 export function userCheckInvite($invite_code) {
   let $params = {
     'invite': $invite_code,
-    access_token: wx.getStorageSync('token')
+    access_token: 11
   }
   return fly.post('user/check-invite', $params);
 }

+ 5 - 2
src/utils/user.js

@@ -1,5 +1,6 @@
 import {userDetail} from "../requests/user";
-import {formatBirthday} from "./index";
+import {formatBirthday,formatTime} from "./index";
+import user_store from '../store/index'
 
 //刷新用户信息
 
@@ -8,6 +9,8 @@ export function reload_userinfo($this) {
     let $data = res.data;
     $this.userinfo = $data.data;
     $this.userinfo.birthday = formatBirthday($this.userinfo.birthday)
-    $this.$store.commit('set_userinfo', $this.userinfo)
+    $this.userinfo['validity_time'] = formatTime($this.userinfo['validity_time'])
+    $this.userinfo.play_time = Math.ceil($this.userinfo.play_time / 60)
+    user_store.commit('set_userinfo', $this.userinfo)
   })
 }