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.

177 lines
4.2 KiB
JavaScript

2 years ago
// pages/infoExcel/index.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
lifePhotoUrl: null,
lifePhotoUrlMini: null,
},
chooseImg: function() {
var that = this;
wx.chooseImage({
count: 1, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
// 返回选定照片的本地文件路径列表tempFilePath可以作为img标签的src属性显示图片
var tempFilePaths = res.tempFilePaths;
// var formData = {'userId': app.globalData.userId};
wx.uploadFile({
url: app.globalData.ip + '/commons/uploadImageReturnUrl',
filePath: res.tempFilePaths[0],
name: 'uploadFile',
header: app.globalData.headers2,
// formData: formData, // HTTP 请求中其他额外的 form data
success: function (res1) {
if (res1.statusCode == 200) {
var result = JSON.parse(res1.data)
if (result.status == 200) {
that.setData({
lifePhotoUrl: result.data.url,
lifePhotoUrlMini: result.data.miniUrl,
});
} else {
app.showTips(that, result.msg);
}
} else if (res.data.status == 9999) {
app.dialogNotLogin();
}
},
fail: function (res2) {
}
})
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getUserDetails();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
getUserDetails: function() {
var that = this;
wx.request({
url: app.globalData.ip + '/user/getUserDetails',
data: {},
header: app.globalData.headers,
method: "POST",
success: function (res) {
console.log(res);
if (res.data.status == 200) {
that.data.userDetails = res.data.data;
that.setData({
userDetails: that.data.userDetails,
lifePhotoUrl: that.data.userDetails.lifePhoto,
lifePhotoUrlMini: that.data.userDetails.lifePhotoMini,
});
} else if (res.data.status == 9999) {
// app.dialogNotLogin();
} else {
app.showTips(that, res.data.msg);
}
}
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onSubmit: function (e) {
var that = this;
var formData = {
'liveAddress' : e.detail.value.liveAddress,
'weChat' : e.detail.value.weChat,
'lifePhotoUrl' : that.data.lifePhotoUrl,
'lifePhotoUrlMini' : that.data.lifePhotoUrlMini,
};
console.log(formData);
wx.request({
url: app.globalData.ip + '/user/updateUserInformationRegistration',
data: formData,
header: app.globalData.headers,
method: "POST",
success: function (res) {
console.log(res);
if (res.data.status == 200) {
wx.showToast({
title: '保存成功',
icon: 'success',
image: '',
duration: 1500,
mask: true,
success: function(res) {
wx.navigateBack({
delta: 1
})
},
fail: function(res) {
wx.hideLoading();
},
complete: function(res) {},
})
} else if (res.data.status == 9999) {
// app.dialogNotLogin();
} else {
app.showTips(that, res.data.msg);
}
}
})
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})