从远程获取头像,用户信息等

This commit is contained in:
mactj 2021-01-19 15:46:14 +08:00
parent 17451b235b
commit 15b7221dc0
4 changed files with 29 additions and 7 deletions

View File

@ -111,7 +111,7 @@ public class MiniComponent {
return sessionInfo; return sessionInfo;
} }
public AjaxResult registration(String openid, String mobile, String nickName, Long deptId) { public AjaxResult registration(String openid, String mobile, String nickName, Long deptId, String avatar) {
SysUser user = new SysUser(); SysUser user = new SysUser();
String userName = MINI_USER_SYMBOL + openid + "-" + deptId; String userName = MINI_USER_SYMBOL + openid + "-" + deptId;
@ -119,6 +119,7 @@ public class MiniComponent {
user.setPhonenumber(mobile); user.setPhonenumber(mobile);
user.setNickName(nickName); user.setNickName(nickName);
user.setDeptId(deptId); user.setDeptId(deptId);
user.setAvatar(avatar);
user.setPassword(MINI_DEFUALT_PASSWORD); user.setPassword(MINI_DEFUALT_PASSWORD);
user.setRoleIds(new Long[]{MINI_DEFUALT_ROLEID}); user.setRoleIds(new Long[]{MINI_DEFUALT_ROLEID});
user.setPostIds(new Long[]{MINI_DEFUALT_POSTID}); user.setPostIds(new Long[]{MINI_DEFUALT_POSTID});

View File

@ -8,8 +8,10 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit; import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.framework.web.service.SysLoginService; import com.ruoyi.framework.web.service.SysLoginService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.winery.component.MiniComponent; import com.ruoyi.winery.component.MiniComponent;
import com.ruoyi.winery.domain.winery.WineryCompanyRecord; import com.ruoyi.winery.domain.winery.WineryCompanyRecord;
import com.ruoyi.winery.enums.IrrigationTypeEnum; import com.ruoyi.winery.enums.IrrigationTypeEnum;
@ -44,7 +46,7 @@ public class MiniUserController {
@Autowired @Autowired
private SysLoginService loginService; private ISysUserService userService;
/** /**
* 通过微信api授权获取手机号 * 通过微信api授权获取手机号
@ -83,7 +85,8 @@ public class MiniUserController {
String mobile = json.getStr("mobile"); String mobile = json.getStr("mobile");
Long deptId = json.getLong("deptId"); Long deptId = json.getLong("deptId");
String nickName = json.getJSONObject("userInfo").getStr("nickName"); String nickName = json.getJSONObject("userInfo").getStr("nickName");
return miniComponent.registration(openid, mobile, nickName, deptId); String avatar = json.getJSONObject("userInfo").getStr("avatarUrl");
return miniComponent.registration(openid, mobile, nickName, deptId, avatar);
} }
@ -107,6 +110,16 @@ public class MiniUserController {
// 生成令牌 // 生成令牌
String token = miniComponent.loginByMini(userAccount); String token = miniComponent.loginByMini(userAccount);
ajax.put(Constants.TOKEN, token); ajax.put(Constants.TOKEN, token);
SysUser user = userService.selectUserByUserName(userAccount);
JSONObject userInfo = new JSONObject();
userInfo.set("nickName",user.getNickName());
userInfo.set("avatarUrl" ,user.getAvatar());
userInfo.set("mobile" ,user.getPhonenumber());
ajax.put("userInfo", userInfo);
return ajax; return ajax;
} }

View File

@ -26,8 +26,11 @@ class AppManager {
if (req2.token) { if (req2.token) {
store.dispatch('setTokenAction', req2.token) store.dispatch('setTokenAction', req2.token)
self.setCacheInfo() self.setCacheInfo()
self.setRemoteUserInfo(req2.userInfo)
} }
wx.hideLoading() wx.hideLoading()
if (callBack) { if (callBack) {
@ -52,6 +55,11 @@ class AppManager {
return wx.getStorageSync('openid') return wx.getStorageSync('openid')
} }
setRemoteUserInfo(userInfo) {
store.dispatch('setMobileAction', userInfo.mobile)
store.dispatch('setUserInfoAction', userInfo)
}
setCacheInfo() { setCacheInfo() {
const mobile = wx.getStorageSync('mobile') const mobile = wx.getStorageSync('mobile')
const openid = wx.getStorageSync('openid') const openid = wx.getStorageSync('openid')

View File

@ -67,7 +67,7 @@
<div class="container" style="margin: 10px 10px 80px 10px;"> <div class="container" style="margin: 10px 10px 80px 10px;">
<div class="user-info"> <div class="user-info">
<van-image round width="120rpx" height="120rpx" :src="user.userInfo.avatarUrl" /> <van-image round width="90rpx" height="90rpx" :src="user.userInfo.avatarUrl" />
<div class="user-info-msg"> <div class="user-info-msg">
<span style="font-size: 18px;">{{user.mobile}}</span> <span style="font-size: 18px;">{{user.mobile}}</span>
<span style="font-size: 12px;">{{user.userInfo.nickName}}</span> <span style="font-size: 12px;">{{user.userInfo.nickName}}</span>
@ -84,7 +84,7 @@
<div class="header-grid-body-bottom"> <div class="header-grid-body-bottom">
<van-grid column-num="3" border="{{ false }}" style="margin-top: 15px;"> <van-grid column-num="3" border="{{ false }}" style="margin-top: 15px;">
<van-grid-item use-slot v-for=" (item, index) in navDefine.MY_MENU1" @tap="onNavItem(item)"> <van-grid-item use-slot v-for=" (item, index) in navDefine.MY_MENU1" @tap="onNavItem(item)">
<van-image round width="120rpx" height="120rpx" :src="item.icon" /> <van-image round width="90rpx" height="90rpx" :src="item.icon" />
<span style="margin-top: 10px;">{{item.name}} </span> <span style="margin-top: 10px;">{{item.name}} </span>
</van-grid-item> </van-grid-item>
</van-grid> </van-grid>
@ -94,7 +94,7 @@
<span style="margin:25px 10px 15px 10px;font-weight: bold;">常用功能</span> <span style="margin:25px 10px 15px 10px;font-weight: bold;">常用功能</span>
<van-grid column-num="3" border="{{ false }}" style="margin-top: 15px;"> <van-grid column-num="3" border="{{ false }}" style="margin-top: 15px;">
<van-grid-item use-slot v-for=" (item, index) in navDefine.MY_MENU2" @tap="onNavItem(item)"> <van-grid-item use-slot v-for=" (item, index) in navDefine.MY_MENU2" @tap="onNavItem(item)">
<van-image round width="120rpx" height="120rpx" :src="item.icon" /> <van-image round width="90rpx" height="90rpx" :src="item.icon" />
<span style="margin-top: 10px;">{{item.name}} </span> <span style="margin-top: 10px;">{{item.name}} </span>
</van-grid-item> </van-grid-item>
</van-grid> </van-grid>
@ -104,7 +104,7 @@
<span style="margin:25px 10px 15px 10px;font-weight: bold;">更多推荐</span> <span style="margin:25px 10px 15px 10px;font-weight: bold;">更多推荐</span>
<van-grid column-num="3" border="{{ false }}" style="margin-top: 15px;"> <van-grid column-num="3" border="{{ false }}" style="margin-top: 15px;">
<van-grid-item use-slot v-for=" (item, index) in navDefine.MY_MENU3" @tap="onNavItem(item)"> <van-grid-item use-slot v-for=" (item, index) in navDefine.MY_MENU3" @tap="onNavItem(item)">
<van-image round width="120rpx" height="120rpx" :src="item.icon" /> <van-image round width="90rpx" height="90rpx" :src="item.icon" />
<span style="margin-top: 10px;">{{item.name}} </span> <span style="margin-top: 10px;">{{item.name}} </span>
</van-grid-item> </van-grid-item>
</van-grid> </van-grid>