147 lines
2.5 KiB
JavaScript
147 lines
2.5 KiB
JavaScript
const App = getApp();
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
userInfo: {},
|
|
UserCategory:[],
|
|
category_id:0,
|
|
category_name:'未选择队伍',
|
|
isLogin: false,
|
|
show:0
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
this.getUserDetail();
|
|
this.getUserCategory();
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
let _this = this;
|
|
_this.setData({
|
|
isLogin: App.checkIsLogin()
|
|
});
|
|
},
|
|
|
|
/**
|
|
* 获取当前用户信息
|
|
*/
|
|
getUserDetail() {
|
|
let _this = this;
|
|
App._post_form('user.index/detail', {
|
|
user_id: wx.getStorageSync('user_id')
|
|
}, result => {
|
|
_this.setData(result.data);
|
|
_this.setData({
|
|
category_id:result.data.userInfo.category_id
|
|
});
|
|
});
|
|
},
|
|
getUserCategory(){
|
|
let _this = this;
|
|
App._post_form('user.index/getUserCategory', {}, result => {
|
|
_this.setData(result.data);
|
|
let UserCategoryArr = result.data.UserCategory;
|
|
for(let i=0; i<UserCategoryArr.length; i++){
|
|
if(UserCategoryArr[i].category_id == _this.data.category_id){
|
|
_this.setData({
|
|
category_name:UserCategoryArr[i].name
|
|
});
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
setCategory(){
|
|
let _this = this;
|
|
_this.setData({
|
|
show:!_this.data.show
|
|
});
|
|
},
|
|
|
|
|
|
radioChange(e) {
|
|
this.setData({
|
|
radio_category_id:e.detail.value
|
|
});
|
|
|
|
},
|
|
submitCategory(){
|
|
//修改队伍
|
|
let _this = this;
|
|
let radio_category_id = _this.data.radio_category_id;
|
|
let user_id = wx.getStorageSync('user_id');
|
|
|
|
App._post_form('user.index/submitCategory', {
|
|
user_id,
|
|
radio_category_id
|
|
}, result => {
|
|
_this.setData({
|
|
show:!_this.data.show
|
|
});
|
|
let status = result.data.status, msg;
|
|
|
|
switch(status) {
|
|
case 0:
|
|
msg = '修改失败';
|
|
break;
|
|
case 1:
|
|
msg = '修改成功';
|
|
break;
|
|
default:
|
|
msg = '修改失败';
|
|
}
|
|
|
|
wx.showToast({
|
|
title: msg,
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
|
|
_this.setData({
|
|
category_name:result.data.category_name
|
|
});
|
|
});
|
|
|
|
},
|
|
|
|
/** 标记保存 */
|
|
saveBio(){
|
|
|
|
},
|
|
|
|
/**
|
|
* 菜单列表导航跳转
|
|
*/
|
|
onTargetMenus(e) {
|
|
let _this = this;
|
|
if (!_this.onCheckLogin()) {
|
|
return false;
|
|
}
|
|
wx.navigateTo({
|
|
url: '/' + e.currentTarget.dataset.url
|
|
})
|
|
},
|
|
/**
|
|
* 验证是否已登录
|
|
*/
|
|
onCheckLogin() {
|
|
let _this = this;
|
|
if (!_this.data.isLogin) {
|
|
App.showError('很抱歉,您还没有登录');
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
|
|
|
|
}) |