xiaohaizhao преди 1 година
родител
ревизия
d16b985b74
променени са 8 файла, в които са добавени 167 реда и са изтрити 101 реда
  1. 18 1
      main.js
  2. 92 78
      manifest.json
  3. 1 1
      pages/login/modules/account.vue
  4. 15 11
      pages/login/modules/dispose.js
  5. 1 1
      pages/login/modules/otherLogin.vue
  6. 1 1
      pages/login/selectSite.vue
  7. 5 8
      utils/Http.js
  8. 34 0
      utils/Socket.js

+ 18 - 1
main.js

@@ -22,10 +22,27 @@ Vue.component('My_listbox', My_listbox);
 import My_search from './components/My_search';
 Vue.component('My_search', My_search);
 //挂载接口
+
+let env = 'dev';
+const http = {};
+// #ifdef H5
+http.baseUrl = env == 'dev' ? "/apis1" : "/apis";
+http.socket = env == 'dev' ? "/socket1" : "/socket";
+// #endif
+// #ifndef H5
+http.baseUrl = env == 'dev' ? "http://60.204.153.188" : "https://oms.idcgroup.com.cn:8079";
+http.socket = env == 'dev' ? "ws://60.204.153.188" : "wss://oms.idcgroup.com.cn:8079";
+// #endif
+console.log("接口地址", http)
+
 import {
   ApiModel
 } from './utils/api'
