Parcourir la source

AI预警移动端

master
yxq il y a 3 mois
Parent
révision
0f2e126ad3
50 fichiers modifiés avec 4737 ajouts et 0 suppressions
  1. +24
    -0
      monitorMobile/App.vue
  2. +10
    -0
      monitorMobile/api/student/home/index.js
  3. +102
    -0
      monitorMobile/api/user.js
  4. +197
    -0
      monitorMobile/common/mixins.vue
  5. +58
    -0
      monitorMobile/common/setting.js
  6. +88
    -0
      monitorMobile/http/api.js
  7. +49
    -0
      monitorMobile/http/config.js
  8. +18
    -0
      monitorMobile/http/install.js
  9. +20
    -0
      monitorMobile/index.html
  10. +46
    -0
      monitorMobile/main.js
  11. +72
    -0
      monitorMobile/manifest.json
  12. +1416
    -0
      monitorMobile/package-lock.json
  13. +10
    -0
      monitorMobile/package.json
  14. +93
    -0
      monitorMobile/pages.json
  15. +48
    -0
      monitorMobile/pages/attendanceCall/index.vue
  16. +22
    -0
      monitorMobile/pages/attendanceCall/passengerFlow/index.vue
  17. +124
    -0
      monitorMobile/pages/attendanceCall/returnBed/index.vue
  18. +22
    -0
      monitorMobile/pages/attendanceCall/rollCall/index.vue
  19. +22
    -0
      monitorMobile/pages/earlyWarning/index.vue
  20. +21
    -0
      monitorMobile/pages/home.vue
  21. +22
    -0
      monitorMobile/pages/my/index.vue
  22. BIN
      monitorMobile/static/image/confirm.png
  23. BIN
      monitorMobile/static/image/peopleNum.png
  24. BIN
      monitorMobile/static/image/tabbar/attendanceCall.png
  25. BIN
      monitorMobile/static/image/tabbar/earlyWarning_active.png
  26. BIN
      monitorMobile/static/image/tabbar/home.png
  27. BIN
      monitorMobile/static/image/tabbar/my.png
  28. +30
    -0
      monitorMobile/store/$u.mixin.js
  29. +75
    -0
      monitorMobile/store/index.js
  30. +10
    -0
      monitorMobile/uni.promisify.adaptor.js
  31. +78
    -0
      monitorMobile/uni.scss
  32. +235
    -0
      monitorMobile/utils/base64.js
  33. +51
    -0
      monitorMobile/utils/date.js
  34. +178
    -0
      monitorMobile/utils/func.js
  35. +99
    -0
      monitorMobile/utils/luch-request/adapters/index.js
  36. +51
    -0
      monitorMobile/utils/luch-request/core/InterceptorManager.js
  37. +199
    -0
      monitorMobile/utils/luch-request/core/Request.js
  38. +20
    -0
      monitorMobile/utils/luch-request/core/buildFullPath.js
  39. +30
    -0
      monitorMobile/utils/luch-request/core/defaults.js
  40. +6
    -0
      monitorMobile/utils/luch-request/core/dispatchRequest.js
  41. +103
    -0
      monitorMobile/utils/luch-request/core/mergeConfig.js
  42. +16
    -0
      monitorMobile/utils/luch-request/core/settle.js
  43. +69
    -0
      monitorMobile/utils/luch-request/helpers/buildURL.js
  44. +14
    -0
      monitorMobile/utils/luch-request/helpers/combineURLs.js
  45. +14
    -0
      monitorMobile/utils/luch-request/helpers/isAbsoluteURL.js
  46. +116
    -0
      monitorMobile/utils/luch-request/index.d.ts
  47. +2
    -0
      monitorMobile/utils/luch-request/index.js
  48. +135
    -0
      monitorMobile/utils/luch-request/utils.js
  49. +685
    -0
      monitorMobile/utils/md5.js
  50. +37
    -0
      monitorMobile/utils/secret.js

+ 24
- 0
monitorMobile/App.vue Voir le fichier

@@ -0,0 +1,24 @@
<script>
export default {
onLaunch: function() {
},
onShow: function() {
},
onHide: function() {
}
}
</script>

<style lang="scss">
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
@import "uview-ui/index.scss";
.uni-tabbar-bottom{
.uni-tabbar{
box-shadow: 0px -3px 9px 0px rgba(0,0,0,0.06), 0px 4px 4px 0px rgba(0,0,0,0.01);
}
}
uni-page-body{
height: 100%;
background-color: #F6F8FA;
}
</style>

+ 10
- 0
monitorMobile/api/student/home/index.js Voir le fichier

@@ -0,0 +1,10 @@

import http from '@/http/api.js'
// 获取校历事件数据
export const getSchoolCalendarlist = (params) => {
return http.request({
url: '/api/blade-basic-data/semester/schoolCalendarlist',
method: 'get',
params
})
}

+ 102
- 0
monitorMobile/api/user.js Voir le fichier

@@ -0,0 +1,102 @@
import http from '@/http/api.js'

// 获取token
const token = (tenantId, username, password, type) => {
return http.request({
url: '/api/blade-auth/oauth/token',
method: 'POST',
header: {
'Tenant-Id': tenantId
},
params: {
tenantId,
username,
password,
grant_type: "password",
scope: "all",
type
}
})
}
const getTenantId = (params) => {
return http.request({
url: '/api/blade-auth/oauth/getTenantId',
method: 'get',
params: {
...params
}
})
}

const refreshToken = (refresh_token, tenantId) => {
return http.request({
url: '/api/blade-auth/oauth/token',
method: 'post',
header: {
'Tenant-Id': tenantId
},
params: {
tenantId,
refresh_token,
grant_type: "refresh_token",
scope: "all",
}
})
}

// 获取用户信息
const userInfo = () => {
return http.request({
url: '/api/blade-user/info',
method: 'GET',
})
}

// 获取用户信息
export const getUser = (id) => {
return http.request({
url: '/api/blade-user/detail',
method: 'GET',
params: { id }
})
}
export const getUserInfo = () => {
return http.request({
url: '/api/blade-user/info',
method: 'get',
})
}
/* 修改用户信息 */
const updateInfo = (row) => {
return http.request({
url: '/api/blade-user/update-info',
method: 'post',
data: row
})
}
// 修改密码
const updatePassword = (data) => {
return http.request({
url: '/api/blade-user/update-password',
method: 'post',
params: data
})
}
// 修改密码
const passwordCheck = (data) => {
return http.request({
url: '/api/blade-user/passwordCheck',
method: 'post',
params: data
})
}

export default {
token,
userInfo,
refreshToken,
getTenantId,
updatePassword,
updateInfo,
passwordCheck
}

+ 197
- 0
monitorMobile/common/mixins.vue Voir le fichier

@@ -0,0 +1,197 @@
<script>
import http from '@/http/api.js'
import {
options
} from '@/http/config.js';
import {
Base64
} from '@/utils/base64.js';
import {
clientId,
clientSecret
} from '@/common/setting'
export default{
methods:{
// 暂存一个跨页面变量 (与 this.GET_PARAM 成对使用)
SET_PARAM(val) {
this.SET_GLOBAL('pageParam', val)
},
// 获取之前暂存的跨页面变量 (与 this.SET_PARAM 成对使用)
GET_PARAM() {
return this.GET_GLOBAL('pageParam')
},
// 进入某个页面
NAV_TO(url, param, usePageParam) {
uni.navigateTo({
url: this.handleNav(url, param, usePageParam)
})
},
// 返回上个页面
// delta 参数为返回的次数
NAV_BACK(delta = 1) {
uni.navigateBack({
delta
})
},
// 跳转到某个页面,跳转后无法返回
JUMP_TO(url, param, usePageParam) {
uni.redirectTo({
url: this.handleNav(url, param, usePageParam)
})
},
// 转到某个 Tab 页
TAB_TO(url, param) {
uni.switchTab({
url: this.handleNav(url, param, true)
})
},
// 【内部方法】处理页面跳转 url 和参数
handleNav(url, param, usePageParam) {
let query = ''
if (param && usePageParam) {
this.SET_PARAM(param)
} else if (param && !usePageParam) {
query += '?' + Object.entries(param).filter(([k, v]) => k && v).map(([k, v]) => k + '=' + v).join('&')
}
return url + query
},
// 设置页面标题
SET_TITLE(title) {
uni.setNavigationBarTitle({
title
})
},
// 监听一个全局事件
ON(name, func) {
uni.$on(name, func)
},
// 仅单次监听一个全局事件
ONCE(name, func) {
uni.$once(name, func)
},
// 触发一个全局事件
EMIT(name, data) {
uni.$emit(name, data)
},
// 移除全局事件监听器
OFF(name, func) {
uni.$off(name, func)
},
// 二次确认提示框
CONFIRM(content='是否确认执行此操作?'){
return new Promise((resolve)=>{
uni.showModal({
title: '提示信息',
content: content,
cancelText: "取消",
confirmText: "确认",
confirmColor: '#F2C827',
cancelColor: '#9E9E9E',
success: function (res) {
if (res.confirm) {
resolve(true)
} else if (res.cancel) {
resolve(false)
}
}
});
})
},
TOAST(title){
uni.showToast({
icon: "none",
title,
duration: 2000,
});
},
UPLOAD_FILE(filePath){
let that = this
// 假设有token值需要在头部需要携带
let header = {}
let accessToken = uni.getStorageSync('accessToken');
if (accessToken) {
header['Blade-Auth'] = 'bearer ' + accessToken;
}
// 客户端认证参数
header['Authorization'] = 'Basic ' + Base64.encode(clientId + ':' + clientSecret);
console.log(filePath)
return new Promise(resovle=>{
uni.uploadFile({
url:options.baseURL + '/api/blade-resource/oss/endpoint/put-uplaod-file?bucketName=',
filePath,
name:'file',
header,
success(e){
if(e.statusCode == 200){
let res = JSON.parse(e.data)
if(res.code == 200){
resovle(res.data)
}else{
resovle(res.msg)
}
}else{
resovle(false)
}
},
fail(e){
console.log('fail',e)
resovle(false)
},
})
})
},
DELETE_FILE(attachIds){
return http.request({
url: '/api/blade-resource/oss/endpoint/remove-file-attachIds',
method: 'post',
params:{attachIds}
})
},
// 显示 loading 提示框
// title 为提示文字
// mask 为是否禁止点击
LOADING(title, mask = true) {
uni.showLoading({
title,
mask
})
},
// 停止展示 loading 提示框
HIDE_LOADING() {
uni.hideLoading()
},
// url获取文件流
DOWNLOAD_FILE(url){
return uni.downloadFile({
url
})
},
//复制链接
COPYLINK(item){
return new Promise((resolve)=>{
uni.setClipboardData({
data: item, // 要复制的路径
success: function(res) {
resolve(true)
// uni.getClipboardData({
// success: function(data) {
// resolve(true)
// },
// fail: function(data1) {
// resolve(false)
// }
// });
}
});
})
},
},
}
</script>

+ 58
- 0
monitorMobile/common/setting.js Voir le fichier

@@ -0,0 +1,58 @@
/**
* 全局变量配置
*/
// #ifdef H5
let origin = window.location.origin
console.log(window.location.origin)
// #endif
module.exports = {
// 应用名
name: 'Rider',
// 应用logo,支持本地路径和网络路径
logo: '/static/images/icon/logo.png',
// 版本号
version: '2.0.0',
version: '2.0.1',
// H5接口Url
// #ifdef H5
devUrl: `${origin}/`,
prodUrl: `${origin}/`,
// #endif
// 小程序接口Url
// #ifndef H5
// devUrl: 'http://192.168.10.46',
devUrl: 'https://www.bjjyp.org.cn/rider',//开发环境接口Url
prodUrl: `https://www.bjjyp.org.cn/rider`,//线上环境接口Url
// prodUrl: 'http://192.168.100.236:1888',
// prodUrl: 'http://114.255.136.189:1888',
// #endif
// 后端数据的接收方式application/json;charset=UTF-8或者application/x-www-form-urlencoded;charset=UTF-8
contentType: 'application/json;charset=UTF-8',
// 后端返回状态码
codeName: 'code',
// 操作正常code
successCode: 200,
// 登录失效code
invalidCode: 401,
// 客户端ID
clientId: 'rider',
// 客户端密钥
clientSecret: 'rider_secret',
// token过期时间
tokenTime: 3000,
switchMode: true, // 是否开启部门切换模式
//本地
previewUrl: 'http://cp.qjkjedu.com/onlinePreview',
//金隅生产
// previewUrl: 'https://www.bjjyp.org.cn/preview/onlinePreview',
}

