|
|
|
// pages/redGrider/redGrider.js
|
|
|
|
var api = require('../../utils/api.js')
|
|
|
|
var config = require('../../utils/config.js')
|
|
|
|
const partyApi = require('../../utils/partApi')
|
|
|
|
const app = getApp()
|
|
|
|
Page({
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
statusHeight: app.globalData.deviceInfo.statusHeight, // 自定义头部状态栏高度
|
|
|
|
navigationHeight: app.globalData.deviceInfo.navigationHeight,
|
|
|
|
userName: {},
|
|
|
|
faceImg: '',
|
|
|
|
pass: 0,
|
|
|
|
userId: '',
|
|
|
|
userInfo: {},
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad(options) {
|
|
|
|
this.getUserProfile()
|
|
|
|
},
|
|
|
|
getUserProfile(e) {
|
|
|
|
// let than = this
|
|
|
|
// wx.getUserInfo({
|
|
|
|
// success: function (res) {
|
|
|
|
// console.log(res);
|
|
|
|
// var userInfo = res.userInfo;
|
|
|
|
// var avatarUrl = userInfo.avatarUrl; // 用户头像链接
|
|
|
|
// // 其他操作...
|
|
|
|
// than.setData({
|
|
|
|
// faceImg: avatarUrl
|
|
|
|
// })
|
|
|
|
// },
|
|
|
|
// fail: function (res) {
|
|
|
|
// // 用户拒绝授权,处理授权失败的情况
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
let obj = JSON.parse(wx.getStorageSync('userInfo'))
|
|
|
|
this.setData({
|
|
|
|
userId: obj.id,
|
|
|
|
faceImg: obj.faceImg
|
|
|
|
})
|
|
|
|
this.getCentralhousehold();
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow() {
|
|
|
|
let savedUserInfoString = wx.getStorageSync("userInfo");
|
|
|
|
if (savedUserInfoString) {
|
|
|
|
let savedUserInfo = JSON.parse(savedUserInfoString);
|
|
|
|
this.setData({
|
|
|
|
userName: savedUserInfo.realName,
|
|
|
|
faceImg: savedUserInfo.faceImg
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
userName: '请先注册',
|
|
|
|
faceImg: '../../images/head.png'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
|
|
},
|
|
|
|
back() {
|
|
|
|
//返回上一级,关闭当前页面
|
|
|
|
wx.navigateBack({
|
|
|
|
delta: 1
|
|
|
|
})
|
|
|
|
},
|
|
|
|
logoout() {
|
|
|
|
let than = this
|
|
|
|
wx.showModal({
|
|
|
|
title: '提示',
|
|
|
|
content: '确定退出登录',
|
|
|
|
success(res) {
|
|
|
|
if (res.confirm) {
|
|
|
|
wx.showLoading({
|
|
|
|
title: "退出中,请稍后...",
|
|
|
|
mask: true,
|
|
|
|
success() {
|
|
|
|
setTimeout(() => {
|
|
|
|
wx.removeStorage({
|
|
|
|
key: 'token',
|
|
|
|
})
|
|
|
|
wx.reLaunch({
|
|
|
|
url: '/pages/login/login'
|
|
|
|
})
|
|
|
|
}, 1000)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
tapchangeImg() {
|
|
|
|
const _this = this;
|
|
|
|
wx.chooseMedia({
|
|
|
|
count: 1,
|
|
|
|
mediaType: ['image'],
|
|
|
|
sourceType: ['album', 'camera'],
|
|
|
|
camera: 'back',
|
|
|
|
success(res) {
|
|
|
|
const url = res.tempFiles[0].tempFilePath;
|
|
|
|
if (url) {
|
|
|
|
wx.uploadFile({
|
|
|
|
filePath: url,
|
|
|
|
name: 'file',
|
|
|
|
url: config.BASEURL() + 'commonsUtils/upload',
|
|
|
|
formData: {},
|
|
|
|
success: function (res) {
|
|
|
|
let imgUrl = JSON.parse(res.data).data.url;
|
|
|
|
if (imgUrl) {
|
|
|
|
_this.setData({
|
|
|
|
faceImg: imgUrl
|
|
|
|
})
|
|
|
|
wx.login({
|
|
|
|
success: (res) => {
|
|
|
|
let para = {}
|
|
|
|
let obj = JSON.parse(wx.getStorageSync('userInfo') || {})
|
|
|
|
para.identityNo = obj.identityNo;
|
|
|
|
para.mobile = obj.mobile;
|
|
|
|
para.partyFlag = obj.partyFlag;
|
|
|
|
para.realName = obj.realName;
|
|
|
|
para.shibei = obj.shibei;
|
|
|
|
para.villageName = obj.villageName;
|
|
|
|
para.workIndustry = obj.workIndustry;
|
|
|
|
para.workType = obj.workType;
|
|
|
|
para.workUnit = obj.workUnit;
|
|
|
|
para.hobbies = obj.hobbies;
|
|
|
|
para.allDeptIds = obj.allDeptIds.split(",");
|
|
|
|
para.couplingCommunity = obj.couplingCommunity.split(",");
|
|
|
|
para.userId = wx.getStorageSync('userId')
|
|
|
|
para.wxCode = res.code
|
|
|
|
para.faceImg = _this.data.faceImg
|
|
|
|
if (res.code) {
|
|
|
|
api.userInfoUpdate(para).then(res => {
|
|
|
|
if (res.code == 0) {
|
|
|
|
wx.setStorageSync(para, 'userInfo')
|
|
|
|
|
|
|
|
_this.getUserInfo()
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getUserInfo() {
|
|
|
|
api.getUserInfo().then(res => {
|
|
|
|
let userInfoString = JSON.stringify(res.data);
|
|
|
|
wx.setStorageSync('userInfo', userInfoString);
|
|
|
|
this.getUserProfile()
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getCentralhousehold() {
|
|
|
|
let para = this.data.userId
|
|
|
|
partyApi.getCentralhousehold(para).then(res => {
|
|
|
|
if (res.data.pass === 1) {
|
|
|
|
this.setData({
|
|
|
|
pass: res.data.pass // 审核状态
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.setData({
|
|
|
|
pass: res.data.pass // 审核状态
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
handelClickEditPassword(){
|
|
|
|
|
|
|
|
},
|
|
|
|
})
|