|
|
|
@ -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,25 +225,37 @@ 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.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({
|
|
|
|
uni.showModal({
|
|
|
|
title: '提示',
|
|
|
|
title: '提示',
|
|
|
|
content: '您已拒绝授权,将无法获取微信昵称信息,请重新授权',
|
|
|
|
content: '您取消了授权,将无法获取微信昵称信息',
|
|
|
|
showCancel: false,
|
|
|
|
showCancel: false,
|
|
|
|
confirmText: '知道了',
|
|
|
|
confirmText: '知道了'
|
|
|
|
success: function(res) {
|
|
|
|
|
|
|
|
console.log('用户已拒绝授权');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
init() {
|
|
|
|
init() {
|
|
|
|
let that = this;
|
|
|
|
let that = this;
|
|
|
|
|