+ 88
- 0
monitorMobile/http/api.js Voir le fichier

@@ -0,0 +1,88 @@
import {
devUrl,
clientId,
clientSecret
} from '@/common/setting'
import {
options
} from '@/http/config.js';
import {
Base64
} from '@/utils/base64.js';
import Request from '@/utils/luch-request/index.js';
const http = new Request(options);
http.interceptors.request.use((config) => { // 可使用async await 做异步操作
// 假设有token值需要在头部需要携带
let accessToken = uni.getStorageSync('accessToken');
if (accessToken) {
config.header['Blade-Auth'] = 'bearer ' + accessToken;
}
// 客户端认证参数
config.header['Authorization'] = 'Basic ' + Base64.encode(clientId + ':' + clientSecret);
// #ifndef H5
let url = config.url
if (process.env.NODE_ENV == 'development' && !url.startsWith("http")) {
// url = url.substring(url.indexOf('/api') + 4)
config.url = url
}
// #endif

// 额外参数
// config.data = config.data || {};
// config.data.pf = uni.getSystemInfoSync().platform;
// config.data.sys = uni.getSystemInfoSync().system;

// 演示custom 用处
// if (config.custom.auth) {
// config.header.token = 'token'
// }
// if (config.custom.loading) {
// uni.showLoading()
// }
/**
/* 演示
if (!token) { // 如果token不存在,return Promise.reject(config) 会取消本次请求
return Promise.reject(config)
}
**/
return config
}, config => { // 可使用async await 做异步操作
return Promise.reject(config)
})
http.interceptors.response.use((response) => {
// 若有数据返回则通过
if (response.data.access_token || response.data.key) {
return response.data
}
// 服务端返回的状态码不等于200,则reject()
if (response.data.code && response.data.code !== 200) {
setTimeout(()=>{
uni.showToast({
title: response.data.msg,
icon: 'none'
});
})
return Promise.reject(response);
}
return response.data;
}, (response) => {
/* 对响应错误做点什么 (statusCode !== 200)*/
setTimeout(()=>{
uni.showToast({
title: response.data.msg || response.data.error_description || '网络错误',
icon: 'none'
});
})
if (response.statusCode == 401) {
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
uni.redirectTo({
url: `/pages/login/login?redirect=/${currentPage.route}`
})
}
return Promise.reject(response)
})
export default http;

+ 49
- 0
monitorMobile/http/config.js Voir le fichier

@@ -0,0 +1,49 @@
import {
devUrl,
prodUrl,
contentType
} from '@/common/setting'
console.log('--',process.env.NODE_ENV)
var options = {
baseURL: process.env.NODE_ENV === 'development' ? devUrl : prodUrl,
header: {
'Content-Type': contentType
},
method: 'POST',
dataType: 'json',
// #ifndef MP-ALIPAY || APP-PLUS
responseType: 'text',
// #endif
// 注:如果局部custom与全局custom有同名属性,则后面的属性会覆盖前面的属性,相当于Object.assign(全局,局部)
custom: {}, // 全局自定义参数默认值
// #ifdef MP-ALIPAY || MP-WEIXIN
timeout: 30000,
// #endif
// #ifdef APP-PLUS
sslVerify: true,
// #endif
// #ifdef H5
// 跨域请求时是否携带凭证(cookies)仅H5支持(HBuilderX 2.6.15+)
//withCredentials: false,
// #endif
// #ifdef APP-PLUS
firstIpv4: false, // DNS解析时优先使用ipv4 仅 App-Android 支持 (HBuilderX 2.8.0+)
// #endif
// 局部优先级高于全局,返回当前请求的task,options。请勿在此处修改options。非必填
// getTask: (task, options) => {
// 相当于设置了请求超时时间500ms
// setTimeout(() => {
// task.abort()
// }, 500)
// },
// 全局自定义验证器。参数为statusCode 且必存在,不用判断空情况。
// validateStatus: (statusCode) => { // statusCode 必存在。此处示例为全局默认配置
// return statusCode >= 200 && statusCode < 300
// }
// 预览地址
// previewUrl: 'https://www.bjjyp.org.cn/preview/onlinePreview',
// previewUrl: 'http://114.255.136.189:6696/onlinePreview',
// previewUrl: 'http://192.168.100.236:85/onlinePreview',
previewUrl: 'http://cp.qjkjedu.com/onlinePreview',
};
export { options };

+ 18
- 0
monitorMobile/http/install.js Voir le fichier

@@ -0,0 +1,18 @@
// 获取api目录所有js文件
const files = require.context('@/api', false, /\.js$/)
// 此处第二个参数vm,就是我们在页面使用的this,可以通过vm获取vuex等操作
const install = (Vue, vm) => {
// 将各个定义的接口名称,统一放进对象挂载到vm.$u.api下(因为vm就是this,也即this.$u.api)
// 自动将所有api挂载到vm.$u.api中
vm.$u.api = {}
files.keys().forEach(key => {
const api = files(key).default
for (let item in api) {
vm.$u.api[item] = api[item]
}
})
}

export default {
install
}

+ 20
- 0
monitorMobile/index.html Voir le fichier

@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script>
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
CSS.supports('top: constant(a)'))
document.write(
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
</script>
<title></title>
<!--preload-links-->
<!--app-context-->
</head>
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main.js"></script>
</body>
</html>

+ 46
- 0
monitorMobile/main.js Voir le fichier

@@ -0,0 +1,46 @@
import App from './App'
import Vue from 'vue'
import store from '@/store';
import mixins from '@/common/mixins.vue'

Vue.mixin(mixins)

// 引入vuex
Vue.prototype.$u = {}
const vuexStore = require("@/store/$u.mixin.js");
Vue.mixin(vuexStore);

// 引入uview-ui
import uView from "uview-ui";
Vue.use(uView);

// #ifndef VUE3
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
return {
app
}
}
// #endif

// 接口集中管理
import httpInstall from '@/http/install.js'
Vue.use(httpInstall, app)

import http from '@/http/api.js'
Vue.prototype.$http = http

// 公共函数
import globalFunc from '@/utils/func.js'
Vue.use(globalFunc, app);

+ 72
- 0
monitorMobile/manifest.json Voir le fichier

@@ -0,0 +1,72 @@
{
"name" : "monitorMobile",
"appid" : "",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {
"usingComponents" : true,
"nvueStyleCompiler" : "uni-app",
"compilerVersion" : 3,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
/* 模块配置 */
"modules" : {},
/* 应用发布信息 */
"distribute" : {
/* android打包配置 */
"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\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios打包配置 */
"ios" : {},
/* SDK配置 */
"sdkConfigs" : {}
}
},
/* 快应用特有相关 */
"quickapp" : {},
/* 小程序特有相关 */
"mp-weixin" : {
"appid" : "",
"setting" : {
"urlCheck" : false
},
"usingComponents" : true
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "2"
}

+ 1416
- 0
monitorMobile/package-lock.json
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


+ 10
- 0
monitorMobile/package.json Voir le fichier

@@ -0,0 +1,10 @@
{
"dependencies": {
"uview-ui": "^2.0.36",
"vuex": "^3.6.2"
},
"devDependencies": {
"sass": "^1.77.8",
"sass-loader": "^10.5.2"
}
}

+ 93
- 0
monitorMobile/pages.json Voir le fichier

@@ -0,0 +1,93 @@
{
"easycom": {
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
},
"tabBar":{
"color":"#777777",
"selectedColor":"#2388FF",
"backgroundColor":"#FFFFFF",
"borderStyle":"white",
"fontSize":"18rpx",
"list": [
{
"pagePath": "pages/home",
"iconPath": "/static/image/tabbar/home.png",
"selectedIconPath": "/static/image/tabbar/home.png",
"text": "首页"
},
{
"pagePath": "pages/attendanceCall/index",
"iconPath": "/static/image/tabbar/attendanceCall.png",
"selectedIconPath": "/static/image/tabbar/attendanceCall.png",
"text": "考勤点名"
},
{
"pagePath": "pages/earlyWarning/index",
"iconPath": "/static/image/tabbar/earlyWarning_active.png",
"selectedIconPath": "/static/image/tabbar/earlyWarning_active.png",
"text": "预警巡警"
},
{
"pagePath": "pages/my/index",
"iconPath": "/static/image/tabbar/my.png",
"selectedIconPath": "/static/image/tabbar/my.png",
"text": "我的"
}
]
},
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
// 首页
{
"path": "pages/home",
"style": {
"navigationBarTitleText": "首页"
}
},
// 考勤点名
{
"path": "pages/attendanceCall/index",
"style": {
"navigationBarTitleText": "考勤点名"
}
},
// {
// "path": "pages/attendanceCall/rollCall/index",
// "style": {
// "navigationBarTitleText": "点名"
// }
// },
// {
// "path": "pages/attendanceCall/returnBed/index",
// "style": {
// "navigationBarTitleText": "归寝"
// }
// },
// {
// "path": "pages/attendanceCall/passengerFlow/index",
// "style": {
// "navigationBarTitleText": "客流"
// }
// },
// 预警巡警
{
"path": "pages/earlyWarning/index",
"style": {
"navigationBarTitleText": "预警巡警"
}
},
// 我的
{
"path": "pages/my/index",
"style": {
"navigationBarTitleText": "我的"
}
}
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "校园监控预警平台",
"navigationBarBackgroundColor": "#fff",
"backgroundColor": "#F8F8F8"
},
"uniIdRouter": {}
}

+ 48
- 0
monitorMobile/pages/attendanceCall/index.vue Voir le fichier

@@ -0,0 +1,48 @@
<template>
<view style="height: 100%;">
<u-tabs :list="tabsList" @click="tabsClick" :activeStyle="{
color: '#000000',
}" itemStyle="height:84rpx;width:33.33%;box-sizing:border-box;background:#fff;border-top:1rpx solid rgba(0,0,0,0.03)"></u-tabs>
<view style="height: calc(100% - 84rpx);">
<component :is="componentName"/>
</view>
</view>
</template>

<script>
import passengerFlow from "./passengerFlow/index.vue"
import returnBed from "./returnBed/index.vue"
import rollCall from "./rollCall/index.vue"
export default {
components:{
passengerFlow,returnBed,rollCall
},
data() {
return {
tabsList: [{
name: "点名",
value: 'rollCall'
},
{
name: "归寝",
value: 'returnBed'
},
{
name: "客流",
value: 'passengerFlow'
},
],
componentName:'rollCall'
}
},
methods: {
tabsClick(item) {
this.componentName = item.value
}
}
}
</script>

<style>

</style>

+ 22
- 0
monitorMobile/pages/attendanceCall/passengerFlow/index.vue Voir le fichier

@@ -0,0 +1,22 @@
<template>
<view>
客流
</view>
</template>

<script>
export default {
data() {
return {
}
},
methods: {
},
}
</script>

<style>

</style>

+ 124
- 0
monitorMobile/pages/attendanceCall/returnBed/index.vue Voir le fichier

