bindbox-mini/utils/checkPhone.js

29 lines
752 B
JavaScript

/**
* 检查手机号绑定状态
* 如果未绑定手机号,则跳转到登录页面进行绑定
* @returns {boolean} 是否已绑定手机号
*/
export function checkPhoneBound() {
// 获取用户信息
const userInfo = uni.getStorageSync('user_info') || {}
const mobile = userInfo.mobile || userInfo.phone || userInfo.phone_number || ''
// 如果已绑定手机号,直接返回
if (mobile) {
return true
}
// 未绑定手机号,显示提示并跳转
uni.showModal({
title: '需要绑定手机号',
content: '为了账号安全,请先绑定手机号',
showCancel: false,
confirmText: '去绑定',
success: () => {
uni.navigateTo({ url: '/pages/login/index?mode=sms' })
}
})
return false
}