个人中心修改资料完善

This commit is contained in:
zdx
2020-12-31 15:19:42 +08:00
parent 923e648a82
commit a3a38b0736
13 changed files with 230 additions and 66 deletions

View File

@@ -18,9 +18,19 @@ const companySubscribesList = ( page) => req({
const getShareCode = ( companyId) => req({
url: "user/share/"+companyId,
})
// 获取用户的基本信息
const getUserInfo = () => req({url: "user/info"}) //用户信息编辑
// 修改用户头像
const EditCover = data => req({url: "user/info/cover",method: "PUT",data: data}) //变更用户头像
const EditNickname = data => req({url: "user/info/nickname",method: "PUT",data: data}) //变更用户昵称
const EditSex= data => req({url: "user/info/sex",method: "PUT",data: data}) //变更用户性别
export default({
userInfo,//用户基本信息
companySubscribesList,//关注企业列表
getShareCode,//获取分享二维码
EditCover,//修改用户头像
getUserInfo,//获取用户消息
EditNickname,//更改用戶名稱
EditSex,//变更用户性别
})

View File

@@ -18,6 +18,7 @@
"pages/user/user_coupon/user_coupon",
"pages/user/user_coupon_data/user_coupon_data",
"pages/user/setting/setting",
"pages/user/setting/aboutMine/edit/edit",
"pages/user/code/code",
"pages/user/setting/aboutUs/aboutUs",
"pages/user/setting/aboutMine/aboutMine",

View File

@@ -116,7 +116,7 @@
<view class="userTop" catchtap="goLogin">
<view class="userTop-head">
<view class="userTop-name"> 游客用户<text>{{info.vip.is_vip?'会员':'游客'}}</text> </view>
<image class="userTop-img" src="/static/images/logo.png"></image>
<image class="userTop-img" src="/static/images/none_head.png"></image>
</view>
<view class="userTop-vip">
<view class="userTop-text">

View File

@@ -8,46 +8,28 @@ Page({
phone: "", //用户信息
nickname: "", //用户昵称
cover: "", //用户头像
columns: ["未知", "男", "女"],
gender: 0 || wx.getStorageSync("gender") * 1,
date: '2016-09-01',
region: ['广东省', '广州市', '海珠区'],
sex:'',
},
besure() {
wx.navigateBack({
delta: 0,
})
},
// 选择性别
pickSex: function (e) {
this.setData({
gender: e.detail.value
});
// console.log("当前选择性别-sex", e.detail.value);
},
// 选择出生年月日
bindTimeChange: function (e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.setData({
time: e.detail.value
})
},
// 选择所在区域
bindRegionChange: function (e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.setData({
region: e.detail.value
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
wx.$api.user.userInfoEdit().then(res => {
this.getUserInfo();
},
// 获取用户的基本信息
getUserInfo() {
wx.$api.user.getUserInfo().then(res => {
this.setData({
phone: res.username,
nickname: res.nickname,
cover: res.avatar
cover: res.avatar,
sex:res.sex
})
})
},
@@ -83,7 +65,9 @@ Page({
if (res.confirm) {
wx.clearStorage({
success: () => {
wx.navigateBack()
wx.navigateTo({
url: '/pages/welcome/index',
})
}
})
}

View File

@@ -1,6 +1,6 @@
{
"usingComponents": {},
"navigationBarTitleText": "修改信息",
"navigationBarTitleText": "个人信息",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#378fff"
}

View File

@@ -8,48 +8,41 @@
</view>
<view class="info_list">
<view class="info_list_title">昵称</view>
<view class="end" bindtap="goUrl">
<input class="txt nowrap" placeholder="请输入昵称"></input>
<navigator class="end" hover-class="none"
url="/pages/user/setting/aboutMine/edit/edit?type=1&nickname={{nickname}}">
<input class="txt nowrap" value="{{nickname}}" disabled placeholder="请输入昵称"></input>
<image src="/static/icons/arrow_right.png" mode="widthFix" style="width:30rpx;"></image>
</navigator>
</view>
</view>
<view class="info_list">
<!-- <view class="info_list">
<view class="info_list_title">真实姓名</view>
<view class="end" bindtap="goUrl">
<input class="txt nowrap" placeholder="请输入真实姓名"></input>
<image src="/static/icons/arrow_right.png" mode="widthFix" style="width:30rpx;"></image>
</view>
</view>
</view> -->
<view class="info_list">
<view class="info_list_title">性别</view>
<view class="end" bindtap="goUrl">
<picker bindchange="pickSex" value="{{ gender }}" class="sex" range="{{ columns }}">
<view>
{{ columns[gender] == "" ? "请输入性别" : "" }}{{ columns[gender] }}
</view>
</picker>
<navigator class="end" hover-class="none"
url="/pages/user/setting/aboutMine/edit/edit?type=2&sex={{sex}}">
<input class="txt nowrap" value="{{sex}}" disabled placeholder="请输入昵称"></input>
<image src="/static/icons/arrow_right.png" mode="widthFix" style="width:30rpx;"></image>
</view>
</navigator>
</view>
<view class="info_list">
<view class="info_list_title">手机号</view>
<view class="end" bindtap="goUrl">
<input class="txt nowrap" placeholder="请输入手机号" maxlength="11"></input>
<image src="/static/icons/arrow_right.png" mode="widthFix" style="width:30rpx;"></image>
<input class="txt nowrap" value="{{phone}}" placeholder="请输入手机号" disabled="true" maxlength="11"></input>
</view>
</view>
<view class="info_list">
<!-- <view class="info_list">
<view class="info_list_title">生日</view>
<view class="end" bindtap="goUrl">
<picker mode="date" value="{{date}}" start="2015-09-01" end="2017-09-01" bindchange="bindDateChange">
<view class="picker">
{{date}}
</view>
</picker>
<navigator class="end" hover-class="none" url="/pages/user/setting/aboutMine/edit/edit?type=2&birthday={{birthday}}">
<input class="txt nowrap" value="{{birthday || '暂未设置'}}" placeholder="" disabled="true" maxlength="11"></input>
<image src="/static/icons/arrow_right.png" mode="widthFix" style="width:30rpx;"></image>
</view>
</view>
<view class="info_list">
</navigator>
</view> -->
<!-- <view class="info_list">
<view class="info_list_title">所在区域</view>
<view class="end" bindtap="goUrl">
<picker mode="region" bindchange="bindRegionChange" value="{{region}}" custom-item="{{customItem}}">
@@ -59,9 +52,8 @@
</picker>
<image src="/static/icons/arrow_right.png" mode="widthFix" style="width:30rpx;"></image>
</view>
</view>
</view> -->
</view>
<view class="beSure" catchtap="besure">退出登录</view>
<view class="beSure beSure1" catchtap="besure">保存</view>
<view class="beSure" catchtap="logOut">退出登录</view>

View File

@@ -58,7 +58,7 @@
}
.beSure {
background-color: #cacaca;
background-color: #378fff;
color: #fff;
font-weight: bold;
position: fixed;
@@ -70,7 +70,7 @@
text-align: center;
border-radius: 0;
font-size: 32rpx;
width: 44%;
border-radius: 50rpx;
}
.beSure1 {

View File

@@ -0,0 +1,96 @@
/**
* Web唐明明
* 匆匆数载恍如梦,岁月迢迢华发增。
* 碌碌无为枉半生,一朝惊醒万事空。
*/
Page({
/**
* 页面的初始数据
*/
data: {
nickname: "",
birthday: '',
type: 1, //1=>微信昵称 2=>生日
columns: ['保密', '男', '女'],
colId: 0, //1->男 2->女 0->保密,
sex: '',
},
onLoad(options) {
this.setData({
type: options.type
})
if (options.type == 2) {
for (var i = 0; i < this.data.columns.length; i++) {
if (this.data.columns[i] == options.sex) {
this.setData({
colId: i,
sex: options.sex
})
}
}
} else if (options.type == 1) {
this.setData({
nickname: options.nickname,
})
}
},
// 选择性别
pickSex: function (e) {
this.setData({
sex: this.data.columns[e.detail.value],
colId: e.detail.value
});
},
/**
* 提交姓名修改信息
*/
setForm(e) {
if (this.data.type == 1) {
let nickName = e.detail.value.nickname
if (nickName != '') {
wx.$api.user.EditNickname({
value: nickName
}).then(() => {
let pages = getCurrentPages(),
prevPage = pages[pages.length - 2];
prevPage.setData({
nickname: nickName
});
wx.navigateBack()
})
} else {
wx.showToast({
title: "昵称不能为空",
icon: "none"
})
}
} else if (this.data.type == 2) {
let sex = this.data.sex
let colId = this.data.colId
if (sex != '') {
wx.$api.user.EditSex({
value: colId
}).then(() => {
let pages = getCurrentPages(),
prevPage = pages[pages.length - 2];
prevPage.setData({
sex: sex
});
wx.navigateBack()
})
} else {
wx.showToast({
title: "性别不能为空",
icon: "none"
})
}
}
}
})

View File

@@ -0,0 +1,6 @@
{
"usingComponents": {},
"navigationBarTitleText": "修改信息",
"navigationBarTextStyle": "white",
"navigationBarBackgroundColor": "#378fff"
}

View File

@@ -0,0 +1,13 @@
<form bindsubmit="setForm">
<view class="inputTxt" wx:if='{{type==1}}'>
<view class="inputTxt-title">昵称</view>
<input placeholder="请输入用户姓名" value="{{nickname}}" name="nickname" />
</view>
<view class="inputTxt" wx:if='{{type==2}}'>
<view class="inputTxt-title">性别</view>
<picker bindchange="pickSex" value="{{ colId }}" class="sex" range="{{ columns }}">
<view> {{sex}} </view>
</picker>
</view>
<button class="beSure" size="default" form-type="submit">确认</button>
</form>

View File

@@ -0,0 +1,51 @@
/**
* Web唐明明
* 匆匆数载恍如梦,岁月迢迢华发增。
* 碌碌无为枉半生,一朝惊醒万事空。
*/
.inputTxt {
background-color: #fff;
padding: 0 30rpx;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
margin-top: 30rpx;
line-height: 90rpx;
}
.inputTxt-title {
font-weight: bold;
color: black;
width: 200rpx;
}
.inputTxt input {
text-align: right;
flex: 1;
height: 90rpx;
}
.beSure[size="default"] {
background-color: #378fff;
color: #fff;
font-weight: bold;
position: fixed;
bottom: 30rpx;
left: 30rpx;
right: 30rpx;
height: 90rpx;
line-height: 90rpx;
border-radius: 0;
font-size: 32rpx;
width: auto;
padding: 0;
border-radius: 50rpx;
}
.sex {
text-align: right;
flex: 1;
}

View File

@@ -8,6 +8,14 @@ Page({
},
// 退出登录
loginOut() {
wx.showModal({
title: "退出提示",
content: "是否现在就退出",
showCancel: true,
confirmColor: "#0b0041",
confirmText: "确定",
success: (res) => {
if (res.confirm) {
wx.clearStorage({
success: (res) => {
wx.reLaunch({
@@ -16,4 +24,7 @@ Page({
},
})
}
}
})
}
})

BIN
static/images/none_head.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB