u
This commit is contained in:
parent
663cfd0a1f
commit
a02748c822
32
index.js
32
index.js
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
// import device from 'current-device' // https://github.com/matthewhudson/current-device
|
// import device from 'current-device' // https://github.com/matthewhudson/current-device
|
||||||
|
// if (device.mobile()){
|
||||||
|
// }else if (device.desktop()){
|
||||||
|
// }else if (device.tablet()){
|
||||||
|
// }
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
import './ican-H5Api.js' // 对齐H5Api: https://ext.dcloud.net.cn/plugin?id=415 // 注意要取消默认自带的 showToast https://uniapp.dcloud.io/api/system/clipboard?id=%e6%b3%a8%e6%84%8f
|
import './ican-H5Api.js' // 对齐H5Api: https://ext.dcloud.net.cn/plugin?id=415 // 注意要取消默认自带的 showToast https://uniapp.dcloud.io/api/system/clipboard?id=%e6%b3%a8%e6%84%8f
|
||||||
@ -62,8 +66,8 @@ module.exports = {
|
|||||||
// 断网或云端返回异常 {errMsg, stack} = error
|
// 断网或云端返回异常 {errMsg, stack} = error
|
||||||
if (/request:fail/.test(exp.errMsg)) {
|
if (/request:fail/.test(exp.errMsg)) {
|
||||||
return { result: { _state: 'CLIENT_BACKEND_BROKEN' } }
|
return { result: { _state: 'CLIENT_BACKEND_BROKEN' } }
|
||||||
}else {
|
} else {
|
||||||
return { result: { _state: 'CLIENT_BACKEND_EXCEPTION' }}
|
return { result: { _state: 'CLIENT_BACKEND_EXCEPTION' } }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
result = resultCloud
|
result = resultCloud
|
||||||
@ -84,10 +88,10 @@ module.exports = {
|
|||||||
if (error.errMsg === 'request:fail') {
|
if (error.errMsg === 'request:fail') {
|
||||||
// 后台断线
|
// 后台断线
|
||||||
result = { _state: 'CLIENT_BACKEND_BROKEN' }
|
result = { _state: 'CLIENT_BACKEND_BROKEN' }
|
||||||
} else (error.errMsg==='request:fail timeout') {
|
} else if (error.errMsg === 'request:fail timeout') {
|
||||||
// 后台异常而超时返回
|
// 后台异常而超时返回
|
||||||
result = { _state: 'CLIENT_BACKEND_TIMEOUT' }
|
result = { _state: 'CLIENT_BACKEND_TIMEOUT' }
|
||||||
}else{
|
} else {
|
||||||
result = { _state: 'CLIENT_BACKEND_EXCEPTION' }
|
result = { _state: 'CLIENT_BACKEND_EXCEPTION' }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -218,24 +222,13 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getSystemInfo() {
|
getSystemInfo() {
|
||||||
let systemInfo = uni.getSystemInfoSync() // 包含 platform (ios|android|other), model (iPhone, iPad, Nexus 6, ...), system (iOS 11.0, Android 4.0, Other 0, ...) 等等
|
let systemInfo = uni.getSystemInfoSync()
|
||||||
|
// model=PC|iPhone|iPad|Nexus 6|...,
|
||||||
|
// platform=ios|android|mac|windows|linux|other,
|
||||||
|
// system=iOS 11.0|Android 4.0|Other 0|... 等等
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
systemInfo.environment = 'h5'
|
systemInfo.environment = 'h5'
|
||||||
|
|
||||||
if (['ios', 'android'].indexOf(systemInfo.platform) >= 0) {
|
|
||||||
systemInfo.device = 'mobile'
|
|
||||||
} else {
|
|
||||||
systemInfo.device = 'desktop'
|
|
||||||
}
|
|
||||||
// if (device.mobile()){
|
|
||||||
// systemInfo.device = 'mobile'
|
|
||||||
// }else if (device.desktop()){
|
|
||||||
// systemInfo.device = 'desktop'
|
|
||||||
// }else if (device.tablet()){
|
|
||||||
// systemInfo.device = 'tablet'
|
|
||||||
// }
|
|
||||||
|
|
||||||
let userAgent = window.navigator.userAgent.toLowerCase()
|
let userAgent = window.navigator.userAgent.toLowerCase()
|
||||||
systemInfo.browser =
|
systemInfo.browser =
|
||||||
/msie/.test(userAgent) && !/opera/.test(userAgent)
|
/msie/.test(userAgent) && !/opera/.test(userAgent)
|
||||||
@ -251,7 +244,6 @@ module.exports = {
|
|||||||
: /micromessenger/.test(userAgent)
|
: /micromessenger/.test(userAgent)
|
||||||
? 'wechat'
|
? 'wechat'
|
||||||
: 'unknown'
|
: 'unknown'
|
||||||
|
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifdef APP-PLUS || APP-PLUS-NVUE
|
// #ifdef APP-PLUS || APP-PLUS-NVUE
|
||||||
|
Loading…
Reference in New Issue
Block a user