diff --git a/app.json b/app.json index 6396a49..92cd7c5 100644 --- a/app.json +++ b/app.json @@ -210,7 +210,8 @@ "pages/togoin/togoin", "pages/user/Detailed/Detailed", "pages/user/user_fw/user_fw", - "pages/user/cardinfo/cardinfo" + "pages/user/cardinfo/cardinfo", + "pages/user/nick_avatar/nick_avatar" ] } diff --git a/packageE/pages/user/nick_avatar/nick_avatar.js b/packageE/pages/user/nick_avatar/nick_avatar.js new file mode 100644 index 0000000..0c9d9da --- /dev/null +++ b/packageE/pages/user/nick_avatar/nick_avatar.js @@ -0,0 +1,106 @@ +// pages/user/userfw/userfw.js +var e = getApp(), os = e.globalData.setting; +var utils = require('../../../../utils/util.js'); +var regeneratorRuntime = require('../../../../utils/runtime.js'); + + +Page({ + /** + * 页面的初始数据 + */ + data: { + defaultAvatar: os.imghost + "/miniapp/images/no-head.jpg", + ob: {}, + load: 0 + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + if(getApp().globalData.up_nick_avatar){ + this.setData({ + ob: JSON.parse(JSON.stringify(getApp().globalData.up_nick_avatar)) + }) + getApp().globalData.up_nick_avatar=null; + } + + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: async function () { + + }, + + + onChooseAvatar: function (e) { + console.log(e, 1111); + var th = this; + getApp().request.uploadFile(os.url + "/api/weshop/comment/uploadCommentImg", { + filePath: e.detail.avatarUrl, + name: "file", + success: function (t) { + var u = t.data.data; + th.setData({'ob.head_pic': u}) + } + }); + + }, + + get_val: function (e) { + console.log(e, 2222); + this.setData({'ob.nickname': e.detail.value}) + }, + + save_data() { + + if (!this.data.ob.head_pic) { + wx.showToast({ + title: '请选择头像', + icon: 'none', + duration: 2000 + }); + return false; + } + + if (!this.data.ob.nickname) { + wx.showToast({ + title: '请输入昵称', + icon: 'none', + duration: 2000 + }); + return false; + } + + if (this.data.load) return false; + this.setData({load: 1}) + + + wx.showLoading(); + getApp().request.put("/api/weshop/users/update", { + data: { + storeId: os.stoid, + user_id: getApp().globalData.user_id, + nickname: this.data.ob.nickname, + head_pic: this.data.ob.head_pic + + }, + success: function (su) { + wx.hideLoading(); + if (su.data.code == 0) { + wx.navigateBack({delta: 1}) + }else{ + this.setData({load: 0}) + wx.showToast({ + title: su.data.msg, + icon: 'none', + duration: 2000 + }); + } + } + }); + } + + +}) \ No newline at end of file diff --git a/packageE/pages/user/nick_avatar/nick_avatar.json b/packageE/pages/user/nick_avatar/nick_avatar.json new file mode 100644 index 0000000..5abf709 --- /dev/null +++ b/packageE/pages/user/nick_avatar/nick_avatar.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "个人信息", + "usingComponents": {} +} \ No newline at end of file diff --git a/packageE/pages/user/nick_avatar/nick_avatar.wxml b/packageE/pages/user/nick_avatar/nick_avatar.wxml new file mode 100644 index 0000000..091c9cc --- /dev/null +++ b/packageE/pages/user/nick_avatar/nick_avatar.wxml @@ -0,0 +1,25 @@ + + + 头像 + + + + + 昵称 + + + + + + + + + + + 确认修改 + + + + \ No newline at end of file diff --git a/packageE/pages/user/nick_avatar/nick_avatar.wxss b/packageE/pages/user/nick_avatar/nick_avatar.wxss new file mode 100644 index 0000000..7808fc6 --- /dev/null +++ b/packageE/pages/user/nick_avatar/nick_avatar.wxss @@ -0,0 +1,30 @@ +.avatar_btn{ width: 60rpx !important; height: 60rpx !important; border-radius:50%; border: none !important; + margin-left:0 !important;margin-right: 0 !important; } +.head_img{ width: 60rpx; height: 60rpx; border-radius: 50%} + +.page_set{ border-top: 20rpx solid #eee; } +.item{ height: 80rpx; border-bottom: 1rpx solid #eee;padding:0 20rpx} +.nick_inp{ text-align: right; color: #999} + + +.confirm { + width: 100%; + left: 0rpx; + bottom: 0rpx; + height: 130rpx; + background-color: rgb(255, 255, 255); + z-index: 9; + +} + +.confirmtext { + width: 495rpx; + height: 65rpx; + color: rgb(255, 255, 255); + background-color: rgb(214, 1, 33); + border-radius: 35rpx; +} + +.load{ + background-color:#ea3993 !important; +} \ No newline at end of file diff --git a/pages/user/userinfo/userinfo.js b/pages/user/userinfo/userinfo.js index 1034f50..26c8251 100644 --- a/pages/user/userinfo/userinfo.js +++ b/pages/user/userinfo/userinfo.js @@ -658,37 +658,46 @@ Page({ // 获取用户头像昵称 getUserProfile(e) { var th = this; - new Promise((resolve, reject) => { - wx.getUserProfile({ - desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 - success: (res) => { - th.data.user.nickname = res.userInfo.nickName; - th.data.user.head_pic = res.userInfo.avatarUrl; - this.setData({ - userInfo: res.userInfo, - hasUserInfo: true, - user: th.data.user, - }); - resolve(res.userInfo); - }, - }); - }).then((userInfo) => { - getApp().request.put("/api/weshop/users/update", { - data: { - storeId: r.stoid, - user_id: getApp().globalData.user_id, - nickname: userInfo.nickName, - head_pic: userInfo.avatarUrl - - }, - success: function(su) { - if (su.data.code == 0) { - console.log("update user info OK"); - } - } - }); - }); + var ob={ + nickname:this.data.user.nickname, + head_pic:this.data.user.head_pic, + } + getApp().globalData.up_nick_avatar=ob; + getApp().goto('/packageE/pages/user/nick_avatar/nick_avatar'); + + + // new Promise((resolve, reject) => { + // wx.getUserProfile({ + // desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 + // success: (res) => { + // th.data.user.nickname = res.userInfo.nickName; + // th.data.user.head_pic = res.userInfo.avatarUrl; + // this.setData({ + // userInfo: res.userInfo, + // hasUserInfo: true, + // user: th.data.user, + // }); + // resolve(res.userInfo); + // }, + // + // }); + // }).then((userInfo) => { + // getApp().request.put("/api/weshop/users/update", { + // data: { + // storeId: r.stoid, + // user_id: getApp().globalData.user_id, + // nickname: userInfo.nickName, + // head_pic: userInfo.avatarUrl + // + // }, + // success: function(su) { + // if (su.data.code == 0) { + // console.log("update user info OK"); + // } + // } + // }); + // }); },