身份证号码登录开发
This commit is contained in:
@@ -72,9 +72,9 @@ const handleIdCardLogin = async (idCard) => {
|
||||
})
|
||||
|
||||
// 跳转到首页
|
||||
uni.reLaunch({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
// uni.reLaunch({
|
||||
// url: '/pages/index/index'
|
||||
// })
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '登录失败',
|
||||
@@ -137,12 +137,11 @@ const getUrlParams = (url) => {
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
onLoad((options) => {
|
||||
// 处理第三方跳转过来的身份证登录
|
||||
if (options.idCardBase64) {
|
||||
if (options.idCard) {
|
||||
// 直接通过参数传递
|
||||
processIdCardLogin(options.idCardBase64)
|
||||
processIdCardLogin(options.idCard)
|
||||
} else {
|
||||
// 从当前URL中获取参数
|
||||
const currentPages = getCurrentPages()
|
||||
@@ -150,8 +149,8 @@ onLoad((options) => {
|
||||
const url = currentPage.$page.fullPath
|
||||
const params = getUrlParams(url)
|
||||
|
||||
if (params.idCardBase64) {
|
||||
processIdCardLogin(params.idCardBase64)
|
||||
if (params.idCard) {
|
||||
processIdCardLogin(params.idCard)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '缺少身份证号码参数',
|
||||
@@ -165,18 +164,18 @@ onLoad((options) => {
|
||||
})
|
||||
|
||||
// 处理身份证登录流程
|
||||
const processIdCardLogin = async (idCardBase64) => {
|
||||
const processIdCardLogin = async (idCard) => {
|
||||
try {
|
||||
// 解码Base64身份证号码
|
||||
const idCard = decodeBase64(idCardBase64)
|
||||
const decodedIdCard = decodeBase64(idCard)
|
||||
|
||||
// 验证身份证号码格式(简单验证)
|
||||
if (!idCard || idCard.length < 15) {
|
||||
if (!decodedIdCard || decodedIdCard.length < 15) {
|
||||
throw new Error('身份证号码格式不正确')
|
||||
}
|
||||
|
||||
// 调用登录接口
|
||||
await handleIdCardLogin(idCard)
|
||||
await handleIdCardLogin(decodedIdCard)
|
||||
|
||||
} catch (error) {
|
||||
console.error('处理身份证登录失败:', error)
|
||||
@@ -192,6 +191,7 @@ const processIdCardLogin = async (idCardBase64) => {
|
||||
|
||||
onMounted(() => {
|
||||
// 页面挂载后的逻辑
|
||||
// 这里可以添加页面挂载后的其他逻辑
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user