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.
684 lines
21 KiB
684 lines
21 KiB
var api = require('../../utils/api.js')
|
|
var global = require('../../utils/config.js')
|
|
const app = getApp()
|
|
Page({
|
|
data: {
|
|
gridId: '',
|
|
gridName: '',
|
|
gridNameArr: [],
|
|
formid: '',
|
|
resToken: '',
|
|
resGridName: '',
|
|
inviteUserId: '',
|
|
GridNameId: "",
|
|
qqMapWX: '',
|
|
streetList: [],
|
|
addressContent: '',
|
|
address: '',
|
|
form: {
|
|
realName: '',
|
|
identityNo: '',
|
|
mobile: '',
|
|
villageName: '', //居住小区名称
|
|
workUnit: '', //工作单位
|
|
workType: '', //单位性质
|
|
workIndustry: '', //所属行业
|
|
partyFlag: 1, //是否为党员
|
|
allDeptIds: [], //社区id
|
|
shibei: '1', //是否居住在市北
|
|
workIndustryText: '', //所属行业其他输入框,
|
|
couplingCommunity: [], //包联社区
|
|
},
|
|
selectedStatus: false,
|
|
selectOption: [{
|
|
label: '党政机关',
|
|
value: '0'
|
|
},
|
|
{
|
|
label: '事业单位',
|
|
value: '1'
|
|
},
|
|
{
|
|
label: '学校',
|
|
value: '8'
|
|
},
|
|
{
|
|
label: '国有企业',
|
|
value: '2'
|
|
},
|
|
{
|
|
label: '私营企业',
|
|
value: '3'
|
|
},
|
|
{
|
|
label: '集体企业',
|
|
value: '4'
|
|
},
|
|
{
|
|
label: '外资企业、合资企业',
|
|
value: '5'
|
|
},
|
|
{
|
|
label: '社会组织',
|
|
value: '6'
|
|
},
|
|
{
|
|
label: '其他',
|
|
value: '7'
|
|
}
|
|
],
|
|
workIndustryArr: [{
|
|
label: '直播电商',
|
|
value: '0'
|
|
}, {
|
|
label: '网约车司机',
|
|
value: '1'
|
|
}, {
|
|
label: '外卖配送人员',
|
|
value: '2'
|
|
}, {
|
|
label: '快递小哥',
|
|
value: '3'
|
|
}, {
|
|
label: '道路运输行业',
|
|
value: '4'
|
|
}, {
|
|
label: '其他',
|
|
value: '5'
|
|
}],
|
|
|
|
workTypeInput: false,
|
|
workTypeText: '', //单位类型为其他的输入框值
|
|
newArr: [],
|
|
multiIds: [],
|
|
multiIndex: [0, 0],
|
|
changeFlag: false,
|
|
newArrC: [],
|
|
multiIdsC: [],
|
|
multiIndexC: [0, 0],
|
|
changeFlagC: false,
|
|
title: '',
|
|
WorkIndustryInput: false,
|
|
visible: false,
|
|
height: '', //屏幕高度
|
|
},
|
|
onLoad(options) {
|
|
if (options.title) {
|
|
wx.setNavigationBarTitle({
|
|
title: options.title,
|
|
})
|
|
let obj = JSON.parse(wx.getStorageSync('userInfo'))
|
|
for (let key in obj) {
|
|
if (!this.data.form.hasOwnProperty(key)) {
|
|
delete obj[key];
|
|
}
|
|
}
|
|
obj.allDeptIds = obj.allDeptIds.split(',')
|
|
obj.couplingCommunity = obj.couplingCommunity.split(',')
|
|
this.setData({
|
|
form: {
|
|
...obj
|
|
},
|
|
title: options.title,
|
|
})
|
|
console.log(this.data.form);
|
|
} else {
|
|
wx.setNavigationBarTitle({
|
|
title: '注册'
|
|
})
|
|
}
|
|
this.getDeptTree()
|
|
},
|
|
//获取街道树
|
|
getDeptTree() {
|
|
api.getDeptTree().then(res => {
|
|
this.setData({
|
|
streetList: res.data[0].children
|
|
})
|
|
let state = {
|
|
arr: [],
|
|
arr1: [],
|
|
arr2: [],
|
|
multiIds: []
|
|
}
|
|
let stateC = JSON.parse(JSON.stringify(state));
|
|
let allDeptIdsStr = this.data.form.allDeptIds.slice(1, 3)
|
|
let couplingCommunityStr = this.data.form.couplingCommunity.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 (this.data.multiIndexC[0] === vk) {
|
|
stateC.multiIds[0] = v;
|
|
}
|
|
if (allDeptIdsStr[0] == v.value && allDeptIdsStr[0]) {
|
|
if (state.arr2.length <= 0) {
|
|
v.children.map((c, ck) => {
|
|
state.arr2.push(c.label);
|
|
if (this.data.multiIndex[1] === ck) {
|
|
state.multiIds[1] = c;
|
|
}
|
|
});
|
|
}
|
|
} else if (!allDeptIdsStr[0]) {
|
|
if (state.arr2.length <= 0) {
|
|
v.children.map((c, ck) => {
|
|
state.arr2.push(c.label);
|
|
if (this.data.multiIndex[1] === ck) {
|
|
state.multiIds[1] = c;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
if (couplingCommunityStr[0] == v.value && couplingCommunityStr[0]) {
|
|
if (stateC.arr2.length <= 0) {
|
|
v.children.map((c, ck) => {
|
|
stateC.arr2.push(c.label);
|
|
if (this.data.multiIndexC[1] === ck) {
|
|
stateC.multiIds[1] = c;
|
|
}
|
|
});
|
|
}
|
|
} else if (!couplingCommunityStr[0]) {
|
|
if (stateC.arr2.length <= 0) {
|
|
v.children.map((c, ck) => {
|
|
stateC.arr2.push(c.label);
|
|
if (this.data.multiIndexC[1] === ck) {
|
|
stateC.multiIds[1] = c;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
});
|
|
state.arr[0] = state.arr1;
|
|
state.arr[1] = state.arr2;
|
|
stateC.arr[0] = state.arr1;
|
|
stateC.arr[1] = stateC.arr2;
|
|
this.setData({
|
|
newArr: state.arr,
|
|
multiIds: state.multiIds,
|
|
newArrC: stateC.arr,
|
|
multiIdsC: stateC.multiIds,
|
|
});
|
|
if (allDeptIdsStr) {
|
|
this.data.streetList.forEach((item, index) => {
|
|
if (item.value == allDeptIdsStr[0]) {
|
|
item.children.forEach((c, i) => {
|
|
if (c.value == allDeptIdsStr[1]) {
|
|
this.setData({
|
|
multiIndex: [index, i],
|
|
changeFlag: true
|
|
})
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
if (couplingCommunityStr) {
|
|
this.data.streetList.forEach((item, index) => {
|
|
if (item.value == couplingCommunityStr[0]) {
|
|
item.children.forEach((c, i) => {
|
|
if (c.value == couplingCommunityStr[1]) {
|
|
console.log(item, index, c, i);
|
|
this.setData({
|
|
multiIndexC: [index, i],
|
|
changeFlagC: true
|
|
})
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
},
|
|
//确定选择社区
|
|
bindMultiPickerChange() {
|
|
console.log(this.data.multiIds);
|
|
this.setData({
|
|
'form.allDeptIds': ['1175270520603930625', this.data.multiIds[0].value, this.data.multiIds[1].value, this.data.multiIds[1].children[0].value],
|
|
changeFlag: true
|
|
})
|
|
},
|
|
bindMultiPickerChangeC() {
|
|
this.setData({
|
|
'form.couplingCommunity': ['1175270520603930625', this.data.multiIdsC[0].value, this.data.multiIdsC[1].value, this.data.multiIdsC[1].children[0].value],
|
|
changeFlagC: 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 = [];
|
|
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;
|
|
};
|
|
switch (e.detail.column) {
|
|
case 0:
|
|
data.multiIndex[1] = 0;
|
|
searchColumn();
|
|
break;
|
|
case 1:
|
|
searchColumn();
|
|
break;
|
|
}
|
|
|
|
this.setData(data);
|
|
this.setData({
|
|
newArr: this.data.newArr,
|
|
changeFlag: true
|
|
})
|
|
console.log(this.data.newArr);
|
|
},
|
|
//滑动社区
|
|
bindMultiPickerColumnChangeC(e) {
|
|
let data = {
|
|
newArrC: this.data.newArrC,
|
|
multiIndexC: this.data.multiIndexC,
|
|
multiIdsC: this.data.multiIdsC,
|
|
};
|
|
data.multiIndexC[e.detail.column] = e.detail.value;
|
|
let searchColumn = () => {
|
|
let arr1 = [];
|
|
this.data.streetList.map((v, vk) => {
|
|
if (data.multiIndexC[0] === vk) {
|
|
data.multiIdsC[0] = {
|
|
...v,
|
|
};
|
|
v.children.map((c, ck) => {
|
|
if (c.label != '武定路社区' && c.label != '陵县路社区') {
|
|
arr1.push(c.label);
|
|
}
|
|
if (data.multiIndexC[1] === ck) {
|
|
data.multiIdsC[1] = {
|
|
...c,
|
|
};
|
|
}
|
|
});
|
|
}
|
|
});
|
|
data.newArrC[1] = arr1;
|
|
};
|
|
switch (e.detail.column) {
|
|
case 0:
|
|
data.multiIndexC[1] = 0;
|
|
searchColumn();
|
|
break;
|
|
case 1:
|
|
searchColumn();
|
|
break;
|
|
}
|
|
|
|
this.setData(data);
|
|
this.setData({
|
|
newArrC: this.data.newArrC,
|
|
changeFlagC: true
|
|
})
|
|
console.log(this.data.newArrC);
|
|
},
|
|
reverseLocation() {
|
|
const _this = this
|
|
this.data.qqMapWX.reverseGeocoder({
|
|
location: {
|
|
latitude: _this.data.form.issueLatitude,
|
|
longitude: _this.data.form.issueLongitude
|
|
},
|
|
success(res) {
|
|
_this.setData({
|
|
addressContent: res.result.address,
|
|
address: res.result.address
|
|
// 'form.issueAddress': res.result.address,
|
|
})
|
|
},
|
|
fail(err) {
|
|
console.debug(err)
|
|
}
|
|
})
|
|
},
|
|
//姓名双向绑定
|
|
bindRealNameInput(e) {
|
|
this.setData({
|
|
'form.realName': e.detail.value
|
|
})
|
|
console.log(this.data.form)
|
|
},
|
|
//身份证双向绑定
|
|
bindRealidentityNoInput(e) {
|
|
this.setData({
|
|
'form.identityNo': e.detail.value
|
|
})
|
|
console.log(this.data.form)
|
|
},
|
|
//工作单位
|
|
bindWorkUnitInput(e) {
|
|
this.setData({
|
|
'form.workUnit': e.detail.value
|
|
})
|
|
console.log(this.data.form)
|
|
},
|
|
//所属行业
|
|
bindWorkIndustryInput(e) {
|
|
this.setData({
|
|
'form.workIndustry': e.detail.value
|
|
})
|
|
console.log(this.data.form)
|
|
},
|
|
//以防下拉
|
|
bindMultiPickerWorkIndustryChange(e) {
|
|
if (e.detail.value == '5') {
|
|
this.setData({
|
|
WorkIndustryInput: true
|
|
})
|
|
}
|
|
this.setData({
|
|
'form.workIndustry': e.detail.value
|
|
})
|
|
console.log(this.data.form)
|
|
},
|
|
//手机号双向绑定
|
|
bindRealMobileInput(e) {
|
|
this.setData({
|
|
'form.mobile': e.detail.value
|
|
})
|
|
console.log(this.data.form)
|
|
},
|
|
//居住小区名称
|
|
bindvillageNameInput(e) {
|
|
this.setData({
|
|
'form.villageName': e.detail.value
|
|
})
|
|
},
|
|
//单选框
|
|
bindFlagshibeiChange(e) {
|
|
this.getDeptTree()
|
|
this.setData({
|
|
'form.shibei': e.detail.value,
|
|
// 'form.allDeptIds': [""],
|
|
'form.couplingCommunity': [],
|
|
multiIndex: [0, 0],
|
|
multiIndexC: [0, 0],
|
|
changeFlag: false,
|
|
changeFlagC: false,
|
|
})
|
|
|
|
},
|
|
bindFlagpartyFlagChange(e) {
|
|
this.setData({
|
|
'form.partyFlag': e.detail.value
|
|
})
|
|
},
|
|
bindworkIndustryTextInput(e) {
|
|
this.setData({
|
|
'form.workIndustryText': e.detail.value
|
|
})
|
|
},
|
|
handleChangeWorkType(e) {
|
|
console.log(e);
|
|
if (e.detail.value == '7') {
|
|
this.setData({
|
|
workTypeInput: true
|
|
})
|
|
}
|
|
this.setData({
|
|
'form.workType': this.data.selectOption[e.detail.value].label,
|
|
})
|
|
console.log(this.data.form);
|
|
},
|
|
|
|
bindWorkTypeTextInput(e) {
|
|
console.log(e, 'cccccc');
|
|
this.setData({
|
|
workTypeText: e.detail.value
|
|
})
|
|
console.log(this.data.workTypeText);
|
|
},
|
|
//单位性质弹框确定
|
|
confirmDlaog(e) {
|
|
console.log(e);
|
|
this.setData({
|
|
workTypeInput: false,
|
|
WorkIndustryInput: false
|
|
})
|
|
},
|
|
//单位性质弹框取消
|
|
cancelDlaog() {
|
|
this.setData({
|
|
workTypeInput: false,
|
|
WorkIndustryInput: false
|
|
})
|
|
},
|
|
getToken: function (gid) {
|
|
let that = this
|
|
wx.login({
|
|
success(res) {
|
|
if (res.code) {
|
|
console.log('微信CODE: ' + res.code)
|
|
let wxCode = res.code
|
|
const para = {
|
|
// inviteUserId: that.data.inviteUserId,
|
|
//写死四机社区第一网格
|
|
// gridId: '1224104693058306049',
|
|
wxCode: res.code
|
|
}
|
|
console.log(wxCode);
|
|
api.getTokenV3(para).then(function (res) {
|
|
global.Token = res.data.token
|
|
wx.removeStorageSync('token')
|
|
wx.setStorageSync('token', res.data.token)
|
|
that.setData({
|
|
resToken: res.data.token,
|
|
resGridName: res.data.grid
|
|
})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
// 单选点击事件
|
|
|
|
showToast(title) {
|
|
wx.showToast({
|
|
title: title,
|
|
icon: 'none',
|
|
duration: 2000
|
|
})
|
|
},
|
|
// 获取用户信息
|
|
getUserInfo() {
|
|
api.getUserInfo().then(res => {
|
|
console.log("用户信息", res)
|
|
let userInfoString = JSON.stringify(res.data);
|
|
wx.setStorageSync('userInfo', userInfoString);
|
|
wx.navigateBack({
|
|
delta: 1
|
|
})
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
|
|
|
|
},
|
|
navigateToIndex() {
|
|
|
|
if (!this.data.form.realName) {
|
|
this.showToast('请输入姓名')
|
|
return false
|
|
}
|
|
if (!this.data.form.identityNo) {
|
|
this.showToast('请填写身份证号')
|
|
return false
|
|
}
|
|
if (!this.data.form.workUnit) {
|
|
this.showToast('请填写工作单位')
|
|
return false
|
|
}
|
|
if (!this.data.form.mobile) {
|
|
this.showToast('请填写手机号')
|
|
return false
|
|
}
|
|
if (this.data.form.shibei == '1') {
|
|
if (this.data.form.allDeptIds.length == 0) {
|
|
this.showToast('请选择报到常住社区名称')
|
|
return false
|
|
}
|
|
if (!this.data.form.villageName) {
|
|
this.showToast('请填写居住小区名称')
|
|
return false
|
|
}
|
|
// if(this.data.form.couplingCommunity.length == 0){
|
|
// this.showToast('请选择包联单位名称')
|
|
// return false
|
|
// }
|
|
} else if (this.data.form.shibei == '0') {
|
|
// if (this.data.form.allDeptIds.length == 0) {
|
|
// this.showToast('请填写单位包联社区名称名称')
|
|
// return false
|
|
// }
|
|
}
|
|
|
|
const para = {
|
|
...this.data.form
|
|
}
|
|
delete para.couplingCommunityStr
|
|
delete para.couplingCommunity
|
|
if (this.data.workTypeText) {
|
|
para.workType = this.data.workTypeText
|
|
}
|
|
wx.showLoading({
|
|
title: "提交中..."
|
|
})
|
|
let than = this
|
|
if (this.data.title) {
|
|
wx.login({
|
|
success: (res) => {
|
|
para.userId = wx.getStorageSync('userId')
|
|
para.wxCode = res.code;
|
|
// let headUrl =wx.getStorageSync("headImg");
|
|
// if (headUrl) {
|
|
// para.faceImg=headUrl
|
|
// }
|
|
if (res.code) {
|
|
api.userInfoUpdate(para).then(res => {
|
|
if (res.code == 0) {
|
|
wx.removeStorageSync('userInfo')
|
|
this.getUserInfo()
|
|
than.showToast('修改成功')
|
|
} else {
|
|
than.showToast(res.msg)
|
|
}
|
|
wx.hideLoading()
|
|
}).catch(err => {
|
|
console.log(err);
|
|
})
|
|
}
|
|
},
|
|
})
|
|
} else {
|
|
let than = this
|
|
wx.login({
|
|
success(res) {
|
|
if (res.code) {
|
|
console.log('微信CODE: ' + res.code)
|
|
const para = {
|
|
...than.data.form,
|
|
wxCode: res.code
|
|
}
|
|
api.getTokenV3(para).then(function (res) {
|
|
if (res.code == '0') {
|
|
let userInfoString = JSON.stringify(res.data);
|
|
wx.setStorageSync("userInfo", userInfoString);
|
|
wx.reLaunch({
|
|
url: '/pages/home/home'
|
|
})
|
|
} else {
|
|
this.showToast(res.msg)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
console.log(this.data.form);
|
|
},
|
|
onReady() {
|
|
let _this = this;
|
|
// 动态获取屏幕高度
|
|
wx.getSystemInfo({
|
|
success: (result) => {
|
|
_this.setData({
|
|
height: result.windowHeight
|
|
});
|
|
},
|
|
})
|
|
},
|
|
closePopup() {
|
|
this.setData({
|
|
visible: false
|
|
})
|
|
},
|
|
dispose() {
|
|
if (!this.data.form.realName) {
|
|
this.showToast('请输入姓名')
|
|
return
|
|
}
|
|
if (!this.data.form.identityNo) {
|
|
this.showToast('请填写身份证号')
|
|
return
|
|
}
|
|
if (!this.data.form.workUnit) {
|
|
this.showToast('请填写工作单位')
|
|
return
|
|
}
|
|
if (!this.data.form.mobile) {
|
|
this.showToast('请填写手机号')
|
|
return
|
|
}
|
|
if (this.data.form.shibei == '1') {
|
|
if (this.data.form.allDeptIds.length == 0) {
|
|
this.showToast('请选择报到常住社区名称')
|
|
return
|
|
}
|
|
if (!this.data.form.villageName) {
|
|
this.showToast('请填写居住小区名称')
|
|
return
|
|
}
|
|
// if(this.data.form.couplingCommunity.length == 0){
|
|
// this.showToast('请选择包联单位名称')
|
|
// return
|
|
// }
|
|
} else if (this.data.form.shibei == '0') {
|
|
// if (this.data.form.allDeptIds.length == 0) {
|
|
// this.showToast('请填写单位包联社区名称名称')
|
|
// return
|
|
// }
|
|
}
|
|
this.setData({
|
|
visible: true
|
|
})
|
|
}
|
|
})
|