浏览代码

添加定时获取用户设备信息功能模块/BUG修复

fanghuisheng 1 年之前
父节点
当前提交
f50aef3b13

+ 38 - 1
src/App.vue

@@ -17,6 +17,11 @@ function initApp() {
   plus.screen.lockOrientation("portrait-primary"); //设置不可横屏
   pushListener(); //开启消息推送监听
   proxy.$setting.clearBadge(0); // 清除数字
+
+  proxy.$settingStore.baseAppInfo(); //动态获取用户设备信息
+  setInterval(() => {
+    proxy.$settingStore.baseAppInfo(); //定时获取用户设备信息
+  }, 1000 * 60 * 5);
   //#endif
 }
 
@@ -47,7 +52,7 @@ function pushListener() {
   //获取应用的CID
   uni.getPushClientId({
     success: (res) => {
-      console.log(res.cid);
+      // console.log(res.cid);
     },
     fail(err) {
       console.log(err);
@@ -78,6 +83,38 @@ function pushListener() {
   });
 }
 
+function wechatToken() {
+  //获取当前页面的url
+  let link = window.location.href;
+  console.log(link, "link");
+  let code = null;
+  // 判断link中有没有code=字符串,
+  if (link.indexOf("code=") == -1) {
+    //没有code= 发请求
+    let appid = "wx41e478e592f9e04a";
+    let uri = encodeURIComponent(link);
+    let authURL = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${uri}&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect`;
+    window.location.href = authURL;
+  } else {
+    //回调函数已经执行 返回的链接存在code= 地址解析
+    let temp = link.split("code=")[1];
+    code = temp.split("&")[0];
+    console.log(code, "code");
+    //存储code
+    uni.setStorageSync("code", code);
+    //对后台发送请求传参code获取token和用户信息
+    const params = code;
+
+    console.log(params);
+
+    // this.$httpApi.getUserInfo(params).then((res) => {
+    //   console.log("idnex 认证原文件", res);
+    //   uni.setStorageSync("mtoken", res);
+    //   console.log("token storage", res);
+    // });
+  }
+}
+
 watchEffect(() => {
   //#ifdef APP-PLUS || MP-WEIXIN
   if (uni.getStorageSync("serveUrl")) {

+ 9 - 0
src/api/common/index.js

@@ -17,3 +17,12 @@ export function score(param) {
         data: param,
     });
 }
+
+//APP心跳
+export function baseAppInfoApi(param) {
+    return request({
+        url: "/service-iot/baseAppInfo/add",
+        method: "POST",
+        data: param,
+    });
+}

+ 5 - 5
src/pages.json

@@ -287,7 +287,7 @@
     },
     // 智慧安防
     {
-      "root": "pages/business/zhaf",
+      "root": "pages/business/zhaf/",
       "pages": [
         //巡检模块 开始
         {
@@ -404,7 +404,7 @@
 
     // 闵行消防
     {
-      "root": "pages/business/mhxf",
+      "root": "pages/business/mhxf/",
       "pages": [
         //消防督察单模块 开始
         //消防督察单模块 结束
@@ -481,7 +481,7 @@
     },
     // 智慧消防
     {
-      "root": "pages/business/zhxf",
+      "root": "pages/business/zhxf/",
       "pages": [
         {
           "path": "messagePush/index",
@@ -537,7 +537,7 @@
     },
     // 消防物联网
     {
-      "root": "pages/business/fireIot",
+      "root": "pages/business/fireIot/",
       "pages": [
         {
           "path": "deviceManage/index",
@@ -641,7 +641,7 @@
     },
     // 业务模块
     {
-      "root": "pages/business",
+      "root": "pages/business/common/",
       "pages": [
         {
           "path": "fastMail/index",

+ 0 - 0
src/pages/business/fastMail/index.vue → src/pages/business/common/fastMail/index.vue


+ 0 - 0
src/pages/business/videoMonitor/index.vue → src/pages/business/common/videoMonitor/index.vue


+ 0 - 0
src/pages/business/videoMonitor/videoDetail.vue → src/pages/business/common/videoMonitor/videoDetail.vue


+ 0 - 0
src/pages/business/videoMonitor/videoList.vue → src/pages/business/common/videoMonitor/videoList.vue


+ 3 - 3
src/pages/index.vue

@@ -150,9 +150,9 @@ function swiperChange(e) {
  * @轮播图点击事件
  */
 function swiperClick(list) {
-  if (typeof list == "object") {
-    let linkType = swiperList.value[swiperIndex.value].linkType;
-    let url = swiperList.value[swiperIndex.value].link;
+  if (typeof swiperList.value[list] == "object") {
+    let linkType = swiperList.value[list].linkType;
+    let url = swiperList.value[list].link;
 
     if (url) {
       if (linkType == 1) {

+ 51 - 0
src/store/modules/setting.js

@@ -7,6 +7,7 @@ import setting from "@/plugins/setting.plugins.js";
 import { useStores } from "@/store/modules/index";
 
 import { uploadAvatar, updateUserProfile } from "@/api/system/user";
+import { baseAppInfoApi } from "@/api/common/index";
 
 const settingStore = defineStore("storage-setting", {
     state: () => ({
@@ -71,6 +72,56 @@ const settingStore = defineStore("storage-setting", {
             //#endif
         },
 
+        /**
+         * @动态获取用户设备信息
+         */
+        baseAppInfo() {
+            var params = {
+                networkType: null, //网络类型
+                deviceBrand: null, //设备品牌
+                deviceId: null, //设备编号
+                deviceModel: null, //设备型号
+                userName: null, //用户账号
+                longitude: "", //经度
+                latitude: "", //纬度
+            };
+
+            uni.getNetworkType({
+                success: function (res) {
+                    params.networkType = res.networkType;
+                },
+            });
+
+            // 获取系统信息
+            const systemInfo = uni.getSystemInfoSync();
+            params.deviceBrand = systemInfo.deviceBrand;
+            params.deviceId = systemInfo.deviceId;
+            params.deviceModel = systemInfo.deviceModel;
+            params.operateSystem = systemInfo.platform;
+
+            uni.getLocation({
+                type: "gcj02",
+                geocode: true,
+                highAccuracyExpireTime: 5000,
+                success: function (res) {
+                    console.log(res);
+                    params.longitude = res.longitude.toString();
+                    params.latitude = res.latitude.toString() ;
+
+                    console.log(params)
+
+                    baseAppInfoApi(params).then((res) => {
+                        console.log(res)
+                    })
+                },
+                fail: function (res) {
+                    baseAppInfoApi(params).then((res) => {
+                        console.log(res)
+                    })
+                },
+            });
+        },
+
         /**
          * @常见问题
          */