Ver Fonte

Merge remote-tracking branch 'origin/master' into master

# Conflicts:
#	src/components/index/login.vue
yerong há 4 anos atrás
pai
commit
82a071a761
3 ficheiros alterados com 442 adições e 396 exclusões
  1. 8 8
      src/components/device/device.vue
  2. 66 58
      src/components/index/login.vue
  3. 368 330
      src/utils/bluetooth.js

+ 8 - 8
src/components/device/device.vue

@@ -146,10 +146,10 @@ import device_connected from "@/components/device/connected";
 //连接玩具
 import toy_connecting from "@/components/device/toy/connecting";
 //开始游戏的界面
-import gameIng from '@/pages/start/index'
+import gameIng from "@/pages/start/index";
 //获取个人信息
 import Toast from "../../../static/vant/toast/toast";
-import {game_devices} from "../../requests/game";
+import { game_devices } from "../../requests/game";
 import game_store from "@/store/game";
 import bluetooth from "@/utils/bluetooth";
 import ble_store from "../../store/bluetooth";
@@ -429,14 +429,14 @@ export default {
       });
     },
     onStartGameShowClose() {
-      $this.start_show = false
-      $this.game_status = 0
+      $this.start_show = false;
+      $this.game_status = 0;
     },
     gameStart() {
-      $this.start_show = true
-      $this.game_status = 1
-      $this.connect_toy = 4
-    }
+      $this.start_show = true;
+      $this.game_status = 1;
+      $this.connect_toy = 4;
+    },
   },
   mounted() {
     $this.get_toy_list();

+ 66 - 58
src/components/index/login.vue

@@ -1,5 +1,8 @@
 <template>
-  <div id="index_login_container" class="animation-slide-right">
+  <div
+    id="index_login_container"
+    class="animation-slide-right"
+  >
     <view class=" text-xl padding text-center">
       <text class=" text-bold title_color">欢迎来到水母星球!</text>
     </view>
@@ -9,39 +12,50 @@
     </div>
 
     <div class="text-center padding-lr padding-top">
-      <button class="cu-btn lg cu-btn-primary text-white text-center" @click="to_regist(0)" v-if="is_scan">注册</button>
-      <button class="cu-btn lg cu-btn-primary text-white text-center" @click="to_scan" v-else>扫一扫加入水母星球</button>
+      <button
+        class="cu-btn lg cu-btn-primary text-white text-center"
+        @click="to_regist(0)"
+        v-if="is_scan"
+      >注册</button>
+      <button
+        class="cu-btn lg cu-btn-primary text-white text-center"
+        @click="to_scan"
+        v-else
+      >扫码注册</button>
     </div>
     <view class="text-center slogen_title">
       <text class="text-gray">如果您在我们实体店,请在店员的指导下连接水母智脑环</text>
     </view>
-    <view class="text-center text-lg padding-lr" @click="to_regist(1)">
+    <view
+      class="text-center text-lg padding-lr"
+      @click="to_regist(1)"
+    >
       <text class="text-gray under_line">账号登录</text>
     </view>
-    <van-toast id="van-toast"/>
-    <van-dialog id="van-dialog"/>
+    <van-toast id="van-toast" />
+    <van-dialog id="van-dialog" />
 
   </div>
 </template>
 <script>
-import Toast from '../../../static/vant/toast/toast';
-import Dialog from '../../../static/vant/dialog/dialog';
-import user_store from '@/store/index'
-import {userCheckInvite, userCheckUnionid} from "../../requests/user";
+import Toast from "../../../static/vant/toast/toast";
+import Dialog from "../../../static/vant/dialog/dialog";
+import user_store from "@/store/index";
+import { userCheckInvite, userCheckUnionid } from "../../requests/user";
 
-var $this
+var $this;
 export default {
   name: "login_container",
   data() {
     return {
       is_scan: false,
-      official_show: false
-    }
+      official_show: false,
+    };
   },
   methods: {
     to_regist($status) {
-      this.$emit('changeStatus', 'regist')
-      this.$emit('changeTitle', $status)
+      this.$emit("changeStatus", "regist");
+      this.$emit("changeTitle", $status);
     },
     to_scan() {
       wx.scanCode({
@@ -51,91 +65,85 @@ export default {
           if ($data.result) {
             let url = decodeURIComponent($data.result);
             let $code = url.match(/\?code=(.*)/);
-            if (url.indexOf('jellyfish') != -1) {
-              Toast.fail('请先登录')
-              return false
-            } else {
-              // 邀请码
-              let $invite_code = $code[1]
-              $this.do_invite_code($invite_code)
-            }
+            // 邀请码
+            let $invite_code = $code[1];
+            $this.do_invite_code($invite_code);
           }
-        }
-      })
+        },
+      });
     },
     //统一处理邀请码的方法
     do_invite_code($code) {
-      $this.is_scan = true
+      $this.is_scan = true;
       wx.login({
         success(res1) {
-          let $js_code = res1.code
-          console.log($js_code)
+          let $js_code = res1.code;
+          console.log($js_code);
           userCheckInvite($code, $js_code).then((res) => {
             let $res = res.data;
             if ($res.code != 0) {
-              Toast.fail($res.errmsg)
+              Toast.fail($res.errmsg);
             }
-          })
-        }
-      })
-      user_store.setters.set_invite_code($code)
+          });
+        },
+      });
+      user_store.setters.set_invite_code($code);
     },
     official_success($e) {
-      console.log('关注组件加载成功', $e)
+      console.log("关注组件加载成功", $e);
     },
     onClickHide() {
-      $this.official_show = false
-    }
+      $this.official_show = false;
+    },
   },
   mounted() {
     mpvue.login({
       success($res) {
-        let $js_code = $res.code
-        user_store.setters.setJsCode($js_code)
+        let $js_code = $res.code;
+        user_store.setters.setJsCode($js_code);
         //检验js_code
         userCheckUnionid($js_code).then((res) => {
           let $res = res.data;
           let $data = $res.data;
-          $this.official_show = $data['have_unionid'] == 2
-        })
-      }
-    })
+          $this.official_show = $data["have_unionid"] == 2;
+        });
+      },
+    });
   },
   onLoad(options) {
-    let $this = this
+    let $this = this;
     // 原有的code
-    let $_code = wx.getStorageSync('code')
+    let $_code = wx.getStorageSync("code");
 
     if (options.q) {
-      let url = decodeURIComponent(options.q)
+      let url = decodeURIComponent(options.q);
       let $code = url.match(/\?code=(.*)/)[1];
-      $this.do_invite_code($code)
-      console.log('1---' + $_code, '2---' + $code)
+      $this.do_invite_code($code);
+      console.log("1---" + $_code, "2---" + $code);
       //判断新的code 和 旧的code 是否一致 不一致则重新登录
       if ($_code && $_code != $code) {
-        Toast.fail('该用户已绑定邀请码')
+        Toast.fail("该用户已绑定邀请码");
       }
     }
     // 测试注释
     else {
       // 跳转到关于水母页面
       //设置是否扫码
-      $this.is_scan = false
+      $this.is_scan = false;
       Dialog.alert({
-        transition: 'fade',
-        message: '如需体验水母星球产品,请使用微信扫一扫水母星球邀请卡,注册水母星球会员',
-        theme: 'round-button',
-      })
+        transition: "fade",
+        message:
+          "如需体验水母星球产品,请使用微信扫一扫水母星球邀请卡,注册水母星球会员",
+        theme: "round-button",
+      });
     }
   },
   created() {
-    $this = this
-  }
-}
+    $this = this;
+  },
+};
 </script>
 <style>
-
-
 .sub_slogen {
   font-size: 22px;
   margin-top: 110px;

Diff do ficheiro suprimidas por serem muito extensas
+ 368 - 330
src/utils/bluetooth.js


Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff