uni-app uni-id-co unbindWeixin解绑微信异常
uni-app uni-id-co unbindWeixin解绑微信异常
产品分类:
uniCloud/腾讯云
示例代码:
节点部分
<text class="groupTitle">第三方绑定</text>
<u-cell-group style="background-color: #FFFFFF;">
<u-cell size="large" title="微信" :value="userInfo.isWeixinBound?'解除绑定':'未绑定'" isLink @tap="toggleWechatBind">
</u-cell>
</u-cell-group>
js部分
// 切换微信绑定
async toggleWechatBind(){
try{
if(this.userInfo.isWeixinBound){
// 解除绑定
await this.$UIC.unbindWeixin() //已挂载到全局
uni.$u.toast('已解除绑定')
await this.getUserInfo() //获取用户信息
}else{
let code = await this.getWechatLoginCode()
let resp= await this.$UIC.bindWeixin({code})
uni.$u.toast('绑定成功')
await this.getUserInfo()
}
}catch(e){
uni.$u.toast(e.message)
}
},
操作步骤:
按照官方文档操作,自己新建的页面,没有使用官方提供的uni-id-pages中的页面
预期结果:
能正常解绑微信
实际结果:
不停提示“请先绑定后再解绑”
bug描述:
uni-co-id unbindWeixin解绑微信异常,不停提示“请先绑定后再解绑”,但我的账号实际已经绑定了微信,并且该账号也绑定了手机,云数据库中也能看到openid等字段,uni-id-co 版本 1.1.20
图片
更多关于uni-app uni-id-co unbindWeixin解绑微信异常的实战教程也可以访问 https://www.itying.com/category-93-b0.html
2 回复
在 uni-id-log表中找一下这个错误记录,发一下。
更多关于uni-app uni-id-co unbindWeixin解绑微信异常的实战教程也可以访问 https://www.itying.com/category-93-b0.html
在使用 uni-app
的 uni-id-co
插件进行微信解绑(unbindWeixin
)操作时,如果遇到异常,可以按照以下步骤进行排查和解决:
1. 检查代码逻辑
确保你的解绑逻辑正确,并且调用了正确的 API。以下是一个示例代码:
const uniID = require('uni-id-co')
async function unbindWeixin(uid) {
try {
const res = await uniID.unbindWeixin({
uid: uid
})
if (res.code === 0) {
console.log('解绑微信成功')
} else {
console.error('解绑微信失败:', res.message)
}
} catch (err) {
console.error('解绑微信异常:', err)
}
}
// 调用示例
unbindWeixin('user_id_123')
2. 检查 uid
是否正确
确保传入的 uid
是正确的,并且该用户已经绑定了微信账号。
3. 检查 uni-id-co
配置
确保 uni-id-co
的配置正确,特别是在 config.json
或 config.js
中的微信相关配置。例如:
{
"wx": {
"appid": "your_wechat_appid",
"secret": "your_wechat_secret"
}
}