// 完善游客信息 // 网络请求工具类 var networkUtil = require('../../utils/network_util.js') var api = require('../../utils/apiFile.js') // 是否有更多 var userId = '' var token = '' Page({ data: { birth:'请选择出生日期', chooseOne:1, chooseTwo:0, showErr:false, today: new Date() }, /*---------生命周期--------*/ onLoad: function (e) { userId = e.userId token = e.token }, chooseCheckboxOne: function () { this.setData({ chooseOne: 1, chooseTwo: 0 }) }, chooseCheckboxTwo: function () { this.setData({ chooseOne: 0, chooseTwo: 1 }) }, chooseBirth(e){ console.log(e.detail.value) this.setData({ birth: e.detail.value}) }, formSubmit: function (e) { var self = this if (this.data.birth == '请选择出生日期') { this.setData({ showErr: true }) return } this.setData({ showErr: false }) networkUtil.showLoading() getApp().globalData.token = token var param = { 'birth': this.data.birth} networkUtil._put(api.kTourisInfo + userId, param, function (res) { console.log(res) wx.showModal({ title: '提示', content: '资料完善成功,立即进入首页', success: function (res) { if (res.confirm) { self.loginSuccess() } } }) }, function (res) { networkUtil.showErrorToast(res.errormsg) }) }, loginSuccess() { // 游客用户 getApp().globalData.tourist = true wx.setStorageSync('tourist', true) wx.setStorageSync('userToken',token) wx.setStorageSync('userId', [userId]) getApp().globalData.userId = [userId] getApp().globalData.currentId = userId wx.navigateBack({ delta: 5 }) } })