no message

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

@ -37,18 +37,17 @@
'color':!newForm.wxname ? '#333' : '#666' 'color':!newForm.wxname ? '#333' : '#666'
}" }"
> >
{{ newForm.wxname || '微信昵称' }} {{ newForm.wxname || '点击获取微信昵称' }}
</div> </div>
</div> </div>
<div class="g_flex_column_center g_flex_none" v-if="!newForm.wxname"> <div class="g_flex_column_center g_flex_none" v-if="!newForm.wxname">
<i class="iconfont icon-gengduo11 g_c_c"></i> <i class="iconfont icon-gengduo11 g_c_c"></i>
</div> </div>
</div> </div>
<button open-type="getUserInfo" <!-- 使用新的getUserProfile方式 -->
style="position: absolute;left: 0;top: 0;width: 100%;height: 100%;opacity: 0;" <view v-if="!newForm.wxname"
@getuserinfo="getUserInfo" @click="getUserProfile"
v-if="!newForm.wxname" style="position: absolute;left: 0;top: 0;width: 100%;height: 100%;z-index: 10;"></view>
></button>
</div> </div>
</div> </div>
</div> </div>
@ -226,26 +225,38 @@ export default {
} }
}, },
methods: { methods: {
getUserInfo(e) { // 使getUserProfile API
getUserProfile() {
let that = this; let that = this;
console.log("获取用户信息:", e); //
if (e.detail.userInfo) { if (that.newForm.wxname && that.newForm.wxname !== '微信昵称') {
// return;
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 {
//
uni.showModal({
title: '提示',
content: '您已拒绝授权,将无法获取微信昵称信息,请重新授权',
showCancel: false,
confirmText: '知道了',
success: function(res) {
console.log('用户已拒绝授权');
}
});
} }
},
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: '您取消了授权,将无法获取微信昵称信息',
showCancel: false,
confirmText: '知道了'
});
}
});
},
init() { init() {
let that = this; let that = this;
that.isloading = true; that.isloading = true;

Loading…
Cancel
Save