// pages/ageChange/ageChange.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { age:1, frommy:0 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if (options && options.frommy) { this.setData({ frommy: options.frommy, age: options.age, }) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, back: function () { wx.navigateBack({ delta: 1 }) }, //选择年龄段 selectAge(e) { let age = e.currentTarget.dataset['index'] this.setData({ age: age }) }, //提交年龄段 updateAge(e){ var that = this; var config = wx.getStorageSync('config'); wx.request({ url: app.url + 'ajax_update_user_age.php', data: { unionId: config.unionId, age: that.data.age }, header: { 'content-type': 'application/json' }, method: 'GET', dataType: 'json', success: function (res) { wx.showToast({ title: '选择成功!', icon: 'success', duration: 2000 }); if (res.data.status == 'OK' && res.data.result.recommend) { wx.redirectTo({ url: '/pages/memberChange/memberChange', }) } else { //是否为邀请入圈 var inviteUrl = wx.getStorageSync('inviteUrl'); if (inviteUrl) { wx.redirectTo({ url: inviteUrl, }); } else { //跳转到首页 wx.switchTab({ url: '../index/index', }); } } }, fail: function (res) { wx.showToast({ title: '系统错误!', icon: 'success', duration: 2000 }); }, complete: function (res) { }, }) }, })