@@ -0,0 +1,124 @@
<template>
<view style="height: 100%;">
<u-empty marginTop="100rpx" :show="false" mode="list" text="暂无数据"></u-empty>
<u-list @scrolltolower="scrolltolower" style="height: calc(100% - 0rpx);">
<u-list-item v-for="(item, index) in list" :key="index">
<view class="whiteCard">
<view class="row1">
<text class="room">寝室302</text>
<view class="peopleNum">
<image src="@/static/image/peopleNum.png" mode=""></image>
<text>寝室人数:6</text>
</view>
</view>
<view class="row2">
<text class="returnNum">归寝人数:4</text>
<text class="noReturnNum">未归寝人数:2</text>
</view>
<view class="bottom">
<view class="returnConfirm">
<image src="@/static/image/confirm.png" mode=""></image>
<text>归寝确认</text>
</view>
</view>
</view>
</u-list-item>
<u-loadmore :status="status" />
</u-list>
</view>
</template>

<script>
export default {
data() {
return {
list: [{},{},{},{},{},{},{},{},{},],
isLoading:false,
status:'loadmore',//loading正在加载 loadmore加载更多 nomore没有更多了
}
},
methods: {
scrolltolower() {
this.loadmore()
},
loadmore() {
if(this.status != 'loadmore')return
this.status = 'loading'
setTimeout(()=>{
for (let i = 0; i < 1; i++) {
this.list.push({},{})
}
// 获取到的总条数>=接口总条数
if(this.list.length>=14){
this.status = 'nomore'
}else{
this.status = 'loadmore'
}
},2000)
}
},
onLoad() {
this.loadmore()
},
}
</script>

<style lang="scss" scoped>
.whiteCard{
background-color: #fff;
border-radius: 18rpx;
margin: 12rpx 28rpx;
padding: 30rpx;
color: #333333;
.row1{
display: flex;
justify-content: space-between;
.room{
font-size: 34rpx;
}
.peopleNum{
uni-image{
width: 34rpx;
height: 34rpx;
position: relative;
top: 6rpx;
margin-right: 6rpx;
}
uni-text{
color: #2388FF;
font-size: 30rpx;
}
}
}
.row2{
margin-top: 18rpx;
display: flex;
justify-content: space-between;
font-size: 30rpx;
.returnNum{
}
.noReturnNum{
}
}
.bottom{
display: flex;
justify-content: center;
align-items: center;
border-top: 1rpx solid rgba(0, 0, 0, 0.1);
margin-top: 24rpx;
padding-top: 22rpx;
.returnConfirm{
uni-image{
width: 34rpx;
height: 34rpx;
position: relative;
top: 6rpx;
margin-right: 6rpx;
}
uni-text{
font-size: 30rpx;
}
}
}
}
</style>

+ 22
- 0
monitorMobile/pages/attendanceCall/rollCall/index.vue Voir le fichier

@@ -0,0 +1,22 @@
<template>
<view>
点名
</view>
</template>

<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>

<style>

</style>

+ 22
- 0
monitorMobile/pages/earlyWarning/index.vue Voir le fichier

@@ -0,0 +1,22 @@
<template>
<view>
预警巡警
</view>
</template>

<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>

<style>

</style>

+ 21
- 0
monitorMobile/pages/home.vue Voir le fichier

@@ -0,0 +1,21 @@
<template>
<view>
首页
</view>
</template>

<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>

<style lang="scss" scoped>
</style>
<style>
</style>

+ 22
- 0
monitorMobile/pages/my/index.vue Voir le fichier

@@ -0,0 +1,22 @@
<template>
<view>
我的
</view>
</template>

<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>

<style>

</style>

BIN
monitorMobile/static/image/confirm.png Voir le fichier

Avant Après
Largeur: 68  |  Hauteur: 68  |  Taille: 1.0 KiB

BIN
monitorMobile/static/image/peopleNum.png Voir le fichier

Avant Après
Largeur: 68  |  Hauteur: 68  |  Taille: 1.3 KiB

BIN
monitorMobile/static/image/tabbar/attendanceCall.png Voir le fichier

Avant Après
Largeur: 80  |  Hauteur: 80  |  Taille: 1.2 KiB

BIN
monitorMobile/static/image/tabbar/earlyWarning_active.png Voir le fichier

Avant Après
Largeur: 80  |  Hauteur: 80  |  Taille: 1.2 KiB

BIN
monitorMobile/static/image/tabbar/home.png Voir le fichier

Avant Après
Largeur: 80  |  Hauteur: 80  |  Taille: 926 B

BIN
monitorMobile/static/image/tabbar/my.png Voir le fichier

Avant Après
Largeur: 80  |  Hauteur: 80  |  Taille: 1001 B

+ 30
- 0
monitorMobile/store/$u.mixin.js Voir le fichier

@@ -0,0 +1,30 @@
// $u.mixin.js

import { mapState } from 'vuex'
import store from "@/store"

// 尝试将用户在根目录中的store/index.js的vuex的state变量,全部加载到全局变量中
let $uStoreKey = [];
try {
$uStoreKey = store.state ? Object.keys(store.state) : [];
} catch (e) {

}

module.exports = {
mounted() {
// 将vuex方法挂在到$u中
// 使用方法为:如果要修改vuex的state中的user.name变量为"史诗" => this.$u.vuex('user.name', '史诗')
// 如果要修改vuex的state的version变量为1.0.1 => this.$u.vue x('version', '1.0.1')
this.$u.vuex = (name, value) => {
this.$store.commit('$uStore', {
name,
value
})
}
},
computed: {
// 将vuex的state中的所有变量,解构到全局混入的mixin中
...mapState($uStoreKey)
}
}

+ 75
- 0
monitorMobile/store/index.js Voir le fichier

@@ -0,0 +1,75 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

let lifeData = {};

try {
// 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
lifeData = uni.getStorageSync('lifeData');
} catch (e) {

}

// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
let saveStateKeys = [];

// 保存变量到本地存储中
const saveLifeData = function(key, value) {
// 判断变量名是否在需要存储的数组中
if (saveStateKeys.indexOf(key) != -1) {
// 获取本地存储的lifeData对象,将变量添加到对象中
let tmp = uni.getStorageSync('lifeData');
// 第一次打开APP,不存在lifeData变量,故放一个{}空对象
tmp = tmp ? tmp : {};
tmp[key] = value;
// 执行这一步后,所有需要存储的变量,都挂载在本地的lifeData对象中
uni.setStorageSync(key, value);
uni.setStorageSync('lifeData', tmp);
}
if(key == 'refreshToken') {
uni.setStorageSync('token', {
content: value,
datetime: new Date().getTime()
})
}
}
const store = new Vuex.Store({
// 下面这些值仅为示例,使用过程中请删除
state: {
// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
userInfo: lifeData.userInfo ? lifeData.userInfo : {
avatar: '',
nick_name: '游客',
tenant_id: '暂无'
},
accessToken: lifeData.accessToken ? lifeData.accessToken : '',
isLogin: lifeData.isLogin ? lifeData.isLogin : false,
// 如果version无需保存到本地永久存储,无需lifeData.version方式
version: '1.0.0',
},
mutations: {
$uStore(state, payload) {
// 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1
let nameArr = payload.name.split('.');
let saveKey = '';
let len = nameArr.length;
if (nameArr.length >= 2) {
let obj = state[nameArr[0]];
for (let i = 1; i < len - 1; i++) {
obj = obj[nameArr[i]];
}
obj[nameArr[len - 1]] = payload.value;
saveKey = nameArr[0];
} else {
// 单层级变量,在state就是一个普通变量的情况
state[payload.name] = payload.value;
saveKey = payload.name;
}
// 保存变量到本地,见顶部函数定义
saveLifeData(saveKey, state[saveKey])
}
}
})

export default store

+ 10
- 0
monitorMobile/uni.promisify.adaptor.js Voir le fichier

@@ -0,0 +1,10 @@
uni.addInterceptor({
returnValue (res) {
if (!(!!res && (typeof res === "object" || typeof res === "function") && typeof res.then === "function")) {
return res;
}
return new Promise((resolve, reject) => {
res.then((res) => res[0] ? reject(res[0]) : resolve(res[1]));
});
},
});

+ 78
- 0
monitorMobile/uni.scss Voir le fichier

@@ -0,0 +1,78 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
*
*/

/**
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/

/* 颜色变量 */

/* 行为相关颜色 */
$uni-color-primary: #007aff;
$uni-color-success: #4cd964;
$uni-color-warning: #f0ad4e;
$uni-color-error: #dd524d;

/* 文字基本颜色 */
$uni-text-color:#333;//基本色
$uni-text-color-inverse:#fff;//反色
$uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息
$uni-text-color-placeholder: #808080;
$uni-text-color-disable:#c0c0c0;

/* 背景颜色 */
$uni-bg-color:#ffffff;
$uni-bg-color-grey:#f8f8f8;
$uni-bg-color-hover:#f1f1f1;//点击状态颜色
$uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色

/* 边框颜色 */
$uni-border-color:#c8c7cc;

/* 尺寸变量 */

/* 文字尺寸 */
$uni-font-size-sm:12px;
$uni-font-size-base:14px;
$uni-font-size-lg:16;

/* 图片尺寸 */
$uni-img-size-sm:20px;
$uni-img-size-base:26px;
$uni-img-size-lg:40px;

/* Border Radius */
$uni-border-radius-sm: 2px;
$uni-border-radius-base: 3px;
$uni-border-radius-lg: 6px;
$uni-border-radius-circle: 50%;

/* 水平间距 */
$uni-spacing-row-sm: 5px;
$uni-spacing-row-base: 10px;
$uni-spacing-row-lg: 15px;

/* 垂直间距 */
$uni-spacing-col-sm: 4px;
$uni-spacing-col-base: 8px;
$uni-spacing-col-lg: 12px;

/* 透明度 */
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度

/* 文章场景相关 */
$uni-color-title: #2C405A; // 文章标题颜色
$uni-font-size-title:20px;
$uni-color-subtitle: #555555; // 二级标题颜色
$uni-font-size-subtitle:26px;
$uni-color-paragraph: #3F536E; // 文章段落颜色
$uni-font-size-paragraph:15px;

@import 'uview-ui/theme.scss';

+ 235
- 0
monitorMobile/utils/base64.js Voir le fichier

