|
|
@ -153,19 +153,15 @@ export default { |
|
|
console.error('获取配置失败:', err); |
|
|
console.error('获取配置失败:', err); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
async submit() { |
|
|
async submit() { |
|
|
// 去除首尾空格 |
|
|
// 去除首尾空格 |
|
|
this.nickName = this.nickName.trim() |
|
|
|
|
|
this.queryvalue = this.queryvalue.trim() |
|
|
this.queryvalue = this.queryvalue.trim() |
|
|
|
|
|
|
|
|
if (!this.queryvalue || !this.rdpasswd) { |
|
|
if (!this.queryvalue || !this.rdpasswd) { |
|
|
uni.showToast({ title: '请输入读者证号和密码', icon: 'none' }); |
|
|
uni.showToast({ title: '请输入读者证号和密码', icon: 'none' }); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uni.showLoading({ title: '绑定中...' }); |
|
|
uni.showLoading({ title: '绑定中...' }); |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
const params = { |
|
|
const params = { |
|
|
...this.screenConfig, |
|
|
...this.screenConfig, |
|
|
@ -173,12 +169,6 @@ export default { |
|
|
queryvalue: this.queryvalue, |
|
|
queryvalue: this.queryvalue, |
|
|
rdpasswd: this.rdpasswd, |
|
|
rdpasswd: this.rdpasswd, |
|
|
}; |
|
|
}; |
|
|
// 420703GD0000748 |
|
|
|
|
|
// {"code":200,"message":"操作成功","data":"{\"messagelist\":[{\"code\":\"R00138\",\"message\":\"未找到符合条件的读者!\"}],\"success\":false}","timestamp":1778154499544} |
|
|
|
|
|
|
|
|
|
|
|
// {"code":200,"message":"操作成功","data":"{\"success\":true,\"pagedata\":[{\"rdClusterCode\":null,\"rdlib\":\"GD\",\"rdid\":\"420105198509200438\",\"rdcfstate\":1}]}","timestamp":1778154647854} |
|
|
|
|
|
|
|
|
|
|
|
// {"code":200,"message":"操作成功","data":"{\"messageList\":[{\"R00131\":\"认证失败,系统存在该读者,密码不匹配!\"}],\"success\":true,\"pagedata\":\"\"}","timestamp":1778155520501} |
|
|
|
|
|
|
|
|
|
|
|
const res = await FetchReaderList(params); |
|
|
const res = await FetchReaderList(params); |
|
|
let result = {}; |
|
|
let result = {}; |
|
|
@ -189,7 +179,6 @@ export default { |
|
|
uni.showToast({ title: '数据解析失败', icon: 'none' }); |
|
|
uni.showToast({ title: '数据解析失败', icon: 'none' }); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 统一提取错误信息 |
|
|
// 统一提取错误信息 |
|
|
let errMsg = ''; |
|
|
let errMsg = ''; |
|
|
if (result.messagelist?.length) { |
|
|
if (result.messagelist?.length) { |
|
|
@ -201,35 +190,50 @@ export default { |
|
|
errMsg = item.message || Object.values(item)[0] || '认证失败'; |
|
|
errMsg = item.message || Object.values(item)[0] || '认证失败'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 420703GD0000748 |
|
|
|
|
|
// {"code":200,"message":"操作成功","data":"{\"messagelist\":[{\"code\":\"R00138\",\"message\":\"未找到符合条件的读者!\"}],\"success\":false}","timestamp":1778154499544} |
|
|
|
|
|
|
|
|
|
|
|
// {"code":200,"message":"操作成功","data":"{\"success\":true,\"pagedata\":[{\"rdClusterCode\":null,\"rdlib\":\"GD\",\"rdid\":\"420105198509200438\",\"rdcfstate\":1}]}","timestamp":1778154647854} |
|
|
|
|
|
|
|
|
|
|
|
// {"code":200,"message":"操作成功","data":"{\"messageList\":[{\"R00131\":\"认证失败,系统存在该读者,密码不匹配!\"}],\"success\":true,\"pagedata\":\"\"}","timestamp":1778155520501} |
|
|
|
|
|
|
|
|
// 成功判断 |
|
|
// 成功判断 |
|
|
const realSuccess = result.success === true && result.pagedata?.length > 0; |
|
|
const realSuccess = result.success === true && result.pagedata?.length > 0; |
|
|
|
|
|
|
|
|
if (realSuccess) { |
|
|
if (realSuccess) { |
|
|
|
|
|
|
|
|
// 开始绑定 |
|
|
// 开始绑定 |
|
|
const openId = uni.getStorageSync("wx_login_code"); |
|
|
const openId = uni.getStorageSync("wx_login_code"); |
|
|
|
|
|
if (!openId) { |
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
title: '绑定提示', |
|
|
|
|
|
content: '未获取到微信登录信息,请重新登录', |
|
|
|
|
|
showCancel: false |
|
|
|
|
|
}) |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
const bindParams = { |
|
|
const bindParams = { |
|
|
openid: openId, |
|
|
openid: openId, |
|
|
bindValue: this.queryvalue, |
|
|
bindValue: this.queryvalue, |
|
|
bindType: 'rdid', |
|
|
bindType: 'rdid', |
|
|
libcode: getApp().globalData.libcode, |
|
|
libcode: getApp().globalData.libcode, |
|
|
} |
|
|
} |
|
|
// 调用绑定接口 |
|
|
|
|
|
const bindRes = await FetchBindReadCard(bindParams); |
|
|
|
|
|
console.log('绑定结果', bindRes); |
|
|
|
|
|
|
|
|
|
|
|
if(bindRes.code === 200 ){ |
|
|
|
|
|
|
|
|
// ========== 绑定接口独立try‑catch,业务错误不会跑到外层大catch ========== |
|
|
|
|
|
try { |
|
|
|
|
|
const bindRes = await FetchBindReadCard(bindParams); |
|
|
|
|
|
if (bindRes.code === 200) { |
|
|
uni.hideLoading(); |
|
|
uni.hideLoading(); |
|
|
uni.showToast({ |
|
|
|
|
|
title: bindRes.data || '读者证绑定成功', |
|
|
|
|
|
icon: 'success' |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
title: '绑定成功', |
|
|
|
|
|
content: bindRes.data || '读者证绑定成功', |
|
|
|
|
|
showCancel: false, |
|
|
|
|
|
success: (modalRes) => { |
|
|
|
|
|
if (modalRes.confirm) { |
|
|
const data = { |
|
|
const data = { |
|
|
libcode: getApp().globalData.libcode, |
|
|
libcode: getApp().globalData.libcode, |
|
|
openId: openId |
|
|
openId: openId |
|
|
} |
|
|
} |
|
|
FetchFindAllReaderBindByOpenId(data).then(res => { |
|
|
FetchFindAllReaderBindByOpenId(data).then(res => { |
|
|
// console.log('获取读者证列表',res) |
|
|
|
|
|
if (res.code === 200 && res.data.length > 0) { |
|
|
if (res.code === 200 && res.data.length > 0) { |
|
|
uni.setStorageSync(STORAGE_KEYS.READER_CARD_LIST, res.data); |
|
|
uni.setStorageSync(STORAGE_KEYS.READER_CARD_LIST, res.data); |
|
|
} else { |
|
|
} else { |
|
|
@ -239,32 +243,59 @@ export default { |
|
|
.catch(err => { |
|
|
.catch(err => { |
|
|
console.error('获取读者证列表失败:', err); |
|
|
console.error('获取读者证列表失败:', err); |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
// 绑定成功后返回上一页 |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
uni.navigateBack(); |
|
|
uni.navigateBack(); |
|
|
}, 1500); |
|
|
|
|
|
}else{ |
|
|
|
|
|
// 绑定失败提示 |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 业务错误:已被绑定、密码不匹配等业务返回错误 |
|
|
uni.hideLoading() |
|
|
uni.hideLoading() |
|
|
uni.showToast({ |
|
|
|
|
|
title: bindResult.message || '绑定失败,请重试', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
|
|
|
const failMsg = bindRes.message || '绑定失败,请重试'; |
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
title: '绑定失败', |
|
|
|
|
|
content: failMsg, |
|
|
|
|
|
showCancel: false |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
} catch (bindErr) { |
|
|
|
|
|
// 这里才是绑定接口真正的请求异常(http错误、网络异常) |
|
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
let errTip = typeof bindErr === 'string' ? bindErr : '绑定请求异常,请稍后重试'; |
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
title: '系统异常', |
|
|
|
|
|
content: errTip, |
|
|
|
|
|
showCancel: false |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
// ====================================================================== |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
uni.hideLoading(); |
|
|
uni.hideLoading(); |
|
|
uni.showToast({ |
|
|
|
|
|
title: errMsg || '读者证或密码错误', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
title: '认证失败', |
|
|
|
|
|
content: errMsg || '读者证或密码错误', |
|
|
|
|
|
showCancel: false |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} catch (err) { |
|
|
} catch (err) { |
|
|
console.error('绑定流程异常:', err) |
|
|
console.error('绑定流程异常:', err) |
|
|
uni.hideLoading(); |
|
|
uni.hideLoading(); |
|
|
uni.showToast({ title: err || '绑定失败', icon: 'none' }); |
|
|
|
|
|
|
|
|
let errTip = '' |
|
|
|
|
|
if (typeof err === 'string') { |
|
|
|
|
|
errTip = err |
|
|
|
|
|
} else if (err && err.message) { |
|
|
|
|
|
errTip = err.message |
|
|
|
|
|
} else { |
|
|
|
|
|
errTip = '绑定失败,请稍后重试' |
|
|
|
|
|
} |
|
|
|
|
|
uni.showModal({ |
|
|
|
|
|
title: '系统异常', |
|
|
|
|
|
content: errTip, |
|
|
|
|
|
showCancel: false |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 跳转到在线办证页面 |
|
|
* 跳转到在线办证页面 |
|
|
*/ |
|
|
*/ |
|
|
|