Kaynağa Gözat

增加远程访问接口,还未调试

zhoutao 3 ay önce
ebeveyn
işleme
2c4bb41cf7
11 değiştirilmiş dosya ile 721 ekleme ve 13 silme
  1. 1 0
      .gitignore
  2. 7 0
      api/wxlogin.js
  3. 18 7
      app.js
  4. 1 1
      app.json
  5. 459 0
      package-lock.json
  6. 6 0
      package.json
  7. 5 5
      pages/home/home.js
  8. 23 0
      sysconfig/sysconfig.js
  9. 114 0
      utils/crypt.js
  10. 18 0
      utils/pdatautil.js
  11. 69 0
      utils/request.js

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+node_modules

+ 7 - 0
api/wxlogin.js

@@ -0,0 +1,7 @@
+import fly from "../utils/request.js"
+
+//用户登录
+export function userMobileLogin(data){
+	return fly.post("wxlogin/userMobileLogin", data)
+}
+

+ 18 - 7
app.js

@@ -1,4 +1,7 @@
 // app.js
+import { userMobileLogin } from './api/wxlogin.js'
+import sysconfig from '../sysconfig/sysconfig.js'
+
 App({
     data: {//数据
         worker: null,//线程句柄
@@ -8,15 +11,23 @@ App({
         imuStartTimestamp: 0,//IMU开始时间戳
     },
     onLaunch() {
-        // 展示本地存储能力
-        const logs = wx.getStorageSync('logs') || []
-        logs.unshift(Date.now())
-        wx.setStorageSync('logs', logs)
-
-        // TODO登录
+        // 用户登录登录(发送 res.code 到后台换取 openId, sessionKey, unionId)
         wx.login({
             success: (res) => {
-                // 发送 res.code 到后台换取 openId, sessionKey, unionId
+                var paramData = {};
+                paramData.code = res.code; //登录凭证
+                paramData.domain_name = sysconfig.default.domanName; //系统二级域名
+                userMobileLogin(paramData).then((resp) => {
+                    //保存token
+                    const tokenKey = wx.getStorageSync(sysconfig.user.tokenKey)
+                    wx.setStorageSync(tokenKey, resp.data.data.token)
+
+                    //保存用户数据
+                    const userInfoKey = wx.getStorageSync(sysconfig.user.userInfoKey)
+                    wx.setStorageSync(userInfoKey, resp.data.data)
+                }).catch((err) => {
+                    console.log(err)
+                })
             }
         })
     },

+ 1 - 1
app.json

@@ -6,7 +6,7 @@
     ],
     "window": {
         "navigationBarTextStyle": "white",
-        "navigationBarTitleText": "秒寻定位系统",
+        "navigationBarTitleText": "室内定位导航系统",
         "navigationBarBackgroundColor": "#FC0000"
     },
     "style": "v2",

+ 459 - 0
package-lock.json

@@ -0,0 +1,459 @@
+{
+  "name": "wxmini",
+  "lockfileVersion": 3,
+  "requires": true,
+  "packages": {
+    "": {
+      "dependencies": {
+        "crypto-js": "^4.2.0",
+        "flyio": "^0.6.14"
+      }
+    },
+    "node_modules/ajv": {
+      "version": "6.12.6",
+      "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
+      "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
+      "dependencies": {
+        "fast-deep-equal": "^3.1.1",
+        "fast-json-stable-stringify": "^2.0.0",
+        "json-schema-traverse": "^0.4.1",
+        "uri-js": "^4.2.2"
+      },
+      "funding": {
+        "type": "github",
+        "url": "https://github.com/sponsors/epoberezkin"
+      }
+    },
+    "node_modules/asn1": {
+      "version": "0.2.6",
+      "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz",
+      "integrity": "sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==",
+      "dependencies": {
+        "safer-buffer": "~2.1.0"
+      }
+    },
+    "node_modules/assert-plus": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
+      "integrity": "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==",
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
+    "node_modules/asynckit": {
+      "version": "0.4.0",
+      "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
+      "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
+    },
+    "node_modules/aws-sign2": {
+      "version": "0.7.0",
+      "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
+      "integrity": "sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA==",
+      "engines": {
+        "node": "*"
+      }
+    },
+    "node_modules/aws4": {
+      "version": "1.13.2",
+      "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.2.tgz",
+      "integrity": "sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw=="
+    },
+    "node_modules/bcrypt-pbkdf": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
+      "integrity": "sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==",
+      "dependencies": {
+        "tweetnacl": "^0.14.3"
+      }
+    },
+    "node_modules/caseless": {
+      "version": "0.12.0",
+      "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
+      "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw=="
+    },
+    "node_modules/combined-stream": {
+      "version": "1.0.8",
+      "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
+      "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
+      "dependencies": {
+        "delayed-stream": "~1.0.0"
+      },
+      "engines": {
+        "node": ">= 0.8"
+      }
+    },
+    "node_modules/core-util-is": {
+      "version": "1.0.2",
+      "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
+      "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ=="
+    },
+    "node_modules/crypto-js": {
+      "version": "4.2.0",
+      "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
+      "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
+    },
+    "node_modules/dashdash": {
+      "version": "1.14.1",
+      "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
+      "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==",
+      "dependencies": {
+        "assert-plus": "^1.0.0"
+      },
+      "engines": {
+        "node": ">=0.10"
+      }
+    },
+    "node_modules/delayed-stream": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
+      "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
+      "engines": {
+        "node": ">=0.4.0"
+      }
+    },
+    "node_modules/ecc-jsbn": {
+      "version": "0.1.2",
+      "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
+      "integrity": "sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==",
+      "dependencies": {
+        "jsbn": "~0.1.0",
+        "safer-buffer": "^2.1.0"
+      }
+    },
+    "node_modules/extend": {
+      "version": "3.0.2",
+      "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
+      "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g=="
+    },
+    "node_modules/extsprintf": {
+      "version": "1.3.0",
+      "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
+      "integrity": "sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==",
+      "engines": [
+        "node >=0.6.0"
+      ]
+    },
+    "node_modules/fast-deep-equal": {
+      "version": "3.1.3",
+      "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
+      "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
+    },
+    "node_modules/fast-json-stable-stringify": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
+      "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="
+    },
+    "node_modules/flyio": {
+      "version": "0.6.14",
+      "resolved": "https://registry.npmjs.org/flyio/-/flyio-0.6.14.tgz",
+      "integrity": "sha512-RE2OXE1ZZmcXOKb0jCtGyquHDxpAqHg17CZ8lmQKRfl3x1kP+NBpaQDx4WgN7DNpLJjFnspTzTEQpwRGg6/xaA==",
+      "dependencies": {
+        "request": "^2.85.0"
+      }
+    },
+    "node_modules/forever-agent": {
+      "version": "0.6.1",
+      "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
+      "integrity": "sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==",
+      "engines": {
+        "node": "*"
+      }
+    },
+    "node_modules/form-data": {
+      "version": "2.3.3",
+      "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
+      "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
+      "dependencies": {
+        "asynckit": "^0.4.0",
+        "combined-stream": "^1.0.6",
+        "mime-types": "^2.1.12"
+      },
+      "engines": {
+        "node": ">= 0.12"
+      }
+    },
+    "node_modules/getpass": {
+      "version": "0.1.7",
+      "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
+      "integrity": "sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==",
+      "dependencies": {
+        "assert-plus": "^1.0.0"
+      }
+    },
+    "node_modules/har-schema": {
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
+      "integrity": "sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==",
+      "engines": {
+        "node": ">=4"
+      }
+    },
+    "node_modules/har-validator": {
+      "version": "5.1.5",
+      "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz",
+      "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==",
+      "deprecated": "this library is no longer supported",
+      "dependencies": {
+        "ajv": "^6.12.3",
+        "har-schema": "^2.0.0"
+      },
+      "engines": {
+        "node": ">=6"
+      }
+    },
+    "node_modules/http-signature": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
+      "integrity": "sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==",
+      "dependencies": {
+        "assert-plus": "^1.0.0",
+        "jsprim": "^1.2.2",
+        "sshpk": "^1.7.0"
+      },
+      "engines": {
+        "node": ">=0.8",
+        "npm": ">=1.3.7"
+      }
+    },
+    "node_modules/is-typedarray": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
+      "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA=="
+    },
+    "node_modules/isstream": {
+      "version": "0.1.2",
+      "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
+      "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g=="
+    },
+    "node_modules/jsbn": {
+      "version": "0.1.1",
+      "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
+      "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg=="
+    },
+    "node_modules/json-schema": {
+      "version": "0.4.0",
+      "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz",
+      "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA=="
+    },
+    "node_modules/json-schema-traverse": {
+      "version": "0.4.1",
+      "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
+      "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
+    },
+    "node_modules/json-stringify-safe": {
+      "version": "5.0.1",
+      "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
+      "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA=="
+    },
+    "node_modules/jsprim": {
+      "version": "1.4.2",
+      "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz",
+      "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==",
+      "dependencies": {
+        "assert-plus": "1.0.0",
+        "extsprintf": "1.3.0",
+        "json-schema": "0.4.0",
+        "verror": "1.10.0"
+      },
+      "engines": {
+        "node": ">=0.6.0"
+      }
+    },
+    "node_modules/mime-db": {
+      "version": "1.52.0",
+      "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
+      "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/mime-types": {
+      "version": "2.1.35",
+      "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
+      "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
+      "dependencies": {
+        "mime-db": "1.52.0"
+      },
+      "engines": {
+        "node": ">= 0.6"
+      }
+    },
+    "node_modules/oauth-sign": {
+      "version": "0.9.0",
+      "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
+      "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==",
+      "engines": {
+        "node": "*"
+      }
+    },
+    "node_modules/performance-now": {
+      "version": "2.1.0",
+      "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
+      "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow=="
+    },
+    "node_modules/psl": {
+      "version": "1.15.0",
+      "resolved": "https://registry.npmjs.org/psl/-/psl-1.15.0.tgz",
+      "integrity": "sha512-JZd3gMVBAVQkSs6HdNZo9Sdo0LNcQeMNP3CozBJb3JYC/QUYZTnKxP+f8oWRX4rHP5EurWxqAHTSwUCjlNKa1w==",
+      "dependencies": {
+        "punycode": "^2.3.1"
+      },
+      "funding": {
+        "url": "https://github.com/sponsors/lupomontero"
+      }
+    },
+    "node_modules/punycode": {
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
+      "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
+      "engines": {
+        "node": ">=6"
+      }
+    },
+    "node_modules/qs": {
+      "version": "6.5.3",
+      "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz",
+      "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==",
+      "engines": {
+        "node": ">=0.6"
+      }
+    },
+    "node_modules/request": {
+      "version": "2.88.2",
+      "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz",
+      "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==",
+      "deprecated": "request has been deprecated, see https://github.com/request/request/issues/3142",
+      "dependencies": {
+        "aws-sign2": "~0.7.0",
+        "aws4": "^1.8.0",
+        "caseless": "~0.12.0",
+        "combined-stream": "~1.0.6",
+        "extend": "~3.0.2",
+        "forever-agent": "~0.6.1",
+        "form-data": "~2.3.2",
+        "har-validator": "~5.1.3",
+        "http-signature": "~1.2.0",
+        "is-typedarray": "~1.0.0",
+        "isstream": "~0.1.2",
+        "json-stringify-safe": "~5.0.1",
+        "mime-types": "~2.1.19",
+        "oauth-sign": "~0.9.0",
+        "performance-now": "^2.1.0",
+        "qs": "~6.5.2",
+        "safe-buffer": "^5.1.2",
+        "tough-cookie": "~2.5.0",
+        "tunnel-agent": "^0.6.0",
+        "uuid": "^3.3.2"
+      },
+      "engines": {
+        "node": ">= 6"
+      }
+    },
+    "node_modules/safe-buffer": {
+      "version": "5.2.1",
+      "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
+      "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
+      "funding": [
+        {
+          "type": "github",
+          "url": "https://github.com/sponsors/feross"
+        },
+        {
+          "type": "patreon",
+          "url": "https://www.patreon.com/feross"
+        },
+        {
+          "type": "consulting",
+          "url": "https://feross.org/support"
+        }
+      ]
+    },
+    "node_modules/safer-buffer": {
+      "version": "2.1.2",
+      "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
+      "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
+    },
+    "node_modules/sshpk": {
+      "version": "1.18.0",
+      "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.18.0.tgz",
+      "integrity": "sha512-2p2KJZTSqQ/I3+HX42EpYOa2l3f8Erv8MWKsy2I9uf4wA7yFIkXRffYdsx86y6z4vHtV8u7g+pPlr8/4ouAxsQ==",
+      "dependencies": {
+        "asn1": "~0.2.3",
+        "assert-plus": "^1.0.0",
+        "bcrypt-pbkdf": "^1.0.0",
+        "dashdash": "^1.12.0",
+        "ecc-jsbn": "~0.1.1",
+        "getpass": "^0.1.1",
+        "jsbn": "~0.1.0",
+        "safer-buffer": "^2.0.2",
+        "tweetnacl": "~0.14.0"
+      },
+      "bin": {
+        "sshpk-conv": "bin/sshpk-conv",
+        "sshpk-sign": "bin/sshpk-sign",
+        "sshpk-verify": "bin/sshpk-verify"
+      },
+      "engines": {
+        "node": ">=0.10.0"
+      }
+    },
+    "node_modules/tough-cookie": {
+      "version": "2.5.0",
+      "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz",
+      "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==",
+      "dependencies": {
+        "psl": "^1.1.28",
+        "punycode": "^2.1.1"
+      },
+      "engines": {
+        "node": ">=0.8"
+      }
+    },
+    "node_modules/tunnel-agent": {
+      "version": "0.6.0",
+      "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
+      "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==",
+      "dependencies": {
+        "safe-buffer": "^5.0.1"
+      },
+      "engines": {
+        "node": "*"
+      }
+    },
+    "node_modules/tweetnacl": {
+      "version": "0.14.5",
+      "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
+      "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA=="
+    },
+    "node_modules/uri-js": {
+      "version": "4.4.1",
+      "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
+      "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
+      "dependencies": {
+        "punycode": "^2.1.0"
+      }
+    },
+    "node_modules/uuid": {
+      "version": "3.4.0",
+      "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
+      "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
+      "deprecated": "Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.",
+      "bin": {
+        "uuid": "bin/uuid"
+      }
+    },
+    "node_modules/verror": {
+      "version": "1.10.0",
+      "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
+      "integrity": "sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==",
+      "engines": [
+        "node >=0.6.0"
+      ],
+      "dependencies": {
+        "assert-plus": "^1.0.0",
+        "core-util-is": "1.0.2",
+        "extsprintf": "^1.2.0"
+      }
+    }
+  }
+}

