Bläddra i källkod

处理了切换脑环,以及一些ui问题

yerong 4 år sedan
förälder
incheckning
a3f8b2f2d0

+ 1 - 1
dist/wx

@@ -1 +1 @@
-Subproject commit c0a20e04f579c751a2022645ea9afa0423529c41
+Subproject commit be99bbb1e7101ee7f0eaaf3979cef9cf027b565b

+ 23 - 29
src/components/device/device.vue

@@ -14,13 +14,13 @@
       <!--      </div>-->
       <div v-if="connect_toy == 0">
         <!--      未连接部分-->
-        <div class="connect_box" v-if="status == 0">
+        <div class="connect_box" v-if="device_status == 0">
           <device_unconnect @open_scan="open_scan"></device_unconnect>
         </div>
 
         <!--      连接中-->
-        <div class="connecting_box" v-if="status != 0 && connect_show == false">
-          <device_connecting :status="status"></device_connecting>
+        <div class="connecting_box" v-if="device_status != 0 && connect_show == false">
+          <device_connecting :status="device_status"></device_connecting>
         </div>
 
         <!-- 已链接 -->
@@ -132,7 +132,7 @@ export default {
   data() {
     return {
       //设备状态 0为未连接,1:连接中,2:已连接 3:连接失败
-      status: 0,
+      device_status: 0,
       connect_show: false,
 
       choose_toy_window: {
@@ -153,7 +153,7 @@ export default {
     };
   },
   watch: {
-    status($new, $old) {
+    device_status($new, $old) {
       //成功连接的方法
       if ($new == 2) {
         $this.connect_show = true;
@@ -165,6 +165,8 @@ export default {
   methods: {
     //打开 扫描二维码
     open_scan() {
+      // 打开蓝牙扫描 重置游戏状态
+      game_store.setters.setGameStatus(0)
       //
       wx.scanCode({
         onlyFromCamera: true,
@@ -172,18 +174,15 @@ export default {
           let $data = res;
           if ($data.result) {
             let url = decodeURIComponent($data.result);
-            let $code = url.match(/\?code=(.*)/)[1];
+            let $code = url.match(/\?ring=(.*)/) ? url.match(/\?ring=(.*)/) : url.match(/\?code=(.*)/);
             // 判断新的标识值
-            if (!$code) {
-              $code = url.match(/\?ring=(.*)/)[1];
-            }
-            $this.code = $code;
+            $this.code = $code[1].toUpperCase();
+            console.log('头环码', $code)
             //打开蓝牙设备
             wx.openBluetoothAdapter({
               success(res) {
                 //判断已经打开连接了
                 if (res["errMsg"] == "openBluetoothAdapter:ok") {
-                  console.log("openBluetoothAdapter success", res);
                   $this.startBluetoothDevicesDiscovery();
                 }
               },
@@ -226,12 +225,11 @@ export default {
       $this.toy_id = $toy.id
       let $hex = $toy["hex"].substr($toy["hex"].length - 2, 2);
       let toy_hex = "0x" + $hex;
-      game_store.commit("setToyHex", toy_hex);
+      game_store.setters.setToyHex(toy_hex)
 
       //连接玩具
       bluetooth.getBLEDeviceServices($this._deviceId)
       setTimeout(() => {
-        console.log($this._deviceId, bluetooth.serviceId, bluetooth.cid)
         bluetooth.sendConnect(toy_hex, $this._deviceId, bluetooth.serviceId, bluetooth.cid, Toast)
         setTimeout(() => {
           bluetooth.watching_toy($this, $this._deviceId, bluetooth.serviceId, bluetooth.cid, Toast)
@@ -251,16 +249,17 @@ export default {
     },
     //  修改设备连接状态
     change_device_status($status = 0) {
-      $this.status = $status;
+      $this.device_status = $status;
       //当蓝牙连接已断开
       //当脑环断开
       if ($status == 0) {
-        let $deviceId = game_store.getters.getDeviceId
-        let $serviceId = game_store.getters.getServiceId
-        let $cid = game_store.getters.getCharacterId
+        game_store.setters.setGameStatus(0)
+        let $deviceId = game_store.getters.getDeviceId()
+        let $serviceId = game_store.getters.getServiceId()
+        let $cid = game_store.getters.getCharacterId()
         bluetooth.shutdownSendControl($deviceId, $serviceId, $cid)
         // 清空链接得设备 三值
-        game_store.commit('clearDeviceToy')
+        game_store.setters.clearDeviceToy()
         $this.connect_toy = $status;
         $this.connect_show = false;
         wx.closeBLEConnection({
@@ -272,10 +271,7 @@ export default {
               message: "已成功断开"
             });
           },
-
         });
-
-
       }
     },
 
@@ -284,7 +280,6 @@ export default {
       wx.startBluetoothDevicesDiscovery({
         allowDuplicatesKey: true,
         success: (res) => {
-          console.log("startBluetoothDevicesDiscovery success", res);
           $this.onBluetoothDeviceFound();
           $this.change_device_status(1);
         },
@@ -303,11 +298,11 @@ export default {
           if (device.localName && (device.localName != '')) {
             device.name = device.localName
           }
-          console.log(device["name"]);
-          if (device["name"] == $this.code) {
+          console.log(device["name"].toUpperCase());
+          if (device["name"].toUpperCase() == $this.code) {
             $this.stopBluetoothDevicesDiscovery();
             $this.device = device;
-            game_store.commit("setDeviceId", device.deviceId);
+            game_store.setters.setDeviceId(device.deviceId)
             $this._deviceId = device.deviceId;
             $this.createBLEConnection();
           }
@@ -316,7 +311,7 @@ export default {
       setTimeout(() => {
         if (!$this.device.deviceId) {
           $this.stopBluetoothDevicesDiscovery();
-          $this.status = 0;
+          $this.device_status = 0;
           $this.connect_show = false;
           Toast.fail("未连接到设备");
         }
@@ -363,13 +358,12 @@ export default {
           };
           $this.toy_list.push(_item);
         });
-        game_store.commit("setToyList", $this.toy_list);
+        game_store.setters.setToyList($this.toy_list)
       });
     },
 
     //  开始游戏的方法
     game_start() {
-      game_store.commit("setToyIndex", $this.toy_action - 1);
       console.log("device.vue", $this._deviceId);
     },
   },
@@ -382,7 +376,7 @@ export default {
   },
   onShow() {
     //判断是否游戏中
-    let $game_status = game_store.getters.getGameStatus;
+    let $game_status = game_store.getters.getGameStatus();
     if ($game_status == 1) {
       Dialog.confirm({
         title: '系统提示',

+ 7 - 7
src/components/device/toy/connecting.vue

@@ -205,13 +205,13 @@ export default {
                 //设置游戏中
                 $this.connect_toy = 4
                 //设置游戏模式
-                game_store.commit('setMode', $event)
+                game_store.setters.setMode($event)
                 // 设置游戏状态为游戏中
-                game_store.commit('setGameStatus', 1)
+                game_store.setters.setGameStatus(1)
                 // 设置游戏记录id
-                game_store.commit('setGameRecordId', $res['game_record_id'])
+                game_store.setters.setGameRecordId($res['game_record_id'])
                 //设置游戏时间长
-                game_store.commit('setPlayTime', $res['play_time'])
+                game_store.setters.setPlayTime($res['play_time'])
                 mpvue.navigateTo({
                   url: "/pages/start/main"
                 })
@@ -233,9 +233,9 @@ export default {
     },
     // 前往正在玩的波动时间界面
     to_playing() {
-      mpvue.navigateTo({
-        url: "/pages/start/main"
-      })
+      // mpvue.navigateTo({
+      //   url: "/pages/start/main"
+      // })
     },
     //修改连接状态
     change_toy_connect_status($status) {

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

@@ -11,7 +11,8 @@
         <img src="https://img.shuimuai.com/lanyashuimu.png" class="connect_img"/>
       </van-col>
     </van-row>
-    <button class="cu-btn lg cu-btn-primary text-white text-center scan_button margin-tb" @click="open_scan">扫码连接脑环</button>
+    <button class="cu-btn lg cu-btn-primary text-white text-center scan_button margin-tb" @click="open_scan">扫码连接脑环
+    </button>
     <van-toast id="van-toast"/>
 
   </div>
@@ -32,6 +33,8 @@ export default {
   },
   created() {
     $this = this
+  },
+  onShow() {
   }
 }
 </script>

+ 4 - 2
src/components/index/login.vue

@@ -13,7 +13,7 @@
       <button class="cu-btn lg cu-btn-primary text-white text-center" @click="to_none" v-else>关于水母星球</button>
     </div>
     <view class="text-center text-xs">
-      <text class="text-gray">如果您在我们的实体店,请在店员的指导下链接脑环</text>
+      <text class="text-gray">如果您在我们实体店,请在店员的指导下连接水母智脑环</text>
     </view>
     <view class="text-center text-lg padding" @click="to_regist(1)">
       <text class="text-gray under_line">账号登录</text>
@@ -25,6 +25,7 @@
 <script>
 import Toast from '../../../static/vant/toast/toast';
 import Dialog from '../../../static/vant/dialog/dialog';
+import user_store from '@/store/index'
 
 var $this
 export default {
@@ -58,7 +59,8 @@ export default {
       let $code = url.match(/\?code=(.*)/)[1];
       $this.is_scan = true
 
-      this.$store.commit('set_invite_code', $code)
+      user_store.setters.set_invite_code($code)
+
       console.log('1---' + $_code, '2---' + $code)
       //判断新的code 和 旧的code 是否一致 不一致则重新登录
       if ($_code && $_code != $code) {

+ 4 - 2
src/components/index/personal.vue

@@ -160,6 +160,7 @@ import {userUpdateLoginTime} from "../../requests/user";
 import {couponReceiveFirst} from "../../requests/coupons";
 import Toast from '../../../static/vant/toast/toast';
 import {reload_userinfo} from "../../utils/user";
+import user_store from '@/store/index'
 
 var $this
 export default {
@@ -171,7 +172,7 @@ export default {
       },
       first: false,
       pop_show: false,
-      invite_code:false
+      invite_code: false
     }
   },
   methods: {
@@ -183,7 +184,8 @@ export default {
           userUpdateLoginTime().then((res) => {
             let $res = res.data
             $this.userinfo['login_time'] = $res.data
-            $this.$store.commit('set_userinfo', $this.userinfo)
+            $this.$store = user_store.setters.set_userinfo($this.userinfo)
+
             wx.setStorageSync("is_first", false)
             reload_userinfo($this)
           })

+ 7 - 8
src/components/index/regist.vue

@@ -39,7 +39,7 @@
       </button>
     </div>
     <view class="text-center text-xs">
-      <text class="text-gray">如果您在我们的实体店,请在店员的指导下链接脑环</text>
+      <text class="text-gray">如果您在我们实体店,请在店员的指导下连接水母智脑环</text>
     </view>
     <van-toast id="van-toast"/>
   </div>
@@ -48,6 +48,8 @@
 <script>
 import {userGetCode, userRegister, userLogin, userDetail} from '@/requests/user'
 import Toast from '../../../static/vant/toast/toast';
+import user_store from '@/store/index'
+import {reload_userinfo} from "../../utils/user";
 
 var $this
 
@@ -168,15 +170,12 @@ export default {
     //登录成功
     login_success($data) {
       Toast.success($data['errmsg'])
-      $this.$store.commit('set_token', $data['data'])
-      $this.$store.commit('set_login')
+      user_store.setters.set_token($data['data'])
+      user_store.setters.set_login()
       $this.$emit('change_login_status', true)
-      $this.$store.commit('set_invite_code', $this.invite)
+      user_store.setters.set_invite_code($this.invite)
       //获取用户信息
-      userDetail().then((res) => {
-        let $data = res.data
-        $this.$store.commit('set_userinfo', $data.data);
-      })
+      reload_userinfo($this)
     },
     //打开倒计时
     open_time_down() {

+ 13 - 16
src/components/user_center/order_list.vue

@@ -13,17 +13,14 @@
         <div>
           <text class="text-gray">{{ order.create_time }}</text>
           <view class="text-right">
-            <template v-if="order.pay_status == 1">
-              <text class="text-bold">未付款</text>
-            </template>
-            <template>
-              <text>已付款</text>
-            </template>
+            <text>交易成功</text>
           </view>
         </div>
       </div>
       <!--      图标部分-->
-      <div slot="thumb" class="thumb_container">
+      <div slot="thumb"
+           class="thumb_container"
+      >
         <img src="https://img.shuimuai.com/web/icon_dingdan.png" class="order_icon" alt="">
       </div>
       <!--      消费产品-->
@@ -35,7 +32,7 @@
         <div class="padding-tb-lg flex justify-between align-center">
           <div>
             <text class="text-gray">付款方式&nbsp;</text>
-              <text class="text-bold">微信支付</text>
+            <text class="text-bold">微信支付</text>
           </div>
           <div>
             <text class="text-gray">实付款&nbsp;</text>
@@ -60,24 +57,24 @@
 var $this
 export default {
   name: "order_list",
-  props: ['status','orders'],
+  props: ['status', 'orders'],
   data() {
-    return {
-
-    }
-  },
-  methods: {
-
+    return {}
   },
+  methods: {},
   mounted() {
   },
-  created(){
+  created() {
     $this = this
   }
 }
 </script>
 
 <style>
+.van-card__thumb {
+  width: 50px !important;
+}
+
 .order_icon {
   width: 37px;
   height: 37px;

+ 12 - 10
src/pages/index/index.vue

@@ -5,12 +5,12 @@
     <!--    未登录 登录窗口模块-->
     <div class="login_card" v-if="!is_login">
       <!--      登录窗口-->
-      <login_container v-if="status == 'login'"
+      <login_container v-if="login_status == 'login'"
                        @changeStatus="change_status"
                        @changeTitle="change_title"
       ></login_container>
       <!--      注册窗口-->
-      <regist_container v-if="status == 'regist'"
+      <regist_container v-if="login_status == 'regist'"
                         @changeStatus='change_status'
                         @change_login_status="change_login_status"
                         :title="regist_title"
@@ -30,7 +30,7 @@
       <div class="content padding-lr">
         <van-row>
           <van-col span="12">
-            <img src="https://img.shuimuai.com/web/index_btn_chongzhizhongxin.png" @click="to_recharge"></img>
+            <img src="https://img.shuimuai.com/web/index_btn_chongzhizhongxin.png"  @click="to_page('user_center/recharge')"></img>
           </van-col>
           <van-col span="12">
             <img src="https://img.shuimuai.com/web/index_btn_gerenzhongxin.png" @click="to_page('user_center')"></img>
@@ -60,6 +60,8 @@ import personal_container from "@/components/index/personal";
 import device_container from "@/components/device/device";
 import Toast from '../../../static/vant/toast/toast';
 import {userDetail} from "../../requests/user";
+import user_store from "../../store/index"
+
 
 var $this
 export default {
@@ -70,7 +72,7 @@ export default {
   data() {
     return {
       // 三种状态 扫码scan 注册regist 登录login
-      status: "login",
+      login_status: "login",
       // is_login: false,
       is_login: false,
       regist_title: ""
@@ -81,7 +83,7 @@ export default {
     },
     //切换到扫码
     change_status($status) {
-      this.status = $status
+      this.login_status = $status
     },
     //跳转充值中心
     to_recharge() {
@@ -91,7 +93,7 @@ export default {
     },
     //修改登录状态
     change_login_status() {
-      this.is_login = this.$store.getters.get_login_status
+      this.is_login = user_store.getters.get_login_status()
     },
     // 修改界面的文字
     change_title($status) {
@@ -119,16 +121,16 @@ export default {
       let $data = res.data
       //判断如果是第一次登录就 弹出领取体验卡
       $this.userinfo = $data.data
-      $this.$store.commit('set_userinfo', $this.userinfo)
+      user_store.setters.set_userinfo($this.userinfo)
     })
   },
   onLoad($option) {
     //  判断存储是否登录
     let $token = wx.getStorageSync('token')
     if ($token) {
-      this.$store.commit('set_token', $token);
-      this.$store.commit('set_login', true);
-      this.is_login = this.$store.getters.get_login_status
+      user_store.setters.set_token($token)
+      user_store.setters.set_login(true)
+      this.is_login = user_store.getters.get_login_status()
     }
   },
   created() {

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

@@ -152,7 +152,7 @@ export default {
     $this = this;
   },
   onLoad(options) {
-    $this.record_id = options.id ? options.id : game_store.getters.getGameRecordId
+    $this.record_id = options.id ? options.id : game_store.getters.getGameRecordId()
     console.log($this.record_id)
   }
 }

+ 78 - 120
src/pages/start/index.vue

@@ -11,8 +11,7 @@
             <van-count-down :time="mode_item.time" format="mm:ss" use-slot auto-start @finish="time_out"
                             @change="watch_time" class="control-count-down"
             >
-              <text v-if="mode == 1">{{ timeData.minutes }}:{{ timeData.seconds }}</text>
-              <text v-if="mode == 2">{{ played_time_text }}</text>
+              <text>{{ timeData.minutes }}:{{ timeData.seconds }}</text>
             </van-count-down>
           </view>
         </van-col>
@@ -55,53 +54,61 @@
 
     <!--    图标模块-->
     <div class="ec_container">
-      <view class="bar">
-        <view>
-          <view class="line"></view>
-          <view class="title">大脑状态</view>
-        </view>
-        <view class="label">
+      <view class="chart_view_first margin-tb-xl">
+
+        <view class="bar">
           <view>
-            <view class="dot dot-orange"></view>
-            <view class="name">Att(专注度)</view>
+            <view class="line"></view>
+            <view class="title">大脑状态</view>
           </view>
-          <view>
-            <view class="dot dot-pink"></view>
-            <view class="name">Att(放松度)</view>
+          <view class="label">
+            <view>
+              <view class="dot dot-orange"></view>
+              <view class="name">Att(专注度)</view>
+            </view>
+            <view>
+              <view class="dot dot-pink"></view>
+              <view class="name">Med(放松度)</view>
+            </view>
           </view>
         </view>
+        <view class="chart">
+          <mpvue-echarts :echarts="echarts" :onInit="attCharts" canvasId="demo-canvas"/>
+        </view>
       </view>
-      <view class="chart">
-        <mpvue-echarts :echarts="echarts" :onInit="attCharts" canvasId="demo-canvas"/>
 
-      </view>
-      <view class="bar">
-        <view>
-          <view class="line"></view>
-          <view class="title">基本脑波</view>
-        </view>
-        <view class="label">
-          <view>
-            <view class="dot dot-blue"></view>
-            <view class="name">Delta</view>
-          </view>
+      <view class="chart_view_second margin-tb-xl">
+
+        <view class="bar">
           <view>
-            <view class="dot dot-green"></view>
-            <view class="name">Theta</view>
+            <view class="line"></view>
+            <view class="title">基本脑波</view>
           </view>
-          <view>
-            <view class="dot dot-yellow"></view>
-            <view class="name">Beta</view>
-          </view>
-          <view>
-            <view class="dot dot-orange-yellow"></view>
-            <view class="name">Alpha</view>
+          <view class="label">
+            <view>
+              <view class="dot dot-blue"></view>
+              <view class="name">Delta</view>
+            </view>
+            <view>
+              <view class="dot dot-green"></view>
+              <view class="name">Theta</view>
+            </view>
+            <view>
+              <view class="dot dot-yellow"></view>
+              <view class="name">Beta</view>
+            </view>
+            <view>
+              <view class="dot dot-orange-yellow"></view>
+              <view class="name">Alpha</view>
+            </view>
           </view>
         </view>
+
+        <view class="chart">
+          <mpvue-echarts :echarts="echarts" :onInit="medCharts" canvasId="demo-canvas-1"/>
+        </view>
       </view>
-      <view class="chart">
-        <mpvue-echarts :echarts="echarts" :onInit="medCharts" canvasId="demo-canvas-1"/>
-      </view>
+
     </div>
 
     <!--    窗口弹出-->
@@ -184,7 +191,7 @@ export default {
         {
           id: 2,
           name: "会员时间消费",
-          time: 20 * 60 * 1000,
+          time: 30 * 60 * 1000,
           err_title: "本次游玩时间已用完"
         },
         {
@@ -244,9 +251,11 @@ export default {
       wx.offBLECharacteristicValueChange()
       Toast.success('已成功断开')
       //设置游戏状态为 停止游戏
-      game_store.commit('setGameStatus', 3)
+      game_store.setters.setGameStatus(3)
       //游戏结束重置游戏时间
-      game_store.commit('setPlayTime', 0)
+      game_store.setters.setPlayTime(0)
+      //游戏结束重置游戏模式
+      game_store.setters.setMode(0)
       //游戏结束传送一下数据
       $this.post_data()
       $this.game_over()
@@ -266,73 +275,6 @@ export default {
         url: "/pages/report/main"
       })
     },
-    //获取蓝牙设备服务
-    getBLEDeviceServices(deviceId) {
-      console.log('获取蓝牙设备服务', deviceId)
-      wx.getBLEDeviceServices({
-        deviceId,
-        success: (res) => {
-          console.log('获取蓝牙设备服务成功')
-          for (let i = 0; i < res.services.length; i++) {
-            if (res.services[i].isPrimary) {
-              this.getBLEDeviceCharacteristics(deviceId, res.services[i].uuid)
-              return
-            }
-          }
-        },
-        fail(res) {
-
-          console.log('获取蓝牙设备失败', res)
-        }
-      })
-    },
-    //获取蓝牙设备某个服务中所有特征值
-    getBLEDeviceCharacteristics(deviceId, serviceId) {
-      console.log('获取蓝牙设备某个服务中所有特征值')
-      wx.getBLEDeviceCharacteristics({
-        deviceId,
-        serviceId,
-        success: (res) => {
-          console.log('getBLEDeviceCharacteristics success', res.characteristics)
-          for (let i = 0; i < res.characteristics.length; i++) {
-            let item = res.characteristics[i]
-            if (item.properties.read) {
-              wx.readBLECharacteristicValue({
-                deviceId,
-                serviceId,
-                characteristicId: item.uuid,
-              })
-            }
-            if (item.properties.write) {
-              $this._deviceId = deviceId
-              $this._serviceId = serviceId
-              $this._characteristicId = item.uuid
-              game_store.commit('setDeviceId', deviceId)
-              game_store.commit('setServiceId', serviceId)
-              game_store.commit('setCid', item.uuid)
-              bluetooth.sendPause(deviceId, serviceId, item.uuid)
-              //获取玩具的值
-              // bluetooth.sendConnect($this.toy_hex, deviceId, serviceId, item.uuid, Toast)
-            }
-
-            if (item.properties.notify || item.properties.indicate) {
-              wx.notifyBLECharacteristicValueChange({
-                deviceId,
-                serviceId,
-                characteristicId: item.uuid,
-                state: true,
-              })
-            }
-          }
-        },
-        fail(res) {
-          console.error('getBLEDeviceCharacteristics', res)
-        }
-      })
-      // 操作之前先监听,保证第一时间获取数据
-      $this.start_game()
-    },
-
     start_game() {
       wx.onBLECharacteristicValueChange((characteristic) => {
         console.log('监听蓝牙时间获取数据')
@@ -362,7 +304,6 @@ export default {
           $this.elc_power = $power
         }
         bluetooth.sendControl($this._deviceId, $this._serviceId, $this._characteristicId)
-
       })
 
     },
@@ -381,6 +322,9 @@ export default {
     //  监听时间发生变动
     watch_time(e) {
       let $datetime = e.mp.detail
+      if ($datetime.seconds.length == 1) {
+        $datetime.seconds = '0' + $datetime.seconds
+      }
       $this.timeData = $datetime
       $this.played_time += 1
       console.log("玩了:" + $this.played_time + "秒")
@@ -395,7 +339,7 @@ export default {
     // 往后端推送一次定时数据
     post_data() {
       let $params = {
-        game_record_id: game_store.getters.getGameRecordId,
+        game_record_id: game_store.getters.getGameRecordId(),
         line: $this.att_list,
         line_med: $this.med_list
       }
@@ -426,7 +370,7 @@ export default {
       //   $play_time = $userinfo['play_time'] * 60 - $current_time
       // }
       let $params = {
-        game_record_id: game_store.getters.getGameRecordId,
+        game_record_id: game_store.getters.getGameRecordId(),
         type: $this.mode,
         play_time: $this.played_time
       }
@@ -442,26 +386,29 @@ export default {
   }
   ,
   mounted() {
+
+    let $deviceId = $this._deviceId = game_store.getters.getDeviceId()
+    let $serviceId = $this._serviceId = game_store.getters.getServiceId()
+    let $cId = $this._characteristicId = game_store.getters.getCharacterId()
+    console.log("游戏开始:", $deviceId, $serviceId, $cId)
+
     //判断是否结束游戏
     if ($this.is_end == true) {
       $this.game_finished()
     } else {
-      $this._deviceId = game_store.getters.getDeviceId
-      console.log("游戏开始:当前device_id", $this._deviceId)
-      $this.getBLEDeviceServices($this._deviceId)
-
+      $this.start_game()
       //  筛选 玩具id
-      $this.toy_hex = game_store.getters.getToyHex
+      $this.toy_hex = game_store.getters.getToyHex()
       // bluetooth.sendConnect($this.toy_hex, $this._deviceId, $this._serviceId, $this._characteristicId)
 
       //筛选模式
-      $this.mode = game_store.getters.getMode
+      $this.mode = game_store.getters.getMode()
 
       //获取用户游玩时间
-      let $play_time = $this.play_time = game_store.getters.getPlayTime
+      let $play_time = $this.play_time = game_store.getters.getPlayTime()
       $this.mode_list.forEach(($val, $index) => {
         $val['time'] = $play_time * 1000
-        if ($val['id'] == $this.mode) {
+        if ($val['id'] == $this.mode && $val['id'] == 1) {
           $this.mode_item = $val
         }
       })
@@ -489,7 +436,7 @@ export default {
     wx.offBLECharacteristicValueChange()
     //存储时间
     let $play_time = $this.timeData.minutes * 60 + $this.timeData.seconds
-    game_store.commit('setPlayTime', $play_time)
+    game_store.setters.setPlayTime($play_time)
     this.pop_show = false
     //设置未结束游戏
     $this.is_end = false
@@ -511,6 +458,7 @@ export default {
   background: linear-gradient(0deg, rgba(40, 157, 206, 0.51), rgba(135, 145, 226, 0.26));
   background-color: #46425E;
   padding: 5px;
+  height: 750px;
 
 }
 
@@ -679,4 +627,14 @@ export default {
   width: 73px;
   height: 83px;
 }
+
+.chart_view_first {
+  position: relative;
+  bottom: 10px;
+}
+
+.chart_view_second {
+  position: relative;
+  bottom: 5px;
+}
 </style>

+ 7 - 3
src/pages/user_center/recharge/index.vue

@@ -162,7 +162,7 @@
 
         </view>
 
-        <view v-if="selection_card.discount < 1">
+        <view v-if="selection_card.goods_id < 4">
           <text class="text-sm text-gray">折扣&emsp;{{ selection_card.discount }}</text>
           <br>
         </view>
@@ -199,7 +199,7 @@
             充值成功
           </text>
         </view>
-        <view class="sub-title" v-if="selection_card.discount < 1">
+        <view class="sub-title" v-if="selection_card.goods_id < 4">
           <text class="text-gray">
             {{ selection_card.goods_name }},请到实体店店员处领取邀请卡
           </text>
@@ -378,7 +378,11 @@ export default {
     //  切换显示
     changeCardShow($id) {
       console.log($id)
-      $this.card_action_show = $id
+      if ($this.card_action_show == $id){
+        $this.card_action_show = 0
+      }else{
+        $this.card_action_show = $id
+      }
     }
   }
   ,

+ 66 - 96
src/store/game.js

@@ -1,99 +1,69 @@
-import Vue from 'vue'
-import Vuex from 'vuex'
-
-Vue.use(Vuex)
+const setters = {
+  clearDeviceToy() {
+    wx.removeStorageSync('deviceId')
+    wx.removeStorageSync('serviceId')
+    wx.removeStorageSync('characteristicId')
+  },
+  //setter模块
+  setDeviceId(deviceId) {
+    wx.setStorageSync('deviceId', deviceId)
+  },
+  setServiceId(serviceId) {
+    wx.setStorageSync('serviceId', serviceId)
+  },
+  setCid(characteristicId) {
+    wx.setStorageSync('characteristicId', characteristicId)
+  },
+  setGameStatus(status) {
+    wx.setStorageSync('game_status', status)
+  },
+  setToyList(toy_list) {
+    wx.setStorageSync('toy_list', toy_list)
+  },
+  setToyHex(toy_hex) {
+    wx.setStorageSync('toy_hex', toy_hex)
+  },
+  setMode(mode) {
+    wx.setStorageSync('mode', mode)
+  },
+  setGameRecordId(param) {
+    wx.setStorageSync('game_record_id', param)
+  },
+  setPlayTime(param) {
+    wx.setStorageSync('play_time', param)
+  }
+}
 
-export default new Vuex.Store({
-  state: {
-    deviceId: "",
-    serviceId: "",
-    characteristicId: "",
-    //游戏状态 0 不在游戏,1游戏中
-    game_status: 0,
-    toy_index: 0,
-    toy_list: [],
-    toy_hex: "",
-    // 使用类型 1次数 2时间 0未选择
-    mode: 0,
-    //游戏记录id
-    game_record_id: 0,
-    //  游戏时间
-    play_time: 0
-  },
-  mutations: {
-    clearDeviceToy(state) {
-      state.deviceId = ""
-      state.serviceId = ""
-      state.characteristicId = ""
-      wx.removeStorageSync('deviceId')
-      wx.removeStorageSync('serviceId')
-      wx.removeStorageSync('characteristicId')
-    },
-    setDeviceId(state, deviceId) {
-      state.deviceId = deviceId
-      wx.setStorageSync('deviceId', deviceId)
-    },
-    setServiceId(state, serviceId) {
-      state.serviceId = serviceId
-      wx.setStorageSync('serviceId', serviceId)
-    },
-    setCid(state, characteristicId) {
-      state.characteristicId = characteristicId
-      wx.setStorageSync('characteristicId', characteristicId)
-    },
-    setGameStatus(state, status) {
-      wx.setStorageSync('status', status)
-      state.game_status = status
-    },
-    setToyList(state, toy_list) {
-      wx.setStorageSync('toy_list', toy_list)
-      state.toy_list = toy_list
-    },
-    setToyHex(state, toy_hex) {
-      wx.setStorageSync('toy_hex', toy_hex)
-      state.toy_hex = toy_hex
-    },
-    setMode(state, mode) {
-      wx.setStorageSync('mode', mode)
-      state.mode = mode
-    },
-    setGameRecordId(state, param) {
-      wx.setStorageSync('game_record_id', param)
-      state.game_record_id = param
-    },
-    setPlayTime(state, param) {
-      wx.setStorageSync('play_time', param)
-      state.play_time = param
-    }
-  },
-  getters: {
-    getDeviceId(state, getters) {
-      return wx.getStorageSync('deviceId')
-    },
-    getServiceId(state, getters) {
-      return wx.getStorageSync('serviceId')
-    },
-    getCharacterId(state, getters) {
-      return wx.getStorageSync('characteristicId')
-    },
-    getGameStatus(state) {
-      return wx.getStorageSync('game_status')
-    },
-    getToyList(state) {
-      return wx.getStorageSync('toy_list')
-    },
-    getToyHex(state) {
-      return wx.getStorageSync('toy_hex')
-    },
-    getMode(state) {
-      return wx.getStorageSync('mode')
-    },
-    getGameRecordId(state) {
-      return wx.getStorageSync('game_record_id')
-    },
-    getPlayTime(state) {
-      return wx.getStorageSync('play_time')
-    }
+const getters = {
+  getDeviceId() {
+    return wx.getStorageSync('deviceId')
+  },
+  getServiceId() {
+    return wx.getStorageSync('serviceId')
+  },
+  getCharacterId() {
+    return wx.getStorageSync('characteristicId')
+  },
+  getGameStatus() {
+    return wx.getStorageSync('game_status')
+  },
+  getToyList() {
+    return wx.getStorageSync('toy_list')
+  },
+  getToyHex() {
+    return wx.getStorageSync('toy_hex')
+  },
+  getMode() {
+    return wx.getStorageSync('mode')
+  },
+  getGameRecordId() {
+    return wx.getStorageSync('game_record_id')
   },
+  getPlayTime() {
+    return wx.getStorageSync('play_time')
+  }
+}
 
-})
+export default {
+  setters, getters
+}

+ 30 - 43
src/store/index.js

@@ -1,47 +1,34 @@
-import Vue from 'vue'
-import Vuex from 'vuex'
-
-Vue.use(Vuex)
-
-export default new Vuex.Store({
-  state: {
-    token: 0,
-    user_id: null,
-    userinfo: {},
-    is_login: false,
-    invite_code: ""
+const setters = {
+  set_token(token) {
+    wx.setStorageSync('token', token)
+  },
+  set_login() {
+    wx.setStorageSync('is_login', true)
+  },
+  set_invite_code(code) {
+    wx.setStorageSync('code', code)
   },
-  mutations: {
-    set_token(state, token) {
-      wx.setStorageSync('token', token)
-      state.token = token
-    },
-    set_login(state) {
-      wx.setStorageSync('is_login', true)
-      state.is_login = true
-    },
-    set_invite_code(state, code) {
-      state.invite_code = code
-      wx.setStorageSync('code', code)
-    },
-    set_userinfo(state, userinfo) {
-      state.userinfo = userinfo
-      wx.setStorageSync('userinfo', userinfo)
-    }
+  set_userinfo(userinfo) {
+    wx.setStorageSync('userinfo', userinfo)
+  }
+}
+const getters = {
+  get_token() {
+    return wx.getStorageSync('token')
   },
-  getters: {
-    get_token(state) {
-      return state.token
-    },
-    get_login_status(state) {
-      return state.is_login
-    },
-    get_userinfo(state) {
-      return state.userinfo
-    },
-    get_invite_code(state) {
-      return state.invite_code
-    }
+  get_login_status() {
+    return wx.getStorageSync('is_login')
+
+  },
+  get_userinfo() {
+    return wx.getStorageSync('userinfo')
+
   },
+  get_invite_code() {
+    return wx.getStorageSync('invite_code')
 
-})
+  }
+}
+export default {
+  setters, getters
+}

+ 9 - 12
src/utils/bluetooth.js

@@ -114,7 +114,7 @@ export default {
         //   title: '正在创建连接',
         // })
 
-        let $game_status = game_store.getters.getGameStatus;
+        let $game_status = game_store.getters.getGameStatus();
         if ($game_status == 1) {
           Toast.loading({
             duration: 0,
@@ -294,7 +294,7 @@ export default {
         Toast.clear()
         if ($val['flag']) {
           Toast.success($val['msg'])
-          let $game_status = game_store.getters.getGameStatus;
+          let $game_status = game_store.getters.getGameStatus();
           if ($game_status == 1) {
             this.sendControl(deviceId, serviceId, Cid)
           }
@@ -361,7 +361,6 @@ export default {
     let $high_beta = "0x" + $low_beta_1 << 16 | "0x" + $low_beta_2 << 8 | "0x" + $low_beta_3
     //Beta数据
     let $beta = parseInt(($high_beta << 8) | $low_beta, 16)
-
     return {
       att: $att,
       med: $med,
@@ -376,9 +375,7 @@ export default {
     if (hex.substr(0, 8) != '55550203') {
       return false
     }
-    console.log("电量16进制:", hex.substr(8, 2))
     let $power = parseInt("0x" + hex.substr(8, 2))
-    console.log("电量10进制:", $power)
     return $power
   },
 
@@ -393,7 +390,7 @@ export default {
         $that.change_device_status(0)
 
         //判断游戏是否游戏中
-        let $game_status = game_store.getters.getGameStatus;
+        let $game_status = game_store.getters.getGameStatus();
         if ($game_status == 1) {
           $that.game_finished()
         }
@@ -415,7 +412,7 @@ export default {
           }
         }
       },
-      fail(res){
+      fail(res) {
         console.log('连接蓝牙成功,获取服务失败')
       }
     })
@@ -442,9 +439,9 @@ export default {
             $this.deviceId = deviceId
             $this.serviceId = serviceId
             $this.cid = item.uuid
-            game_store.commit('setDeviceId', deviceId)
-            game_store.commit('setServiceId', serviceId)
-            game_store.commit('setCid', item.uuid)
+            game_store.setters.setDeviceId(deviceId)
+            game_store.setters.setServiceId(serviceId)
+            game_store.setters.setCid(item.uuid)
             $this.sendPause(deviceId, serviceId, item.uuid)
             //获取玩具的值
             // bluetooth.sendConnect($this.toy_hex, deviceId, serviceId, item.uuid)
@@ -491,7 +488,7 @@ export default {
         //连接成功 打开核销窗口
         // $this.pay_window = true
         $this.change_toy_connect_status(2)
-        let $game_status = game_store.getters.getGameStatus;
+        let $game_status = game_store.getters.getGameStatus();
         if ($game_status == 1) {
           $this.change_toy_connect_status(4)
         }
@@ -582,7 +579,7 @@ export default {
         //   title: '正在创建连接',
         // })
 
-        let $game_status = game_store.getters.getGameStatus;
+        let $game_status = game_store.getters.getGameStatus();
         if ($game_status == 1) {
           Toast.loading({
             duration: 0,

+ 1 - 1
src/utils/user.js

@@ -16,6 +16,6 @@ export function reload_userinfo($this) {
     $this.invite_code = wx.getStorageSync('code') ? wx.getStorageSync('code') : $this.userinfo['invite_id']
 
     // $this.userinfo.play_time = Math.ceil($this.userinfo.play_time / 60)
-    user_store.commit('set_userinfo', $this.userinfo)
+    user_store.setters.set_userinfo($this.userinfo)
   })
 }