@@ -0,0 +1,235 @@
/*
* base64.js
*
* Licensed under the BSD 3-Clause License.
* http://opensource.org/licenses/BSD-3-Clause
*
* References:
* http://en.wikipedia.org/wiki/Base64
*/
;(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined'
? module.exports = factory(global)
: typeof define === 'function' && define.amd
? define(factory) : factory(global)
}((
typeof self !== 'undefined' ? self
: typeof window !== 'undefined' ? window
: typeof global !== 'undefined' ? global
: this
), function(global) {
'use strict';
// existing version for noConflict()
global = global || {};
var _Base64 = global.Base64;
var version = "2.5.1";
// if node.js and NOT React Native, we use Buffer
var buffer;
if (typeof module !== 'undefined' && module.exports) {
try {
buffer = eval("require('buffer').Buffer");
} catch (err) {
buffer = undefined;
}
}
// constants
var b64chars
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var b64tab = function(bin) {
var t = {};
for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
return t;
}(b64chars);
var fromCharCode = String.fromCharCode;
// encoder stuff
var cb_utob = function(c) {
if (c.length < 2) {
var cc = c.charCodeAt(0);
return cc < 0x80 ? c
: cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
+ fromCharCode(0x80 | (cc & 0x3f)))
: (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))
+ fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
+ fromCharCode(0x80 | ( cc & 0x3f)));
} else {
var cc = 0x10000
+ (c.charCodeAt(0) - 0xD800) * 0x400
+ (c.charCodeAt(1) - 0xDC00);
return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
+ fromCharCode(0x80 | ((cc >>> 12) & 0x3f))
+ fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
+ fromCharCode(0x80 | ( cc & 0x3f)));
}
};
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
var utob = function(u) {
return u.replace(re_utob, cb_utob);
};
var cb_encode = function(ccc) {
var padlen = [0, 2, 1][ccc.length % 3],
ord = ccc.charCodeAt(0) << 16
| ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
| ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)),
chars = [
b64chars.charAt( ord >>> 18),
b64chars.charAt((ord >>> 12) & 63),
padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
];
return chars.join('');
};
var btoa = global.btoa ? function(b) {
return global.btoa(b);
} : function(b) {
return b.replace(/[\s\S]{1,3}/g, cb_encode);
};
var _encode = buffer ?
buffer.from && Uint8Array && buffer.from !== Uint8Array.from
? function (u) {
return (u.constructor === buffer.constructor ? u : buffer.from(u))
.toString('base64')
}
: function (u) {
return (u.constructor === buffer.constructor ? u : new buffer(u))
.toString('base64')
}
: function (u) { return btoa(utob(u)) }
;
var encode = function(u, urisafe) {
return !urisafe
? _encode(String(u))
: _encode(String(u)).replace(/[+\/]/g, function(m0) {
return m0 == '+' ? '-' : '_';
}).replace(/=/g, '');
};
var encodeURI = function(u) { return encode(u, true) };
// decoder stuff
var re_btou = new RegExp([
'[\xC0-\xDF][\x80-\xBF]',
'[\xE0-\xEF][\x80-\xBF]{2}',
'[\xF0-\xF7][\x80-\xBF]{3}'
].join('|'), 'g');
var cb_btou = function(cccc) {
switch(cccc.length) {
case 4:
var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
| ((0x3f & cccc.charCodeAt(1)) << 12)
| ((0x3f & cccc.charCodeAt(2)) << 6)
| (0x3f & cccc.charCodeAt(3)),
offset = cp - 0x10000;
return (fromCharCode((offset >>> 10) + 0xD800)
+ fromCharCode((offset & 0x3FF) + 0xDC00));
case 3:
return fromCharCode(
((0x0f & cccc.charCodeAt(0)) << 12)
| ((0x3f & cccc.charCodeAt(1)) << 6)
| (0x3f & cccc.charCodeAt(2))
);
default:
return fromCharCode(
((0x1f & cccc.charCodeAt(0)) << 6)
| (0x3f & cccc.charCodeAt(1))
);
}
};
var btou = function(b) {
return b.replace(re_btou, cb_btou);
};
var cb_decode = function(cccc) {
var len = cccc.length,
padlen = len % 4,
n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)
| (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0)
| (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0)
| (len > 3 ? b64tab[cccc.charAt(3)] : 0),
chars = [
fromCharCode( n >>> 16),
fromCharCode((n >>> 8) & 0xff),
fromCharCode( n & 0xff)
];
chars.length -= [0, 0, 2, 1][padlen];
return chars.join('');
};
var _atob = global.atob ? function(a) {
return global.atob(a);
} : function(a){
return a.replace(/\S{1,4}/g, cb_decode);
};
var atob = function(a) {
return _atob(String(a).replace(/[^A-Za-z0-9\+\/]/g, ''));
};
var _decode = buffer ?
buffer.from && Uint8Array && buffer.from !== Uint8Array.from
? function(a) {
return (a.constructor === buffer.constructor
? a : buffer.from(a, 'base64')).toString();
}
: function(a) {
return (a.constructor === buffer.constructor
? a : new buffer(a, 'base64')).toString();
}
: function(a) { return btou(_atob(a)) };
var decode = function(a){
return _decode(
String(a).replace(/[-_]/g, function(m0) { return m0 == '-' ? '+' : '/' })
.replace(/[^A-Za-z0-9\+\/]/g, '')
);
};
var noConflict = function() {
var Base64 = global.Base64;
global.Base64 = _Base64;
return Base64;
};
// export Base64
global.Base64 = {
VERSION: version,
atob: atob,
btoa: btoa,
fromBase64: decode,
toBase64: encode,
utob: utob,
encode: encode,
encodeURI: encodeURI,
btou: btou,
decode: decode,
noConflict: noConflict,
__buffer__: buffer
};
// if ES5 is available, make Base64.extendString() available
if (typeof Object.defineProperty === 'function') {
var noEnum = function(v){
return {value:v,enumerable:false,writable:true,configurable:true};
};
global.Base64.extendString = function () {
Object.defineProperty(
String.prototype, 'fromBase64', noEnum(function () {
return decode(this)
}));
Object.defineProperty(
String.prototype, 'toBase64', noEnum(function (urisafe) {
return encode(this, urisafe)
}));
Object.defineProperty(
String.prototype, 'toBase64URI', noEnum(function () {
return encode(this, true)
}));
};
}
//
// export Base64 to the namespace
//
if (global['Meteor']) { // Meteor.js
Base64 = global.Base64;
}
// module.exports and AMD are mutually exclusive.
// module.exports has precedence.
if (typeof module !== 'undefined' && module.exports) {
module.exports.Base64 = global.Base64;
}
else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], function(){ return global.Base64 });
}
// that's it!
return {Base64: global.Base64}
}));

+ 51
- 0
monitorMobile/utils/date.js Voir le fichier

@@ -0,0 +1,51 @@
export const calcDate = (date1, date2) => {
let date3 = date2 - date1;

let days = Math.floor(date3 / (24 * 3600 * 1000))

let leave1 = date3 % (24 * 3600 * 1000) //计算天数后剩余的毫秒数
let hours = Math.floor(leave1 / (3600 * 1000))

let leave2 = leave1 % (3600 * 1000) //计算小时数后剩余的毫秒数
let minutes = Math.floor(leave2 / (60 * 1000))

let leave3 = leave2 % (60 * 1000) //计算分钟数后剩余的毫秒数
let seconds = Math.round(date3 / 1000)
return {
leave1,
leave2,
leave3,
days: days,
hours: hours,
minutes: minutes,
seconds: seconds,
}
}

/**
* 日期格式化
*/
export function dateFormat(date, format) {
format = format || 'yyyy-MM-dd hh:mm:ss';
if (date !== 'Invalid Date') {
let o = {
"M+": date.getMonth() + 1, //month
"d+": date.getDate(), //day
"h+": date.getHours(), //hour
"m+": date.getMinutes(), //minute
"s+": date.getSeconds(), //second
"q+": Math.floor((date.getMonth() + 3) / 3), //quarter
"S": date.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
(date.getFullYear() + "").substr(4 - RegExp.$1.length));
for (let k in o)
if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length === 1 ? o[k] :
("00" + o[k]).substr(("" + o[k]).length));
return format;
}
return '';

}

+ 178
- 0
monitorMobile/utils/func.js Voir le fichier

@@ -0,0 +1,178 @@
// 全局公共方法
const install = (Vue, vm) => {

// 登录操作
const login = (userInfo, redirect) => {
vm.$u.vuex('userInfo', userInfo)
vm.$u.vuex('accessToken', userInfo.access_token)
vm.$u.vuex('refreshToken', userInfo.refresh_token)
vm.$u.vuex('isLogin', true)
if(userInfo.user_type == 1) {
// 教师首页
if (redirect) {
uni.redirectTo({
url: redirect,
fail() {
uni.switchTab({
url: redirect
})
}
})
} else uni.redirectTo({
url: '/pages/home/index'
})
} else if(userInfo.user_type == 2) {
// 学生首页
if (redirect) {
uni.redirectTo({
url: redirect,
fail() {
uni.switchTab({
url: redirect
})
}
})
} else uni.navigateTo({
url: '/pages-student/home/index'
})
}
// if(userInfo)
// debugger
}

// 退出登录
const logout = (callback) => {
// vm.$u.vuex('userInfo', {
// avatar: '',
// nick_name: '游客',
// tenant_id: '暂无'
// })
// vm.$u.vuex('accessToken', '')
// vm.$u.vuex('isLogin', false)
// uni.redirectTo({
// url: '/pages/login/login'
// })
callback()
}

// 检查登录状态
const checkLogin = (e = {}) => {
if (!vm.isLogin) {
uni.navigateTo({
url: '/pages/login/login'
})
return false
}
return true
}

// 跳转路由前检查登录状态
const route = (url) => {
if (!vm.isLogin) {
uni.showToast({
title: '请先登录',
icon: 'none'
})
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
setTimeout(() => {
uni.navigateTo({
url: `/pages/login/login?redirect=/${currentPage.route}`
})
}, 500)
return false
}
uni.navigateTo({
url: url
})
}

// URL参数转对象
const paramsToObj = (url) => {
if (url.indexOf('?') != -1) {
let arr = url.split('?')[1]
}
let arr = url.split('&')
let obj = {}
for (let i of arr) {
obj[i.split('=')[0]] = i.split('=')[1]
}
return obj
}

// 刷新当前页面
const refreshPage = () => {
const pages = getCurrentPages()
const currentPage = pages[pages.length - 1]
const path = '/' + currentPage.route + vm.$u.queryParams(currentPage.options)
if (vm.$u.test.contains(currentPage.route, 'tabbar')) {
uni.reLaunch({
url: path,
fail: (err) => {
console.log(err)
}
})
} else {
uni.redirectTo({
url: path,
fail: (err) => {
console.log(err)
}
})
}
}

// 提示
const showToast = (data = {}) => {
if (typeof data == 'string') {
uni.showToast({
title: data,
icon: 'none'
})
} else {
uni.showToast({
title: data.title,
icon: data.icon || 'none',
image: data.image || '',
mask: data.mask || false,
position: data.position || 'center',
duration: data.duration || 1500,
success: () => {
setTimeout(() => {
if (data.back) return uni.navigateBack()
data.success && data.success()
}, data.duration || 1500)
}
})
}
}

// 刷新token
const refreshToken = (data) => {
return new Promise((resolve) => {
console.log('refreshTokenrefreshToken',data)
vm.$u.vuex('accessToken', data.access_token)
vm.$u.vuex('refreshToken', data.refresh_token)
resolve()
})
}

// 将定义的方法挂载,使用this.$u.func.xx调用
Vue.prototype.$u.func = {
login,
logout,
route,
checkLogin,
paramsToObj,
refreshPage,
showToast,
refreshToken
}
}
export default {
install
}

+ 99
- 0
monitorMobile/utils/luch-request/adapters/index.js Voir le fichier

@@ -0,0 +1,99 @@
import buildURL from '../helpers/buildURL'
import buildFullPath from '../core/buildFullPath'
import settle from '../core/settle'
import { isUndefined } from "../utils"

/**
* 返回可选值存在的配置
* @param {Array} keys - 可选值数组
* @param {Object} config2 - 配置
* @return {{}} - 存在的配置项
*/
const mergeKeys = (keys, config2) => {
let config = {}
keys.forEach(prop => {
if (!isUndefined(config2[prop])) {
config[prop] = config2[prop]
}
})
return config
}
export default (config) => {
return new Promise((resolve, reject) => {
let fullPath = buildURL(buildFullPath(config.baseURL, config.url), config.params)
const _config = {
url: fullPath,
header: config.header,
complete: (response) => {
config.fullPath = fullPath
response.config = config
try {
// 对可能字符串不是json 的情况容错
if (typeof response.data === 'string') {
response.data = JSON.parse(response.data)
}
// eslint-disable-next-line no-empty
} catch (e) {
}
settle(resolve, reject, response)
}
}
let requestTask
if (config.method === 'UPLOAD') {
delete _config.header['content-type']
delete _config.header['Content-Type']
let otherConfig = {
// #ifdef MP-ALIPAY
fileType: config.fileType,
// #endif
filePath: config.filePath,
name: config.name
}
const optionalKeys = [
// #ifdef APP-PLUS || H5
'files',
// #endif
// #ifdef H5
'file',
// #endif
// #ifdef H5 || APP-PLUS
'timeout',
// #endif
'formData'
]
requestTask = uni.uploadFile({..._config, ...otherConfig, ...mergeKeys(optionalKeys, config)})
} else if (config.method === 'DOWNLOAD') {
// #ifdef H5 || APP-PLUS
if (!isUndefined(config['timeout'])) {
_config['timeout'] = config['timeout']
}
// #endif
requestTask = uni.downloadFile(_config)
} else {
const optionalKeys = [
'data',
'method',
// #ifdef H5 || APP-PLUS || MP-ALIPAY || MP-WEIXIN
'timeout',
// #endif
'dataType',
// #ifndef MP-ALIPAY
'responseType',
// #endif
// #ifdef APP-PLUS
'sslVerify',
// #endif
// #ifdef H5
'withCredentials',
// #endif
// #ifdef APP-PLUS
'firstIpv4',
// #endif
]
requestTask = uni.request({..._config,...mergeKeys(optionalKeys, config)})
}
if (config.getTask) {
config.getTask(requestTask, config)
}
})
}

