Procházet zdrojové kódy

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

yerong před 4 roky
rodič
revize
c043e73911

+ 1 - 1
dist/wx

@@ -1 +1 @@
-Subproject commit 7a56addf40ff37aaa66055e394adb6d6280a6a8f
+Subproject commit 613432c68cdcca4685c8d2c0ba04b8080e31bb6a

+ 3 - 3
src/App.vue

@@ -57,15 +57,15 @@ export default {
   width: 100%;
 }
 
-.under_line{
+.under_line {
   text-decoration: underline;
 }
 
-.text-primary{
+.text-primary {
   color: #6858C4;
 }
 
-.bg-primary{
+.bg-primary {
   background-color: #6858C4;
 }
 

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

@@ -175,7 +175,7 @@ export default {
           }
         }
       })
-
+      //
       //     }
       //   }
       // })
@@ -197,7 +197,21 @@ export default {
       $this.on_close()
       $this.change_toy_connect_status(1)
       $this._device_index = $this.toy_action - 1
-      $this.connect_toy = 2
+      let $toy = $this.toy_list[$this.toy_action - 1]
+      let $hex = $toy['hex'].substr($toy['hex'].length - 2, 2)
+      let toy_hex = '0x' + $hex
+      game_store.commit('setToyHex', toy_hex)
+      //判断是否游戏中
+      let $game_status = game_store.getters.getGameStatus
+      console.log('choose_ok_game_status', $game_status)
+      if ($game_status == 1) {
+        $this.connect_toy = 4
+        mpvue.navigateTo({
+          url: "/pages/start/main"
+        })
+      } else {
+        $this.connect_toy = 2
+      }
     },
     //修改玩具连接状态
     change_toy_connect_status($status = 0) {
@@ -318,6 +332,16 @@ export default {
   created() {
     $this = this
   },
+  onShow() {
+    //判断是否游戏中
+    let $game_status = game_store.getters.getGameStatus
+    console.log('choose_ok_game_status', $game_status)
+    if ($game_status == 1) {
+      $this.connect_toy = 4
+    } else {
+      $this.connect_toy = 2
+    }
+  },
   onLoad(options) {
     // 原有的code
     let $_code = wx.getStorageSync('code')

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

@@ -85,7 +85,7 @@
       <!--      玩具连接失败-->
       <div v-if="connect_toy == 3">
         <van-col span="8">
-          <button class="cu-btn bg-red lg cu-btn-primary" @click="choose_pay_window">
+          <button class="cu-btn bg-red lg cu-btn-primary" @click="open_choose_toy">
             <img src="https://img.shuimuai.com/m_xuanzewanju.png" alt="" class="cut_brain_icon">
             <text class=" cut_text">选择玩具</text>
           </button>
@@ -104,7 +104,7 @@
       <!--      玩具连接中-->
       <div v-if="connect_toy == 4">
         <van-col span="8">
-          <button class="cu-btn bg-red lg cu-btn-primary" @click="choose_pay_window">
+          <button class="cu-btn bg-red lg cu-btn-primary" @click="open_choose_toy">
             <img src="https://img.shuimuai.com/m_xuanzewanju.png" alt="" class="cut_brain_icon">
             <text class=" cut_text">选择玩具</text>
           </button>
@@ -113,7 +113,7 @@
         <van-col span="8">
           <button class="cu-btn bg-green lg ">
             <img src="https://img.shuimuai.com/web/start_game_icon.png" alt="" class="cut_start_game_icon">
-            <text class=" cut_text" style="padding: 0px;">游戏中</text>
+            <text class=" cut_text" style="padding: 0px;" @click="to_playing">游戏中</text>
           </button>
         </van-col>
 
@@ -158,6 +158,7 @@
 <script>
 import {gameStart} from "@/requests/game";
 import Toast from "../../../../static/vant/toast/toast";
+import game_store from '../../../store/game'
 
 let $this;
 export default {
@@ -188,9 +189,10 @@ export default {
       }
       gameStart($params).then((res) => {
         let $data = res.data
+        let $res = $data.data
         console.log('游戏开始返回', $data)
-        // if ($data.code == 0) {
-        if ($data.code) {
+        if ($data.code == 0) {
+          // if ($data.code) {
           Toast.success({
             message: $data.errmsg,
             onClose() {
@@ -198,8 +200,16 @@ export default {
               $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?mode=" + $event + "&toy_id=" + $this.toy_id
+                url: "/pages/start/main"
               })
             }
           })
@@ -215,7 +225,9 @@ export default {
     },
     // 前往正在玩的波动时间界面
     to_playing() {
-      console.log('跳转')
+      mpvue.navigateTo({
+        url: "/pages/start/main"
+      })
     },
     //修改连接状态
     change_toy_connect_status($status) {

+ 5 - 5
src/components/index/personal.vue

@@ -200,11 +200,11 @@ export default {
       let $data = res.data
       //判断如果是第一次登录就 弹出领取体验卡
       $this.userinfo = $data.data
-      // if ($this.userinfo.login_time == 0) {
-      //   $this.first = true
-      // } else if ($this.userinfo.play_time == 0) {
-      //   $this.pop_show = true
-      // }
+      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);
     })
 

+ 1 - 1
src/components/static/connecting.css

@@ -4,7 +4,7 @@
 }
 
 .cut_start_game_icon {
-  width: 30px;
+  width: 28px;
   height: 30px;
 }
 

+ 14 - 10
src/pages/agent/index/index.vue

@@ -8,16 +8,16 @@
         <div class="userinfo padding-tb-sm">
           <van-col span="3" offset="2">
             <view class="cu-avatar lg"
-                  :style="'background-image:url('+userinfo.avatar+');'"></view>
+                  :style="'background-image:url('+userinfo.portrait+');'"></view>
           </van-col>
 
           <van-col span="6" offset="1">
             <view class="label">
               <view class="text-bold">
-                <text class="text-white text-lg">{{ userinfo.nickname }}</text>
+                <text class="text-white text-lg">{{ userinfo.nick_name }}</text>
               </view>
               <view class="padding-tb-sm">
-                <text class="text-white text-sm">{{ userinfo.agent_name }}</text>
+                <text class="text-white text-sm">{{ userinfo.level_name }}</text>
               </view>
             </view>
           </van-col>
@@ -64,7 +64,7 @@
           </van-col>
           <van-col span="6" @click="to_agent_invite_card">
             <view>
-              <text class="text-xxl text-white">0</text>
+              <text class="text-xxl text-white">{{ agent_info.invite_count }}</text>
             </view>
             <view>
               <text class="text-normal text-sm">邀请卡库存</text>
@@ -79,7 +79,7 @@
     <!--      提现金额-->
     <div class="withdraw_container flex justify-between align-center padding-lr" @click="to_agent_cal_center">
       <text class="text-white">可提现金额(元)</text>
-      <text class="text-white withdraw_money">{{ agent_info.user_balance }}.00</text>
+      <text class="text-white withdraw_money">{{ agent_info.user_balance }}</text>
     </div>
 
     <!--      菜单列表-->
@@ -101,10 +101,10 @@
 </template>
 
 <script>
-
-
 import {agentDetail, agentIncomeDetail} from "../../../requests/agent";
+import utils from '@/utils/index'
 
+var $this
 export default {
   name: "agent_index_container",
   filter: {},
@@ -116,7 +116,7 @@ export default {
       //代理商详情
       agent_info: {},
       //代理商收益详情
-      income_info:{}
+      income_info: {}
     }
   },
   methods: {
@@ -150,8 +150,8 @@ export default {
         let $data = res.data;
         $this.agent_info = $data.data;
       })
-      agentIncomeDetail().then((res)=>{
-        let $data =res.data;
+      agentIncomeDetail().then((res) => {
+        let $data = res.data;
         $this.income_info = $data.data;
       })
     }
@@ -159,6 +159,10 @@ export default {
   mounted() {
     $this.get_agent_detail()
     $this.userinfo = wx.getStorageSync('userinfo')
+    $this.userinfo['level_name'] = utils.get_level_name()
+  },
+  created() {
+    $this = this
   }
 }
 </script>

+ 18 - 6
src/pages/index/index.vue

@@ -32,10 +32,10 @@
         </div>
       </div>
       <div class="content">
-        <img src="https://img.shuimuai.com/chongzhizhongxin.png" @click="to_page('recharge')"></img>
-        <img src="https://img.shuimuai.com/shebeiguanli.png" @click="to_page('user_center')"></img>
-        <img src="https://img.shuimuai.com/chongzhizhongxin.png" @click="to_page('report')"></img>
-        <img src="https://img.shuimuai.com/shebeiguanli.png" @click="to_page('agent/index')"></img>
+        <img src="https://img.shuimuai.com/web/index_btn_chongzhizhongxin.png" @click="to_page('recharge')"></img>
+        <img src="https://img.shuimuai.com/web/index_btn_gerenzhongxin.png" @click="to_page('user_center')"></img>
+        <img src="https://img.shuimuai.com/web/index_btn_chengjijilu.png" @click="to_page('report')"></img>
+        <img src="https://img.shuimuai.com/web/index_btn_dailishang.png" @click="to_page('agent/index')"></img>
       </div>
     </div>
     <van-toast id="van-toast"/>
@@ -51,8 +51,9 @@ import regist_container from '@/components/index/regist'
 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";
 
-
+var $this
 export default {
   name: "index_container",
   components: {
@@ -93,7 +94,7 @@ export default {
     },
     //跳转页面
     to_page($page) {
-      if (!this.is_login){
+      if (!this.is_login) {
         Toast.fail("请先登录")
         return false
       }
@@ -104,6 +105,14 @@ export default {
   },
   mounted() {
   },
+  onShow() {
+    userDetail().then((res) => {
+      let $data = res.data
+      //判断如果是第一次登录就 弹出领取体验卡
+      $this.userinfo = $data.data
+      $this.$store.commit('set_userinfo', $this.userinfo)
+    })
+  },
   onLoad($option) {
     //  判断存储是否登录
     let $token = wx.getStorageSync('token')
@@ -112,6 +121,9 @@ export default {
       this.$store.commit('set_login', true);
       this.is_login = this.$store.getters.get_login_status
     }
+  },
+  created(){
+    $this = this
   }
 }
 </script>

+ 72 - 45
src/pages/start/index.vue

@@ -9,7 +9,8 @@
           </view>
           <view class="text-lg   padding-top">
             <van-count-down :time="mode_item.time" format="mm:ss" use-slot auto-start @finish="time_out"
-                            @change="watch_time">
+                            @change="watch_time" class="control-count-down"
+            >
               <text>{{ timeData.minutes }}:{{ timeData.seconds }}</text>
             </van-count-down>
           </view>
@@ -21,7 +22,7 @@
           </view>
           <button class="cu-btn bg-red text-white margin-top-sm" @click="game_finished">
             <img src="https://img.shuimuai.com/m_duankainaohuan.png" class="cut_brain_icon" alt="">
-            <text class="padding-lr cut_text text-sm" @click="game_finished">停止游玩</text>
+            <text class="padding-lr cut_text text-sm">停止游玩</text>
           </button>
         </van-col>
       </van-row>
@@ -131,7 +132,7 @@ import util from '../../utils/index'
 import bluetooth from "../../utils/bluetooth";
 import game_store from "@/store/game";
 import Toast from '../../../static/vant/toast/toast';
-import {game_devices, gameAddLine} from "../../requests/game";
+import {game_devices, gameAddLine, gameEnd} from "../../requests/game";
 
 var att_charts,
   med_charts,
@@ -199,12 +200,19 @@ export default {
       attCharts: initAttChart,
       medCharts: initMedChart,
       user_info: {},
+      //设备值
       _deviceId: "",
       _serviceId: "",
       _characteristicId: "",
+
       toy_index: 0,
       toy_id: 0,
       toy: {},
+      toy_hex: "",
+
+      play_time: 0,
+
+      //图标数据集合
       att_list: [],
       med_list: [],
       delta_list: [],
@@ -216,26 +224,17 @@ export default {
   methods: {
     //游戏结束方法
     game_finished() {
-      let $deviceId = game_store.getters.getDeviceId
-      let $serviceId = game_store.getters.getServiceId
-      let $charatorId = game_store.getters.getCharacterId
-      console.log('delta_list', $this.delta_list)
-      console.log('alpha_list', $this.alpha_list)
-      console.log('beta_list', $this.beta_list)
-      console.log('theta_list', $this.theta_list)
       //停止控制游戏
-      bluetooth.sendEnd($deviceId, $serviceId, $charatorId)
-      //关闭脑环
-      // wx.closeBLEConnection({
-      //   deviceId: $deviceId,
-      //   success(res) {
-      //   }
-      // })
+      bluetooth.sendPause($this._deviceId, $this._serviceId, $this._characteristicId)
+      bluetooth.sendEnd($this._deviceId, $this._serviceId, $this._characteristicId)
       const countDown = $this.$mp.page.selectComponent('.control-count-down');
       countDown.pause();
       Toast.success('已成功断开')
       //设置游戏状态为 停止游戏
       game_store.commit('setGameStatus', 0)
+      //游戏结束传送一下数据
+      $this.post_data()
+      $this.game_over()
       $this.to_report()
     },
     //  关闭弹窗
@@ -291,7 +290,8 @@ export default {
               game_store.commit('setServiceId', serviceId)
               game_store.commit('setCid', item.uuid)
               bluetooth.sendPause(deviceId, serviceId, item.uuid)
-              bluetooth.sendConnect($this.toy, deviceId, serviceId, item.uuid)
+              //获取玩具的值
+              bluetooth.sendConnect($this.toy_hex, deviceId, serviceId, item.uuid)
             }
 
             if (item.properties.notify || item.properties.indicate) {
@@ -336,6 +336,7 @@ export default {
         }
 
         //连接玩具
+        console.log('玩具hexStr', hexStr)
         let $flag = bluetooth.connect_toy(hexStr, $this._deviceId, $this._serviceId, $this._characteristicId)
         if ($flag) {
           console.log('info', $this._deviceId, $this._serviceId, $this._characteristicId)
@@ -358,61 +359,87 @@ export default {
     watch_time(e) {
       let $datetime = e.mp.detail
       $this.timeData = $datetime
+      //时间倒数
       if ($datetime.seconds == '00') {
-        console.log('满一分钟')
+        //  时间满一分钟 则提交一次数据
+        // 添加折线图的点
+        $this.post_data()
       }
     },
     // 往后端推送一次定时数据
     post_data() {
       let $params = {
-        "game_record_id": 1,
-        "line": $this.att_list
+        game_record_id: game_store.getters.getGameRecordId,
+        line: $this.att_list
       }
       gameAddLine($params).then((res) => {
         let $data = res.data
         if ($data.code == 0) {
+          $this.att_list = []
+          $this.med_list = []
+          $this.delta_list = []
+          $this.alpha_list = []
+          $this.theta_list = []
+          $this.beta_list = []
           console.log('推送数据成功')
         } else {
           console.log('推送数据失败')
         }
       })
+    },
+    //  结束游戏
+    game_over() {
+      let $current_time = $this.timeData.minutes * 60 + $this.timeData.seconds
+      let $play_time = $this.play_time - $current_time
+      let $params = {
+        record_id: game_store.getters.getGameRecordId,
+        type: $this.mode,
+        play_time: $play_time
+      }
+      gameEnd($params).then((res) => {
+        let $data = res.data
+      })
     }
   }
   ,
   mounted() {
-    $this._deviceId = game_store.getters.getDeviceId
-    $this.toy_index = game_store.getters.getToyIndex
-    $this.getBLEDeviceServices($this._deviceId)
   },
   created() {
     $this = this;
   },
-  onLoad($option) {
-    //获取用户游玩时间
-    $this.userinfo = wx.getStorageSync('userinfo')
-    $this.mode_list.forEach(($val, $index) => {
-      if ($val['id'] == 2) {
-        $val['time'] = parseInt($this.userinfo['play_time']) * 60 * 1000
-      }
-    })
+  onShow() {
+    $this._deviceId = game_store.getters.getDeviceId
+    $this.getBLEDeviceServices($this._deviceId)
+
+    //  筛选 玩具id
+    $this.toy_hex = game_store.getters.getToyHex
+    // bluetooth.sendConnect($this.toy_hex, $this._deviceId, $this._serviceId, $this._characteristicId)
+
+
     //筛选模式
-    $this.mode = $option.mode
+    $this.mode = game_store.getters.getMode
+
+    //获取用户游玩时间
+    let $play_time = $this.play_time = game_store.getters.getPlayTime
     $this.mode_list.forEach(($val, $index) => {
-      if ($option.mode == $val['id']) {
+      $val['time'] = $play_time * 1000
+      if ($val['id'] == $this.mode) {
         $this.mode_item = $val
       }
     })
-    //  筛选 玩具id
-    $this.toy_id = $option.toy_id
-    game_devices().then((res) => {
-      let $data = res.data
-      let $toylist = $data.data
-      $toylist.forEach(($val, $index) => {
-        if ($val['device_id'] == $this.toy_id) {
-          $this.toy = $val
-        }
-      })
-    })
+
+  },
+  onLoad() {
+  },
+  onUnload() {
+    const countDown = $this.$mp.page.selectComponent('.control-count-down');
+    countDown.pause();
+    bluetooth.sendPause($this._deviceId, $this._serviceId, $this._characteristicId)
+    bluetooth.sendEnd($this._deviceId, $this._serviceId, $this._characteristicId)
+
+    let $play_time = $this.timeData.minutes * 60 + $this.timeData.seconds
+    console.log($play_time)
+    game_store.commit('setPlayTime', $play_time)
   }
 }
 </script>

+ 87 - 8
src/pages/user_center/edit/index.vue

@@ -1,34 +1,79 @@
 <template>
   <div class="uc_edit_container">
     <van-cell title="头像">
-      <img :src="userinfo.avatar" alt="" class="avatar">
+      <img :src="userinfo.portrait" alt="" class="avatar">
     </van-cell>
     <van-cell title="手机号" :value="userinfo.phone" is-link url="/pages/user_center/edit/confirm_phone_first/main"/>
-    <van-cell title="会员码" is-link>
+    <van-cell title="会员码" is-link url="/pages/user_center/vip_code/main">
       <van-icon name="qr"/>
     </van-cell>
-    <van-cell title="昵称" :value="userinfo.nickname"/>
-    <van-cell title="性别" is-link>
-      <template v-if="userinfo.gender">
+    <van-cell title="昵称" :value="userinfo.user_name"/>
+    <van-cell title="性别" is-link @click="gender_picker = true">
+      <template v-if="userinfo.sex == 1">
       </template>
-      <template v-else>
+      <template v-if="userinfo.sex == 2">
       </template>
+      <template v-if="userinfo.sex == 0">
+        保密
+      </template>
     </van-cell>
-    <van-cell title="生日" :value="userinfo.birthday" is-link/>
+    <van-cell title="生日" :value="userinfo.birthday" is-link @click="birthday_picker = true"/>
     <van-cell title="家庭组" :value="userinfo.home_group" is-link/>
     <van-cell title="推荐人" :value="userinfo.recommend"/>
+
+    <van-popup
+      :show="gender_picker"
+      round
+      position="bottom"
+    >
+      <van-picker
+        :columns="gender"
+        @confirm="onGenderChange"
+        @cancel="gender_picker = false"
+        show-toolbar
+        title="更换性别"
+        :default-index="userinfo.gender"
+      />
+    </van-popup>
+
+
+    <van-toast id="van-toast"/>
+
+    <van-popup
+      :show="birthday_picker"
+      round
+      position="bottom"
+    >
+      <van-datetime-picker
+        type="date"
+        :value="_birthday"
+        @confirm="onDateChange"
+        @cancel="birthday_picker = false"
+        :max-date="max_date"
+      />
+    </van-popup>
+
   </div>
 </template>
 
 <script>
+import {userChangeBirthday, userChangeSex, userDetail} from "../../../requests/user";
+import Toast from "../../../../static/vant/toast/toast";
+import {formatBirthday} from '../../../utils/index'
+
 var $this
 export default {
   name: "uc_edit_container",
   components: {},
   data() {
     return {
+      gender: [
+        '保密', '男', '女'
+      ],
+      _birthday: "",
+      max_date: new Date().getTime(),
       userinfo: {
         avatar: "https://img.shuimuai.com/weixintouxiang.png",
         phone: '13722886629',
@@ -38,13 +83,47 @@ export default {
         birthday: "1862-02-32",
         home_group: "超级复读机",
         recommend: "莲花山云雨"
-      }
+      },
+      gender_picker: false,
+      birthday_picker: false
     }
   },
   methods: {
+    //修改性别
+    onGenderChange($val) {
+      let $gender = $this.userinfo.sex = $val.mp.detail.index
+      let $params = {
+        sex: $gender
+      }
+      userChangeSex($params).then((res) => {
+        let $data = res.data
+        Toast.success($data.errmsg)
+      })
+      $this.gender_picker = false
+    },
+    onDateChange($val) {
+      console.log($val.mp.detail)
+      let $birthday = $val.mp.detail / 1000
+      let $params = {
+        birthday: $birthday
+      }
+      $this.userinfo.birthday = formatBirthday($birthday)
+      userChangeBirthday($params).then((res) => {
+        let $data = res.data;
+        Toast.success($data.errmsg)
+      })
+      $this.birthday_picker = false
+
+    }
   }
   ,
   mounted() {
+    userDetail().then((res) => {
+      let $data = res.data;
+      $this.userinfo = $data.data;
+      $this.userinfo.birthday = formatBirthday($this.userinfo.birthday)
+
+    })
   },
   created() {
     $this = this;

+ 3 - 0
src/pages/user_center/edit/main.json

@@ -3,6 +3,9 @@
     "van-popup": "../../../static/vant/popup/index",
     "van-icon": "../../../static/vant/icon/index",
     "van-cell": "../../../static/vant/cell/index",
+    "van-picker": "../../../static/vant/picker/index",
+    "van-datetime-picker": "../../../static/vant/datetime-picker/index",
+    "van-toast": "../../../static/vant/toast/index",
     "van-cell-group": "../../../static/vant/cell-group/index"
   }
 }

+ 29 - 22
src/pages/user_center/index.vue

@@ -5,18 +5,18 @@
     <view class="user">
       <view class="up">
         <view class="left">
-          <img src="https://img.shuimuai.com/weixintouxiang.png"/>
+          <img :src="userinfo.portrait"/>
           <view>
             <text>
-              <text>小疯兔</text>
+              <text>{{ userinfo.user_name }}</text>
             </text>
-            <text>普通会员 有效期至 2020.11.11</text>
+            <text>{{ userinfo.level_name }} 有效期至 {{ userinfo.validity_time }}</text>
           </view>
         </view>
-        <view class="right">
-          <img src="https://img.shuimuai.com/m_icon_xiaoxi%402x.png"/>
-          <text>消息中心</text>
-        </view>
+<!--        <view class="right">-->
+<!--          <img src="https://img.shuimuai.com/m_icon_xiaoxi%402x.png"/>-->
+<!--          <text>消息中心</text>-->
+<!--        </view>-->
       </view>
       <view class="down">
         <view>0</view>
@@ -28,15 +28,15 @@
     </view>
     <view class="detail">
       <view>
-        <view>80</view>
-        <view>可用时长(分钟)</view>
+        <view>{{ userinfo.play_time }}</view>
+        <view>可用时长(分钟)</view>
       </view>
       <view>
-        <view>20</view>
+        <view>{{ userinfo.coupon }}</view>
         <view>体验券</view>
       </view>
       <view>
-        <view>80</view>
+        <view>{{ userinfo.experience }}</view>
         <view>次卡</view>
       </view>
     </view>
@@ -53,10 +53,10 @@
     <van-cell-group class="menu">
       <van-cell title="我的订单" icon="notes-o" is-link url="/pages/user_center/orders/main"/>
       <van-cell title="代理商中心" icon="manager-o" is-link url="/pages/agent/index/main"/>
-      <van-cell title="家庭组" icon="wap-home-o" is-link/>
-      <van-cell title="收货地址" icon="location-o" is-link/>
+<!--      <van-cell title="家庭组" icon="wap-home-o" is-link/>-->
+      <van-cell title="收货地址" icon="location-o" is-link url="/pages/user_center/address/edit/main"/>
       <van-cell title="联系客服" icon="service-o" is-link/>
-      <van-button open-type="contact" block custom-class="contact_button" >
+      <van-button open-type="contact" block custom-class="contact_button">
         <div>
           <view>
             <van-icon name="service-o"/>&nbsp;联系客服
@@ -69,12 +69,16 @@
 </template>
 
 <script>
+import utils from '@/utils/index'
+
 var $this
 export default {
   name: "uc_container",
   components: {},
   data() {
-    return {}
+    return {
+      userinfo: {},
+    }
   },
   methods: {
     to_edit() {
@@ -83,21 +87,21 @@ export default {
       })
     },
     //跳转vip权益
-    to_vip(){
+    to_vip() {
       mpvue.navigateTo({
-        url:"/pages/user_center/vip/main"
+        url: "/pages/user_center/vip/main"
       })
     },
     //打开扫一扫
-    open_scan(){
+    open_scan() {
       mpvue.scanCode({
-        onlyFromCamera:true
+        onlyFromCamera: true
       })
     },
     //跳转会员码
-    to_vip_code(){
+    to_vip_code() {
       mpvue.navigateTo({
-        url:"/pages/user_center/vip_code/main"
+        url: "/pages/user_center/vip_code/main"
       })
     }
   }
@@ -108,7 +112,10 @@ export default {
     $this = this;
   },
   onLoad() {
-  }
+    $this.userinfo = wx.getStorageSync('userinfo')
+    $this.userinfo['validity_time'] = utils.formatTime($this.userinfo['validity_time'])
+    $this.userinfo['level_name'] = utils.get_level_name($this.userinfo['level'])
+  },
 }
 </script>
 

+ 179 - 158
src/pages/user_center/recharge/index.vue

@@ -12,7 +12,7 @@
         </view>
       </div>
       <view>
-        <text class="text-bold mine_min">30</text>
+        <text class="text-bold mine_min">{{ userinfo.play_time }}</text>
       </view>
     </div>
 
@@ -23,166 +23,120 @@
     </div>
 
     <!--    黄金会员-->
-    <div class="gold vip">
-      <van-row>
-        <van-col span="8" offset="6">
-          <div class="card_body">
-            <view>
-              <text class="mine_min  text-white">200</text>
-              <text class="text-white">分钟</text>
-            </view>
-            <view>
-              <text class="text-white text-sm">3个月专注力训练课程</text>
-            </view>
-            <view>
-              <text class="text-white text-sm">分级利润权益</text>
-            </view>
-          </div>
-        </van-col>
-
-        <van-col span="5" offset="4">
-          <div class="card_body">
-
-            <view>
-              <text class="text-white text-sm">价格</text>
-            </view>
-            <view>
-              <text class="text-white mine_min">199</text>
-            </view>
-            <img src="https://img.shuimuai.com/web/btn_seedetil_2.png" class="check_detail" alt="">
-
-          </div>
-        </van-col>
-
-      </van-row>
-    </div>
+    <div v-for="(item,index) in time_cards" :key="index">
+      <div class="vip" :class="item.bg">
+        <van-row>
+          <van-col span="8" offset="6">
+            <div class="card_body">
+              <view>
+                <text class="mine_min  text-white">{{ item.play_time }}</text>
+                <text class="text-white">分钟</text>
+              </view>
+              <view>
+                <text class="text-white text-sm">{{ item.title1 }}</text>
+              </view>
+              <view>
+                <text class="text-white text-sm">{{ item.title2 }}</text>
+              </view>
+            </div>
+          </van-col>
+
+          <van-col span="5" offset="4">
+            <div class="card_body">
+
+              <view>
+                <text class="text-white text-sm">价格</text>
+              </view>
+              <view>
+                <text class="text-white mine_min">{{ item.price }}</text>
+              </view>
+              <img src="https://img.shuimuai.com/web/btn_seedetil_2.png" class="check_detail" alt=""
+                   @click="card_action_show = item.goods_id">
+
+            </div>
+          </van-col>
+
+        </van-row>
+      </div>
 
-    <!--    描述-->
-    <view class="desc">
+      <view v-if="card_action_show == item.goods_id">
 
-      黄金会员权益:<br>
-      1)获得核销时间为200分钟,有效期3个自然月(从购买当日时间开始计时)。<br>
-      2)获得5张次卡(实体卡),次卡不能自己使用,只能用给其它人使用。获得次卡的用户A可进行1次到店体验,且成为黄金会员的一级分销用户。<br>
-      如果次卡用户A进行消费,则黄金会员用户则获得以下对应的分润:<br>
-      购买次卡获得20元分润,购买黄金会员卡获得50元分润,购买白金会员获得100元分润,购买钻石会员则获得200元分润,线下购买创客代理获得300元分润,线下购买区域代理获得600元分润,线下购买合伙人,获得2000元分润。<br>
-      如果次卡用户A发展其它人B成为水母会员用户,则B作为次卡用户A的一级分销用户,也是黄金会员的二级分销用户,如果B产生消费,则次卡会员A获得一级分润(同上述的黄金会员一级分润)黄金会员可获得如下二级分润:<br>
-      B购买次卡获得5元分润,购买黄金会员卡获得15元分润,购买白金会员获得30元分润,购买钻石会员则获得60元分润。线下购买创客代理获得90元分润,线下购买区域代理获得180元分润,线下购买合伙人,获得600元分润。<br>
 
-    </view>
+        <!--    描述-->
+        <view class="desc" v-html="item.content">
 
+        </view>
 
-    <!--    购买按钮-->
-    <div class="buy_button">
-      <button class="cu-btn lg bg-orange text-center margin " @click="open_order_confirm">购买黄金会员</button>
-    </div>
 
-    <!--    白金会员-->
-    <div class="platina vip">
-      <van-row>
-        <van-col span="8" offset="6">
-          <div class="card_body">
-            <view>
-              <text class="mine_min  text-white">600</text>
-              <text class="text-white">分钟</text>
-            </view>
-            <view>
-              <text class="text-white text-sm">租赁设备</text>
-            </view>
-            <view>
-              <text class="text-white text-sm">更高分级利润权益</text>
-            </view>
-          </div>
-        </van-col>
-
-        <van-col span="5" offset="4">
-          <div class="card_body">
-
-            <view>
-              <text class="text-white text-sm">价格</text>
-            </view>
-            <view>
-              <text class="text-white mine_min">599</text>
-            </view>
-            <img src="https://img.shuimuai.com/web/btn_seedetil_2.png" class="check_detail" alt="">
-
-          </div>
-        </van-col>
-
-      </van-row>
+        <!--    购买按钮-->
+        <div class="buy_button">
+          <button class="cu-btn lg bg-orange text-center margin " @click="open_order_confirm(item)">购买{{
+              item.goods_name
+            }}
+          </button>
+        </div>
+      </view>
     </div>
 
-    <!--    钻石会员-->
-    <div class="diamond vip">
-      <van-row>
-        <van-col span="8" offset="6">
-          <div class="card_body">
-            <view>
-              <text class="mine_min  text-white">1000</text>
-              <text class="text-white text-sm">分钟</text>
-            </view>
-            <view>
-              <text class="text-white text-sm">租赁设备</text>
-            </view>
-            <view>
-              <text class="text-white text-sm">更高分级利润权益</text>
-            </view>
-          </div>
-        </van-col>
-
-        <van-col span="5" offset="4">
-          <div class="card_body">
-
-            <view>
-              <text class="text-white text-sm">价格</text>
-            </view>
-            <view>
-              <text class="text-white mine_min">199</text>
-            </view>
-            <img src="https://img.shuimuai.com/web/btn_seedetil_2.png" class="check_detail" alt="">
-
-          </div>
-        </van-col>
-
-      </van-row>
-    </div>
 
     <div class="title flex padding align-center">
       <div class="line margin-right"></div>
-      <text>体验磁卡次卡</text>
+      <text>体验次卡</text>
     </div>
     <!--  体验次卡-->
-    <div class="normal vip">
-      <van-row>
-        <van-col span="8" offset="6">
-          <div class="card_body">
-            <view>
-              <text class="mine_min  text-white">200</text>
-              <text class="text-white">分钟</text>
-            </view>
-            <view>
-              <text class="text-white text-sm">3个月专注力训练课程</text>
-            </view>
-            <view>
-              <text class="text-white text-sm">分级利润权益</text>
-            </view>
-          </div>
-        </van-col>
-
-        <van-col span="5" offset="4">
-          <div class="card_body">
-
-            <view>
-              <text class="text-white text-sm">价格</text>
-            </view>
-            <view>
-              <text class="text-white mine_min">199</text>
-            </view>
-            <img src="https://img.shuimuai.com/web/btn_seedetil_2.png" class="check_detail" alt="">
-
-          </div>
-        </van-col>
-
-      </van-row>
+    <div v-for="(item,index) in frequency_card" :key="index">
+
+      <div class="normal vip">
+        <van-row>
+          <van-col span="8" offset="6">
+            <div class="card_body">
+              <view>
+                <text class="mine_min  text-white">{{ item.play_time }}</text>
+                <text class="text-white">分钟</text>
+              </view>
+              <view>
+                <text class="text-white text-sm">{{ item.title1 }}</text>
+              </view>
+              <view>
+                <text class="text-white text-sm">{{ item.title2 }}</text>
+              </view>
+            </div>
+          </van-col>
+
+          <van-col span="5" offset="4">
+            <div class="card_body">
+
+              <view>
+                <text class="text-white text-sm">价格</text>
+              </view>
+              <view>
+                <text class="text-white mine_min">{{ item.price }}</text>
+              </view>
+              <img src="https://img.shuimuai.com/web/btn_seedetil_2.png" class="check_detail" alt=""
+                   @click="card_action_show = item.goods_id">
+
+            </div>
+          </van-col>
+
+        </van-row>
+      </div>
+      <view v-if="card_action_show == item.goods_id">
+
+
+        <!--    描述-->
+        <view class="desc" v-html="item.content">
+
+        </view>
+
+
+        <!--    购买按钮-->
+        <div class="buy_button">
+          <button class="cu-btn lg bg-orange text-center margin " @click="open_order_confirm(item)">购买{{
+              item.goods_name
+            }}
+          </button>
+        </div>
+      </view>
     </div>
 
 
@@ -190,11 +144,11 @@
     <van-popup :show="order_confirm" @close="close_order_confirm" round closeable>
       <div class="order_confirm padding">
         <view>
-          <text class="text-sm text-gray">已选商品&emsp;水母星球-钻石会员</text>
+          <text class="text-sm text-gray">已选商品&emsp;水母星球-{{ selection_card.goods_name }}</text>
           <br>
         </view>
         <view>
-          <text class="text-sm text-gray">商品价格&emsp;299元</text>
+          <text class="text-sm text-gray">商品价格&emsp;{{ selection_card.price }}元</text>
           <br>
 
         </view>
@@ -205,7 +159,7 @@
         </view>
         <view class="order_price_container">
           <text class="text-sm text-gray">实付(元)&emsp;</text>
-          <text class="mine_min">299</text>
+          <text class="mine_min">{{ selection_card.price }}</text>
         </view>
         <button class="cu-btn bg-primary lg text-white recharge_button" @click="success_pay">立即充值</button>
       </div>
@@ -238,12 +192,13 @@
         </view>
         <view class="sub-title">
           <text class="text-gray">
-            黄金会员包含 5张 实体邀请卡,我们将以快递形式发出,请填写收货地址.
+            {{ selection_card.goods_name }}卡,我们将以快递形式发出,请填写收货地址.
           </text>
         </view>
         <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-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>
         </div>
       </div>
     </van-popup>
@@ -252,6 +207,9 @@
 
 <script>
 
+import {goodsCardList} from "../../../requests/goods";
+import {createOrder} from "../../../requests/orders";
+
 var $this
 export default {
   name: "uc_recharge_container",
@@ -260,14 +218,25 @@ export default {
     return {
       order: {},
       order_confirm: false,
+      card_action_show: 1,
       err_show: false,
-      success_show: true
+      success_show: false,
+      //时间卡列表
+      time_cards: [],
+      //次卡列表
+      frequency_card: [],
+      //用户信息
+      userinfo: {},
+      //  选中的充值卡
+      selection_card: {}
     }
   },
+  watch: {},
   methods: {
     //弹出确认订单
-    open_order_confirm() {
+    open_order_confirm($item) {
       $this.order_confirm = true
+      $this.selection_card = $item
     },
     //关闭确认订单
     close_order_confirm() {
@@ -293,20 +262,72 @@ export default {
     repay() {
 
     },
+    to_index() {
+      mpvue.navigateTo({
+        url: "/pages/index/main"
+      })
+    },
     // 成功支付
     success_pay() {
       // 支付成功后得回调方法
+      let $params = {
+        goods_id: $this.selection_card.goods_id,
+        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
+          }
+        })
+      })
       //  接收回调方法后弹出支付成功
     },
     //跳转填写地址
-    to_write_address(){
+    to_write_address() {
       mpvue.navigateTo({
-        url:"/pages/user_center/address/list/main"
+        url: "/pages/user_center/address/list/main"
+      })
+    },
+    // 获取充值卡列表
+    get_card_list() {
+      goodsCardList().then((res) => {
+        let $data = res.data.data
+        $this.time_cards = $data.time_card
+        let $bg = ['gold', 'platina', 'diamond']
+        $this.time_cards.forEach(($val, $index) => {
+          $this.time_cards[$index]['bg'] = $bg[$index]
+          $this.time_cards[$index]['price'] = Math.ceil($val['price'])
+        })
+        $this.frequency_card = $data.frequency_card
+        $this.frequency_card.forEach(($val, $index) => {
+          $this.frequency_card[$index]['bg'] = 'normal'
+          $this.frequency_card[$index]['price'] = Math.round($val['price'])
+        })
       })
     }
   }
   ,
   mounted() {
+    $this.get_card_list()
+    $this.userinfo = wx.getStorageSync('userinfo')
   },
   created() {
     $this = this;

+ 11 - 4
src/pages/user_center/vip_code/index.vue

@@ -4,12 +4,12 @@
       <view class="user margin-xl">
         <view class="up">
           <view class="left">
-            <img src="https://img.shuimuai.com/weixintouxiang.png"/>
+            <img :src="userinfo.portrait"/>
             <view>
               <text>
-                <text>小疯兔</text>
+                <text>{{ userinfo.user_name }}</text>
               </text>
-              <text>普通会员 有效期至 2020.11.11</text>
+              <text>{{ userinfo.level_name }} 有效期至 {{ userinfo.validity_time }}</text>
             </view>
           </view>
         </view>
@@ -20,13 +20,16 @@
 </template>
 
 <script>
+import utils from '@/utils/index'
 
 var $this
 export default {
   name: "uc_vip_code_container",
   components: {},
   data() {
-    return {}
+    return {
+      userinfo: {}
+    }
   },
   methods: {}
   ,
@@ -36,6 +39,10 @@ export default {
     $this = this;
   },
   onLoad() {
+    $this.userinfo = wx.getStorageSync('userinfo')
+    $this.userinfo['validity_time'] = utils.formatTime($this.userinfo['validity_time'])
+    $this.userinfo['level_name'] = utils.get_level_name($this.userinfo['level'])
+
   }
 }
 </script>

+ 9 - 0
src/requests/goods.js

@@ -0,0 +1,9 @@
+import fly from "./main";
+import store from "@/store/index"
+
+
+// 设备列表
+export function goodsCardList($params = {}) {
+  $params['access_token'] = wx.getStorageSync('token')
+  return fly.post('goods/card-list', $params)
+}

+ 5 - 5
src/requests/user.js

@@ -19,7 +19,7 @@ export function userLogin($params) {
 
 //用户详情
 export function userDetail() {
-  let $token = store.getters.get_token
+  let $token = wx.getStorageSync('token')
   let $params = {
     access_token: $token
   }
@@ -28,7 +28,7 @@ export function userDetail() {
 
 //校验验证码
 export function userCheckCode($params) {
-  let $token = store.getters.get_token
+  let $token = wx.getStorageSync('token')
   $params['access_token'] = $token
   return fly.post('user/check-code', $params)
 }
@@ -36,21 +36,21 @@ export function userCheckCode($params) {
 
 //修改手机号码
 export function userChangePhone($params) {
-  let $token = store.getters.get_token
+  let $token = wx.getStorageSync('token')
   $params['access_token'] = $token
   return fly.post('user/change-phone', $params)
 }
 
 //修改性别
 export function userChangeSex($params) {
-  let $token = store.getters.get_token
+  let $token = wx.getStorageSync('token')
   $params['access_token'] = $token
   return fly.post('user/change-sex', $params)
 }
 
 //修改生日
 export function userChangeBirthday($params) {
-  let $token = store.getters.get_token
+  let $token = wx.getStorageSync('token')
   $params['access_token'] = $token
   return fly.post('user/change-birthday', $params)
 }

+ 32 - 8
src/store/game.js

@@ -11,13 +11,19 @@ export default new Vuex.Store({
     //游戏状态 0 不在游戏,1游戏中
     game_status: 0,
     toy_index: 0,
-    toy_list: []
+    toy_list: [],
+    toy_hex: "",
+    // 使用类型 1次数 2时间 0未选择
+    mode: 0,
+    //游戏记录id
+    game_record_id: 0,
+    //  游戏时间
+    play_time: 0
   },
   mutations: {
     setDeviceId(state, deviceId) {
       state.deviceId = deviceId
     },
-
     setServiceId(state, serviceId) {
       state.serviceId = serviceId
     },
@@ -27,11 +33,20 @@ export default new Vuex.Store({
     setGameStatus(state, status) {
       state.game_status = status
     },
-    setToyIndex(state, toy_index) {
-      state.toy_index = toy_index
-    },
     setToyList(state, toy_list) {
       state.toy_list = toy_list
+    },
+    setToyHex(state, toy_hex) {
+      state.toy_hex = toy_hex
+    },
+    setMode(state, mode) {
+      state.mode = mode
+    },
+    setGameRecordId(state, param) {
+      state.game_record_id = param
+    },
+    setPlayTime(state, param) {
+      state.play_time = param
     }
   },
   getters: {
@@ -47,11 +62,20 @@ export default new Vuex.Store({
     getGameStatus(state) {
       return state.game_status
     },
-    getToyIndex(state) {
-      return state.toy_index
-    },
     getToyList(state) {
       return state.toy_list
+    },
+    getToyHex(state) {
+      return state.toy_hex
+    },
+    getMode(state) {
+      return state.mode
+    },
+    getGameRecordId(state) {
+      return state.game_record_id
+    },
+    getPlayTime(state) {
+      return state.play_time
     }
   },
 

+ 31 - 9
src/utils/bluetooth.js

@@ -2,6 +2,11 @@ export default {
   // 发送开启脑电数据包指令
   sendOpen(deviceId, serviceId, Cid) {
     // 向蓝牙设备发送一个0x00的16进制数据
+
+    // 玩具对应指令数组
+    let CheckSum = ((0x03 + 0x00 + 0x00 + 0x00 + 0xff) ^ 0xFFFFFFFF) & 0xFF
+    let $CheckSum = "0x" + CheckSum.toString(16)
+
     let buffer = new ArrayBuffer(8)
     let dataView = new DataView(buffer)
     dataView.setUint8(0, '0xaa')
@@ -11,7 +16,7 @@ export default {
     dataView.setUint8(4, '0x00')
     dataView.setUint8(5, '0x00')
     dataView.setUint8(6, '0xff')
-    dataView.setUint8(7, '0xfd')
+    dataView.setUint8(7, $CheckSum)
     // 向低功耗蓝牙设备特征值中写入二进制数据
     console.log(buffer)
     wx.writeBLECharacteristicValue({
@@ -33,6 +38,10 @@ export default {
   // 发送开启教具脑控指令
   sendControl(deviceId, serviceId, Cid) {
     const that = this
+
+    // 玩具对应指令数组
+    let CheckSum = ((0x03 + 0x00 + 0x00 + 0x00 + 0x07) ^ 0xFFFFFFFF) & 0xFF
+    let $CheckSum = "0x" + CheckSum.toString(16)
     // 向蓝牙设备发送一个0x00的16进制数据
     let buffer = new ArrayBuffer(8)
     let dataView = new DataView(buffer)
@@ -43,7 +52,7 @@ export default {
     dataView.setUint8(4, '0x00')
     dataView.setUint8(5, '0x00')
     dataView.setUint8(6, '0x07')
-    dataView.setUint8(7, '0xf5')
+    dataView.setUint8(7, $CheckSum)
     // 向低功耗蓝牙设备特征值中写入二进制数据
     console.log(buffer)
     wx.writeBLECharacteristicValue({
@@ -64,13 +73,16 @@ export default {
     })
   },
   // 发送连接玩具指令
-  sendConnect($toy, deviceId, serviceId, Cid) {
+  sendConnect($hex, deviceId, serviceId, Cid) {
     //获取最后两个字节
-    let $toy_hex = $toy['bluetooth'].substr($toy['bluetooth'].length - 2, 2)
-
     const that = this
     // 玩具对应指令数组
     let arr = ['0x01', '0x02', '0x03', '0x04', '0x05', '0x06', '0x07', '0x08', '0x09', '0x0a', '0x0b']
+    let arr1 = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b]
+    let $index = arr.indexOf($hex)
+    let CheckSum = ((0x03 + 0x00 + arr1[$index] + 0x00 + 0x0a) ^ 0xFFFFFFFF) & 0xFF
+    let $CheckSum = "0x" + CheckSum.toString(16)
+
     // 向蓝牙设备发送指令
     let buffer = new ArrayBuffer(8)
     let dataView = new DataView(buffer)
@@ -78,10 +90,10 @@ export default {
     dataView.setUint8(1, '0xcc')
     dataView.setUint8(2, '0x03')
     dataView.setUint8(3, '0x00')
-    dataView.setUint8(4, '0x'+$toy_hex)
+    dataView.setUint8(4, arr[$index])
     dataView.setUint8(5, '0x00')
     dataView.setUint8(6, '0x0a')
-    dataView.setUint8(7, '0xf1')
+    dataView.setUint8(7, $CheckSum)
     // 向低功耗蓝牙设备特征值中写入二进制数据
     console.log(buffer)
     wx.writeBLECharacteristicValue({
@@ -111,6 +123,11 @@ export default {
   //发送断开玩具的指令
   sendEnd(deviceId, serviceId, Cid) {
     //AA CC 03 00 00 00 09 F3
+
+    // 玩具对应指令数组
+    let CheckSum = ((0x03 + 0x00 + 0x00 + 0x00 + 0x09) ^ 0xFFFFFFFF) & 0xFF
+    let $CheckSum = "0x" + CheckSum.toString(16)
+
     let buffer = new ArrayBuffer(8)
     let dataView = new DataView(buffer)
     dataView.setUint8(0, '0xaa')
@@ -120,7 +137,7 @@ export default {
     dataView.setUint8(4, '0x00')
     dataView.setUint8(5, '0x00')
     dataView.setUint8(6, '0x09')
-    dataView.setUint8(7, '0xf3')
+    dataView.setUint8(7, $CheckSum)
     // 向低功耗蓝牙设备特征值中写入二进制数据
     console.log(buffer)
     wx.writeBLECharacteristicValue({
@@ -143,6 +160,11 @@ export default {
   // 发送停止发送脑电数据包指令
   sendPause(deviceId, serviceId, Cid) {
     let that = this
+
+
+    // 玩具对应指令数组
+    let CheckSum = ((0x03 + 0x00 + 0x00 + 0x00 + 0x08) ^ 0xFFFFFFFF) & 0xFF
+    let $CheckSum = "0x" + CheckSum.toString(16)
     // 向蓝牙设备发送一个0x00的16进制数据
     let buffer = new ArrayBuffer(8)
     let dataView = new DataView(buffer)
@@ -153,7 +175,7 @@ export default {
     dataView.setUint8(4, '0x00')
     dataView.setUint8(5, '0x00')
     dataView.setUint8(6, '0x00')
-    dataView.setUint8(7, '0xfc')
+    dataView.setUint8(7, $CheckSum)
     // 向低功耗蓝牙设备特征值中写入二进制数据
     console.log(buffer)
     wx.writeBLECharacteristicValue({

+ 21 - 5
src/utils/index.js

@@ -5,12 +5,26 @@ function formatNumber(n) {
 
 export function formatTime(date) {
   var date = new Date(date)
+  const year = date.getFullYear()
   const month = date.getMonth() + 1
   const day = date.getDate()
 
   const hour = date.getHours()
 
-  const t1 = [ month, day].map(formatNumber).join('/')
+  const t1 = [year, month, day].map(formatNumber).join('/')
+
+  return `${t1}`
+}
+
+export function formatBirthday(date) {
+  var date = new Date(date)
+  const year = date.getFullYear()
+  const month = date.getMonth() + 1
+  const day = date.getDate()
+
+  const hour = date.getHours()
+
+  const t1 = [year, month, day].map(formatNumber).join('-')
 
   return `${t1}`
 }
@@ -214,14 +228,16 @@ function getBaseOption(delta, theta, alpha, beta) {
   return option
 }
 
-//检查 邀请码
-export function check_option(options, Toast, $this) {
-
+//获取等级名称
+function get_level_name($level_id) {
+  let $level = ['普通用户', '体验会员', '黄金会员', '白金会员', '钻石会员', '创客代理', '合伙人', '店员', '店长']
+  return $level[$level_id]
 }
 
 export default {
   formatNumber,
   formatTime,
   getLineOption,
-  getBaseOption
+  getBaseOption,
+  get_level_name
 }