97 lines
2.3 KiB
JavaScript
97 lines
2.3 KiB
JavaScript
const API_HOST = 'https://filter.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: '/packagePage/pages/ctrllist/ctrllist',
|
|
text: '医院',
|
|
iconPath: API_HOST + '/miniapp/static/tabnav1a.png',
|
|
selectedIconPath: API_HOST + '/miniapp/static/tabnav1.png'
|
|
},
|
|
{
|
|
pagePath: '/packagePage/pages/positionindex/positionindex',
|
|
text: '点位',
|
|
iconPath: API_HOST + '/miniapp/static/extend_gray.png',
|
|
selectedIconPath: API_HOST + '/miniapp/static/extend_active.png'
|
|
},
|
|
{
|
|
pagePath: '/packagePage/pages/record/record',
|
|
text: '记录',
|
|
iconPath: API_HOST + '/miniapp/static/code_gray.png',
|
|
selectedIconPath: API_HOST + '/miniapp/static/code_active.png'
|
|
},
|
|
{
|
|
pagePath: '/packagePage/pages/ctrldevice/ctrldevice',
|
|
text: '更换',
|
|
iconPath: API_HOST + '/miniapp/static/thor_gray.png',
|
|
selectedIconPath: API_HOST + '/miniapp/static/thor_active.png'
|
|
}
|
|
],
|
|
// tabbar 切换
|
|
tabbarSwitch: function(e) {
|
|
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)
|
|
}
|
|
} |