From 939bd28997ccd90f13f1b0df919cbf8283f178ef Mon Sep 17 00:00:00 2001 From: SelfRidicule Date: Thu, 28 Mar 2024 17:02:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=8F=E8=BF=B0:=E8=8E=B7=E5=8F=96=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miniprogram/api/user/user.js | 8 ++++++++ miniprogram/pages/index/index.js | 16 +++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/miniprogram/api/user/user.js b/miniprogram/api/user/user.js index 3e6ecc6..3fa0507 100644 --- a/miniprogram/api/user/user.js +++ b/miniprogram/api/user/user.js @@ -11,3 +11,11 @@ export function userProfile(id) { }); } +// 用户信息 +export function getUserInfoRq(id) { + return request({ + url: '/wx/getUserInfo?userId=' + id, + method: "get", + }); +} + diff --git a/miniprogram/pages/index/index.js b/miniprogram/pages/index/index.js index 3b6b691..b068638 100644 --- a/miniprogram/pages/index/index.js +++ b/miniprogram/pages/index/index.js @@ -7,7 +7,8 @@ import { } from "../../api/common/scan.js" import { - userProfile + userProfile, + getUserInfoRq } from "../../api/user/user.js" import { @@ -157,7 +158,7 @@ Page({ }, onLoad(options) { - console.log('onLoad options' , options); + console.log('onLoad options', options); let _this = this; // 轮播图 @@ -189,10 +190,15 @@ Page({ let _this = this let userId = wx.getStorageSync('userId'); if (userId) { - userProfile(userId).then(res => { - console.log('userProfile', res); + getUserInfoRq(userId).then(res => { + console.log('getUserInfoRq', res); + let userDetail = res.data; + // 存储用户信息 + wx.setStorageSync('openid', userDetail.openid) + wx.setStorageSync('user', userDetail) + wx.setStorageSync('userId', userDetail.id) _this.setData({ - userDetail: res.data + userDetail }) }) } else {