+ 51
- 0
monitorMobile/utils/luch-request/core/InterceptorManager.js Voir le fichier

@@ -0,0 +1,51 @@
'use strict'


function InterceptorManager() {
this.handlers = []
}

/**
* Add a new interceptor to the stack
*
* @param {Function} fulfilled The function to handle `then` for a `Promise`
* @param {Function} rejected The function to handle `reject` for a `Promise`
*
* @return {Number} An ID used to remove interceptor later
*/
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
this.handlers.push({
fulfilled: fulfilled,
rejected: rejected
})
return this.handlers.length - 1
}

/**
* Remove an interceptor from the stack
*
* @param {Number} id The ID that was returned by `use`
*/
InterceptorManager.prototype.eject = function eject(id) {
if (this.handlers[id]) {
this.handlers[id] = null
}
}

/**
* Iterate over all the registered interceptors
*
* This method is particularly useful for skipping over any
* interceptors that may have become `null` calling `eject`.
*
* @param {Function} fn The function to call for each interceptor
*/
InterceptorManager.prototype.forEach = function forEach(fn) {
this.handlers.forEach(h => {
if (h !== null) {
fn(h)
}
})
}

export default InterceptorManager

+ 199
- 0
monitorMobile/utils/luch-request/core/Request.js Voir le fichier

@@ -0,0 +1,199 @@
/**
* @Class Request
* @description luch-request http请求插件
* @version 3.0.6
* @Author lu-ch
* @Date 2021-05-10
* @Email webwork.s@qq.com
* 文档: https://www.quanzhan.co/luch-request/
* github: https://github.com/lei-mu/luch-request
* DCloud: http://ext.dcloud.net.cn/plugin?id=392
* HBuilderX: beat-3.0.4 alpha-3.0.4
*/


import dispatchRequest from './dispatchRequest'
import InterceptorManager from './InterceptorManager'
import mergeConfig from './mergeConfig'
import defaults from './defaults'
import { isPlainObject } from '../utils'

export default class Request {
/**
* @param {Object} arg - 全局配置
* @param {String} arg.baseURL - 全局根路径
* @param {Object} arg.header - 全局header
* @param {String} arg.method = [GET|POST|PUT|DELETE|CONNECT|HEAD|OPTIONS|TRACE] - 全局默认请求方式
* @param {String} arg.dataType = [json] - 全局默认的dataType
* @param {String} arg.responseType = [text|arraybuffer] - 全局默认的responseType。支付宝小程序不支持
* @param {Object} arg.custom - 全局默认的自定义参数
* @param {Number} arg.timeout - 全局默认的超时时间,单位 ms。默认60000。H5(HBuilderX 2.9.9+)、APP(HBuilderX 2.9.9+)、微信小程序(2.10.0)、支付宝小程序
* @param {Boolean} arg.sslVerify - 全局默认的是否验证 ssl 证书。默认true.仅App安卓端支持(HBuilderX 2.3.3+)
* @param {Boolean} arg.withCredentials - 全局默认的跨域请求时是否携带凭证(cookies)。默认false。仅H5支持(HBuilderX 2.6.15+)
* @param {Boolean} arg.firstIpv4 - 全DNS解析时优先使用ipv4。默认false。仅 App-Android 支持 (HBuilderX 2.8.0+)
* @param {Function(statusCode):Boolean} arg.validateStatus - 全局默认的自定义验证器。默认statusCode >= 200 && statusCode < 300
*/
constructor(arg = {}) {
if (!isPlainObject(arg)) {
arg = {}
console.warn('设置全局参数必须接收一个Object')
}
this.config = {...defaults, ...arg}
this.interceptors = {
request: new InterceptorManager(),
response: new InterceptorManager()
}
}

/**
* @Function
* @param {Request~setConfigCallback} f - 设置全局默认配置
*/
setConfig(f) {
this.config = f(this.config)
}

middleware(config) {
config = mergeConfig(this.config, config)
let chain = [dispatchRequest, undefined]
let promise = Promise.resolve(config)

this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
chain.unshift(interceptor.fulfilled, interceptor.rejected)
})

this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
chain.push(interceptor.fulfilled, interceptor.rejected)
})

while (chain.length) {
promise = promise.then(chain.shift(), chain.shift())
}

return promise
}

/**
* @Function
* @param {Object} config - 请求配置项
* @prop {String} options.url - 请求路径
* @prop {Object} options.data - 请求参数
* @prop {Object} [options.responseType = config.responseType] [text|arraybuffer] - 响应的数据类型
* @prop {Object} [options.dataType = config.dataType] - 如果设为 json,会尝试对返回的数据做一次 JSON.parse
* @prop {Object} [options.header = config.header] - 请求header
* @prop {Object} [options.method = config.method] - 请求方法
* @returns {Promise<unknown>}
*/
request(config = {}) {
return this.middleware(config)
}

get(url, options = {}) {
return this.middleware({
url,
method: 'GET',
...options
})
}

post(url, data, options = {}) {
return this.middleware({
url,
data,
method: 'POST',
...options
})
}

// #ifndef MP-ALIPAY
put(url, data, options = {}) {
return this.middleware({
url,
data,
method: 'PUT',
...options
})
}

// #endif

// #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-BAIDU
delete(url, data, options = {}) {
return this.middleware({
url,
data,
method: 'DELETE',
...options
})
}

// #endif

// #ifdef H5 || MP-WEIXIN
connect(url, data, options = {}) {
return this.middleware({
url,
data,
method: 'CONNECT',
...options
})
}

// #endif

// #ifdef H5 || MP-WEIXIN || MP-BAIDU
head(url, data, options = {}) {
return this.middleware({
url,
data,
method: 'HEAD',
...options
})
}

// #endif

// #ifdef APP-PLUS || H5 || MP-WEIXIN || MP-BAIDU
options(url, data, options = {}) {
return this.middleware({
url,
data,
method: 'OPTIONS',
...options
})
}

// #endif

// #ifdef H5 || MP-WEIXIN
trace(url, data, options = {}) {
return this.middleware({
url,
data,
method: 'TRACE',
...options
})
}

// #endif

upload(url, config = {}) {
config.url = url
config.method = 'UPLOAD'
return this.middleware(config)
}

download(url, config = {}) {
config.url = url
config.method = 'DOWNLOAD'
return this.middleware(config)
}
}


/**
* setConfig回调
* @return {Object} - 返回操作后的config
* @callback Request~setConfigCallback
* @param {Object} config - 全局默认config
*/

+ 20
- 0
monitorMobile/utils/luch-request/core/buildFullPath.js Voir le fichier

@@ -0,0 +1,20 @@
'use strict'

import isAbsoluteURL from '../helpers/isAbsoluteURL'
import combineURLs from '../helpers/combineURLs'

/**
* Creates a new URL by combining the baseURL with the requestedURL,
* only when the requestedURL is not already an absolute URL.
* If the requestURL is absolute, this function returns the requestedURL untouched.
*
* @param {string} baseURL The base URL
* @param {string} requestedURL Absolute or relative URL to combine
* @returns {string} The combined full path
*/
export default function buildFullPath(baseURL, requestedURL) {
if (baseURL && !isAbsoluteURL(requestedURL)) {
return combineURLs(baseURL, requestedURL)
}
return requestedURL
}

+ 30
- 0
monitorMobile/utils/luch-request/core/defaults.js Voir le fichier

@@ -0,0 +1,30 @@
/**
* 默认的全局配置
*/


export default {
baseURL: '',
header: {},
method: 'GET',
dataType: 'json',
// #ifndef MP-ALIPAY
responseType: 'text',
// #endif
custom: {},
// #ifdef H5 || APP-PLUS || MP-ALIPAY || MP-WEIXIN
timeout: 60000,
// #endif
// #ifdef APP-PLUS
sslVerify: true,
// #endif
// #ifdef H5
withCredentials: false,
// #endif
// #ifdef APP-PLUS
firstIpv4: false,
// #endif
validateStatus: function validateStatus(status) {
return status >= 200 && status < 300
}
}

+ 6
- 0
monitorMobile/utils/luch-request/core/dispatchRequest.js Voir le fichier

@@ -0,0 +1,6 @@
import adapter from '../adapters/index'


export default (config) => {
return adapter(config)
}

+ 103
- 0
monitorMobile/utils/luch-request/core/mergeConfig.js Voir le fichier

@@ -0,0 +1,103 @@
import {deepMerge, isUndefined} from '../utils'

/**
* 合并局部配置优先的配置,如果局部有该配置项则用局部,如果全局有该配置项则用全局
* @param {Array} keys - 配置项
* @param {Object} globalsConfig - 当前的全局配置
* @param {Object} config2 - 局部配置
* @return {{}}
*/
const mergeKeys = (keys, globalsConfig, config2) => {
let config = {}
keys.forEach(prop => {
if (!isUndefined(config2[prop])) {
config[prop] = config2[prop]
} else if (!isUndefined(globalsConfig[prop])) {
config[prop] = globalsConfig[prop]
}
})
return config
}
/**
*
* @param globalsConfig - 当前实例的全局配置
* @param config2 - 当前的局部配置
* @return - 合并后的配置
*/
export default (globalsConfig, config2 = {}) => {
const method = config2.method || globalsConfig.method || 'GET'
let config = {
baseURL: globalsConfig.baseURL || '',
method: method,
url: config2.url || '',
params: config2.params || {},
custom: {...(globalsConfig.custom || {}), ...(config2.custom || {})},
header: deepMerge(globalsConfig.header || {}, config2.header || {})
}
const defaultToConfig2Keys = ['getTask', 'validateStatus']
config = {...config, ...mergeKeys(defaultToConfig2Keys, globalsConfig, config2)}

// eslint-disable-next-line no-empty
if (method === 'DOWNLOAD') {
// #ifdef H5 || APP-PLUS
if (!isUndefined(config2.timeout)) {
config['timeout'] = config2['timeout']
} else if (!isUndefined(globalsConfig.timeout)) {
config['timeout'] = globalsConfig['timeout']
}
// #endif
} else if (method === 'UPLOAD') {
delete config.header['content-type']
delete config.header['Content-Type']
const uploadKeys = [
// #ifdef APP-PLUS || H5
'files',
// #endif
// #ifdef MP-ALIPAY
'fileType',
// #endif
// #ifdef H5
'file',
// #endif
'filePath',
'name',
// #ifdef H5 || APP-PLUS
'timeout',
// #endif
'formData',
]
uploadKeys.forEach(prop => {
if (!isUndefined(config2[prop])) {
config[prop] = config2[prop]
}
})
// #ifdef H5 || APP-PLUS
if (isUndefined(config.timeout) && !isUndefined(globalsConfig.timeout)) {
config['timeout'] = globalsConfig['timeout']
}
// #endif
} else {
const defaultsKeys = [
'data',
// #ifdef H5 || APP-PLUS || MP-ALIPAY || MP-WEIXIN
'timeout',
// #endif
'dataType',
// #ifndef MP-ALIPAY
'responseType',
// #endif
// #ifdef APP-PLUS
'sslVerify',
// #endif
// #ifdef H5
'withCredentials',
// #endif
// #ifdef APP-PLUS
'firstIpv4',
// #endif
]
config = {...config, ...mergeKeys(defaultsKeys, globalsConfig, config2)}
}

return config
}

