CompleteTouristInfo.js 1.97 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
// 完善游客信息

// 网络请求工具类
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().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate()
},
/*---------生命周期--------*/
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
})
}
})