yangg пре 2 месеци
родитељ
комит
116a88ba9f

+ 2 - 2
api/user.js

@@ -43,9 +43,9 @@ export function wxLogin(loginParams) {
  * @param {String} userId - 用户ID,可选
  * @returns {Promise} - 返回用户详细信息
  */
-export const getUserInfo = (userId) => {
+export const getUserInfo = (userId,openid) => {
   // 如果提供了userId,则获取指定用户信息,否则获取当前登录用户信息
-  const url = userId ? `/wechat/getUserDetail?id=${userId}` : '/wechat/getUserDetail';
+  const url = userId ? `/api/wechat/get_user_info?id=${userId}&openid=${openid}` : '/wechat/getUserDetail';
   return http.get(url);
 };
 

+ 2 - 2
pages/index/index.vue

@@ -216,7 +216,7 @@ import { apiBaseUrl } from '@/common/config.js';
 					const userInfo = JSON.parse(uni.getStorageSync('userInfo'));
 					console.log('id:', userInfo.id);
 					
-					getUserInfo(userInfo.id)
+					getUserInfo(userInfo.id,userInfo.openid)
 						.then(res => {
 							uni.hideLoading();
 							const userData = res;
@@ -490,7 +490,7 @@ import { apiBaseUrl } from '@/common/config.js';
 				fillUserInfo(submitData)
 					.then(res => {
 						uni.hideLoading();
-						this.updateLocalUserInfo(res.id);
+						this.updateLocalUserInfo(res.id,JSON.parse(uni.getStorageSync('userInfo')).openid);
 
 						uni.showToast({
 							title: '提交成功',

+ 4 - 4
pages/login/login.vue

@@ -165,7 +165,7 @@ export default {
         is_new_user: data.is_new_user || false,
         
         loginTime: new Date().getTime(),
-        tenant_id: 1
+        /* tenant_id: 1 */
       };
       
       console.log('构建的用户数据:', userData);
@@ -191,7 +191,7 @@ export default {
       
       // 如果有用户ID,则获取完整的用户信息
       if (userData.id) {
-        this.fetchUserDetail(userData.id, userData);
+        this.fetchUserDetail(userData.id, userData,userData.openid);
       } else {
         // 如果没有用户ID,直接完成登录流程
         this.completeLogin();
@@ -199,12 +199,12 @@ export default {
     },
     
     // 获取用户详细信息
-    async fetchUserDetail(userId, basicUserData) {
+    async fetchUserDetail(userId, basicUserData, openid) {
       try {
         console.log('获取用户详细信息,用户ID:', userId);
         
         // 调用获取用户详情API
-        const userDetail = await getUserInfo(userId);
+        const userDetail = await getUserInfo(userId, openid);
         console.log('获取用户详细信息成功:', userDetail);
         
         if (userDetail) {

+ 1 - 1
pages/my/my.vue

@@ -472,7 +472,7 @@ export default {
 				const userId = this.userInfo.userId;
 				
 				// 调用获取用户详情API
-				const userDetail = await getUserInfo(userId);
+				const userDetail = await getUserInfo(userId,JSON.parse(uni.getStorageSync('userInfo')).openid);
 				console.log('获取用户详细信息成功:', userDetail);
 				
 				if (userDetail) {

+ 2 - 2
unpackage/dist/dev/mp-weixin/api/user.js

@@ -28,8 +28,8 @@ function wxLogin(loginParams) {
     }
   });
 }
-const getUserInfo = (userId) => {
-  const url = userId ? `/wechat/getUserDetail?id=${userId}` : "/wechat/getUserDetail";
+const getUserInfo = (userId, openid) => {
+  const url = userId ? `/api/wechat/get_user_info?id=${userId}&openid=${openid}` : "/wechat/getUserDetail";
   return utils_request.http.get(url);
 };
 const logout = () => {

+ 2 - 2
unpackage/dist/dev/mp-weixin/pages/index/index.js

@@ -114,7 +114,7 @@ const _sfc_main = {
       try {
         const userInfo = JSON.parse(common_vendor.index.getStorageSync("userInfo"));
         console.log("id:", userInfo.id);
-        api_user.getUserInfo(userInfo.id).then((res) => {
+        api_user.getUserInfo(userInfo.id, userInfo.openid).then((res) => {
           common_vendor.index.hideLoading();
           const userData = res;
           if (!userData.name || !userData.phone) {
@@ -349,7 +349,7 @@ const _sfc_main = {
       };
       api_user.fillUserInfo(submitData).then((res) => {
         common_vendor.index.hideLoading();
-        this.updateLocalUserInfo(res.id);
+        this.updateLocalUserInfo(res.id, JSON.parse(common_vendor.index.getStorageSync("userInfo")).openid);
         common_vendor.index.showToast({
           title: "提交成功",
           icon: "success",

+ 5 - 5
unpackage/dist/dev/mp-weixin/pages/login/login.js

@@ -119,8 +119,8 @@ const _sfc_main = {
         unionid: data.unionid || "",
         session_key: data.session_key || "",
         is_new_user: data.is_new_user || false,
-        loginTime: (/* @__PURE__ */ new Date()).getTime(),
-        tenant_id: 1
+        loginTime: (/* @__PURE__ */ new Date()).getTime()
+        /* tenant_id: 1 */
       };
       console.log("构建的用户数据:", userData);
       return userData;
@@ -139,16 +139,16 @@ const _sfc_main = {
       common_vendor.index.setStorageSync("userInfo", JSON.stringify(userData));
       console.log("基本用户信息已保存");
       if (userData.id) {
-        this.fetchUserDetail(userData.id, userData);
+        this.fetchUserDetail(userData.id, userData, userData.openid);
       } else {
         this.completeLogin();
       }
     },
     // 获取用户详细信息
-    async fetchUserDetail(userId, basicUserData) {
+    async fetchUserDetail(userId, basicUserData, openid) {
       try {
         console.log("获取用户详细信息,用户ID:", userId);
-        const userDetail = await api_user.getUserInfo(userId);
+        const userDetail = await api_user.getUserInfo(userId, openid);
         console.log("获取用户详细信息成功:", userDetail);
         if (userDetail) {
           const updatedUserInfo = {

+ 1 - 1
unpackage/dist/dev/mp-weixin/pages/my/my.js

@@ -307,7 +307,7 @@ const _sfc_main = {
         if (!this.isLogin)
           return;
         const userId = this.userInfo.userId;
-        const userDetail = await api_user.getUserInfo(userId);
+        const userDetail = await api_user.getUserInfo(userId, JSON.parse(common_vendor.index.getStorageSync("userInfo")).openid);
         console.log("获取用户详细信息成功:", userDetail);
         if (userDetail) {
           this.updateUserInfo(userDetail);

+ 1 - 1
unpackage/dist/dev/mp-weixin/project.config.json

@@ -8,7 +8,7 @@
     "urlCheck": false,
     "es6": true,
     "postcss": false,
-    "minified": true,
+    "minified": false,
     "newFeature": true,
     "bigPackageSizeSupport": true,
     "babelSetting": {