From 9181a05b5b14dbb40d1ddaf2c1e3a63baab70311 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Thu, 6 Apr 2023 15:51:25 +0800 Subject: [PATCH] 呢称在输入的优化 --- packageE/pages/user/nick_avatar/nick_avatar.js | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------- 1 file changed, 50 insertions(+), 47 deletions(-) diff --git a/packageE/pages/user/nick_avatar/nick_avatar.js b/packageE/pages/user/nick_avatar/nick_avatar.js index c2042a0..83e0d63 100644 --- a/packageE/pages/user/nick_avatar/nick_avatar.js +++ b/packageE/pages/user/nick_avatar/nick_avatar.js @@ -56,57 +56,60 @@ Page({ save_data() { var that=this; + setTimeout(()=>{ + if (!this.data.ob.head_pic) { + wx.showToast({ + title: '请选择头像', + icon: 'none', + duration: 2000 + }); + return false; + } - 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 + 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: { + store_id: os.stoid, + user_id: getApp().globalData.user_id, + nickname: this.data.ob.nickname, + head_pic: this.data.ob.head_pic + + }, + success: function (su) { + + setTimeout(()=>{ + wx.hideLoading(); + if (su.data.code == 0) { + wx.navigateBack({delta: 1}) + }else{ + that.setData({load: 0}) + wx.showToast({ + title: su.data.msg, + icon: 'none', + duration: 2000 + }); + } + },1000) + + + } }); - return false; - } - - if (this.data.load) return false; - this.setData({load: 1}) - - - wx.showLoading(); - getApp().request.put("/api/weshop/users/update", { - data: { - store_id: os.stoid, - user_id: getApp().globalData.user_id, - nickname: this.data.ob.nickname, - head_pic: this.data.ob.head_pic - - }, - success: function (su) { - - setTimeout(()=>{ - wx.hideLoading(); - if (su.data.code == 0) { - wx.navigateBack({delta: 1}) - }else{ - that.setData({load: 0}) - wx.showToast({ - title: su.data.msg, - icon: 'none', - duration: 2000 - }); - } - },1000) + },500) - } - }); } -- libgit2 0.21.4