no message

cyl/job_im
jscyl13849007907 3 weeks ago
parent 4d4ad332ef
commit 9d927b8860

@ -37,18 +37,17 @@
'color':!newForm.wxname ? '#333' : '#666'
}"
>
{{ newForm.wxname || '微信昵称' }}
{{ newForm.wxname || '点击获取微信昵称' }}
</div>
</div>
<div class="g_flex_column_center g_flex_none" v-if="!newForm.wxname">
<i class="iconfont icon-gengduo11 g_c_c"></i>
</div>
</div>
<button open-type="getUserInfo"
style="position: absolute;left: 0;top: 0;width: 100%;height: 100%;opacity: 0;"
@getuserinfo="getUserInfo"
v-if="!newForm.wxname"
></button>
<!-- 使用新的getUserProfile方式 -->
<view v-if="!newForm.wxname"
@click="getUserProfile"
style="position: absolute;left: 0;top: 0;width: 100%;height: 100%;z-index: 10;"></view>
</div>
</div>
</div>
@ -226,25 +225,37 @@ export default {
}
},
methods: {
getUserInfo(e) {
// 使getUserProfile API
getUserProfile() {
let that = this;
console.log("获取用户信息:", e);
if (e.detail.userInfo) {
//
that.newForm.wxname = e.detail.userInfo.nickName;
that.newForm.wxavatar = e.detail.userInfo.avatarUrl || 'https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/default.svg';
} else {
//
//
if (that.newForm.wxname && that.newForm.wxname !== '微信昵称') {
return;
}
uni.getUserProfile({
desc: '用于完善用户资料', //
success: (res) => {
console.log("获取用户信息成功:", res);
if (res.userInfo) {
that.newForm.wxname = res.userInfo.nickName;
that.newForm.wxavatar = res.userInfo.avatarUrl || 'https://bocai-cms.oss-cn-beijing.aliyuncs.com/web-resource/pugongying/default.svg';
uni.showToast({
title: '获取成功',
icon: 'success'
});
}
},
fail: (err) => {
console.log("获取用户信息失败:", err);
uni.showModal({
title: '提示',
content: '您已拒绝授权,将无法获取微信昵称信息,请重新授权',
content: '您取消了授权,将无法获取微信昵称信息',
showCancel: false,
confirmText: '知道了',
success: function(res) {
console.log('用户已拒绝授权');
}
confirmText: '知道了'
});
}
});
},
init() {
let that = this;

Loading…
Cancel
Save