فهرست منبع

修改了玩具连接的问题
打开了代理商模块

yerong 4 سال پیش
والد
کامیت
afd14e3b36

+ 1 - 1
.gitignore

@@ -3,7 +3,7 @@ node_modules/
 npm-debug.log*
 yarn-debug.log*
 yarn-error.log*
-
+dist/
 # Editor directories and files
 .idea
 *.suo

+ 1 - 1
dist/wx

@@ -1 +1 @@
-Subproject commit fd2eab9532dd71d0b8d18f5088235e8a87c21276
+Subproject commit 4c8eeb94e26baa77ee001468070da575ef3d3035

+ 2 - 10
src/components/device/device.vue

@@ -238,16 +238,8 @@ export default {
       game_store.setters.setToyHex(toy_hex)
 
       //连接玩具
-      bluetooth.getBLEDeviceServices($this._deviceId)
-      setTimeout(() => {
-        bluetooth.sendConnect(toy_hex, $this._deviceId, bluetooth.serviceId, bluetooth.cid, Toast)
-        setTimeout(() => {
-          bluetooth.watching_toy($this, $this._deviceId, bluetooth.serviceId, bluetooth.cid, Toast)
-        }, 800)
-
-      }, 1000)
-
-
+      // 打开数据帧
+      bluetooth.sendConnect(toy_hex, $this._deviceId, bluetooth.serviceId, bluetooth.cid, Toast, $this)
     },
     //修改玩具连接状态
     change_toy_connect_status($status = 0) {

+ 2 - 1
src/components/device/toy/connecting.vue

@@ -218,7 +218,8 @@ export default {
                 // 设置游戏记录id
                 game_store.setters.setGameRecordId($res['game_record_id'])
                 //设置游戏时间长
-                wx.removeStorageSync('play_time')
+                wx.removeStorageSync('played_time')
+                game_store.setters.setPlayTime($res['play_time'])
                 mpvue.navigateTo({
                   url: "/pages/start/main",
                   success() {

+ 24 - 13
src/components/index/login.vue

@@ -44,19 +44,20 @@ export default {
     to_scan() {
       wx.scanCode({
         onlyFromCamera: true,
+        success(res) {
+          let $data = res;
+          if ($data.result) {
+            let url = decodeURIComponent($data.result);
+            let $code = url.match(/\?code=(.*)/);
+            // 邀请码
+            let $invite_code = $code[1]
+            $this.do_invite_code($invite_code)
+          }
+        }
       })
     },
-  },
-  mounted() {
-  },
-  onLoad(options) {
-    let $this = this
-    // 原有的code
-    let $_code = wx.getStorageSync('code')
-
-    if (options.q) {
-      let url = decodeURIComponent(options.q)
-      let $code = url.match(/\?code=(.*)/)[1];
+    //统一处理邀请码的方法
+    do_invite_code($code) {
       $this.is_scan = true
       wx.login({
         success(res1) {
@@ -72,14 +73,24 @@ export default {
           })
         }
       })
+    }
+  },
+  mounted() {
+  },
+  onLoad(options) {
+    let $this = this
+    // 原有的code
+    let $_code = wx.getStorageSync('code')
 
+    if (options.q) {
+      let url = decodeURIComponent(options.q)
+      let $code = url.match(/\?code=(.*)/)[1];
+      $this.do_invite_code($code)
       console.log('1---' + $_code, '2---' + $code)
       //判断新的code 和 旧的code 是否一致 不一致则重新登录
       if ($_code && $_code != $code) {
         Toast.fail('该用户已绑定邀请码')
       }
-
-
     }
     // 测试注释
     else {

+ 9 - 2
src/pages/agent/customer/index.vue

@@ -79,6 +79,7 @@
       :max-date="max_date"
     ></van-calendar>
 
+    <van-toast id="van-toast"/>
 
   </div>
 </template>
@@ -86,6 +87,7 @@
 <script>
 
 import {agentUserList} from "../../../requests/agent";
+import Toast from '../../../../static/vant/toast/toast'
 
 var $this
 export default {
@@ -183,7 +185,7 @@ export default {
       let [start, end] = $event.mp.detail;
       $this.filter_date = $this.formatDate(start) + '-' + $this.formatDate(end)
       $this.start_time = Math.round(new Date(start).getTime() / 1000)
-      $this.end_time = Math.round(new Date(new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1).getTime()).getTime() / 1000)
+      $this.end_time = Math.round(new Date(new Date(new Date(end).getTime() + 24 * 60 * 60 * 1000 - 1).getTime()).getTime() / 1000)
       $this.get_user_list($this.customer_type_action - 1, $this.start_time, $this.end_time)
       $this.calendar_show = false
     },
@@ -194,6 +196,10 @@ export default {
       $this.get_user_list($id - 1)
     },
     get_user_list($type, $start_time, $end_time) {
+      Toast.loading({
+        message: "加载中",
+        duration: 0
+      })
       let $params = {}
       if ($type) {
         $params['type'] = $type
@@ -203,6 +209,7 @@ export default {
         $params['end_time'] = $end_time
       }
       agentUserList($params).then((res) => {
+        Toast.clear()
         let $data = res.data;
         $this.user_list = $data.data
         $this.customer_count = $this.user_list.length
@@ -212,7 +219,7 @@ export default {
   mounted() {
     $this.min_date = new Date(2020, 10, 11).getTime()
     $this.max_date = new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1).getTime()
-    $this.get_user_list(0, $this.min_date, $this.max_date)
+    $this.get_user_list(0, false, false)
   },
   created() {
     $this = this

+ 2 - 1
src/pages/agent/customer/main.json

@@ -4,6 +4,7 @@
     "van-card": "../../../static/vant/card/index",
     "van-calendar": "../../../static/vant/calendar/index",
     "van-row": "../../../static/vant/row/index",
-    "van-col": "../../../static/vant/col/index"
+    "van-col": "../../../static/vant/col/index",
+    "van-toast": "../../../static/vant/toast/index"
   }
 }

+ 11 - 18
src/pages/agent/extend/detail/index.vue

@@ -4,22 +4,14 @@
     <van-cell title="消费产品" :value="order.goods_name" :border="false"></van-cell>
     <van-cell title="下单时间" :value="order.create_time" :border='false'></van-cell>
     <van-cell title="买家" :value="order.user_name" :border="false"></van-cell>
-    <van-cell title="卖家等级" value="一级消费" :border="false"></van-cell>
-
-    <van-row class="">
-      <van-col span="14">
-        <van-cell title="佣金收益" :value="order.invite_rebater" :border="false" custom-class="not_show"></van-cell>
-        <van-cell title="结算状态"  :border="false">
-          <text v-if="order.provide_status == 1">收益到余额</text>
-          <text v-if="order.provide_status == 2">未收益</text>
-          <text v-if="order.provide_status == 3">收益到冻结余额</text>
-        </van-cell>
-      </van-col>
-      <van-col span="10">
-        <van-cell title="佣金收益" :value="order.rebater" :border="false"></van-cell>
-        <van-cell title="订单总价" :value="order.price" :border="false"></van-cell>
-      </van-col>
-    </van-row>
+<!--    <van-cell title="卖家等级" value="一级消费" :border="false"></van-cell>-->
+    <van-cell title="结算状态" :border="false">
+      <text v-if="order.provide_status == 1">收益到余额</text>
+      <text v-if="order.provide_status == 2">未收益</text>
+      <text v-if="order.provide_status == 3">收益到冻结余额</text>
+    </van-cell>
+    <van-cell title="佣金收益" :value="order.rebater" :border="false"></van-cell>
+    <van-cell title="订单总价" :value="order.price" :border="false"></van-cell>
 
 
   </div>
@@ -65,10 +57,11 @@ export default {
 </script>
 
 <style scoped>
-page{
+page {
   background-color: #fff;
 }
-.not_show{
+
+.not_show {
   opacity: 0;
 }
 

+ 8 - 1
src/pages/agent/extend/orders/index.vue

@@ -77,6 +77,7 @@
       :min-date="min_date"
       :max-date="max_date"
     ></van-calendar>
+    <van-toast id="van-toast"/>
 
 
   </div>
@@ -86,6 +87,7 @@
 
 import {agentOrderList} from "../../../../requests/agent";
 import util from '@/utils/index'
+import Toast from '../../../../../static/vant/toast/toast'
 
 var $this
 export default {
@@ -159,7 +161,7 @@ export default {
       let [start, end] = $event.mp.detail;
       $this.filter_date = $this.formatDate(start) + '-' + $this.formatDate(end)
       $this.start_time = Math.round(new Date(start).getTime() / 1000)
-      $this.end_time = Math.round(new Date(new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1).getTime()).getTime() / 1000)
+      $this.end_time = Math.round(new Date(new Date(new Date(end).getTime() + 24 * 60 * 60 * 1000 - 1).getTime()).getTime() / 1000)
       $this.get_order_list($this.start_time, $this.end_time)
       $this.calendar_show = false
     },
@@ -171,12 +173,17 @@ export default {
     },
     //获取订单列表
     get_order_list($start_time, $end_time) {
+      Toast.loading({
+        message:"加载中",
+        duration:0
+      })
       let $params = {}
       if ($start_time && $end_time) {
         $params['start_time'] = $start_time
         $params['end_time'] = $end_time
       }
       agentOrderList($params).then((res) => {
+        Toast.clear()
         let $data = res.data
         let $result = $data.data;
         $this.order_counts = $result.count;

+ 2 - 1
src/pages/agent/extend/orders/main.json

@@ -2,6 +2,7 @@
   "usingComponents": {
     "van-divider": "../../../../static/vant/divider/index",
     "van-card": "../../../../static/vant/card/index",
-    "van-calendar": "../../../../static/vant/calendar/index"
+    "van-calendar": "../../../../static/vant/calendar/index",
+    "van-toast": "../../../../static/vant/toast/index"
   }
 }

+ 8 - 2
src/pages/agent/income_cal/index.vue

@@ -75,7 +75,7 @@
       :max-date="max_date"
     ></van-calendar>
 
-
+<van-toast id="van-toast" />
   </div>
 </template>
 
@@ -83,6 +83,7 @@
 
 import {agentIncomeDetail, agentIncomeList} from "../../../requests/agent";
 import util from '@/utils/index'
+import Toast from '../../../../static/vant/toast/toast'
 
 var $this
 export default {
@@ -160,18 +161,23 @@ export default {
       let [start, end] = $event.mp.detail;
       $this.filter_date = $this.formatDate(start) + '-' + $this.formatDate(end)
       $this.start_time = Math.round(new Date(start).getTime() / 1000)
-      $this.end_time = Math.round(new Date(new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1).getTime()).getTime() / 1000)
+      $this.end_time = Math.round(new Date(new Date(new Date(end).getTime() + 24 * 60 * 60 * 1000 - 1).getTime()).getTime() / 1000)
       $this.get_income_list($this.start_time, $this.end_time)
       $this.calendar_show = false
     },
     // 收益列表
     get_income_list($start_time, $end_time) {
+      Toast.loading({
+        message:"加载中",
+        duration:0
+      })
       let $params = {}
       if ($start_time && $end_time) {
         $params['start_time'] = $start_time
         $params['end_time'] = $end_time
       }
       agentIncomeList($params).then((res) => {
+        Toast.clear()
         let $data = res.data
         let $result = $data.data;
         $this.total = $result.total;

+ 2 - 1
src/pages/agent/income_cal/main.json

@@ -2,6 +2,7 @@
   "usingComponents": {
     "van-divider": "../../../static/vant/divider/index",
     "van-card": "../../../static/vant/card/index",
-    "van-calendar": "../../../static/vant/calendar/index"
+    "van-calendar": "../../../static/vant/calendar/index",
+    "van-toast": "../../../static/vant/toast/index"
   }
 }

+ 9 - 5
src/pages/agent/index/index.vue

@@ -121,7 +121,7 @@ export default {
   },
   methods: {
     //跳转收益中心
-    to_income(){
+    to_income() {
       mpvue.navigateTo({
         url: "/pages/agent/income_cal/main"
       })
@@ -167,6 +167,9 @@ export default {
     $this.userinfo = wx.getStorageSync('userinfo')
     $this.userinfo['level_name'] = utils.get_level_name($this.userinfo.level)
   },
+  onShow() {
+    $this.get_agent_detail()
+  },
   created() {
     $this = this
   }
@@ -194,11 +197,12 @@ export default {
   background-image: url("https://img.shuimuai.com/web/frame_dailishang_tixian.png");
   background-position: center;
   background-size: 100% 100%;
-    width: 353px;
-    height: 65px;
-    margin: 10px auto;
+  width: 353px;
+  height: 65px;
+  margin: 10px auto;
 }
-.withdraw_money{
+
+.withdraw_money {
   font-size: 24px;
 }
 </style>

+ 11 - 0
src/pages/index/index.vue

@@ -49,6 +49,8 @@
     </div>
     <van-toast id="van-toast"/>
 
+<!--     <button class="cu-btn lg cu-btn-primary text-white text-center margin-tb" @click="auth_msg">获取消息授权-->
+<!--    </button>-->
   </div>
 </template>
 
@@ -116,6 +118,15 @@ export default {
       mpvue.navigateTo({
         url: "/pages/" + $page + "/main"
       })
+    },
+    auth_msg(){
+      wx.requestSubscribeMessage({
+        tmplIds:['NV-xb_oOPutXLVge0ZnBxct_nNxS1j1XNCMtfp2c8zw','70xngszQ62NWHbbCjbggbz5-pvOu3Z8ttLbjfplJXLg'],
+        success(res){
+          console.log(res)
+          Toast.success("授权成功")
+        }
+      })
     }
   },
   mounted() {

+ 8 - 23
src/pages/start/index.vue

@@ -115,25 +115,6 @@
 
     </div>
 
-    <!--    窗口弹出-->
-    <!--    <van-popup :show="pop_show" @close="close_pop" round :close-on-click-overlay="false"-->
-    <!--               overlay-->
-    <!--               z-index="99">-->
-    <!--      <div class="err_container flex flex-direction align-center justify-around">-->
-    <!--        <view>-->
-    <!--          <text class="title">-->
-    <!--            本次游玩时间已到-->
-    <!--          </text>-->
-    <!--        </view>-->
-    <!--        <view>-->
-    <!--          <text class="sub-title">-->
-    <!--            您的{{ mode_item.name }}消费已用完-->
-    <!--          </text>-->
-    <!--        </view>-->
-    <!--        <img src="https://img.shuimuai.com/web/sign_notimeJfish.png" class="err_img" alt="">-->
-    <!--        <button class="cu-btn lg bg-primary text-white" @click="game_finished">查看报告</button>-->
-    <!--      </div>-->
-    <!--    </van-popup>-->
     <van-toast id="van-toast"/>
     <van-dialog id="van-dialog"/>
   </div>
@@ -269,6 +250,7 @@ export default {
       })
       setTimeout(() => {
         Toast.clear()
+        $this.mode_item = {}
         $this.to_report()
       }, 800)
     },
@@ -463,10 +445,13 @@ export default {
         }
 
       ]
-      //获取用户游玩时间
-      let $played_time = $this.play_time = game_store.getters.getPlayTime() ? game_store.getters.getPlayTime() : 0
+
+      //可玩时间
+      let $play_time = $this.play_time = game_store.getters.getPlayTime()
+      //已经完了多长时间
+      let $played_time = $this.played_time = game_store.getters.getPlayedTime() ? game_store.getters.getPlayedTime() : 0
       $this.mode_item = mode_list[$this.mode - 1]
-      let $origin_time = mode_list[$this.mode - 1]['time']
+      let $origin_time = $play_time * 1000
       $this.mode_item['time'] = $origin_time - ($played_time * 1000)
       $this.start_game()
 
@@ -495,7 +480,7 @@ export default {
       bluetooth.sendEnd($this._deviceId, $this._serviceId, $this._characteristicId)
       wx.offBLECharacteristicValueChange()
       //存储时间
-      game_store.setters.setPlayTime($this.played_time)
+      game_store.setters.setPlayedTime($this.played_time)
       //设置未结束游戏
       $this.is_end = false
     }

+ 7 - 0
src/store/game.js

@@ -34,6 +34,9 @@ const setters = {
   },
   setPlayTime(param) {
     wx.setStorageSync('play_time', param)
+  },
+  setPlayedTime(param){
+    wx.setStorageSync('played_time',param)
   }
 }
 
@@ -64,6 +67,10 @@ const getters = {
   },
   getPlayTime() {
     return wx.getStorageSync('play_time')
+  },
+  //完了多长时间
+  getPlayedTime(){
+    return wx.getStorageSync('played_time')
   }
 }
 

+ 9 - 6
src/utils/bluetooth.js

@@ -1,5 +1,6 @@
 import game_store from "../store/game";
 import ble_store from "../store/bluetooth"
+import bluetooth from "../store/bluetooth";
 
 export default {
   test_name: 'hello world',
@@ -81,7 +82,7 @@ export default {
     })
   },
   // 发送连接玩具指令
-  sendConnect($hex, deviceId, serviceId, Cid, Toast) {
+  sendConnect($hex, deviceId, serviceId, Cid, Toast, $this) {
     //获取最后两个字节
     const that = this
     // 玩具对应指令数组
@@ -114,6 +115,7 @@ export default {
         // wx.showLoading({
         //   title: '正在创建连接',
         // })
+        that.watching_toy($this, deviceId, serviceId, Cid, Toast)
 
         let $game_status = game_store.getters.getGameStatus();
         if ($game_status == 1) {
@@ -452,6 +454,8 @@ export default {
             game_store.setters.setDeviceId(deviceId)
             game_store.setters.setServiceId(serviceId)
             game_store.setters.setCid(item.uuid)
+            //打开数据帧
+            $this.sendOpen(deviceId, serviceId, item.uuid)
             // $this.sendPause(deviceId, serviceId, item.uuid)
             //获取玩具的值
             // bluetooth.sendConnect($this.toy_hex, deviceId, serviceId, item.uuid)
@@ -474,23 +478,22 @@ export default {
   },
   //监听玩具得状态
   watching_toy($this, deviceId, serviceId, Cid, Toast) {
-    Toast.clear()
     Toast.loading({
       duration: 0,
       forbidClick: false,
-      message: "检测连接中"
+      message: "正在创建连接"
     })
     let that = this
     let $count = 0
     setTimeout(() => {
       Toast.clear()
-    }, 10000)
+    }, 5000)
     //关闭核销选项窗口
     // $this.pay_window = false
     wx.onBLECharacteristicValueChange((characteristic) => {
       try {
-        console.log("收到" + that.ab2hex(characteristic.value));
         let hexStr = that.ab2hex(characteristic.value)
+        console.log("收到" + hexStr);
         //连接玩具
         let $flag = that.connect_toy(hexStr, deviceId, serviceId, Cid, Toast)
         //连接不上设备
@@ -507,7 +510,7 @@ export default {
           that.watchingDevice($this)
         } else {
           $count++
-          if ($count == 15) {
+          if ($count == 10) {
             Toast.clear()
             $this.change_toy_connect_status(3)
             wx.offBLECharacteristicValueChange()