From 9d927b886061b9bc042eeef0dfc4cb12c66dba99 Mon Sep 17 00:00:00 2001
From: jscyl13849007907 <13849007907@163.com>
Date: Mon, 18 May 2026 15:52:32 +0800
Subject: [PATCH] no message
---
root/bind/applyForm.vue | 59 +++++++++++++++++++++++++++++--------------------
1 file changed, 35 insertions(+), 24 deletions(-)
diff --git a/root/bind/applyForm.vue b/root/bind/applyForm.vue
index face299..1b11440 100644
--- a/root/bind/applyForm.vue
+++ b/root/bind/applyForm.vue
@@ -37,18 +37,17 @@
'color':!newForm.wxname ? '#333' : '#666'
}"
>
- {{ newForm.wxname || '微信昵称' }}
+ {{ newForm.wxname || '点击获取微信昵称' }}
-
+
+
@@ -226,26 +225,38 @@ 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 {
- // 用户拒绝授权
- uni.showModal({
- title: '提示',
- content: '您已拒绝授权,将无法获取微信昵称信息,请重新授权',
- showCancel: false,
- confirmText: '知道了',
- success: function(res) {
- console.log('用户已拒绝授权');
- }
- });
+ // 检查是否已经授权过
+ 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: '您取消了授权,将无法获取微信昵称信息',
+ showCancel: false,
+ confirmText: '知道了'
+ });
+ }
+ });
+ },
init() {
let that = this;
that.isloading = true;