init project
This commit is contained in:
180
pages/userInfo/index.js
Normal file
180
pages/userInfo/index.js
Normal file
@@ -0,0 +1,180 @@
|
||||
// pages/userInfo/index.js
|
||||
const app = getApp();
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
setList: [],
|
||||
isShowSheet: false,
|
||||
members: {},
|
||||
gohome: true
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function() {
|
||||
this.getData();
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function() {
|
||||
return {
|
||||
title: '智慧云馆'
|
||||
}
|
||||
},
|
||||
|
||||
// 切换头像
|
||||
changeAvatar() {
|
||||
let that = this;
|
||||
wx.chooseImage({
|
||||
count: 1,
|
||||
success: function (e) {
|
||||
wx.showLoading({
|
||||
title: '正在上传...',
|
||||
mask: true,
|
||||
})
|
||||
app.$api.uploadAvatar({
|
||||
filePath: e.tempFilePaths[0]
|
||||
}).then(res => {
|
||||
wx.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success',
|
||||
})
|
||||
that.getData();
|
||||
}, err => {});
|
||||
},
|
||||
fail: function (res) {
|
||||
console.log(res);
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
// 修改性别
|
||||
changeSex(val) {
|
||||
this.setData({
|
||||
setList: [{
|
||||
label: '男',
|
||||
value: 0,
|
||||
type: 'sex'
|
||||
}, {
|
||||
label: '女',
|
||||
value: 1,
|
||||
type: 'sex'
|
||||
}, {
|
||||
label: '不选择',
|
||||
value: 2,
|
||||
type: 'sex'
|
||||
}],
|
||||
isShowSheet: true
|
||||
})
|
||||
},
|
||||
|
||||
// 隐藏sheet弹框
|
||||
cancelSheet() {
|
||||
this.setData({
|
||||
isShowSheet: false
|
||||
})
|
||||
},
|
||||
|
||||
// 选择sheet
|
||||
selectedSheet(e) {
|
||||
let obj = e.detail;
|
||||
if (obj.type == 'avatar') {
|
||||
if (obj.value == 0) {
|
||||
this.photograph('camera');
|
||||
}
|
||||
if (obj.value == 1) {
|
||||
this.photograph('album');
|
||||
}
|
||||
}
|
||||
if (obj.type == 'sex') {
|
||||
this.updateSex(obj.value);
|
||||
}
|
||||
this.setData({
|
||||
isShowSheet: false
|
||||
})
|
||||
},
|
||||
|
||||
// 修改性别 上传服务器
|
||||
updateSex(val) {
|
||||
app.$api.memberUpdateInformation({
|
||||
sex: val
|
||||
}).then(res => {
|
||||
this.getData();
|
||||
}, err => {
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
// 修改信息
|
||||
changeMessage(e) {
|
||||
let label = e.currentTarget.dataset.label;
|
||||
let value = e.currentTarget.dataset.value ? e.currentTarget.dataset.value : "";
|
||||
wx.removeStorageSync('history');
|
||||
wx.navigateTo({
|
||||
url: `/pages/register/index?label=${label}&value=${value}&codeType=3`,
|
||||
})
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
getData() {
|
||||
wx.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true,
|
||||
})
|
||||
app.$api.memberInformation({}).then(res => {
|
||||
this.setData({
|
||||
members: res.members
|
||||
})
|
||||
}, err => {
|
||||
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user