+ 16
- 0
monitorMobile/utils/luch-request/core/settle.js Voir le fichier

@@ -0,0 +1,16 @@
/**
* Resolve or reject a Promise based on response status.
*
* @param {Function} resolve A function that resolves the promise.
* @param {Function} reject A function that rejects the promise.
* @param {object} response The response.
*/
export default function settle(resolve, reject, response) {
const validateStatus = response.config.validateStatus
const status = response.statusCode
if (status && (!validateStatus || validateStatus(status))) {
resolve(response)
} else {
reject(response)
}
}

+ 69
- 0
monitorMobile/utils/luch-request/helpers/buildURL.js Voir le fichier

@@ -0,0 +1,69 @@
'use strict'

import * as utils from './../utils'

function encode(val) {
return encodeURIComponent(val).
replace(/%40/gi, '@').
replace(/%3A/gi, ':').
replace(/%24/g, '$').
replace(/%2C/gi, ',').
replace(/%20/g, '+').
replace(/%5B/gi, '[').
replace(/%5D/gi, ']')
}

/**
* Build a URL by appending params to the end
*
* @param {string} url The base of the url (e.g., http://www.google.com)
* @param {object} [params] The params to be appended
* @returns {string} The formatted url
*/
export default function buildURL(url, params) {
/*eslint no-param-reassign:0*/
if (!params) {
return url
}

var serializedParams
if (utils.isURLSearchParams(params)) {
serializedParams = params.toString()
} else {
var parts = []

utils.forEach(params, function serialize(val, key) {
if (val === null || typeof val === 'undefined') {
return
}

if (utils.isArray(val)) {
key = key + '[]'
} else {
val = [val]
}

utils.forEach(val, function parseValue(v) {
if (utils.isDate(v)) {
v = v.toISOString()
} else if (utils.isObject(v)) {
v = JSON.stringify(v)
}
parts.push(encode(key) + '=' + encode(v))
})
})

serializedParams = parts.join('&')
}

if (serializedParams) {
var hashmarkIndex = url.indexOf('#')
if (hashmarkIndex !== -1) {
url = url.slice(0, hashmarkIndex)
}

url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams
}

return url
}

+ 14
- 0
monitorMobile/utils/luch-request/helpers/combineURLs.js Voir le fichier

@@ -0,0 +1,14 @@
'use strict'

/**
* Creates a new URL by combining the specified URLs
*
* @param {string} baseURL The base URL
* @param {string} relativeURL The relative URL
* @returns {string} The combined URL
*/
export default function combineURLs(baseURL, relativeURL) {
return relativeURL
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
: baseURL
}

+ 14
- 0
monitorMobile/utils/luch-request/helpers/isAbsoluteURL.js Voir le fichier

@@ -0,0 +1,14 @@
'use strict'

/**
* Determines whether the specified URL is absolute
*
* @param {string} url The URL to test
* @returns {boolean} True if the specified URL is absolute, otherwise false
*/
export default function isAbsoluteURL(url) {
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
// by any combination of letters, digits, plus, period, or hyphen.
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url)
}

+ 116
- 0
monitorMobile/utils/luch-request/index.d.ts Voir le fichier

@@ -0,0 +1,116 @@
type AnyObject = Record<string | number | symbol, any>
type HttpPromise<T> = Promise<HttpResponse<T>>;
type Tasks = UniApp.RequestTask | UniApp.UploadTask | UniApp.DownloadTask
export interface RequestTask {
abort: () => void;
offHeadersReceived: () => void;
onHeadersReceived: () => void;
}
export interface HttpRequestConfig<T = Tasks> {
/** 请求基地址 */
baseURL?: string;
/** 请求服务器接口地址 */
url?: string;

/** 请求查询参数,自动拼接为查询字符串 */
params?: AnyObject;
/** 请求体参数 */
data?: AnyObject;

/** 文件对应的 key */
name?: string;
/** HTTP 请求中其他额外的 form data */
formData?: AnyObject;
/** 要上传文件资源的路径。 */
filePath?: string;
/** 需要上传的文件列表。使用 files 时,filePath 和 name 不生效,App、H5( 2.6.15+) */
files?: Array<{
name?: string;
file?: File;
uri: string;
}>;
/** 要上传的文件对象,仅H5(2.6.15+)支持 */
file?: File;

/** 请求头信息 */
header?: AnyObject;
/** 请求方式 */
method?: "GET" | "POST" | "PUT" | "DELETE" | "CONNECT" | "HEAD" | "OPTIONS" | "TRACE" | "UPLOAD" | "DOWNLOAD";
/** 如果设为 json,会尝试对返回的数据做一次 JSON.parse */
dataType?: string;
/** 设置响应的数据类型,支付宝小程序不支持 */
responseType?: "text" | "arraybuffer";
/** 自定义参数 */
custom?: AnyObject;
/** 超时时间,仅微信小程序(2.10.0)、支付宝小程序支持 */
timeout?: number;
/** DNS解析时优先使用ipv4,仅 App-Android 支持 (HBuilderX 2.8.0+) */
firstIpv4?: boolean;
/** 验证 ssl 证书 仅5+App安卓端支持(HBuilderX 2.3.3+) */
sslVerify?: boolean;
/** 跨域请求时是否携带凭证(cookies)仅H5支持(HBuilderX 2.6.15+) */
withCredentials?: boolean;

/** 返回当前请求的task, options。请勿在此处修改options。 */
getTask?: (task: T, options: HttpRequestConfig<T>) => void;
/** 全局自定义验证器 */
validateStatus?: (statusCode: number) => boolean | void;
}
export interface HttpResponse<T = any> {
config: HttpRequestConfig;
statusCode: number;
cookies: Array<string>;
data: T;
errMsg: string;
header: AnyObject;
}
export interface HttpUploadResponse<T = any> {
config: HttpRequestConfig;
statusCode: number;
data: T;
errMsg: string;
}
export interface HttpDownloadResponse extends HttpResponse {
tempFilePath: string;
}
export interface HttpError {
config: HttpRequestConfig;
statusCode?: number;
cookies?: Array<string>;
data?: any;
errMsg: string;
header?: AnyObject;
}
export interface HttpInterceptorManager<V, E = V> {
use(
onFulfilled?: (config: V) => Promise<V> | V,
onRejected?: (config: E) => Promise<E> | E
): void;
eject(id: number): void;
}
export abstract class HttpRequestAbstract {
constructor(config?: HttpRequestConfig);
config: HttpRequestConfig;
interceptors: {
request: HttpInterceptorManager<HttpRequestConfig, HttpRequestConfig>;
response: HttpInterceptorManager<HttpResponse, HttpError>;
}
middleware<T = any>(config: HttpRequestConfig): HttpPromise<T>;
request<T = any>(config: HttpRequestConfig<UniApp.RequestTask>): HttpPromise<T>;
get<T = any>(url: string, config?: HttpRequestConfig<UniApp.RequestTask>): HttpPromise<T>;
upload<T = any>(url: string, config?: HttpRequestConfig<UniApp.UploadTask>): HttpPromise<T>;
delete<T = any>(url: string, data?: AnyObject, config?: HttpRequestConfig<UniApp.RequestTask>): HttpPromise<T>;
head<T = any>(url: string, data?: AnyObject, config?: HttpRequestConfig<UniApp.RequestTask>): HttpPromise<T>;
post<T = any>(url: string, data?: AnyObject, config?: HttpRequestConfig<UniApp.RequestTask>): HttpPromise<T>;
put<T = any>(url: string, data?: AnyObject, config?: HttpRequestConfig<UniApp.RequestTask>): HttpPromise<T>;
connect<T = any>(url: string, data?: AnyObject, config?: HttpRequestConfig<UniApp.RequestTask>): HttpPromise<T>;
options<T = any>(url: string, data?: AnyObject, config?: HttpRequestConfig<UniApp.RequestTask>): HttpPromise<T>;
trace<T = any>(url: string, data?: AnyObject, config?: HttpRequestConfig<UniApp.RequestTask>): HttpPromise<T>;

download(url: string, config?: HttpRequestConfig<UniApp.DownloadTask>): Promise<HttpDownloadResponse>;

setConfig(onSend: (config: HttpRequestConfig) => HttpRequestConfig): void;
}

declare class HttpRequest extends HttpRequestAbstract { }
export default HttpRequest;

+ 2
- 0
monitorMobile/utils/luch-request/index.js Voir le fichier

@@ -0,0 +1,2 @@
import Request from './core/Request'
export default Request

+ 135
- 0
monitorMobile/utils/luch-request/utils.js Voir le fichier

@@ -0,0 +1,135 @@
'use strict'

// utils is a library of generic helper functions non-specific to axios

var toString = Object.prototype.toString

/**
* Determine if a value is an Array
*
* @param {Object} val The value to test
* @returns {boolean} True if value is an Array, otherwise false
*/
export function isArray (val) {
return toString.call(val) === '[object Array]'
}


/**
* Determine if a value is an Object
*
* @param {Object} val The value to test
* @returns {boolean} True if value is an Object, otherwise false
*/
export function isObject (val) {
return val !== null && typeof val === 'object'
}

/**
* Determine if a value is a Date
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a Date, otherwise false
*/
export function isDate (val) {
return toString.call(val) === '[object Date]'
}

/**
* Determine if a value is a URLSearchParams object
*
* @param {Object} val The value to test
* @returns {boolean} True if value is a URLSearchParams object, otherwise false
*/
export function isURLSearchParams (val) {
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams
}


/**
* Iterate over an Array or an Object invoking a function for each item.
*
* If `obj` is an Array callback will be called passing
* the value, index, and complete array for each item.
*
* If 'obj' is an Object callback will be called passing
* the value, key, and complete object for each property.
*
* @param {Object|Array} obj The object to iterate
* @param {Function} fn The callback to invoke for each item
*/
export function forEach (obj, fn) {
// Don't bother if no value provided
if (obj === null || typeof obj === 'undefined') {
return
}

// Force an array if not already something iterable
if (typeof obj !== 'object') {
/*eslint no-param-reassign:0*/
obj = [obj]
}

if (isArray(obj)) {
// Iterate over array values
for (var i = 0, l = obj.length; i < l; i++) {
fn.call(null, obj[i], i, obj)
}
} else {
// Iterate over object keys
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
fn.call(null, obj[key], key, obj)
}
}
}
}

/**
* 是否为boolean 值
* @param val
* @returns {boolean}
*/
export function isBoolean(val) {
return typeof val === 'boolean'
}

/**
* 是否为真正的对象{} new Object
* @param {any} obj - 检测的对象
* @returns {boolean}
*/
export function isPlainObject(obj) {
return Object.prototype.toString.call(obj) === '[object Object]'
}



/**
* Function equal to merge with the difference being that no reference
* to original objects is kept.
*
* @see merge
* @param {Object} obj1 Object to merge
* @returns {Object} Result of all merge properties
*/
export function deepMerge(/* obj1, obj2, obj3, ... */) {
let result = {}
function assignValue(val, key) {
if (typeof result[key] === 'object' && typeof val === 'object') {
result[key] = deepMerge(result[key], val)
} else if (typeof val === 'object') {
result[key] = deepMerge({}, val)
} else {
result[key] = val
}
}
for (let i = 0, l = arguments.length; i < l; i++) {
forEach(arguments[i], assignValue)
}
return result
}

export function isUndefined (val) {
return typeof val === 'undefined'
}

+ 685
- 0
monitorMobile/utils/md5.js Voir le fichier

