闸门智控小程序
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
export default {
|
||||
users: {
|
||||
yanan: {
|
||||
pass: 'yanan123',
|
||||
id: 1,
|
||||
user: 'yanan',
|
||||
name: 'yanan',
|
||||
dept: '系统控制',
|
||||
title: '管理员',
|
||||
mobile: '13288888888'
|
||||
}
|
||||
},
|
||||
devices: [
|
||||
[],
|
||||
[
|
||||
{
|
||||
id: 1,
|
||||
name:'北桥沟',
|
||||
addr:'陕西省延安市宝塔区北桥沟'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name:'黄蒿洼',
|
||||
addr:'陕西省延安市宝塔区黄蒿洼路'
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
const API_HOST = 'https://gate.api.opmonitor.com/'
|
||||
export default {
|
||||
apiHost: API_HOST,
|
||||
dateTimeStr: function() {
|
||||
let d = new Date()
|
||||
let a = []
|
||||
a.push('' + d.getFullYear())
|
||||
a.push(('' + (d.getMonth() + 1)).padStart(2, '0'))
|
||||
a.push(('' + d.getDate()).padStart(2, '0'))
|
||||
a.push(('' + d.getHours()).padStart(2, '0'))
|
||||
a.push(('' + d.getMinutes()).padStart(2, '0'))
|
||||
a.push(('' + d.getSeconds()).padStart(2, '0'))
|
||||
return `${a[0]}-${a[1]}-${a[2]} ${a[3]}:${a[4]}:${a[5]}`
|
||||
},
|
||||
tabBar: [
|
||||
{
|
||||
pagePath: '/pages/index/index',
|
||||
text: '首页',
|
||||
iconPath: API_HOST + '/miniapp/static/tabnav1a.png',
|
||||
selectedIconPath: API_HOST + '/miniapp/static/tabnav1.png'
|
||||
},
|
||||
{
|
||||
pagePath: '/packagePage/pages/my/my',
|
||||
text: '我的',
|
||||
iconPath: API_HOST + '/miniapp/static/tabnav2a.png',
|
||||
selectedIconPath: API_HOST + '/miniapp/static/tabnav2.png'
|
||||
}
|
||||
],
|
||||
// tabbar 切换
|
||||
tabbarSwitch: function(e) {
|
||||
let lastPagePath = uni.getStorageSync('lastPagePath')
|
||||
if ( e.pagePath != lastPagePath) {
|
||||
uni.reLaunch({
|
||||
url: e.pagePath
|
||||
})
|
||||
}
|
||||
},
|
||||
// check login
|
||||
checkLogin: function() {
|
||||
let info = uni.getStorageSync('user')
|
||||
if (typeof(info) == 'object' && info.account != undefined) {
|
||||
return info
|
||||
} else {
|
||||
uni.reLaunch({
|
||||
url: '/packagePage/pages/auth/auth'
|
||||
})
|
||||
}
|
||||
},
|
||||
// toast
|
||||
showHint: function(msg = 'hello', sec = 2000) {
|
||||
uni.showToast({
|
||||
title: msg,
|
||||
duration: sec,
|
||||
icon: 'none',
|
||||
mask: true
|
||||
})
|
||||
},
|
||||
// request
|
||||
request: function(uri, callback, reqData = {}, reqMethod = 'GET') {
|
||||
let params = {
|
||||
url:API_HOST + uri,
|
||||
method: reqMethod,
|
||||
data: reqData,
|
||||
success: callback,
|
||||
fail:function() {
|
||||
uni.showToast({
|
||||
title: '加载失败',
|
||||
duration: 2000,
|
||||
icon: 'none',
|
||||
mask: true
|
||||
})
|
||||
},
|
||||
complete: function() {
|
||||
uni.hideLoading()
|
||||
}
|
||||
}
|
||||
if (reqMethod == 'POST') {
|
||||
params.header = {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
uni.request(params)
|
||||
},
|
||||
// websocket
|
||||
websocket: {
|
||||
url: 'wss://gpic.opmonitor.com/wss',
|
||||
socketOpen:false,
|
||||
socketMsgQueue: [],
|
||||
cmd: {
|
||||
'全部关掉':'000100000008FF0F001E00080100',
|
||||
'主污泵启动':'000100000006FF05001EFF00',
|
||||
'主污泵停止':'000100000006FF05001E0000',
|
||||
'备污泵启动':'000100000006FF050020FF00',
|
||||
'备污泵停止':'000100000006FF0500200000',
|
||||
'雨水泵启动':'000100000006FF050022FF00',
|
||||
'雨水泵停止':'000100000006FF0500220000',
|
||||
'闸门上升':'000100000006FF050024FF00',
|
||||
'闸门停止上升':'000100000006FF0500240000',
|
||||
'闸门下降':'000100000006FF050025FF00',
|
||||
'闸门停止下降':'000100000006FF0500250000',
|
||||
'工控机报警复位':'000100000006FF0500270000',
|
||||
'M130设置为本地自动':'000100000006FF0500820000',
|
||||
'M130设置为远程手动':'000100000006FF050082FF00'
|
||||
},
|
||||
send: (myapp, type, name, content, f_did) => {
|
||||
//type: connect | control
|
||||
let info = uni.getStorageSync('user')
|
||||
let sendData = {
|
||||
cmd: type,
|
||||
ws_client_id: info.id
|
||||
}
|
||||
if (type == 'connect') {
|
||||
sendData['user_id'] = info.account
|
||||
}
|
||||
|
||||
if (type == 'control') {
|
||||
// sendData['device_id'] = device_id == undefined ? 0 : device_id
|
||||
sendData['device_id'] = f_did == undefined ? 0 : f_did
|
||||
sendData['name'] = name == undefined ? '' : name
|
||||
sendData['content'] = content == undefined ? '' : content
|
||||
}
|
||||
let sendDataJson = JSON.stringify(sendData)
|
||||
|
||||
if (myapp.websocket.socketOpen) {
|
||||
console.log('ws send:' + sendDataJson)
|
||||
uni.sendSocketMessage({data: sendDataJson})
|
||||
} else {
|
||||
console.log('ws push:' + sendDataJson)
|
||||
myapp.websocket.socketMsgQueue.push(sendDataJson)
|
||||
}
|
||||
}
|
||||
},
|
||||
mqtt_ws: {
|
||||
url: 'wss://mqtt.gpic.opmonitor.com/mqtt',
|
||||
socketOpen:false,
|
||||
socketMsgQueue: [],
|
||||
send: (contentJson) => {
|
||||
if (myapp.mqtt_ws.socketOpen) {
|
||||
console.log('ws send:' + contentJson)
|
||||
uni.sendSocketMessage({data: contentJson})
|
||||
} else {
|
||||
console.log('ws push:' + contentJson)
|
||||
myapp.mqtt_ws.socketMsgQueue.push(contentJson)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user