You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

215 lines
4.4 KiB
JavaScript

2 years ago
// pages/makeInfoSure/index.js
const app = getApp();
const commonUtil = require("../../utils/commonUtil.js");
Page({
/**
* 页面的初始数据
*/
data: {
userInformation: {},
date: '',
},
bindDateChange: function(e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.setData({
date: e.detail.value
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this;
/*wx.getStorage({
key: 'userInformation',
success: function(res) {
console.log(res.data);
that.data.userInformation = res.data;
that.setData({
userInformation: that.data.userInformation
});
}
})*/
if (app.isNotEmptyCheck(app.globalData.user.healthTime)) {
var healthTime = commonUtil.formatDateYMD(app.globalData.user.healthTime);
this.setData({
date: healthTime
})
}
},
showTips: function (_that, msg) {
_that.setData({
popErrorMsg: msg,
pop: 1,
});
setTimeout(() => {
_that.setData({
popErrorMsg: '',
pop: 0,
});
return;
}, 2000)
},
dialog: function (title, content, btxt) {
wx.showModal({
title: title,
content: content,
showCancel: false,
confirmColor: "#e60012",
confirmText: btxt,
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
formSubmit: function (e) {
var that = this;
console.log(e);
// if (!username.test(e.detail.value.userName)) {
// that.showTips(this, "请输入正确的姓名");
// return
// }
if (e.detail.value.date == '') {
that.showTips(this, "请选择时间");
return
}
wx.showLoading({
title: '保存中...',
mask: true
})
wx.request({
url: app.globalData.ip + '/user/auth/health/saveHealthTime',
data: {
healthTime: e.detail.value.date
},
header: app.globalData.headers,
method: "POST",
success: function (res) {
console.log(res);
wx.hideLoading();
if (res.data.status == 200) {
app.globalData.user.healthAuth = 1;
app.globalData.user.healthTime = e.detail.value.date;
app.success("保存成功");
wx.switchTab({
url: '/pages/me/index',
})
} else if (res.data.status == 9999) {
app.dialogNotLogin();
} else {
app.showTips(that, res.data.msg);
}
}
})
},
saveIDCard: function(realName, IDCard) {
let that = this;
wx.request({
url: app.globalData.ip + '/user/auth/authIDCard',
data: {
realName: realName,
IDCard: IDCard
},
header: app.globalData.headers,
method: "POST",
success: function (res) {
// console.log(res);
if (res.data.status == 200) {
wx.showToast({
title: '保存成功',
icon: 'success',
image: '',
duration: 1000,
mask: true,
success: function(res) {
wx.hideLoading();
app.globalData.user.idauth = 1;//如果身份证上传成功,登录缓存的实名认证状态更新为已实名
that.makeInfoSuccess();
},
fail: function(res) {
wx.hideLoading();
},
complete: function(res) {},
})
} else {
app.showTips(that, res.data.msg);
}
}
})
},
makeInfoSuccess:function(){
wx.switchTab({
url: '/pages/me/index',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})