@@ -0,0 +1,685 @@
/**
* [js-md5]{@link https://github.com/emn178/js-md5}
*
* @namespace md5
* @version 0.7.3
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2017
* @license MIT
*/
(function () {
'use strict';

var ERROR = 'input is invalid type';
var WINDOW = typeof window === 'object';
var root = WINDOW ? window : {};
if (root.JS_MD5_NO_WINDOW) {
WINDOW = false;
}
var WEB_WORKER = !WINDOW && typeof self === 'object';
var NODE_JS = !root.JS_MD5_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
if (NODE_JS) {
root = global;
} else if (WEB_WORKER) {
root = self;
}
var COMMON_JS = !root.JS_MD5_NO_COMMON_JS && typeof module === 'object' && module.exports;
var AMD = typeof define === 'function' && define.amd;
var ARRAY_BUFFER = !root.JS_MD5_NO_ARRAY_BUFFER && typeof ArrayBuffer !== 'undefined';
var HEX_CHARS = '0123456789abcdef'.split('');
var EXTRA = [128, 32768, 8388608, -2147483648];
var SHIFT = [0, 8, 16, 24];
var OUTPUT_TYPES = ['hex', 'array', 'digest', 'buffer', 'arrayBuffer', 'base64'];
var BASE64_ENCODE_CHAR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');

var blocks = [], buffer8;
if (ARRAY_BUFFER) {
var buffer = new ArrayBuffer(68);
buffer8 = new Uint8Array(buffer);
blocks = new Uint32Array(buffer);
}

if (root.JS_MD5_NO_NODE_JS || !Array.isArray) {
Array.isArray = function (obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
};
}

if (ARRAY_BUFFER && (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
ArrayBuffer.isView = function (obj) {
return typeof obj === 'object' && obj.buffer && obj.buffer.constructor === ArrayBuffer;
};
}

/**
* @method hex
* @memberof md5
* @description Output hash as hex string
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
* @returns {String} Hex string
* @example
* md5.hex('The quick brown fox jumps over the lazy dog');
* // equal to
* md5('The quick brown fox jumps over the lazy dog');
*/
/**
* @method digest
* @memberof md5
* @description Output hash as bytes array
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
* @returns {Array} Bytes array
* @example
* md5.digest('The quick brown fox jumps over the lazy dog');
*/
/**
* @method array
* @memberof md5
* @description Output hash as bytes array
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
* @returns {Array} Bytes array
* @example
* md5.array('The quick brown fox jumps over the lazy dog');
*/
/**
* @method arrayBuffer
* @memberof md5
* @description Output hash as ArrayBuffer
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
* @returns {ArrayBuffer} ArrayBuffer
* @example
* md5.arrayBuffer('The quick brown fox jumps over the lazy dog');
*/
/**
* @method buffer
* @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
* @memberof md5
* @description Output hash as ArrayBuffer
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
* @returns {ArrayBuffer} ArrayBuffer
* @example
* md5.buffer('The quick brown fox jumps over the lazy dog');
*/
/**
* @method base64
* @memberof md5
* @description Output hash as base64 string
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
* @returns {String} base64 string
* @example
* md5.base64('The quick brown fox jumps over the lazy dog');
*/
var createOutputMethod = function (outputType) {
return function (message) {
return new Md5(true).update(message)[outputType]();
};
};

/**
* @method create
* @memberof md5
* @description Create Md5 object
* @returns {Md5} Md5 object.
* @example
* var hash = md5.create();
*/
/**
* @method update
* @memberof md5
* @description Create and update Md5 object
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
* @returns {Md5} Md5 object.
* @example
* var hash = md5.update('The quick brown fox jumps over the lazy dog');
* // equal to
* var hash = md5.create();
* hash.update('The quick brown fox jumps over the lazy dog');
*/
var createMethod = function () {
var method = createOutputMethod('hex');
if (NODE_JS) {
method = nodeWrap(method);
}
method.create = function () {
return new Md5();
};
method.update = function (message) {
return method.create().update(message);
};
for (var i = 0; i < OUTPUT_TYPES.length; ++i) {
var type = OUTPUT_TYPES[i];
method[type] = createOutputMethod(type);
}
return method;
};

var nodeWrap = function (method) {
var crypto = eval("require('crypto')");
var Buffer = eval("require('buffer').Buffer");
var nodeMethod = function (message) {
if (typeof message === 'string') {
return crypto.createHash('md5').update(message, 'utf8').digest('hex');
} else {
if (message === null || message === undefined) {
throw ERROR;
} else if (message.constructor === ArrayBuffer) {
message = new Uint8Array(message);
}
}
if (Array.isArray(message) || ArrayBuffer.isView(message) ||
message.constructor === Buffer) {
return crypto.createHash('md5').update(new Buffer(message)).digest('hex');
} else {
return method(message);
}
};
return nodeMethod;
};



/**
* Md5 class
* @class Md5
* @description This is internal class.
* @see {@link md5.create}
*/
function Md5(sharedMemory) {
if (sharedMemory) {
blocks[0] = blocks[16] = blocks[1] = blocks[2] = blocks[3] =
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
this.blocks = blocks;
this.buffer8 = buffer8;
} else {
if (ARRAY_BUFFER) {
var buffer = new ArrayBuffer(68);
this.buffer8 = new Uint8Array(buffer);
this.blocks = new Uint32Array(buffer);
} else {
this.blocks = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
}
}
this.h0 = this.h1 = this.h2 = this.h3 = this.start = this.bytes = this.hBytes = 0;
this.finalized = this.hashed = false;
this.first = true;
}

/**
* @method update
* @memberof Md5
* @instance
* @description Update hash
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
* @returns {Md5} Md5 object.
* @see {@link md5.update}
*/
Md5.prototype.update = function (message) {
if (this.finalized) {
return;
}

var notString, type = typeof message;
if (type !== 'string') {
if (type === 'object') {
if (message === null) {
throw ERROR;
} else if (ARRAY_BUFFER && message.constructor === ArrayBuffer) {
message = new Uint8Array(message);
} else if (!Array.isArray(message)) {
if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
throw ERROR;
}
}
} else {
throw ERROR;
}
notString = true;
}
var code, index = 0, i, length = message.length, blocks = this.blocks;
var buffer8 = this.buffer8;

while (index < length) {
if (this.hashed) {
this.hashed = false;
blocks[0] = blocks[16];
blocks[16] = blocks[1] = blocks[2] = blocks[3] =
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
}

if (notString) {
if (ARRAY_BUFFER) {
for (i = this.start; index < length && i < 64; ++index) {
buffer8[i++] = message[index];
}
} else {
for (i = this.start; index < length && i < 64; ++index) {
blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
}
}
} else {
if (ARRAY_BUFFER) {
for (i = this.start; index < length && i < 64; ++index) {
code = message.charCodeAt(index);
if (code < 0x80) {
buffer8[i++] = code;
} else if (code < 0x800) {
buffer8[i++] = 0xc0 | (code >> 6);
buffer8[i++] = 0x80 | (code & 0x3f);
} else if (code < 0xd800 || code >= 0xe000) {
buffer8[i++] = 0xe0 | (code >> 12);
buffer8[i++] = 0x80 | ((code >> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f);
} else {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
buffer8[i++] = 0xf0 | (code >> 18);
buffer8[i++] = 0x80 | ((code >> 12) & 0x3f);
buffer8[i++] = 0x80 | ((code >> 6) & 0x3f);
buffer8[i++] = 0x80 | (code & 0x3f);
}
}
} else {
for (i = this.start; index < length && i < 64; ++index) {
code = message.charCodeAt(index);
if (code < 0x80) {
blocks[i >> 2] |= code << SHIFT[i++ & 3];
} else if (code < 0x800) {
blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
} else if (code < 0xd800 || code >= 0xe000) {
blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
} else {
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
}
}
}
}
this.lastByteIndex = i;
this.bytes += i - this.start;
if (i >= 64) {
this.start = i - 64;
this.hash();
this.hashed = true;
} else {
this.start = i;
}
}
if (this.bytes > 4294967295) {
this.hBytes += this.bytes / 4294967296 << 0;
this.bytes = this.bytes % 4294967296;
}
return this;
};

Md5.prototype.finalize = function () {
if (this.finalized) {
return;
}
this.finalized = true;
var blocks = this.blocks, i = this.lastByteIndex;
blocks[i >> 2] |= EXTRA[i & 3];
if (i >= 56) {
if (!this.hashed) {
this.hash();
}
blocks[0] = blocks[16];
blocks[16] = blocks[1] = blocks[2] = blocks[3] =
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
}
blocks[14] = this.bytes << 3;
blocks[15] = this.hBytes << 3 | this.bytes >>> 29;
this.hash();
};

Md5.prototype.hash = function () {
var a, b, c, d, bc, da, blocks = this.blocks;

if (this.first) {
a = blocks[0] - 680876937;
a = (a << 7 | a >>> 25) - 271733879 << 0;
d = (-1732584194 ^ a & 2004318071) + blocks[1] - 117830708;
d = (d << 12 | d >>> 20) + a << 0;
c = (-271733879 ^ (d & (a ^ -271733879))) + blocks[2] - 1126478375;
c = (c << 17 | c >>> 15) + d << 0;
b = (a ^ (c & (d ^ a))) + blocks[3] - 1316259209;
b = (b << 22 | b >>> 10) + c << 0;
} else {
a = this.h0;
b = this.h1;
c = this.h2;
d = this.h3;
a += (d ^ (b & (c ^ d))) + blocks[0] - 680876936;
a = (a << 7 | a >>> 25) + b << 0;
d += (c ^ (a & (b ^ c))) + blocks[1] - 389564586;
d = (d << 12 | d >>> 20) + a << 0;
c += (b ^ (d & (a ^ b))) + blocks[2] + 606105819;
c = (c << 17 | c >>> 15) + d << 0;
b += (a ^ (c & (d ^ a))) + blocks[3] - 1044525330;
b = (b << 22 | b >>> 10) + c << 0;
}

a += (d ^ (b & (c ^ d))) + blocks[4] - 176418897;
a = (a << 7 | a >>> 25) + b << 0;
d += (c ^ (a & (b ^ c))) + blocks[5] + 1200080426;
d = (d << 12 | d >>> 20) + a << 0;
c += (b ^ (d & (a ^ b))) + blocks[6] - 1473231341;
c = (c << 17 | c >>> 15) + d << 0;
b += (a ^ (c & (d ^ a))) + blocks[7] - 45705983;
b = (b << 22 | b >>> 10) + c << 0;
a += (d ^ (b & (c ^ d))) + blocks[8] + 1770035416;
a = (a << 7 | a >>> 25) + b << 0;
d += (c ^ (a & (b ^ c))) + blocks[9] - 1958414417;
d = (d << 12 | d >>> 20) + a << 0;
c += (b ^ (d & (a ^ b))) + blocks[10] - 42063;
c = (c << 17 | c >>> 15) + d << 0;
b += (a ^ (c & (d ^ a))) + blocks[11] - 1990404162;
b = (b << 22 | b >>> 10) + c << 0;
a += (d ^ (b & (c ^ d))) + blocks[12] + 1804603682;
a = (a << 7 | a >>> 25) + b << 0;
d += (c ^ (a & (b ^ c))) + blocks[13] - 40341101;
d = (d << 12 | d >>> 20) + a << 0;
c += (b ^ (d & (a ^ b))) + blocks[14] - 1502002290;
c = (c << 17 | c >>> 15) + d << 0;
b += (a ^ (c & (d ^ a))) + blocks[15] + 1236535329;
b = (b << 22 | b >>> 10) + c << 0;
a += (c ^ (d & (b ^ c))) + blocks[1] - 165796510;
a = (a << 5 | a >>> 27) + b << 0;
d += (b ^ (c & (a ^ b))) + blocks[6] - 1069501632;
d = (d << 9 | d >>> 23) + a << 0;
c += (a ^ (b & (d ^ a))) + blocks[11] + 643717713;
c = (c << 14 | c >>> 18) + d << 0;
b += (d ^ (a & (c ^ d))) + blocks[0] - 373897302;
b = (b << 20 | b >>> 12) + c << 0;
a += (c ^ (d & (b ^ c))) + blocks[5] - 701558691;
a = (a << 5 | a >>> 27) + b << 0;
d += (b ^ (c & (a ^ b))) + blocks[10] + 38016083;
d = (d << 9 | d >>> 23) + a << 0;
c += (a ^ (b & (d ^ a))) + blocks[15] - 660478335;
c = (c << 14 | c >>> 18) + d << 0;
b += (d ^ (a & (c ^ d))) + blocks[4] - 405537848;
b = (b << 20 | b >>> 12) + c << 0;
a += (c ^ (d & (b ^ c))) + blocks[9] + 568446438;
a = (a << 5 | a >>> 27) + b << 0;
d += (b ^ (c & (a ^ b))) + blocks[14] - 1019803690;
d = (d << 9 | d >>> 23) + a << 0;
c += (a ^ (b & (d ^ a))) + blocks[3] - 187363961;
c = (c << 14 | c >>> 18) + d << 0;
b += (d ^ (a & (c ^ d))) + blocks[8] + 1163531501;
b = (b << 20 | b >>> 12) + c << 0;
a += (c ^ (d & (b ^ c))) + blocks[13] - 1444681467;
a = (a << 5 | a >>> 27) + b << 0;
d += (b ^ (c & (a ^ b))) + blocks[2] - 51403784;
d = (d << 9 | d >>> 23) + a << 0;
c += (a ^ (b & (d ^ a))) + blocks[7] + 1735328473;
c = (c << 14 | c >>> 18) + d << 0;
b += (d ^ (a & (c ^ d))) + blocks[12] - 1926607734;
b = (b << 20 | b >>> 12) + c << 0;
bc = b ^ c;
a += (bc ^ d) + blocks[5] - 378558;
a = (a << 4 | a >>> 28) + b << 0;
d += (bc ^ a) + blocks[8] - 2022574463;
d = (d << 11 | d >>> 21) + a << 0;
da = d ^ a;
c += (da ^ b) + blocks[11] + 1839030562;
c = (c << 16 | c >>> 16) + d << 0;
b += (da ^ c) + blocks[14] - 35309556;
b = (b << 23 | b >>> 9) + c << 0;
bc = b ^ c;
a += (bc ^ d) + blocks[1] - 1530992060;
a = (a << 4 | a >>> 28) + b << 0;
d += (bc ^ a) + blocks[4] + 1272893353;
d = (d << 11 | d >>> 21) + a << 0;
da = d ^ a;
c += (da ^ b) + blocks[7] - 155497632;
c = (c << 16 | c >>> 16) + d << 0;
b += (da ^ c) + blocks[10] - 1094730640;
b = (b << 23 | b >>> 9) + c << 0;
bc = b ^ c;
a += (bc ^ d) + blocks[13] + 681279174;
a = (a << 4 | a >>> 28) + b << 0;
d += (bc ^ a) + blocks[0] - 358537222;
d = (d << 11 | d >>> 21) + a << 0;
da = d ^ a;
c += (da ^ b) + blocks[3] - 722521979;
c = (c << 16 | c >>> 16) + d << 0;
b += (da ^ c) + blocks[6] + 76029189;
b = (b << 23 | b >>> 9) + c << 0;
bc = b ^ c;
a += (bc ^ d) + blocks[9] - 640364487;
a = (a << 4 | a >>> 28) + b << 0;
d += (bc ^ a) + blocks[12] - 421815835;
d = (d << 11 | d >>> 21) + a << 0;
da = d ^ a;
c += (da ^ b) + blocks[15] + 530742520;
c = (c << 16 | c >>> 16) + d << 0;
b += (da ^ c) + blocks[2] - 995338651;
b = (b << 23 | b >>> 9) + c << 0;
a += (c ^ (b | ~d)) + blocks[0] - 198630844;
a = (a << 6 | a >>> 26) + b << 0;
d += (b ^ (a | ~c)) + blocks[7] + 1126891415;
d = (d << 10 | d >>> 22) + a << 0;
c += (a ^ (d | ~b)) + blocks[14] - 1416354905;
c = (c << 15 | c >>> 17) + d << 0;
b += (d ^ (c | ~a)) + blocks[5] - 57434055;
b = (b << 21 | b >>> 11) + c << 0;
a += (c ^ (b | ~d)) + blocks[12] + 1700485571;
a = (a << 6 | a >>> 26) + b << 0;
d += (b ^ (a | ~c)) + blocks[3] - 1894986606;
d = (d << 10 | d >>> 22) + a << 0;
c += (a ^ (d | ~b)) + blocks[10] - 1051523;
c = (c << 15 | c >>> 17) + d << 0;
b += (d ^ (c | ~a)) + blocks[1] - 2054922799;
b = (b << 21 | b >>> 11) + c << 0;
a += (c ^ (b | ~d)) + blocks[8] + 1873313359;
a = (a << 6 | a >>> 26) + b << 0;
d += (b ^ (a | ~c)) + blocks[15] - 30611744;
d = (d << 10 | d >>> 22) + a << 0;
c += (a ^ (d | ~b)) + blocks[6] - 1560198380;
c = (c << 15 | c >>> 17) + d << 0;
b += (d ^ (c | ~a)) + blocks[13] + 1309151649;
b = (b << 21 | b >>> 11) + c << 0;
a += (c ^ (b | ~d)) + blocks[4] - 145523070;
a = (a << 6 | a >>> 26) + b << 0;
d += (b ^ (a | ~c)) + blocks[11] - 1120210379;
d = (d << 10 | d >>> 22) + a << 0;
c += (a ^ (d | ~b)) + blocks[2] + 718787259;
c = (c << 15 | c >>> 17) + d << 0;
b += (d ^ (c | ~a)) + blocks[9] - 343485551;
b = (b << 21 | b >>> 11) + c << 0;

if (this.first) {
this.h0 = a + 1732584193 << 0;
this.h1 = b - 271733879 << 0;
this.h2 = c - 1732584194 << 0;
this.h3 = d + 271733878 << 0;
this.first = false;
} else {
this.h0 = this.h0 + a << 0;
this.h1 = this.h1 + b << 0;
this.h2 = this.h2 + c << 0;
this.h3 = this.h3 + d << 0;
}
};

/**
* @method hex
* @memberof Md5
* @instance
* @description Output hash as hex string
* @returns {String} Hex string
* @see {@link md5.hex}
* @example
* hash.hex();
*/
Md5.prototype.hex = function () {
this.finalize();

var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;

return HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +
HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] +
HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] +
HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] +
HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +
HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] +
HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] +
HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] +
HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +
HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] +
HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] +
HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] +
HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +
HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] +
HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] +
HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F];
};

