// pages/member/info_costom/info_costom.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { custom_title: '', custom_value: '' }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { this._getMemberInfo2(); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { }, //绑定输入信息的值 custom_inp(e) { let val = e.detail.value; this.setData({ "custom_value": val.trim() }); }, //获取自定义数据 _getMemberInfo2() { let that = this; let urlStr = app.getNetAddresss("member.member.get-custom-field"); app._getNetWork({ url: urlStr, success: function(resdata) { var res = resdata.data; if (res.result == 1) { that.setData({ custom_title: res.data.custom_title }); } }, fail: function(res) { console.log(res); } }); }, submitInfo() { if (app._isTextEmpty(this.data.custom_value)) { wx.showToast({ icon: 'none', title: this.data.custom_title + "信息不能为空", duration: 1500 }); return; } // let that = this; let urlStr = app.getNetAddresss("member.member.save-custom-field"); urlStr += '&custom_value=' + this.data.custom_value; app._getNetWork({ url: urlStr, success: function(resdata) { var res = resdata.data; if (res.result == 1) { wx.showToast({ title: '成功', icon: 'none', duration: 1500, success: function() { setTimeout(function() { //要延时执行的代码 wx.navigateBack({ delta: 1 }); }, 1500); //延迟时间 }, }); } else { wx.showToast({ title: res.msg, icon: 'none', duration: 1500, success: function() { setTimeout(function() { //要延时执行的代码 wx.navigateBack({ delta: 1 }); }, 1500); //延迟时间 }, }); } }, fail: function(res) { console.log(res); } }); } });