Files
2025-12-22 17:13:05 +08:00

86 lines
1.5 KiB
JavaScript

//网络错误
import $store from "@/store/index.js"
const networkError = function({
code = 0,
msg = '网络异常'
} = {}) {
if (code !== 0) return;
uni.showToast({
title: msg,
icon: 'none',
duration: 4000
})
}
//服务器错误处理
const serverError = function({
code = -1,
msg = '服务器错误'
} = {}) {
uni.showModal({
title: '提示',
content: msg,
showCancel: false
})
}
//错误信息
const msgError = function({
msg = '错误'
} = {}) {
uni.showToast({
title: msg,
icon: 'none',
duration: 4000
})
}
// 没有购买权限
const authError = async function({
msg = '没有购买权限,请前去认证',
showCancel = true,
} = {}) {
let [, {
confirm
}] = await uni.showModal({
title: '温馨提示',
content: msg,
confirmText: '前往认证',
cancelText: '暂不认证',
showCancel,
})
if (!confirm) return;
let {
driver_status
} = $store.state.user.userInfo
let page = driver_status == -1 ? `apply` : `apply-result`
let url = `/mine/pages/${page}`
uni.navigateTo({
url
})
}
// 没有购买权限
const vipError = async function({
msg = '只有对应身份的用户才能领取,请前去升级',
showCancel = true,
} = {}) {
let [, {
confirm
}] = await uni.showModal({
title: '温馨提示',
content: msg,
confirmText: '前往升级',
cancelText: '暂不升级',
showCancel,
})
if (!confirm) return;
let url = `/mine/pages/stored/list`
uni.navigateTo({
url
})
}
export {
networkError,
serverError,
msgError,
authError,
vipError
}