82 lines
1.9 KiB
JavaScript
82 lines
1.9 KiB
JavaScript
const API_HOST = 'https://dis.mwims.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'
|
|
}
|
|
],
|
|
tabbarSwitch: function(e) {
|
|
//console.log(JSON.stringify(e))
|
|
let lastPagePath = uni.getStorageSync('lastPagePath')
|
|
if ( e.pagePath != lastPagePath) {
|
|
uni.reLaunch({
|
|
url: e.pagePath
|
|
})
|
|
}
|
|
},
|
|
checkLogin: function() {
|
|
let info = uni.getStorageSync('user')
|
|
if (typeof(info) == 'object' && info.token != undefined) {
|
|
return info
|
|
} else {
|
|
uni.reLaunch({
|
|
url: '/packagePage/pages/auth/auth'
|
|
})
|
|
}
|
|
},
|
|
showHint: function(msg = 'hello', sec = 2000) {
|
|
uni.showToast({
|
|
title: msg,
|
|
duration: sec,
|
|
icon: 'none'
|
|
})
|
|
},
|
|
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'
|
|
})
|
|
},
|
|
complete: function() {
|
|
uni.hideLoading()
|
|
}
|
|
}
|
|
if (reqMethod == 'POST') {
|
|
params.header = {
|
|
'content-type': 'application/x-www-form-urlencoded'
|
|
}
|
|
}
|
|
uni.showLoading({
|
|
title: '加载中'
|
|
})
|
|
uni.request(params)
|
|
}
|
|
} |