市北党建引领小程序初始化
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

399 lines
10 KiB

// subpages/redSail/pages/flowParty/flowParty.js
const api = require('../../../../utils/partApi')
Page({
/**
* 页面的初始数据
*/
data: {
selectedStatus:false,
selectList:[],
look:true,
informFlag:false,
longitude: 120.372537,
latitude: 36.098056,
scale: 13,
form:{
name:'',//姓名
idCard:'',//身份证
mobile:'',//手机哈
partyName:'',//现属党支部
freelance:'0',//自由职业者
workUnit:'',//工作单位
workAddr:'',//工作地址
allDeptIds:[],//所属社区id
deptName:''//社区名称
},
pickerValue:'',
newArr:[],
multiIds:[],
multiIndex: [0, 0],
submitStatus:false,
changeFlag:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getDeptTree()
let {realName,identityNo,allDeptIds,mobile,workUnit} = JSON.parse(wx.getStorageSync('userInfo') )
console.log(workUnit);
this.setData({
'form.name':realName,
'form.idCard':identityNo,
'form.mobile':mobile,
'form.allDeptIds':allDeptIds.split(','),
'form.workUnit':workUnit,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// this.getByLoginUser()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
showToast (title) {
wx.showToast({
title: title,
icon: 'none',
duration: 2000
})
},
getDeptTree() {
api.getDeptTree().then(res => {
this.setData({
streetList: res.data[0].children
})
let state = {
arr: [],
arr1: [],
arr2: [],
multiIds: []
}
let str = this.data.form.allDeptIds.slice(1,3)
this.data.streetList.map((v, vk) => {
state.arr1.push(v.label);
if (this.data.multiIndex[0] === vk) {
state.multiIds[0] = v;
}
if(str[0] == v.value){
if (state.arr2.length <= 0) {
v.children.map((c, ck) => {
if(c.label != '武定路社区' && c.label !='陵县路社区'){
state.arr2.push(c.label);
}
if (this.data.multiIndex[1] === ck) {
state.multiIds[1] = c;
}
});
}
}
});
state.arr[0] = state.arr1;
state.arr[1] = state.arr2;
this.setData({
newArr: state.arr,
multiIds: state.multiIds,
});
this.data.streetList.forEach((item,index)=>{
if(item.value == str[0]){
item.children.forEach((c,i)=>{
if(c.value == str[1]){
this.setData({
multiIndex:[index,i],
changeFlag:true
})
}
})
}
})
}).catch(err => {
console.log(err)
})
},
bindRealNameInput (e) {
this.setData({
'form.name': e.detail.value
})
console.log(this.data.form)
},
//身份证双向绑定
bindRealIdcardInput (e) {
this.setData({
'form.idCard': e.detail.value
})
console.log(this.data.form)
},
//手机号双向绑定
bindRealMobileInput (e) {
this.setData({
'form.mobile': e.detail.value
})
console.log(this.data.form)
},
//工作单位双向绑定
bindRealWorkUnitInput (e) {
this.setData({
'form.workUnit': e.detail.value
})
console.log(this.data.form)
},
//工作单位地址双向绑定
bindRealWorkAddrInput (e) {
this.setData({
'form.workAddr': e.detail.value
})
console.log(this.data.form)
},
handleClickWorkUnitInput(){
this.showToast('请前往个人信息修改工作单位')
},
//现属党支部双向绑定
bindRealPartInput(e){
this.setData({
'form.partyName': e.detail.value
})
console.log(this.data.form)
},
handelClickTwo(){
wx.navigateBack({
delta: 2
})
},
bindFlagFreelanceChange(e){
this.setData({
'form.freelance': e.detail.value
})
},
bindMultiPickerChange() {
this.setData({
'form.allDeptIds':['1175270520603930625',this.data.multiIds[0].value,this.data.multiIds[1].value],
changeFlag:true
})
},
bindMultiPickerColumnChange(e) {
let data = {
newArr: this.data.newArr,
multiIndex: this.data.multiIndex,
multiIds: this.data.multiIds,
};
data.multiIndex[e.detail.column] = e.detail.value;
let searchColumn = () => {
let arr1 = [];
let arr2 = [];
this.data.streetList.map((v, vk) => {
if (data.multiIndex[0] === vk) {
data.multiIds[0] = {
...v,
};
v.children.map((c, ck) => {
if(c.label != '武定路社区' && c.label !='陵县路社区'){
arr1.push(c.label);
}
if (data.multiIndex[1] === ck) {
data.multiIds[1] = {
...c,
};
}
});
}
});
data.newArr[1] = arr1;
data.newArr[2] = arr2;
};
switch (e.detail.column) {
case 0:
// 每次切换还原初始值
data.multiIndex[1] = 0;
// data.multiIndex[2] = 0;
// 执行函数处理
searchColumn();
break;
case 1:
// data.multiIndex[2] = 0;
searchColumn();
break;
case 2:
searchColumn();
break;
}
this.setData(data);
this.setData({
newArr:this.data.newArr.splice(0,2),
changeFlag:true
})
},
pickerConfirm (e) {
console.log(e);
if(e.currentTarget.dataset.value == '0'){
this.setData({
'form.freelance': e.detail.selectedValue[0],
selectedStatus: false
});
}
},
handleCLickShow(e){
this.setData({
pickerValue:e.currentTarget.dataset.value,
selectedStatus: true,
selectList:[]
})
if(e.currentTarget.dataset.value == '0'){
this.setData({
selectList: [{label:'是',value:'1'}, {label:'否',value:'0'}]
})
}else if(e.currentTarget.dataset.value == '1'){
this.setData({
selectList: this.data.streetList
})
}
},
submit(){
if (!this.data.form.name) {
this.showToast('请输入姓名')
return false
}
if (!this.data.form.idCard) {
this.showToast('请填写身份证号')
return false
}
if (!this.data.form.mobile) {
this.showToast('请填写手机号')
return false
}
if (!this.data.form.partyName) {
this.showToast('请填写现属党支部')
return false
}
if (!this.data.form.freelance) {
this.showToast('请选择是否为自由职业者')
return false
}
if (!this.data.form.workUnit) {
this.showToast('请填写工作单位')
return false
}
if(this.data.form.freelance == 0){
if (!this.data.form.workAddr) {
this.showToast('请填写工作单位地址')
return false
}
}
if (this.data.form.allDeptIds.length == 0) {
this.showToast('请选择所属社区')
return false
}
const para = {
...this.data.form
}
para.freelance = parseInt(para.freelance)
wx.showLoading({
title: "提交中..."
})
console.log(para);
let than = this
api.submitFlowparty(para).then(res=>{
wx.hideLoading()
if(res.code == '0'){
than.setData({
submitStatus:true
})
}else{
than.showToast(res.msg)
}
}).catch(err=>{
wx.hideLoading()
console.log(err);
})
},
getByLoginUser(){
api.getByLoginUser().then(res=>{
if (res.code !== 0) {
return this.$message.error(res.msg)
}
let arr = res.data.options[0].children.filter((item)=>(item.children))
this.setData({
streetList : arr
})
})
},
pickerCancel () {
this.setData({
selectedStatus: false
});
},
handleCheckbox(e){
console.log(e);
if(e.detail .value.length!=0){
this.setData({
look:false
})
}else{
this.setData({
look:true
})
}
},
handleBack(){
wx.navigateBack({
delta: 1
})
},
handleNext(){
this.setData({
informFlag:true
})
}
})