在开发环境运行一切正常,但是真机调试,或者上传为体验版运行,获取用户昵称永远得到“微信用户”。
<button bindtap="getUserProfile" disabled='{{btnDisabled}}' class="btn"> 重新设置头像昵称 </button>
getUserProfile(e) {
wx.getUserProfile({
desc: '用于完善用户资料',
success: (res) => {
console.log("getUserProfile success:", res)
}
})
},
日志(res的值):
getUserProfile success:
{cloudID: , encryptedData: "sZEE76thK12h/pm7DKuvvfatY1Bfh5HW4VUkkuTYwr/x5x+RkciSvFFa03bbT/jmPqhEYZabky+ziwrrTjZA0460QlA/cIcx4IGjIRpmXlzFEwQQKvI4rNQZXU0k1Tvjtdkn/oCHn/R9HLVe6fQegPie+maoe3nYTbKykp46CJR4ehuYP031IqXAixVN0n+r5sxZ9JDB8yNJ43KffRH4O0XeRxKkz3SWRyJFlf/PIdld/Mic+lk5I/r7Wn3b1PkrGoLO2qy3UyEiHm1vxdIF/bWLjzmX8nuPaEjBAHWM7nCMiKnEFdv1OlhKtKKR5SqhSXkc3P3VL1EWQthfe4quXCnxaQQEUQgw1bXb+0USXRHpJ2nXFGDdtDYNRK+n6eu7dVQAJFc45JR6GyWPQODCU0uheaAioYc3jV8mgLowlYlHxWKLnQLR26EY579N+68k", iv: "CC2FCmtZuF16Hf/vNLQg==", signature: "c4c8e5b30eabe268cfeaa422e20dde5bd59", userInfo: , …}
cloudID: undefined
encryptedData: "sZEE76thK12h/pm7DKuvvfatY1Bfh5HW4VUkkuTYwr/x5x+RkciSvFFa03bbT/jmPqhEYZabky+ziwrrTjZA0460QlA/cIcx4IGjIRpmXlzFEwQQKvI4rNQZXU0k1Tvjtdkn/oCHn/R9HLVe6fQegPie+maoe3nYTbKykp46CJR4ehuYP031IqXAixVN0n+r5sxZ9JDB8yNJ43KffRH4O0XeRxKkz3SWRyJFlf/PIdld/Mic+lk5I/r7Wn3b1PkrGoLO2qy3UyEiHm1vxdIF/bWLjzmX8nuPaEjBAHWM7nCMiKnEFdv1OlhKtKKR5SqhSXkc3P3VL1EWQthfe4quXCnxaQQEUQgw1bXb+0USXRHpJ2nXFGDdtDYNRK+n6eu7dVQAJFc45JR6GyWPQODCU0uheaAioYc3jV8mgLowlYlHxWKLnQLR26EY579N+68k"
errMsg: "getUserProfile:ok"
iv: "CC2FCmtZuF16+KHf/vNLQg=="
rawData: "{"nickName":"微信用户","gender":0,"language":"","city":"","province":"","country":"","avatarUrl":"https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132","is_demote":true}"
signature: "c4c8e5b30eabe268cfeaa422e20ddead0fb5bd59"
userInfo: Object
avatarUrl: "https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132"
city: ""
country: ""
gender: 0
is_demote: true
language: ""
nickName: "微信用户"
province: ""
__proto__: Object
__proto__: Object
测试微信版本:8.0.37
参考https://developers.weixin.qq.com/community/develop/doc/00022c683e8a80b29bed2142b56c01
这个微信已经整改了,参考:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/userProfile.html
就离谱。。。
getUserProfile接口有调整,参考公告:https://developers.weixin.qq.com/community/develop/doc/00022c683e8a80b29bed2142b56c01 ;
头像昵称填写功能可以了解一下:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/userProfile.html