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.
799 lines
24 KiB
799 lines
24 KiB
var api = require('../../utils/api.js')
|
|
var global = require('../../utils/config.js')
|
|
Page({
|
|
data: {
|
|
gridId: '',
|
|
gridName: '',
|
|
gridNameArr: [],
|
|
formid: '',
|
|
resToken: '',
|
|
resGridName: '',
|
|
inviteUserId: '',
|
|
GridNameId: "",
|
|
qqMapWX: '',
|
|
streetList: [],
|
|
addressContent: '',
|
|
address: '',
|
|
idNo: '',
|
|
form: {
|
|
userId: '',
|
|
realName: '',
|
|
identityNo: '',
|
|
mobile: '',
|
|
faceImg: '',
|
|
villageName: '', //居住小区名称
|
|
workUnit: '', //工作单位
|
|
workType: '', //单位性质
|
|
workIndustry: '', //所属行业
|
|
hobbies: '', // 服务意向
|
|
partyFlag: 1, //是否为党员
|
|
allDeptIds: [], //社区id
|
|
shibei: '1', //是否居住在市北
|
|
workIndustryText: '', //所属行业其他输入框,
|
|
couplingCommunity: [], //包联社区
|
|
region:''
|
|
},
|
|
selectedStatus: false,
|
|
selectOption: [{
|
|
label: '机关企事业单位',
|
|
value: '0'
|
|
},
|
|
{
|
|
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'
|
|
}],
|
|
serviceOpitons: [{
|
|
label: '便民服务',
|
|
value: '0'
|
|
}, {
|
|
label: '科技科普',
|
|
value: '1'
|
|
}, {
|
|
label: '文化艺术',
|
|
value: '2'
|
|
}, {
|
|
label: '体育健康',
|
|
value: '3'
|
|
}, {
|
|
label: '秩序维护',
|
|
value: '4'
|
|
}, {
|
|
label: '环境治理',
|
|
value: '5'
|
|
}, {
|
|
label: '纠纷调解',
|
|
value: '6'
|
|
}, {
|
|
label: '关爱帮扶',
|
|
value: '7'
|
|
}, {
|
|
label: '垃圾分类',
|
|
value: '0'
|
|
}, {
|
|
label: '支教助学',
|
|
value: '8'
|
|
}, {
|
|
label: '卫生健康',
|
|
value: '9'
|
|
}, {
|
|
label: '法律服务',
|
|
value: '10'
|
|
}, {
|
|
label: '其他',
|
|
value: '11'
|
|
}],
|
|
regionOptions:[
|
|
{
|
|
label: '市南区',
|
|
value: '0'
|
|
},
|
|
{
|
|
label: '李沧区',
|
|
value: '1'
|
|
},
|
|
{
|
|
label: '崂山区',
|
|
value: '2'
|
|
},
|
|
{
|
|
label: '西海岸新区',
|
|
value: '3'
|
|
},
|
|
{
|
|
label: '城阳区',
|
|
value: '4'
|
|
},
|
|
{
|
|
label: '即墨区',
|
|
value: '5'
|
|
},
|
|
{
|
|
label: '胶州市',
|
|
value: '6'
|
|
},
|
|
{
|
|
label: '平度市',
|
|
value: '7'
|
|
},
|
|
{
|
|
label: '莱西市',
|
|
value: '8'
|
|
},
|
|
],
|
|
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) {
|
|
this.getDeptTree()
|
|
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];
|
|
}
|
|
}
|
|
if (obj.identityNo.length == 18) {
|
|
this.idNo = obj.identityNo;
|
|
let temp = '*********';
|
|
let str = obj.identityNo.slice(0, 4);
|
|
let end = obj.identityNo.slice(15, 18);
|
|
obj.identityNo = str + temp + end;
|
|
}
|
|
let region = ''
|
|
if(obj.villageName != ''){
|
|
if(obj.villageName.indexOf('-') > 1){
|
|
let temp = obj.villageName
|
|
region = temp.split('-')[0]
|
|
obj.villageName = temp.split('-')[1]
|
|
}
|
|
}
|
|
obj.allDeptIds = obj.allDeptIds.split(',')
|
|
obj.couplingCommunity = obj.couplingCommunity.split(',')
|
|
this.setData({
|
|
form: {
|
|
...obj,
|
|
region:region
|
|
},
|
|
title: options.title,
|
|
})
|
|
} else {
|
|
wx.setNavigationBarTitle({
|
|
title: '注册'
|
|
})
|
|
}
|
|
|
|
},
|
|
//获取街道树
|
|
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() {
|
|
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
|
|
})
|
|
},
|
|
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
|
|
})
|
|
},
|
|
fail(err) {
|
|
console.debug(err)
|
|
}
|
|
})
|
|
},
|
|
//姓名双向绑定
|
|
bindRealNameInput(e) {
|
|
this.setData({
|
|
'form.realName': e.detail.value
|
|
})
|
|
},
|
|
//身份证双向绑定
|
|
bindRealidentityNoInput(e) {
|
|
this.setData({
|
|
'form.identityNo': e.detail.value,
|
|
})
|
|
this.idNo = e.detail.value
|
|
},
|
|
//工作单位
|
|
bindWorkUnitInput(e) {
|
|
this.setData({
|
|
'form.workUnit': e.detail.value
|
|
})
|
|
},
|
|
//所属行业
|
|
bindWorkIndustryInput(e) {
|
|
this.setData({
|
|
'form.workIndustry': e.detail.value
|
|
})
|
|
},
|
|
//以防下拉
|
|
bindMultiPickerWorkIndustryChange(e) {
|
|
if (e.detail.value == '5') {
|
|
this.setData({
|
|
WorkIndustryInput: true
|
|
})
|
|
}
|
|
this.setData({
|
|
'form.workIndustry': e.detail.value
|
|
})
|
|
},
|
|
//手机号双向绑定
|
|
bindRealMobileInput(e) {
|
|
this.setData({
|
|
'form.mobile': e.detail.value
|
|
})
|
|
},
|
|
//居住小区名称
|
|
bindvillageNameInput(e) {
|
|
this.setData({
|
|
'form.villageName': e.detail.value
|
|
})
|
|
},
|
|
bindRegionVillageName(e) {
|
|
this.setData({
|
|
'form.villageName': e.detail.value
|
|
})
|
|
},
|
|
//单选框
|
|
bindFlagshibeiChange(e) {
|
|
this.getDeptTree()
|
|
this.setData({
|
|
'form.shibei': e.detail.value,
|
|
'form.couplingCommunity': [],
|
|
multiIndex: [0, 0],
|
|
multiIndexC: [0, 0],
|
|
changeFlag: false,
|
|
changeFlagC: false,
|
|
})
|
|
if(e.detail.value != null && e.detail.value === '0'){
|
|
this.setData({
|
|
'form.villageName': '',
|
|
'form.allDeptIds':''
|
|
})
|
|
}
|
|
},
|
|
bindFlagpartyFlagChange(e) {
|
|
this.setData({
|
|
'form.partyFlag': e.detail.value
|
|
})
|
|
},
|
|
bindworkIndustryTextInput(e) {
|
|
this.setData({
|
|
'form.workIndustryText': e.detail.value
|
|
})
|
|
},
|
|
handleChangeWorkType(e) {
|
|
if (e.detail.value == '7') {
|
|
this.setData({
|
|
workTypeInput: true
|
|
})
|
|
}
|
|
this.setData({
|
|
'form.workType': this.data.selectOption[e.detail.value].label,
|
|
})
|
|
},
|
|
handleChangeRegion(e) {
|
|
this.setData({
|
|
'form.region': this.data.regionOptions[e.detail.value].label,
|
|
})
|
|
},
|
|
|
|
handleChangeServiceType(e) {
|
|
if (e.detail.value == '7') {
|
|
this.setData({
|
|
hobbies: true
|
|
})
|
|
}
|
|
this.setData({
|
|
'form.hobbies': this.data.serviceOpitons[e.detail.value].label,
|
|
})
|
|
},
|
|
|
|
bindWorkTypeTextInput(e) {
|
|
this.setData({
|
|
workTypeText: e.detail.value
|
|
})
|
|
},
|
|
//单位性质弹框确定
|
|
confirmDlaog(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) {
|
|
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 => {
|
|
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.password != this.data.checkPassword) {
|
|
this.showToast('两次密码不一致')
|
|
return false
|
|
}
|
|
if (!this.data.form.identityNo) {
|
|
this.showToast('请填写身份证号码')
|
|
return false
|
|
}
|
|
this.data.form.identityNo = this.idNo
|
|
if (this.data.form.identityNo.length != 18) {
|
|
this.showToast('请填写正确的身份证号码')
|
|
return false
|
|
}else {
|
|
this.data.form.identityNo = this.idNo;
|
|
}
|
|
if (this.data.form.mobile.length != 11 || !this.data.form.mobile) {
|
|
this.showToast('请填写正确的手机号码')
|
|
return false
|
|
}
|
|
if (!this.data.form.workUnit) {
|
|
this.showToast('请填写工作单位')
|
|
return false
|
|
}
|
|
if (!this.data.form.workIndustry) {
|
|
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
|
|
}
|
|
} else if (this.data.form.shibei == '0') {
|
|
if(this.data.form.region != '' && this.data.form.villageName != ''){
|
|
let temp = this.data.form.region + '-' + this.data.form.villageName;
|
|
this.data.form.villageName = temp
|
|
}
|
|
this.data.form.allDeptIds = []
|
|
}
|
|
const para = {
|
|
...this.data.form
|
|
}
|
|
para.userId = wx.getStorageSync('userId')
|
|
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.wxCode = res.code;
|
|
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) {
|
|
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)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
},
|
|
onReady() {
|
|
let _this = this;
|
|
// 动态获取屏幕高度
|
|
wx.getSystemInfo({
|
|
success: (result) => {
|
|
_this.setData({
|
|
height: result.windowHeight
|
|
});
|
|
},
|
|
})
|
|
},
|
|
closePopup() {
|
|
this.setData({
|
|
visible: false
|
|
})
|
|
},
|
|
bindPassWordInput(e) {
|
|
this.setData({
|
|
'form.password': e.detail.value
|
|
})
|
|
},
|
|
bindCheckPassWordInput(e) {
|
|
this.setData({
|
|
checkPassword: e.detail.value
|
|
})
|
|
},
|
|
dispose() {
|
|
if (!this.data.form.realName) {
|
|
this.showToast('请输入姓名')
|
|
return
|
|
}
|
|
if (!this.data.form.identityNo && this.data.form.identityNo.length == 18) {
|
|
this.showToast('请填写正确的身份证号码')
|
|
return
|
|
}
|
|
if (!this.data.form.workIndustry) {
|
|
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.region){
|
|
this.showToast('请选择行政区域')
|
|
return
|
|
}
|
|
this.data.form.allDeptIds = []
|
|
}
|
|
this.setData({
|
|
visible: true
|
|
})
|
|
}
|
|
})
|