-Vue.prototype.$Http = new ApiModel();
+Vue.prototype.$Http = new ApiModel(http);
+import {
+  Socket
+} from './utils/Socket'
+Vue.prototype.$Socket = new Socket(http);
 
 App.mpType = 'app'
 const app = new Vue({

+ 92 - 78
manifest.json

@@ -1,29 +1,29 @@
 {
-    "name" : "智慧水务",
-    "appid" : "__UNI__4021CF0",
-    "description" : "",
-    "versionName" : "1.0.0",
-    "versionCode" : "100",
-    "transformPx" : false,
+    "name": "智慧水务",
+    "appid": "__UNI__4021CF0",
+    "description": "",
+    "versionName": "1.0.0",
+    "versionCode": "100",
+    "transformPx": false,
     /* 5+App特有相关 */
-    "app-plus" : {
-        "usingComponents" : true,
-        "nvueStyleCompiler" : "智慧水务",
-        "compilerVersion" : 3,
-        "runmode" : "liberate",
-        "splashscreen" : {
-            "alwaysShowBeforeRender" : false,
-            "waiting" : false,
-            "autoclose" : true,
-            "delay" : 0
+    "app-plus": {
+        "usingComponents": true,
+        "nvueStyleCompiler": "智慧水务",
+        "compilerVersion": 3,
+        "runmode": "liberate",
+        "splashscreen": {
+            "alwaysShowBeforeRender": false,
+            "waiting": false,
+            "autoclose": true,
+            "delay": 0
         },
         /* 模块配置 */
-        "modules" : {},
+        "modules": {},
         /* 应用发布信息 */
-        "distribute" : {
+        "distribute": {
             /* android打包配置 */
-            "android" : {
-                "permissions" : [
+            "android": {
+                "permissions": [
                     "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
                     "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
                     "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
@@ -42,90 +42,104 @@
                 ]
             },
             /* ios打包配置 */
-            "ios" : {},
+            "ios": {},
             /* SDK配置 */
-            "sdkConfigs" : {}
+            "sdkConfigs": {}
         }
     },
     /* 快应用特有相关 */
-    "quickapp" : {},
+    "quickapp": {},
     /* 小程序特有相关 */
-    "mp-weixin" : {
-        "appid" : "wxd162e1286b6d7ecd",
-        "setting" : {
-            "urlCheck" : false,
-            "es6" : true,
-            "postcss" : true,
-            "minified" : true
+    "mp-weixin": {
+        "appid": "wxd162e1286b6d7ecd",
+        "setting": {
+            "urlCheck": false,
+            "es6": true,
+            "postcss": true,
+            "minified": true
         },
-        "optimization" : {
-            "subPackages" : true
+        "optimization": {
+            "subPackages": true
         },
-        "usingComponents" : true,
-        "permission" : {
-            "scope.userLocation" : {
-                "desc" : "为了您更好的体验,请确认获取您的位置"
+        "usingComponents": true,
+        "permission": {
+            "scope.userLocation": {
+                "desc": "为了您更好的体验,请确认获取您的位置"
             }
         },
-        "requiredPrivateInfos" : [ "getLocation" ]
+        "requiredPrivateInfos": ["getLocation"]
     },
-    "mp-alipay" : {
-        "usingComponents" : true
+    "mp-alipay": {
+        "usingComponents": true
     },
-    "mp-baidu" : {
-        "usingComponents" : true
+    "mp-baidu": {
+        "usingComponents": true
     },
-    "mp-toutiao" : {
-        "usingComponents" : true
+    "mp-toutiao": {
+        "usingComponents": true
     },
-    "uniStatistics" : {
-        "enable" : false
+    "uniStatistics": {
+        "enable": false
     },
-    "vueVersion" : "2",
-    "h5" : {
-        "router" : {
-            "mode" : "hash",
-            "base" : "./"
+    "vueVersion": "2",
+    "h5": {
+        "router": {
+            "mode": "hash",
+            "base": "./"
         },
-        "devServer" : {
-            "https" : false,
-            "disableHostCheck" : true,
-            "proxy" : {
-                "/apis1" : {
-                    "target" : "http://60.204.153.188",
-                    "changeOrigin" : true,
-                    "pathRewrite" : {
-                        "^/apis1" : ""
+        "devServer": {
+            "https": false,
+            "disableHostCheck": true,
+            "proxy": {
+                "/socket1": {
+                    "target": "ws://60.204.153.188",
+                    "changeOrigin": true,
+                    "pathRewrite": {
+                        "^/apis1": ""
                     }
                 },
-                "/apis" : {
-                    "target" : "https://oms.idcgroup.com.cn:8079",
-                    "changeOrigin" : false,
-                    "pathRewrite" : {
-                        "^/apis" : ""
+                "/socket": {
+                    "target": "wss://oms.idcgroup.com.cn:8079",
+                    "changeOrigin": false,
+                    "pathRewrite": {
+                        "^/apis": ""
                     }
                 },
-                "/txwzfw" : {
-                    "target" : "https://apis.map.qq.com",
-                    "changeOrigin" : false,
-                    "pathRewrite" : {
-                        "^/txwzfw" : ""
+                "/apis1": {
+                    "target": "http://60.204.153.188",
+                    "changeOrigin": true,
+                    "pathRewrite": {
+                        "^/apis1": ""
+                    }
+                },
+                "/apis": {
+                    "target": "https://oms.idcgroup.com.cn:8079",
+                    "changeOrigin": false,
+                    "pathRewrite": {
+                        "^/apis": ""
+                    }
+                },
+                "/txwzfw": {
+                    "target": "https://apis.map.qq.com",
+                    "changeOrigin": false,
+                    "pathRewrite": {
+                        "^/txwzfw": ""
                     }
                 }
             }
         },
-        "optimization" : {
-            "treeShaking" : {
-                "enable" : true
+        "optimization": {
+            "treeShaking": {
+                "enable": true
             }
         },
-        "title" : "智慧水务",
-        "sdkConfigs" : {
-            "maps" : {
-                "qqmap" : {
-                    "key" : "UVVBZ-UOGWZ-ZUWXC-TJQMT-TUWLO-IVFTN"
+        "title": "智慧水务",
+        "sdkConfigs": {
+            "maps": {
+                "qqmap": {
+                    "key": "UVVBZ-UOGWZ-ZUWXC-TJQMT-TUWLO-IVFTN"
                 }
             }
         }
     }
-}
+}

+ 1 - 1
pages/login/modules/account.vue

@@ -95,7 +95,7 @@ export default {
 						account: this.account.account,
 						password: this.memory == 1 ? this.account.password : ''
 					});
-					loginMsg(res.account_list, this.$Http)
+					loginMsg(res.account_list, this)
 				}
 			})
 

+ 15 - 11
pages/login/modules/dispose.js

@@ -2,15 +2,17 @@ let count = 0; //接口完成数量
 import {
     parsingAuth
 } from "../../../utils/auth";
+let that = null;
 
-function loginMsg(account_list, _Http, storage = true) {
+function loginMsg(account_list, _this, storage = true) {
+    that = _this;
     if (storage) uni.setStorageSync("account_list", account_list);
     uni.setStorageSync("isAgreement", true);
     if (account_list.length == 1) {
         uni.setStorageSync('userMsg', account_list[0])
-        query_userauth(_Http);
-        // query_adspacelist(_Http);
-        querySite_Parameter(_Http);
+        query_userauth();
+        // query_adspacelist();
+        querySite_Parameter();
     } else {
         uni.navigateTo({
             url: '/pages/login/selectSite'
@@ -18,8 +20,8 @@ function loginMsg(account_list, _Http, storage = true) {
     }
 }
 /* 获取用户权限 */
-function query_userauth(_Http) {
-    _Http.basic({
+function query_userauth() {
+    that.$Http.basic({
         "classname": "sysmanage.develop.userauth.userauth",
         "method": "query_userauth",
         content: {
@@ -38,8 +40,8 @@ function query_userauth(_Http) {
     });
 }
 /* 查询站点数据 */
-function querySite_Parameter(_Http) {
-    _Http.basic({
+function querySite_Parameter() {
+    that.$Http.basic({
         id: 20230608103802,
         "content": {}
     }).then(res => {
@@ -54,8 +56,8 @@ function querySite_Parameter(_Http) {
     })
 }
 /* 查询轮播图 */
-function query_adspacelist(_Http) {
-    _Http.basic({
+function query_adspacelist() {
+    that.$Http.basic({
         id: 20230608100802,
         "content": {}
     }).then(res => {
@@ -74,7 +76,9 @@ function toHome() {
     if (count < 2) return;
     uni.reLaunch({
         url: '/pages/index/index',
-    })
+    });
+/*     that.$Socket.initSocket()
+    console.log("Socket", that.$Socket) */
 }
 /* 站点数据查询 */
 module.exports = {

+ 1 - 1
pages/login/modules/otherLogin.vue

@@ -54,7 +54,7 @@ export default {
                     }).then(res => {
                         console.log("微信快捷登录", res)
                         if (that.cutoff(res.msg)) return;
-                        loginMsg(res.account_list, that.$Http)
+                        loginMsg(res.account_list, that)
                     })
                 }
             })

+ 1 - 1
pages/login/selectSite.vue

@@ -30,7 +30,7 @@ export default {
                 title: '提示',
                 content: `是否确定登录“${site.sitename}”站点的“${site.name}”账号`,
                 success: ({ confirm }) => {
-                    if (confirm) loginMsg([site], that.$Http, false);
+                    if (confirm) loginMsg([site], that, false);
                 }
             })
         },

+ 5 - 8
utils/Http.js

@@ -1,6 +1,8 @@
 class HTTP {
-    constructor() {
-        this.env = 'dev';
+    constructor({
+        baseUrl
+    }) {
+        this.baseUrl = baseUrl;
     }
     request({
         url,
@@ -21,12 +23,7 @@ class HTTP {
             mask: true
         })
         uni.request({
-            // #ifdef H5
-            url: (this.env == 'dev' ? "/apis1" : "/apis") + '/waserver/rest' + url,
-            // #endif
-            // #ifndef H5
-            url: (this.env == 'dev' ? "http://60.204.153.188" : "https://oms.idcgroup.com.cn:8079") + '/waserver/rest' + url,
-            // #endif 
+            url: this.baseUrl + '/waserver/rest' + url,
             data: data,
             method: method,
             header: header,

+ 34 - 0
utils/Socket.js

@@ -0,0 +1,34 @@
+class Socket {
+    constructor({
+        socket
+    }) {
+        this.baseUrl = socket;
+        this.socketEstablish = false; //是否建立链接
+        this.socketCallback = () => {
+
+        };
+    }
+    initSocket() {
+        this.SocketTask = uni.connectSocket({
+            url: this.baseUrl + '/waserver/webSocket/' + uni.getStorageSync('userMsg').token,
+            complete: (res) => {
+                console.log(res)
+            }
+        })
+        this.SocketTask.onOpen(function (res) {
+            this.socketEstablish = true;
+        })
+        this.SocketTask.onMessage(function (res) {
+            this.socketCallback(res)
+        })
+        this.SocketTask.onError(function (res) {
+            this.socketEstablish = false;
+        })
+        this.SocketTask.onClose(function (res) {
+            this.socketEstablish = false;
+        })
+    }
+}
+export {
+    Socket
+}