/**
* @method toString
* @memberof Md5
* @instance
* @description Output hash as hex string
* @returns {String} Hex string
* @see {@link md5.hex}
* @example
* hash.toString();
*/
Md5.prototype.toString = Md5.prototype.hex;

/**
* @method digest
* @memberof Md5
* @instance
* @description Output hash as bytes array
* @returns {Array} Bytes array
* @see {@link md5.digest}
* @example
* hash.digest();
*/
Md5.prototype.digest = function () {
this.finalize();

var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3;
return [
h0 & 0xFF, (h0 >> 8) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 24) & 0xFF,
h1 & 0xFF, (h1 >> 8) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 24) & 0xFF,
h2 & 0xFF, (h2 >> 8) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 24) & 0xFF,
h3 & 0xFF, (h3 >> 8) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 24) & 0xFF
];
};

/**
* @method array
* @memberof Md5
* @instance
* @description Output hash as bytes array
* @returns {Array} Bytes array
* @see {@link md5.array}
* @example
* hash.array();
*/
Md5.prototype.array = Md5.prototype.digest;

/**
* @method arrayBuffer
* @memberof Md5
* @instance
* @description Output hash as ArrayBuffer
* @returns {ArrayBuffer} ArrayBuffer
* @see {@link md5.arrayBuffer}
* @example
* hash.arrayBuffer();
*/
Md5.prototype.arrayBuffer = function () {
this.finalize();

var buffer = new ArrayBuffer(16);
var blocks = new Uint32Array(buffer);
blocks[0] = this.h0;
blocks[1] = this.h1;
blocks[2] = this.h2;
blocks[3] = this.h3;
return buffer;
};

/**
* @method buffer
* @deprecated This maybe confuse with Buffer in node.js. Please use arrayBuffer instead.
* @memberof Md5
* @instance
* @description Output hash as ArrayBuffer
* @returns {ArrayBuffer} ArrayBuffer
* @see {@link md5.buffer}
* @example
* hash.buffer();
*/
Md5.prototype.buffer = Md5.prototype.arrayBuffer;

/**
* @method base64
* @memberof Md5
* @instance
* @description Output hash as base64 string
* @returns {String} base64 string
* @see {@link md5.base64}
* @example
* hash.base64();
*/
Md5.prototype.base64 = function () {
var v1, v2, v3, base64Str = '', bytes = this.array();
for (var i = 0; i < 15;) {
v1 = bytes[i++];
v2 = bytes[i++];
v3 = bytes[i++];
base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +
BASE64_ENCODE_CHAR[(v1 << 4 | v2 >>> 4) & 63] +
BASE64_ENCODE_CHAR[(v2 << 2 | v3 >>> 6) & 63] +
BASE64_ENCODE_CHAR[v3 & 63];
}
v1 = bytes[i];
base64Str += BASE64_ENCODE_CHAR[v1 >>> 2] +
BASE64_ENCODE_CHAR[(v1 << 4) & 63] +
'==';
return base64Str;
};

var exports = createMethod();

if (COMMON_JS) {
module.exports = exports;
} else {
/**
* @method md5
* @description Md5 hash function, export to global in browsers.
* @param {String|Array|Uint8Array|ArrayBuffer} message message to hash
* @returns {String} md5 hashes
* @example
* md5(''); // d41d8cd98f00b204e9800998ecf8427e
* md5('The quick brown fox jumps over the lazy dog'); // 9e107d9d372bb6826bd81d3542a419d6
* md5('The quick brown fox jumps over the lazy dog.'); // e4d909c290d0fb1ca068ffaddf22cbd0
*
* // It also supports UTF-8 encoding
* md5('中文'); // a7bac2239fcdcb3a067903d8077c4a07
*
* // It also supports byte `Array`, `Uint8Array`, `ArrayBuffer`
* md5([]); // d41d8cd98f00b204e9800998ecf8427e
* md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e
*/
root.md5 = exports;
if (AMD) {
define(function () {
return exports;
});
}
}
})();

+ 37
- 0
monitorMobile/utils/secret.js Voir le fichier

@@ -0,0 +1,37 @@
/**
* 对页面上输入的密码进行加密传输给后台进行验证,对返回的数据进行解密,在页面展示
*/
let CryptoJS = require('crypto-js'); // 引入AES源码js
export default {
/*
* 对密码进行加密,传输给后台进行验证
* @param {String} word 需要加密的密码
* @param {String} keyStr 对密码加密的秘钥
* @return {String} 加密的密文
* */
encrypt(word, keyStr) { // 加密
keyStr = keyStr ? keyStr : 'abcd1234ABCDQGJ1';
let key = CryptoJS.enc.Utf8.parse(keyStr);
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return encrypted.toString();
},
/*
* 对加密之后的密文在页面上进行解密,以便用户进行修改
* @param {String} word 需要加密的密码
* @param {String} keyStr 对密码加密的秘钥
* @return {String} 解密的明文
* */
decrypt(word, keyStr) { // 解密
keyStr = keyStr ? keyStr : 'ABGHNJHGSHUYG12';
let key = CryptoJS.enc.Utf8.parse(keyStr);
let decrypt = CryptoJS.AES.decrypt(word, key, {
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
return CryptoJS.enc.Utf8.stringify(decrypt).toString();
},
};

Chargement…
Annuler
Enregistrer