处理昵称

develop
jscyl13849007907 12 months ago
parent ee7e54fcde
commit ccfa0d8db4

@ -20,7 +20,7 @@
</block> </block>
<view class="usernamebox"> <view class="usernamebox">
<view class="username"> <view class="username">
<view class="theusername">{{userInfo.user.nickName || '伯才用户' }}</view> <view class="theusername">{{userInfo.user.userName || '伯才用户' }}</view>
<i class="iconfont icon-nv3 f12" style="color:#fb8585;line-height:20px" wx:if="{{userInfo.user.sex == 2}}"></i> <i class="iconfont icon-nv3 f12" style="color:#fb8585;line-height:20px" wx:if="{{userInfo.user.sex == 2}}"></i>
<i class="iconfont icon-nan3 f12" style="color:#10aeff;line-height:20px" wx:if="{{userInfo.user.sex == 1}}"></i> <i class="iconfont icon-nan3 f12" style="color:#10aeff;line-height:20px" wx:if="{{userInfo.user.sex == 1}}"></i>
</view> </view>

@ -29,18 +29,19 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
let that = this;
if (wx.getStorageSync("configInfo")) { if (wx.getStorageSync("configInfo")) {
this.setData({ this.setData({
configInfo: { ...wx.getStorageSync("configInfo"), biao: false }, configInfo: { ...wx.getStorageSync("configInfo"), biao: false },
}); });
console.log('configInfo', this.data.configInfo); console.log('configInfo', this.data.configInfo);
} }
setTimeout(() => { that.copyUpdateToken(()=>{
console.log('app.globalData.loginUserInfo',app.globalData.loginUserInfo); console.log('app.globalData.loginUserInfo',app.globalData.loginUserInfo);
this.setData({ that.setData({
userInfo: app.globalData.loginUserInfo, userInfo: app.globalData.loginUserInfo,
}); });
}, 100); })
}, },
showToggle () { showToggle () {
@ -108,6 +109,22 @@ Page({
}) })
}, },
copyUpdateToken(callback=()=>{}){
let that = this;
customRequest('/appLoginByToken', { header: 'headers', method: 'GET', data: {} }).then((res) => {
console.log(res);
app.globalData.agencyStatus = res.data.data.agencyStatus;
app.globalData.loginUserInfo = res.data.data;
wx.setStorageSync("loginUser", res.data.data);
wx.setStorageSync("LOGINUSER_ID", res.data.data.user.agencyId);
this.setData({
drawerShow: false
})
// that.onLoad()
// that.onShow()
callback();
})
},
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */

@ -22,7 +22,7 @@
<view class="userName"> <view class="userName">
<view class="fw500">用户名</view> <view class="fw500">用户名</view>
<view> <view>
<view>{{userInfo.nickName}}</view> <view>{{userInfo.userName}}</view>
<view class="iconfont icon-gengduo11"></view> <view class="iconfont icon-gengduo11"></view>
</view> </view>
</view> </view>

@ -7,7 +7,7 @@ Page({
*/ */
data: { data: {
userId: "", userId: "",
nickName: "", userName: "",
btnLoading: false, btnLoading: false,
}, },
@ -21,7 +21,7 @@ Page({
var that = this; var that = this;
if (app.isEmptyCheck(e.detail.value.nickName)) { if (app.isEmptyCheck(e.detail.value.userName)) {
wx.showToast({ wx.showToast({
icon: "none", icon: "none",
title: "请输入姓名", title: "请输入姓名",
@ -34,10 +34,12 @@ Page({
var formData = e.detail.value; var formData = e.detail.value;
// formData["userId"] = that.data.userId; // formData["userId"] = that.data.userId;
console.log(formData);
customRequest("/user/updateNickName", { header: 'headers', method: 'POST', data:formData }).then((res) => { customRequest("/user/updateNickName", { header: 'headers', method: 'POST', data:{
nickName:formData.userName
} }).then((res) => {
if (res.data.status == 200) { if (res.data.status == 200) {
app.globalData.user.nickName = formData.nickName; app.globalData.user.userName = formData.userName;
wx.navigateBack({ wx.navigateBack({
delta: 1, delta: 1,
@ -93,7 +95,7 @@ Page({
onShow: function () { onShow: function () {
this.setData({ this.setData({
userId: app.globalData.user.id, userId: app.globalData.user.id,
nickName: app.globalData.user.nickName, userName: app.globalData.user.userName,
}); });
}, },

@ -4,7 +4,7 @@
<view class="weui-cell"> <view class="weui-cell">
<view class="weui-cell__hd"><label class="weui-label fw500">用户名</label></view> <view class="weui-cell__hd"><label class="weui-label fw500">用户名</label></view>
<view class="weui-cell__bd"> <view class="weui-cell__bd">
<input name="nickName" type='nickname' value="{{nickName}}" class="weui-input tr" placeholder="请输入用户名" placeholder-class="weui-input__placeholder" /> <input name="userName" type='userName' value="{{userName}}" class="weui-input tr" placeholder="请输入用户名" placeholder-class="weui-input__placeholder" />
</view> </view>
</view> </view>
</view> </view>

Loading…
Cancel
Save