+ 6 - 0
package.json

@@ -0,0 +1,6 @@
+{
+  "dependencies": {
+    "crypto-js": "^4.2.0",
+    "flyio": "^0.6.14"
+  }
+}

+ 5 - 5
pages/home/home.js

@@ -213,23 +213,23 @@ Page({
         // a81710d91a5e 4号基站
 
         // 1号基站,基站ID,频率ID(0 - 8),时隙ID(0 - 3),X坐标(单位厘米),Y坐标(单位厘米),MAC地址,定位类型,1维定位基站数,1维定位基站ID队列
-        oneItem = this.generateOneInstallBts(10001, 0, 0, 0, 0, "685377178192", 2, 0, "")
+        oneItem = this.generateOneInstallBts(10001, 3, 0, 0, 720, "685377178192", 3, 1, "10005")
         this.data.installBtsList.push(oneItem)
 
         //2号基站
-        oneItem = this.generateOneInstallBts(10002, 1, 1, 2500, 0, "685377183652", 3, 1, "10005")
+        oneItem = this.generateOneInstallBts(10002, 4, 1, 2500, 720, "685377183652", 2, 0, "")
         this.data.installBtsList.push(oneItem)
 
         //3号基站
-        oneItem = this.generateOneInstallBts(10003, 2, 2, 2500, 800, "6853771679b0", 2, 0, "")
+        oneItem = this.generateOneInstallBts(10003, 5, 2, 2500, 0, "6853771679b0", 2, 0, "")
         this.data.installBtsList.push(oneItem)
 
         //4号基站
-        oneItem = this.generateOneInstallBts(10004, 3, 3, 0, 800, "68537716c686", 2, 0, "")
+        oneItem = this.generateOneInstallBts(10004, 6, 3, 0, 0, "68537716c686", 2, 0, "")
         this.data.installBtsList.push(oneItem)
 
         //5号基站
-        oneItem = this.generateOneInstallBts(10005, 4, 0, 5000, 0, "685377183238", 1, 1, "10002")
+        oneItem = this.generateOneInstallBts(10005, 7, 0, 0, 3300, "685377183238", 1, 1, "10001")
         this.data.installBtsList.push(oneItem)
 
         // //6号基站

+ 23 - 0
sysconfig/sysconfig.js

@@ -0,0 +1,23 @@
+//系统参数
+let config = {
+    copyright: 'MiaoXun',//开发公司
+    app: {//软件资料
+        titleCh: '声波定位系统',
+        titleEn: 'APLS',
+        version: 'V2.0.00',
+        snCode: 'T0T3061F!',
+    },
+	domanName:'hzdz',
+	user:{
+		tokenKey:'apls-8000-token',
+		userInfoKey:'apls-8000-user-info-key'
+	},
+	apiWhiteList:["userMobileLogin"],
+	//系统消息
+	sysMsg:[
+		'REC_LOCARION_AUDIO_DATA',//录音模块到定位模块的音频数据
+	]
+}
+
+export default config
+

+ 114 - 0
utils/crypt.js

@@ -0,0 +1,114 @@
+import cryptojs from 'crypto-js'
+
+var codecutil = {}
+
+export default codecutil //全局导出对象
+
+//MD5(Message-Digest Algorithm),信息摘要算法
+//一种被广泛使用的密码散列函数,可以产生出一个128位(16字节)的散列值(hash value),用于确保信息传输完整一致
+codecutil.md5 = function (data) {
+    return cryptojs.MD5(data).toString()
+}
+
+//SHA1(Secure Hash Algorithm 1),安全散列算法,
+//SHA-1可以生成一个被称为消息摘要的160位(20字节)散列值,散列值通常的呈现形式为40个十六进制数
+codecutil.sha1 = function (data) {
+    return cryptojs.SHA1(data).toString()
+}
+
+//SHA256(Secure Hash Algorithm 1),安全散列算法,
+//对于任意长度的消息,SHA256都会产生一个256位的哈希值,称作消息摘要。这个摘要相当于是个长度为32个字节的数组,共256位,通常由一个长度为64的十六进制字符串来表示
+codecutil.sha256 = function (data) {
+    return cryptojs.SHA256(data).toString()
+}
+
+//解析密钥
+codecutil.aesDeKey = function (key) {
+    return cryptojs.enc.Utf8.parse(key)
+}
+
+//aes加密
+codecutil.aesEncode = function (data, key) {
+    if (data && key) {
+        let aesKey = cryptojs.enc.Utf8.parse(key) //将密钥按照utf8格式化
+        let content = cryptojs.enc.Utf8.parse(data)//将明文按照utf8格式化
+
+        //加密后已经是base64编码格式的数据
+        const ciphertext = cryptojs.AES.encrypt(content, aesKey, { iv: aesKey, mode: cryptojs.mode.CBC, padding: cryptojs.pad.Pkcs7 }).toString()
+
+        return ciphertext
+    } else {
+        return ''
+    }
+}
+
+//aes解密
+codecutil.aesDecode = function (data, key) {
+    if (data && key) {
+        var ciphertext = codecutil.base64Decode(data)
+
+        // var bytes = cryptojs.AES.decrypt(ciphertext, key, { mode: cryptojs.mode.ECB, padding: cryptojs.pad.Pkcs7 })
+        var bytes = cryptojs.AES.decrypt(ciphertext, key, { mode: cryptojs.mode.CBC, padding: cryptojs.pad.Pkcs7 })
+        var plaintext = bytes.toString(cryptojs.enc.Utf8)
+
+        return plaintext
+    } else {
+        return ''
+    }
+}
+
+//base64加密
+codecutil.base64Encode = function (data) {
+    if (data) {
+        var bytes = cryptojs.enc.Utf8.parse(data)
+        var plaintext = bytes.toString(cryptojs.enc.Base64)
+
+        plaintext = plaintext.toString()
+        // plaintext = plaintext.replace(/\//g, '_')
+        // plaintext = plaintext.replace(/\+/g, '-')
+        // plaintext = plaintext.replace(/=/g, '')
+
+        return plaintext
+    } else {
+        return ''
+    }
+}
+
+//base64解密
+codecutil.base64Decode = function (data) {
+    if (data) {
+        var ciphertext = data.toString()
+        ciphertext = ciphertext.replace(/_/g, '/')
+        ciphertext = ciphertext.replace(/-/g, '+')
+        for (var i = 0; i < 4 - ciphertext.length % 4; i++) {
+            ciphertext = ciphertext + '='
+        }
+
+        var bytes = cryptojs.enc.Base64.parse(ciphertext)
+        var plaintext = bytes.toString(cryptojs.enc.Utf8)
+
+        return plaintext
+    } else {
+        return ''
+    }
+}
+
+codecutil.hexEncode = function (data) {
+    if (data) {
+        var bytes = cryptojs.enc.Utf8.parse(data)
+        var plaintext = bytes.toString(cryptojs.enc.Hex)
+        return plaintext
+    } else {
+        return ''
+    }
+}
+
+codecutil.hexDecode = function (data) {
+    if (data) {
+        var bytes = cryptojs.enc.Hex.parse(data)
+        var plaintext = bytes.toString(cryptojs.enc.Utf8)
+        return plaintext
+    } else {
+        return ''
+    }
+}

+ 18 - 0
utils/pdatautil.js

@@ -0,0 +1,18 @@
+import crypt from './crypt.js'
+
+var pdatautil = {}
+
+export default pdatautil //全局导出对象
+
+// 用于编码路由参数
+pdatautil.encode = function (json) {
+    var encodedata = crypt.base64Encode(JSON.stringify(json))
+    return encodedata
+}
+
+// 用于解码路由参数
+pdatautil.decode = function (data) {
+    var decodedata = crypt.base64Decode(data)
+    var json = JSON.parse(decodedata)
+    return json
+}

+ 69 - 0
utils/request.js

@@ -0,0 +1,69 @@
+import sysconfig from '../sysconfig/sysconfig.js'
+import crypt from './crypt.js'
+
+let Fly = require("flyio/dist/npm/wx")//引入fly包
+let fly = new Fly()
+
+//本地
+fly.config.baseURL = "http://127.0.0.1:8080/msapi"
+
+//远程
+fly.config.baseURL = "http://www.locaty.com.cn/msapi"
+
+//请求拦截,config是请求对象
+fly.interceptors.request.use((config) => {
+    //组织请求参数密钥
+    const aesKey = sysconfig.copyright + sysconfig.app.snCode
+
+    //同步读取本地token
+    const token = wx.getStorageSync(sysconfig.user.tokenKey)
+
+    if (token) {
+        //判断当前请求api是否在白名单内,在白名单内的api不需要添加token
+        let apiName = ""
+        const urlList = config.url.split("/")
+        const apiWhiteList = sysconfig.apiWhiteList
+        if (urlList.length > 1) {
+            apiName = urlList[1]
+        } else {
+            apiName = urlList[0]
+        }
+
+        //不在白名单内,则添加token,并且对token进行加密
+        if (!apiWhiteList.includes(apiName)) {
+            let item = {}
+            item["rnd"] = Math.random().toString()
+            item["token"] = token
+            let plaintext = JSON.stringify(item)
+
+            //对token进行加密
+            const ciphertext = crypt.aesEncode(plaintext, aesKey)
+            config.headers.Authorization = ciphertext
+        }
+    }
+
+    //对get参数进行加密
+    if (config.params && (Object.keys(config.params).length) > 0) {
+        const params = config.params
+        const paramsText = JSON.stringify(params)
+        if (paramsText != "{}") {
+            const ciphertext = crypt.aesEncode(params, aesKey)
+            config.params = {}
+            config.params = ciphertext
+        }
+    }
+
+    //对post参数进行加密
+    if (config.body && (Object.keys(config.body).length) > 0) {
+        const plaintext = JSON.stringify(config.body)
+        const ciphertext = crypt.aesEncode(plaintext, aesKey)
+        config.body = {}
+        config.body = ciphertext
+    }
+
+    return config
+}, error => {
+    return Promise.reject(error)
+})
+
+export default fly