Browse Source

合并冲突3/19 ( 添加转发小程序 )

Luhan1997 4 years ago
parent
commit
81eb56ba58

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

@@ -5,18 +5,11 @@
       <text class="">我的设备</text>
     </view>
     <div class="device padding">
-      <!--      <div class="head flex justify-between">-->
-
-      <!--        <div class="my_msg" @click="get_toy_list">-->
-      <!--          <text class="cuIcon-mark"></text>-->
-      <!--          <text class="under_line">获取设备列表</text>-->
-      <!--        </div>-->
-      <!--      </div>-->
+      <!--      未连接部分-->
       <div v-if="connect_toy == 0">
-        <!--      未连接部分-->
         <div
           class="connect_box"
-          v-if="device_status == 0"
+          v-if="device_status == 0 && connect_show == false"
         >
           <device_unconnect @open_scan="open_scan"></device_unconnect>
         </div>
@@ -433,7 +426,6 @@ export default {
       $this.game_status = 0;
     },
     gameStart() {
-      $this.start_show = true;
       $this.game_status = 1;
       $this.connect_toy = 4;
     },
@@ -449,7 +441,7 @@ export default {
     let $game_status = game_store.getters.getGameStatus();
     if ($game_status == 3) {
       //不在游戏状态
-      $this.change_toy_connect_status(0);
+      $this.connect_toy = 0;
       $this.connect_show = true;
       bluetooth.watchingDevice($this);
       bluetooth.watch_bluetooth_status($this);

+ 13 - 5
src/pages/competition/index.vue

@@ -723,8 +723,9 @@ import {
   getJsSDK,
   getPromotionRanking,
 } from "../../requests/competition";
-import Toast from "../../../static/vant/toast/toast";
-import { reload_userinfo } from "../../utils/user";
+import Toast from '../../../static/vant/toast/toast';
+import {reload_userinfo} from "../../utils/user";
+import {userDetail} from "../../requests/user";
 
 var $this;
 var $now = Math.round(new Date() / 1000);
@@ -834,7 +835,7 @@ export default {
     },
     //时间产生变化时
     onTimeChange($e) {
-      let $datetime = ($this.timeData = $e.mp.detail);
+      let $datetime = $this.timeData = $e.mp.detail
       for (let $key in $datetime) {
         if ($datetime[$key].toString().length == 1) {
           $datetime[$key] = "0" + $datetime[$key];
@@ -946,8 +947,15 @@ export default {
     },
   },
   mounted() {
-    reload_userinfo($this);
-    let $userinfo = wx.getStorageSync("userinfo");
+    userDetail().then((res) => {
+      let $data = res.data;
+      $this.userinfo = $data.data;
+      $this.userinfo['validity_time'] = formatTime($this.userinfo['validity_time'])
+      $this.userinfo['level_name'] = utils.get_level_name($this.userinfo['level'])
+      $this.userinfo['free_time'] = formatSeconds($this.userinfo['free_time'])
+      store.setters.set_userinfo($this.userinfo)
+    })
+    let $userinfo = wx.getStorageSync('userinfo')
     //检查用户是否参与比赛了
     checkJoined($this.activity_id, $userinfo.user_id).then((res) => {
       let $res = res.data;

+ 100 - 96
src/pages/index/index.vue

@@ -3,38 +3,27 @@
     <!--    banner模块-->
     <banner></banner>
     <!--    未登录 登录窗口模块-->
-    <div
-      class="login_card"
-      v-if="!is_login"
-    >
+    <div class="login_card" v-if="!is_login">
       <!--      登录窗口-->
-      <login_container
-        v-if="login_status == 'login'"
-        @changeStatus="change_status"
-        @changeTitle="change_title"
+      <login_container v-if="login_status == 'login'"
+                       @changeStatus="change_status"
+                       @changeTitle="change_title"
       ></login_container>
       <!--      注册窗口-->
-      <regist_container
-        v-if="login_status == 'regist'"
-        @changeStatus='change_status'
-        @change_login_status="change_login_status"
-        :title="regist_title"
+      <regist_container v-if="login_status == 'regist'"
+                        @changeStatus='change_status'
+                        @change_login_status="change_login_status"
+                        :title="regist_title"
       ></regist_container>
 
     </div>
     <!--    登陆后 的个人首页-->
-    <div
-      class="personal_card"
-      v-if="is_login"
-    >
+    <div class="personal_card" v-if="is_login">
       <personal_container @change_login_status="change_login_status"></personal_container>
 
       <device_container></device_container>
     </div>
-    <div
-      class="service"
-      :class="{'service_login_page':is_login==false}"
-    >
+    <div class="service" :class="{'service_login_page':is_login==false}">
       <view class="padding-tb">
         <text class="cuIcon-titles text-primary"></text>
         <text class="">功能服务</text>
@@ -42,62 +31,50 @@
       <div class="content">
         <van-row>
           <van-col span="12">
-            <img
-              src="https://img.shuimuai.com/index_btn_chongzhizhongxin.png"
-              @click="to_page('user_center/recharge')"
-            ></img>
+            <img src="https://img.shuimuai.com/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>
+            <img src="https://img.shuimuai.com/web/index_btn_gerenzhongxin.png" @click="to_page('user_center')"></img>
           </van-col>
         </van-row>
 
         <van-row>
           <van-col span="12">
-            <img
-              src="https://img.shuimuai.com/web/index_btn_chengjijilu.png"
-              @click="to_page('game_record')"
-            ></img>
+            <img src="https://img.shuimuai.com/web/index_btn_chengjijilu.png" @click="to_page('game_record')"></img>
           </van-col>
           <van-col span="12">
-            <img
-              src="https://img.shuimuai.com/index_btn_dailishang.png"
-              @click="to_page('agent/index')"
-            ></img>
+            <img src="https://img.shuimuai.com/index_btn_dailishang.png" @click="to_page('agent/index')"></img>
           </van-col>
         </van-row>
       </div>
     </div>
-    <van-toast id="van-toast" />
-
+    <van-toast id="van-toast"/>
+    <van-dialog id="van-dialog"/>
     <!--     <button class="cu-btn lg cu-btn-primary text-white text-center margin-tb" @click="auth_msg">获取消息授权-->
     <!--    </button>-->
   </div>
 </template>
 
 <script>
-import banner from "@/components/banner";
-import login_container from "@/components/index/login";
-import regist_container from "@/components/index/regist";
+import banner from '@/components/banner'
+import login_container from '@/components/index/login'
+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";
-import user_store from "../../store/index";
-import { reload_userinfo } from "../../utils/user";
+import Toast from '../../../static/vant/toast/toast';
+import Dialog from '../../../static/vant/dialog/dialog'
+import {userDetail} from "../../requests/user";
+import user_store from "../../store/index"
+import game_store from "../../store/game"
+import game_util, {post_data} from '../../utils/game'
+
 
-var $this;
+var $this
 export default {
   name: "index_container",
   components: {
-    banner,
-    login_container,
-    regist_container,
-    personal_container,
-    device_container,
+    banner, login_container, regist_container, personal_container, device_container
   },
   data() {
     return {
@@ -105,97 +82,123 @@ export default {
       login_status: "login",
       // is_login: false,
       is_login: false,
-      regist_title: "",
-    };
+      regist_title: ""
+    }
   },
   methods: {
-    get_init_data() {},
+    get_init_data() {
+    },
     //切换到扫码
     change_status($status) {
-      this.login_status = $status;
+      this.login_status = $status
     },
     //跳转充值中心
     to_recharge() {
       mpvue.navigateTo({
-        url: "/pages/user_center/recharge/main",
-      });
+        url: "/pages/user_center/recharge/main"
+      })
     },
     //修改登录状态
     change_login_status() {
-      this.is_login = user_store.getters.get_login_status();
+      this.is_login = user_store.getters.get_login_status()
     },
     // 修改界面的文字
     change_title($status) {
       if ($status == 0) {
-        this.regist_title = "注册";
+        this.regist_title = "注册"
       } else if ($status == 1) {
-        this.regist_title = "登录";
+        this.regist_title = "登录"
       }
     },
     //跳转页面
     to_page($page) {
-      if ($page == "agent/index") {
+      if ($page == 'agent/index') {
         //店员店长不可进
         if ($this.userinfo.level == 8 || $this.userinfo.level == 9) {
-          Toast.fail("店员、店长不可进");
-          return false;
+          Toast.fail("店员、店长不可进")
+          return false
         }
       }
       if (!this.is_login) {
-        Toast.fail("请先登录");
-        return false;
+        Toast.fail("请先登录")
+        return false
       }
       mpvue.navigateTo({
-        url: "/pages/" + $page + "/main",
-      });
+        url: "/pages/" + $page + "/main"
+      })
     },
     auth_msg() {
       wx.requestSubscribeMessage({
-        tmplIds: [
-          "NV-xb_oOPutXLVge0ZnBxct_nNxS1j1XNCMtfp2c8zw",
-          "70xngszQ62NWHbbCjbggbz5-pvOu3Z8ttLbjfplJXLg",
-        ],
+        tmplIds: ['NV-xb_oOPutXLVge0ZnBxct_nNxS1j1XNCMtfp2c8zw', '70xngszQ62NWHbbCjbggbz5-pvOu3Z8ttLbjfplJXLg'],
         success(res) {
-          console.log(res);
-          Toast.success("授权成功");
-        },
-      });
-    },
+          console.log(res)
+          Toast.success("授权成功")
+        }
+      })
+    }
   },
   mounted() {
     wx.login({
       success(res) {
         console.log(res);
-      },
-    });
+      }
+    })
   },
   onShow() {
     userDetail().then((res) => {
-      let $data = res.data;
+      let $data = res.data
       //判断如果是第一次登录就 弹出领取体验卡
-      $this.userinfo = $data.data;
-      user_store.setters.set_userinfo($this.userinfo);
-    });
+      $this.userinfo = $data.data
+      user_store.setters.set_userinfo($this.userinfo)
+    })
+  },
+  onHide() {
   },
