You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
826 B
38 lines
826 B
/**
|
|
* 未登录时不强制跳转,仅在用户主动操作(下单、加购等)时提示登录
|
|
*/
|
|
export function getToken(vm) {
|
|
return vm?.vuex_token || uni.getStorageSync('lifeData')?.vuex_token || ''
|
|
}
|
|
|
|
/**
|
|
* @returns {Promise<boolean>} 用户确认去登录为 true
|
|
*/
|
|
export function promptLogin(vm, options = {}) {
|
|
const {
|
|
title = '提示',
|
|
content = '登录后可继续操作,是否前往登录?',
|
|
confirmText = '去登录',
|
|
} = options
|
|
return new Promise((resolve) => {
|
|
uni.showModal({
|
|
title,
|
|
content,
|
|
confirmText,
|
|
cancelText: '暂不登录',
|
|
success: (res) => {
|
|
if (res.confirm) {
|
|
vm.$u.route({
|
|
url: '/pages/login/login',
|
|
type: 'navigateTo',
|
|
})
|
|
resolve(true)
|
|
} else {
|
|
resolve(false)
|
|
}
|
|
},
|
|
fail: () => resolve(false),
|
|
})
|
|
})
|
|
}
|