Browse Source

修改了连接玩具的数量,优化连接教具的方式

yerong 4 years ago
parent
commit
d8fb4a265f
4 changed files with 56 additions and 38 deletions
  1. 1 1
      dist/wx
  2. 11 4
      src/components/device/device.vue
  3. 38 32
      src/components/index/regist.vue
  4. 6 1
      src/pages/start/index.vue

+ 1 - 1
dist/wx

@@ -1 +1 @@
-Subproject commit a3e43df8186c0e6e4b44f44c5fa3a210de5e77fe
+Subproject commit 680687f460f6f5d626ef2d846c4ab02289421648

+ 11 - 4
src/components/device/device.vue

@@ -41,7 +41,7 @@
             :connect_toy="connect_toy"
             :deviceId="_deviceId"
             :toy_id="toy_action"
-            :toy="toy_list[toy_action - 1]"
+            :toy="toy_item"
             :device_bg="device_bg"
             :device_power="device_power"
             @open_choose_toy="open_choose_toy"
@@ -71,7 +71,7 @@
       <!-- 内容 -->
       <div class="padding toy_list">
         <van-row gutter="14" class="toy_list_content">
-          <van-col span="8" v-for="(toy, index) in toy_list" :key="index">
+          <van-col span="12" v-for="(toy, index) in toy_list" :key="index" class="text-center">
             <div
               class="toy_item flex flex-direction justify-center align-center"
               @click="choose_toy(index)"
@@ -148,6 +148,7 @@ export default {
       },
       //'水柱音箱', '喷雾恐龙(大)', '喷雾恐龙(小)', '轨道车', '碰碰车', '小车(大)', '小车(中)', '小车(小)', '飞行器(大)', '飞行器(小)', '水母灯'
       toy_list: [],
+      toy_item:{},
       toy_action: 1,
       // connect_show: true,
       //连接玩具 0:未连接 1:连接中 2:已连接 3:连接失败 4:游戏中
@@ -226,7 +227,12 @@ export default {
       $this.change_toy_connect_status(1);
       $this._device_index = $this.toy_action - 1;
       //获取玩具
-      let $toy = $this.toy_list[$this.toy_action - 1];
+      let $toy = {}
+      $this.toy_list.forEach(($val, $index) => {
+        if ($val['id']==$this.toy_action){
+          $this.toy_item = $toy = $val
+        }
+      })
       $this.toy_id = $toy.id
       let $hex = $toy["hex"].substr($toy["hex"].length - 2, 2);
       let toy_hex = "0x" + $hex;
@@ -626,6 +632,7 @@ export default {
 }
 
 .toy_item {
+  margin: 0px auto;
   width: 120px;
   height: 130px;
 }
@@ -653,7 +660,7 @@ export default {
 }
 
 .toy_list_content {
-  width: 120%;
+  width: 100%;
   display: inline-block;
   display: flex;
   flex-wrap: wrap;

+ 38 - 32
src/components/index/regist.vue

@@ -338,7 +338,7 @@ export default {
     },
     //获取验证码
     get_verify_code() {
-      let $reg = /(13\d|14[579]|15[^4\D]|17[^49\D]|18\d)\d{8}/
+      let $reg = /(13\d|14[579]|15[^4\D]|17[^49\D]|18\d|19\d)\d{8}/
       if ($reg.test($this.phone) == false) {
         Toast.fail('请输入正确手机号')
         return false;
@@ -371,38 +371,44 @@ export default {
       $params['portrait'] = $this._userinfo.avatarUrl
       $params['sex'] = $this._userinfo.gender
       // }
-
-      if ($this.title == "注册") {
-        userRegister($params).then((res) => {
-            console.log(res)
-            wx.setStorageSync("is_first", true)
-            let $data = res.data
-            if (!$data['code']) {
-              Toast.clear()
-              $this.login_success($data)
-            } else {
-              Toast.fail($data['errmsg'])
-            }
-          },
-          (err) => {
-            console.log(err)
+      mpvue.login({
+        success($res) {
+          let $js_code = $res.code
+          $params['js_code'] = $js_code
+          if ($this.title == "注册") {
+            userRegister($params).then((res) => {
+                console.log(res)
+                wx.setStorageSync("is_first", true)
+                let $data = res.data
+                if (!$data['code']) {
+                  Toast.clear()
+                  $this.login_success($data)
+                } else {
+                  Toast.fail($data['errmsg'])
+                }
+              },
+              (err) => {
+                console.log(err)
+              }
+            )
+          } else if ($this.title == "登录") {
+            userLogin($params).then((res) => {
+                wx.setStorageSync("is_first", false)
+                let $data = res.data
+                Toast.clear()
+                if ($data['code'] == 0) {
+                  $this.login_success($data)
+                } else {
+                  Toast.fail($data['errmsg'])
+                }
+              },
+              (err) => {
+                console.log(err)
+              })
           }
-        )
-      } else if ($this.title == "登录") {
-        userLogin($params).then((res) => {
-            wx.setStorageSync("is_first", false)
-            let $data = res.data
-            Toast.clear()
-            if ($data['code'] == 0) {
-              $this.login_success($data)
-            } else {
-              Toast.fail($data['errmsg'])
-            }
-          },
-          (err) => {
-            console.log(err)
-          })
-      }
+
+        }
+      })
 
     },
     //登录成功

+ 6 - 1
src/pages/start/index.vue

@@ -264,7 +264,7 @@ export default {
     to_report() {
       mpvue.reLaunch({
         url: "/pages/report/main",
-        success(){
+        success() {
           $this.timeData = {}
         }
       })
@@ -443,6 +443,11 @@ export default {
       //已经完了多长时间
       let $played_time = $this.played_time = game_store.getters.getPlayedTime() ? game_store.getters.getPlayedTime() : 0
 
+      //判断可玩时长超出了时间 就直接结束游戏
+      if ($played_time>=($play_time * 1000)) {
+        $this.game_finished()
+      }
+
       $this.mode_item = {}
       $this.mode_item = mode_list[$this.mode - 1]
       let $origin_time = $play_time * 1000