-  onHide() {},
   onLoad($option) {
-    // if (process.env.NODE_ENV == 'development') {
-    //   wx.setStorageSync('token', '7MZYqpAWOdw8WDxsgUV5QkQnKfrU5L_7')
-    // }
+    if (process.env.NODE_ENV == 'development') {
+      wx.setStorageSync('token', '7MZYqpAWOdw8WDxsgUV5QkQnKfrU5L_7')
+    }
+
+    console.log(game_store.getters.getGameAttMedDatas())
+    console.log(game_store.getters.getPlayedTime())
+    console.log(
+      "游戏状态:" + game_store.getters.getGameStatus(),
+
+      "游戏记录id:" + game_store.getters.getGameRecordId()
+    )
+    if (game_store.getters.getGameStatus() == 1) {
+      // Dialog.confirm({
+      //   title: '系统提示',
+      //   message: '您上一个游戏尚未结束,是否继续?',
+      // })
+      //   .then(() => {
+      //     Toast.success('是')
+      //   })
+      //   .catch(() => {
+      //     //添加数据,结束游戏
+      //     Toast.fail('否')
+      //     post_data(game_store.getters.getGameAttMedDatas())
+      //   });
+      Dialog.alert({
+        title: '系统提示',
+        message: '正在结束上一个游戏',
+      }).then(() => {
+        post_data(game_store.getters.getGameAttMedDatas())
+      });
+    }
+
     //  判断存储是否登录
-    let $token = wx.getStorageSync("token");
+    let $token = wx.getStorageSync('token')
     if ($token) {
-      user_store.setters.set_token($token);
-      user_store.setters.set_login(true);
-      this.is_login = user_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() {
-    $this = this;
-  },
-  //发送给朋友
-  onShareAppMessage() {},
-};
+    $this = this
+  }
+}
 </script>
 
 <style scoped>
