|
|
const app = getApp();
|
|
|
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
user: {},
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
var that = this;
|
|
|
if (app.globalData.isLogin) {
|
|
|
that.getUserInfo();
|
|
|
} else {
|
|
|
|
|
|
app.userLoginCallback = res => {
|
|
|
that.getUserInfo();
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
getUserInfo: function() {
|
|
|
var that = this;
|
|
|
|
|
|
wx.request({
|
|
|
url: app.globalData.ip + '/user/auth/getUserInfo',
|
|
|
data: {},
|
|
|
header: app.globalData.header,
|
|
|
method: "POST",
|
|
|
success: function (res) {
|
|
|
console.log(res);
|
|
|
if (res.data.status == 200) {
|
|
|
that.setData({
|
|
|
user: res.data.data
|
|
|
});
|
|
|
} else if (res.data.status == 9999) {
|
|
|
app.dialogNotLogin();
|
|
|
} else {
|
|
|
app.showTips(that, res.data.msg);
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
chooseImage: function(e) {
|
|
|
var that = this;
|
|
|
var type = e.currentTarget.dataset.type;
|
|
|
wx.chooseImage({
|
|
|
count: 1, // 默认9
|
|
|
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
|
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
|
|
success: function (res) {
|
|
|
app.load("上传中");
|
|
|
// 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
|
|
|
var tempFilePaths = res.tempFilePaths;
|
|
|
var formData = {'type' : type};
|
|
|
wx.uploadFile({
|
|
|
url: app.globalData.ip + '/user/auth/uploadImage',
|
|
|
filePath: res.tempFilePaths[0],
|
|
|
name: 'uploadFile',
|
|
|
header: app.globalData.header2, // 设置请求的 header
|
|
|
formData: formData, // HTTP 请求中其他额外的 form data
|
|
|
success: function (res1) {
|
|
|
console.log(res1);
|
|
|
if (res1.statusCode == 200) {
|
|
|
var result = JSON.parse(res1.data)
|
|
|
if (result.status == 200) {
|
|
|
if (type == 4) {
|
|
|
that.data.user['healthImgFrontm'] = result.data.miniUrl;
|
|
|
that.data.user['healthImgFront'] = result.data.url;
|
|
|
} else if (type == 5) {
|
|
|
that.data.user['healthImgBackm'] = result.data.miniUrl;
|
|
|
that.data.user['healthImgBack'] = result.data.url;
|
|
|
}
|
|
|
that.setData({
|
|
|
user: that.data.user
|
|
|
});
|
|
|
} else {
|
|
|
app.showTips(that, result.msg);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
wx.hideLoading();
|
|
|
},
|
|
|
fail: function (res2) {
|
|
|
wx.hideLoading();
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
bindHealthTimeChange: function(e) {
|
|
|
var that = this;
|
|
|
that.data.user.healthTime = e.detail.value;
|
|
|
that.setData({
|
|
|
user: that.data.user
|
|
|
});
|
|
|
},
|
|
|
saveHealthCard: function() {
|
|
|
var that = this;
|
|
|
|
|
|
if (app.isEmptyCheck(that.data.user.healthImgFront)) {
|
|
|
app.showTips(that, "请上传健康证正面照片");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (app.isEmptyCheck(that.data.user.healthImgBack)) {
|
|
|
app.showTips(that, "请上传健康证反面照片");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (app.isEmptyCheck(that.data.user.healthTime)) {
|
|
|
app.showTips(that, "到期时间不能为空");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
app.load("保存中...");
|
|
|
|
|
|
wx.request({
|
|
|
url: app.globalData.ip + '/user/auth/health/saveHealthTime',
|
|
|
data: {
|
|
|
healthTime: that.data.user.healthTime
|
|
|
},
|
|
|
header: app.globalData.header,
|
|
|
method: "POST",
|
|
|
success: function (res) {
|
|
|
console.log(res);
|
|
|
wx.hideLoading();
|
|
|
|
|
|
if (res.data.status == 200) {
|
|
|
app.success("保存成功");
|
|
|
} else if (res.data.status == 9999) {
|
|
|
app.dialogNotLogin();
|
|
|
} else {
|
|
|
app.showTips(that, res.data.msg);
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
/*chooseImage: function () {
|
|
|
wx.chooseImage({
|
|
|
count: 1,
|
|
|
sizeType: ['original', 'compressed'],
|
|
|
sourceType: ['album', 'camera'],
|
|
|
success(res) {
|
|
|
// tempFilePath可以作为img标签的src属性显示图片
|
|
|
const tempFilePaths = res.tempFilePaths
|
|
|
}
|
|
|
})
|
|
|
},*/
|
|
|
|
|
|
}) |