diff --git a/apis/interfaces/user.js b/apis/interfaces/user.js index 32b22c3..57035ed 100644 --- a/apis/interfaces/user.js +++ b/apis/interfaces/user.js @@ -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,//变更用户性别 }) diff --git a/app.json b/app.json index e7f9f0c..dc92cdd 100644 --- a/app.json +++ b/app.json @@ -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", diff --git a/pages/user/index.wxml b/pages/user/index.wxml index 57eb50b..aa8bf59 100644 --- a/pages/user/index.wxml +++ b/pages/user/index.wxml @@ -116,7 +116,7 @@ 游客用户{{info.vip.is_vip?'会员':'游客'}} - + diff --git a/pages/user/setting/aboutMine/aboutMine.js b/pages/user/setting/aboutMine/aboutMine.js index 305f085..6019d18 100644 --- a/pages/user/setting/aboutMine/aboutMine.js +++ b/pages/user/setting/aboutMine/aboutMine.js @@ -8,46 +8,28 @@ Page({ phone: "", //用户信息 nickname: "", //用户昵称 cover: "", //用户头像 - columns: ["未知", "男", "女"], - gender: 0 || wx.getStorageSync("gender") * 1, - date: '2016-09-01', - region: ['广东省', '广州市', '海珠区'], + sex:'', }, - besure(){ + + 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 + delta: 0, }) }, /** * 生命周期函数--监听页面加载 */ 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', + }) } }) } diff --git a/pages/user/setting/aboutMine/aboutMine.json b/pages/user/setting/aboutMine/aboutMine.json index 4cb5236..c85f6d8 100644 --- a/pages/user/setting/aboutMine/aboutMine.json +++ b/pages/user/setting/aboutMine/aboutMine.json @@ -1,6 +1,6 @@ { "usingComponents": {}, - "navigationBarTitleText": "修改信息", + "navigationBarTitleText": "个人信息", "navigationBarTextStyle": "white", "navigationBarBackgroundColor": "#378fff" } \ No newline at end of file diff --git a/pages/user/setting/aboutMine/aboutMine.wxml b/pages/user/setting/aboutMine/aboutMine.wxml index 4a9ad2b..6f9789b 100644 --- a/pages/user/setting/aboutMine/aboutMine.wxml +++ b/pages/user/setting/aboutMine/aboutMine.wxml @@ -8,48 +8,41 @@ 昵称 - - + + - + - + 性别 - - - - {{ columns[gender] == "" ? "请输入性别" : "" }}{{ columns[gender] }} - - + + - + 手机号 - - + - + + -退出登录 -保存 \ No newline at end of file +退出登录 \ No newline at end of file diff --git a/pages/user/setting/aboutMine/aboutMine.wxss b/pages/user/setting/aboutMine/aboutMine.wxss index a50f86d..bf584ea 100644 --- a/pages/user/setting/aboutMine/aboutMine.wxss +++ b/pages/user/setting/aboutMine/aboutMine.wxss @@ -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 { diff --git a/pages/user/setting/aboutMine/edit/edit.js b/pages/user/setting/aboutMine/edit/edit.js new file mode 100644 index 0000000..7c83b24 --- /dev/null +++ b/pages/user/setting/aboutMine/edit/edit.js @@ -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" + }) + } + } + } +}) \ No newline at end of file diff --git a/pages/user/setting/aboutMine/edit/edit.json b/pages/user/setting/aboutMine/edit/edit.json new file mode 100644 index 0000000..4cb5236 --- /dev/null +++ b/pages/user/setting/aboutMine/edit/edit.json @@ -0,0 +1,6 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "修改信息", + "navigationBarTextStyle": "white", + "navigationBarBackgroundColor": "#378fff" +} \ No newline at end of file diff --git a/pages/user/setting/aboutMine/edit/edit.wxml b/pages/user/setting/aboutMine/edit/edit.wxml new file mode 100644 index 0000000..8fd16b9 --- /dev/null +++ b/pages/user/setting/aboutMine/edit/edit.wxml @@ -0,0 +1,13 @@ +
+ + 昵称 + + + + 性别 + + {{sex}} + + + +
\ No newline at end of file diff --git a/pages/user/setting/aboutMine/edit/edit.wxss b/pages/user/setting/aboutMine/edit/edit.wxss new file mode 100644 index 0000000..57f94f4 --- /dev/null +++ b/pages/user/setting/aboutMine/edit/edit.wxss @@ -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; +} \ No newline at end of file diff --git a/pages/user/setting/setting.js b/pages/user/setting/setting.js index 4dceb12..2a80493 100644 --- a/pages/user/setting/setting.js +++ b/pages/user/setting/setting.js @@ -8,12 +8,23 @@ Page({ }, // 退出登录 loginOut() { - wx.clearStorage({ + wx.showModal({ + title: "退出提示", + content: "是否现在就退出", + showCancel: true, + confirmColor: "#0b0041", + confirmText: "确定", success: (res) => { - wx.reLaunch({ - url: '/pages/welcome/index', - }) - }, + if (res.confirm) { + wx.clearStorage({ + success: (res) => { + wx.reLaunch({ + url: '/pages/welcome/index', + }) + }, + }) + } + } }) } }) \ No newline at end of file diff --git a/static/images/none_head.png b/static/images/none_head.png new file mode 100644 index 0000000..472a188 Binary files /dev/null and b/static/images/none_head.png differ