@@ -252,4 +255,5 @@ export default {
   position: relative;
   z-index: 5;
 }
+
 </style>

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

@@ -316,6 +316,7 @@ export default {
             Toast.clear()
             let $res = res.data;
             $this.record = $res.data
+            $this.record.play_time = formatSeconds($this.record.play_time)
 
             let $options = getHightPieChartOption($this.record.height)
             hight_att_pie_charts.setOption($options)
@@ -343,7 +344,6 @@ export default {
               //截断得数量
               $this.data_section = Math.ceil($this.record.play_time / $five_min)
             }
-            $this.record.play_time = formatSeconds($this.record.play_time)
           },
           (err) => {
             Toast.fail('错误代码:' + res.code + ',联系客服')
@@ -381,7 +381,7 @@ export default {
               $option = util.getLineOption($line_data, [0])
             }
             att_charts.setOption($option)
-          }, 1000)
+          }, 800)
         },
         (err) => {
           Toast.fail('错误代码:' + res.code + ',联系客服')

+ 6 - 1
src/utils/game.js

@@ -3,6 +3,10 @@ import {gameAddLine, gameEnd} from "../requests/game";
 
 // 往后端推送一次定时数据
 export function post_data($big_data) {
+  wx.showLoading({
+    title:"正在结束上一个游戏",
+    mask:true
+  })
   var $this = this
   //判断数据长度大于理想状态 需要对数组进行切割 逐个提交数据
   let $len = 300
@@ -75,8 +79,9 @@ function to_report() {
   mpvue.navigateTo({
     url: "/pages/report/main?id=" + game_store.getters.getGameRecordId(),
     success() {
+      wx.hideLoading()
       //设置游戏状态为 停止游戏
-      game_store.setters.setGameStatus(3)
+      game_store.setters.setGameStatus(0)
       //游戏结束重置游戏时间
       wx.removeStorageSync('play_time')
       //删除游戏专注数据