|
@ -44,6 +44,7 @@ Page({ |
|
|
houseInfo: {}, // 通过roomCode获取的房屋信息
|
|
|
houseInfo: {}, // 通过roomCode获取的房屋信息
|
|
|
inputDisabled: false, // 输入身份证号,查询到信息的话,禁止修改
|
|
|
inputDisabled: false, // 输入身份证号,查询到信息的话,禁止修改
|
|
|
selectBuildingId: '', // 选择的楼栋id
|
|
|
selectBuildingId: '', // 选择的楼栋id
|
|
|
|
|
|
userState: '' |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -58,14 +59,6 @@ Page({ |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
this.getUserState() |
|
|
this.getUserState() |
|
|
this.checkWxUnionId() |
|
|
|
|
|
this.getWxCode() |
|
|
|
|
|
wx.hideToast() |
|
|
|
|
|
if (!this.data.roomCode) { |
|
|
|
|
|
this.getPersonalInfo().then(res => { |
|
|
|
|
|
this.getVillageList() |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
}, |
|
|
getVillageList () { |
|
|
getVillageList () { |
|
|
const params = { |
|
|
const params = { |
|
@ -187,11 +180,22 @@ Page({ |
|
|
if (res.code) { |
|
|
if (res.code) { |
|
|
let code = res.code |
|
|
let code = res.code |
|
|
api.getToken(code).then(res => { |
|
|
api.getToken(code).then(res => { |
|
|
const state = res.data.userState |
|
|
_this.data.userState = res.data.userState |
|
|
app.globalData.infoCompleted = state |
|
|
if (_this.data.userState == '4') { |
|
|
wx.setStorageSync('topGridName', res.data.grid) |
|
|
_this.getHouseInfo() |
|
|
wx.setStorageSync('token', res.data.token) |
|
|
} else { |
|
|
_this.getUserInfoById() |
|
|
wx.setStorageSync('topGridName', res.data.grid) |
|
|
|
|
|
wx.setStorageSync('token', res.data.token) |
|
|
|
|
|
_this.getUserInfoById() |
|
|
|
|
|
_this.checkWxUnionId() |
|
|
|
|
|
_this.getWxCode() |
|
|
|
|
|
if (!_this.data.roomCode) { |
|
|
|
|
|
_this.getPersonalInfo().then(res => { |
|
|
|
|
|
_this.getVillageList() |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
wx.hideToast() |
|
|
}) |
|
|
}) |
|
|
} else { |
|
|
} else { |
|
|
console.log('登录失败' + res.errMsg) |
|
|
console.log('登录失败' + res.errMsg) |
|
@ -199,16 +203,135 @@ Page({ |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
getTokenByGridId () { |
|
|
|
|
|
let that = this |
|
|
|
|
|
wx.login({ |
|
|
|
|
|
success(res) { |
|
|
|
|
|
if (res.code) { |
|
|
|
|
|
console.log('微信CODE: ' + res.code) |
|
|
|
|
|
let wxCode = res.code |
|
|
|
|
|
const para = { |
|
|
|
|
|
inviteUserId: '', |
|
|
|
|
|
gridId: that.data.houseInfo.gridId, |
|
|
|
|
|
wxCode: wxCode |
|
|
|
|
|
} |
|
|
|
|
|
api.getTokenV3(para).then(function (res) { |
|
|
|
|
|
wx.removeStorageSync('token') |
|
|
|
|
|
wx.setStorageSync('token', res.data.token) |
|
|
|
|
|
if (that.data.userState == '4') { |
|
|
|
|
|
that.getUserState() |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
// 有信息,跳转
|
|
|
|
|
|
navigateTo (idCard) { |
|
|
|
|
|
const params = { |
|
|
|
|
|
idCard: idCard, |
|
|
|
|
|
roomCode: this.data.roomCode |
|
|
|
|
|
} |
|
|
|
|
|
api.getSkipDirection(params).then(res => { |
|
|
|
|
|
if (res.data.type == '1') { |
|
|
|
|
|
// 留在当前页面,进行注册绑定
|
|
|
|
|
|
this.getHouseInfo() |
|
|
|
|
|
} else if (res.data.type == '2') { |
|
|
|
|
|
// 直接跳转到房屋页面
|
|
|
|
|
|
wx.reLaunch({ |
|
|
|
|
|
url: `../index/index?roomCode=${this.data.roomCode}` |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
// 无权访问
|
|
|
|
|
|
wx.reLaunch({ |
|
|
|
|
|
url: `../noAccess/noAccess` |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
// 有信息,跳转
|
|
|
|
|
|
navigateTo2 (idCard) { |
|
|
|
|
|
const params = { |
|
|
|
|
|
idCard: idCard, |
|
|
|
|
|
roomCode: this.data.roomCode |
|
|
|
|
|
} |
|
|
|
|
|
api.getSkipDirection(params).then(res => { |
|
|
|
|
|
if (res.data.type == '1') { |
|
|
|
|
|
// 留在当前页面,进行注册绑定
|
|
|
|
|
|
wx.showModal({ |
|
|
|
|
|
title: '提示', |
|
|
|
|
|
content: '请联系工作人员添加房屋绑定关系', |
|
|
|
|
|
showCancel: false, |
|
|
|
|
|
success (res) { |
|
|
|
|
|
if (res.confirm) { |
|
|
|
|
|
console.log('用户点击确定') |
|
|
|
|
|
wx.reLaunch({ |
|
|
|
|
|
url: '/pages/index/index' |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} else if (res.data.type == '2') { |
|
|
|
|
|
// 直接跳转到房屋页面
|
|
|
|
|
|
wx.reLaunch({ |
|
|
|
|
|
url: `../index/index?roomCode=${this.data.roomCode}` |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
// 无权访问
|
|
|
|
|
|
wx.reLaunch({ |
|
|
|
|
|
url: `../noAccess/noAccess` |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
// 获取用户信息
|
|
|
// 获取用户信息
|
|
|
getUserInfoById () { |
|
|
getUserInfoById () { |
|
|
api.getUserInfo().then(res => { |
|
|
api.getUserInfo().then(res => { |
|
|
console.log("用户信息", res) |
|
|
console.log("用户信息", res) |
|
|
if (res.data.identityNo) { |
|
|
if (res.data.identityNo) { |
|
|
wx.reLaunch({ |
|
|
this.setData({ |
|
|
url: `../index/index?roomCode=${this.data.roomCode}` |
|
|
'fmData.identityNo': res.data.identityNo, |
|
|
|
|
|
'fmData.realName': res.data.realName, |
|
|
|
|
|
'fmData.sex': this.getGender(res.data.identityNo), |
|
|
|
|
|
'fmData.mobile': res.data.mobile, |
|
|
|
|
|
'fmData.road': res.data.road |
|
|
|
|
|
}) |
|
|
|
|
|
this.navigateTo(res.data.identityNo) |
|
|
|
|
|
} else { |
|
|
|
|
|
this.getHouseInfo() |
|
|
|
|
|
} |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
console.log(err) |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
// 获取用户信息2
|
|
|
|
|
|
getUserInfoById2 () { |
|
|
|
|
|
api.getUserInfo().then(res => { |
|
|
|
|
|
console.log("用户信息", res) |
|
|
|
|
|
if (res.data.identityNo) { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
'fmData.identityNo': res.data.identityNo, |
|
|
|
|
|
'fmData.realName': res.data.realName, |
|
|
|
|
|
'fmData.sex': this.getGender(res.data.identityNo), |
|
|
|
|
|
'fmData.mobile': res.data.mobile, |
|
|
|
|
|
'fmData.road': res.data.road |
|
|
|
|
|
}) |
|
|
|
|
|
this.navigateTo2(res.data.identityNo) |
|
|
|
|
|
} else { |
|
|
|
|
|
wx.showModal({ |
|
|
|
|
|
title: '提示', |
|
|
|
|
|
content: '绑定失败', |
|
|
|
|
|
showCancel: false, |
|
|
|
|
|
success (res) { |
|
|
|
|
|
if (res.confirm) { |
|
|
|
|
|
console.log('用户点击确定') |
|
|
|
|
|
wx.reLaunch({ |
|
|
|
|
|
url: '/pages/index/index' |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
this.getHouseInfo() |
|
|
|
|
|
}).catch(err => { |
|
|
}).catch(err => { |
|
|
console.log(err) |
|
|
console.log(err) |
|
|
}) |
|
|
}) |
|
@ -222,20 +345,28 @@ Page({ |
|
|
roomCode: this.data.roomCode |
|
|
roomCode: this.data.roomCode |
|
|
} |
|
|
} |
|
|
api.getHouseInfo(params).then(res => { |
|
|
api.getHouseInfo(params).then(res => { |
|
|
console.log(res.data) |
|
|
console.log('getHouseInfo: ', res.data) |
|
|
if (res.code == 0) { |
|
|
if (res.code == 0) { |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
houseInfo: res.data |
|
|
houseInfo: res.data |
|
|
}) |
|
|
}) |
|
|
|
|
|
if (this.data.userState == '4') { |
|
|
|
|
|
this.getTokenByGridId() |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
// 获取成员信息
|
|
|
// 获取成员信息
|
|
|
getFamilyMember () { |
|
|
getFamilyMember () { |
|
|
if (!this.data.fmData.identityNo) { |
|
|
if (!this.identityCodeValid(this.data.fmData.identityNo)) { |
|
|
return |
|
|
wx.showToast({ |
|
|
} |
|
|
title: '身份证不合法', |
|
|
if (this.data.fmData.identityNo.length < 16) { |
|
|
icon: 'none', |
|
|
|
|
|
duration: 2500 |
|
|
|
|
|
}) |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
'fmData.identityNo': '' |
|
|
|
|
|
}) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
const params = { |
|
|
const params = { |
|
@ -257,7 +388,57 @@ Page({ |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
getGender (psidno) { |
|
|
|
|
|
var num = psidno.charAt(16); |
|
|
|
|
|
if (num % 2 == 0) { |
|
|
|
|
|
return '0'; |
|
|
|
|
|
}else { |
|
|
|
|
|
return '1'; |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
// 校验身份证是否正确
|
|
|
|
|
|
identityCodeValid (idcode) { |
|
|
|
|
|
var weightFactor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2] |
|
|
|
|
|
// 校验码
|
|
|
|
|
|
var checkCode = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'] |
|
|
|
|
|
|
|
|
|
|
|
var code = idcode + '' |
|
|
|
|
|
var last = idcode[17]// 最后一位
|
|
|
|
|
|
|
|
|
|
|
|
var seventeen = code.substring(0, 17) |
|
|
|
|
|
|
|
|
|
|
|
// ISO 7064:1983.MOD 11-2
|
|
|
|
|
|
// 判断最后一位校验码是否正确
|
|
|
|
|
|
var arr = seventeen.split('') |
|
|
|
|
|
var len = arr.length |
|
|
|
|
|
var num = 0 |
|
|
|
|
|
for (var i = 0; i < len; i++) { |
|
|
|
|
|
num = num + arr[i] * weightFactor[i] |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取余数
|
|
|
|
|
|
var resisue = num % 11 |
|
|
|
|
|
var lastNo = checkCode[resisue] |
|
|
|
|
|
|
|
|
|
|
|
// 格式的正则
|
|
|
|
|
|
// 正则思路
|
|
|
|
|
|
/* |
|
|
|
|
|
第一位不可能是0 |
|
|
|
|
|
第二位到第六位可以是0-9 |
|
|
|
|
|
第七位到第十位是年份,所以七八位为19或者20 |
|
|
|
|
|
十一位和十二位是月份,这两位是01-12之间的数值 |
|
|
|
|
|
十三位和十四位是日期,是从01-31之间的数值 |
|
|
|
|
|
十五,十六,十七都是数字0-9 |
|
|
|
|
|
十八位可能是数字0-9,也可能是X |
|
|
|
|
|
*/ |
|
|
|
|
|
var idcardPatter = /^[1-9][0-9]{5}([1][9][0-9]{2}|[2][0][0|1][0-9])([0][1-9]|[1][0|1|2])([0][1-9]|[1|2][0-9]|[3][0|1])[0-9]{3}([0-9]|[X])$/ |
|
|
|
|
|
|
|
|
|
|
|
// 判断格式是否正确
|
|
|
|
|
|
var format = idcardPatter.test(idcode) |
|
|
|
|
|
|
|
|
|
|
|
// 返回验证结果,校验码和格式同时正确才算是合法的身份证号码
|
|
|
|
|
|
return !!(last === lastNo && format) |
|
|
|
|
|
}, |
|
|
// 身份证号
|
|
|
// 身份证号
|
|
|
bindIdCardInput (e) { |
|
|
bindIdCardInput (e) { |
|
|
this.setData({ |
|
|
this.setData({ |
|
@ -269,7 +450,7 @@ Page({ |
|
|
this.setData({ |
|
|
this.setData({ |
|
|
'fmData.identityNo': e.detail.value |
|
|
'fmData.identityNo': e.detail.value |
|
|
}) |
|
|
}) |
|
|
this.getFamilyMember() |
|
|
// this.getFamilyMember()
|
|
|
}, |
|
|
}, |
|
|
// 姓名 双向绑定
|
|
|
// 姓名 双向绑定
|
|
|
bindRealNameInput (e) { |
|
|
bindRealNameInput (e) { |
|
@ -472,7 +653,7 @@ Page({ |
|
|
} else if (this.data.getMobileType === 'self') { |
|
|
} else if (this.data.getMobileType === 'self') { |
|
|
this.submitPersonalInfoBySelf() |
|
|
this.submitPersonalInfoBySelf() |
|
|
} |
|
|
} |
|
|
this.submitHouseInfo() |
|
|
// this.submitHouseInfo()
|
|
|
}, |
|
|
}, |
|
|
// 提交完善信息-从微信获取手机号方式
|
|
|
// 提交完善信息-从微信获取手机号方式
|
|
|
submitPersonalInfoByWx () { |
|
|
submitPersonalInfoByWx () { |
|
@ -493,7 +674,7 @@ Page({ |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
if (!this.data.fmData.road) { |
|
|
if (!this.data.fmData.road) { |
|
|
this.showToast('请填写所在街道') |
|
|
this.showToast('请填写路牌号') |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
// if (!this.data.fmData.smsCode) {
|
|
|
// if (!this.data.fmData.smsCode) {
|
|
@ -513,13 +694,15 @@ Page({ |
|
|
gridId: this.data.gridInfo.gridId ? this.data.gridInfo.gridId : this.data.houseInfo.gridId, |
|
|
gridId: this.data.gridInfo.gridId ? this.data.gridInfo.gridId : this.data.houseInfo.gridId, |
|
|
wxCode: this.data.unionIdStatus === '0' ? this.data.wxInfo.wxCode : '', |
|
|
wxCode: this.data.unionIdStatus === '0' ? this.data.wxInfo.wxCode : '', |
|
|
encryptedData: this.data.unionIdStatus === '0' ? this.data.wxInfo.encryptedData : '', |
|
|
encryptedData: this.data.unionIdStatus === '0' ? this.data.wxInfo.encryptedData : '', |
|
|
iv: this.data.unionIdStatus === '0' ? this.data.wxInfo.iv : '' |
|
|
iv: this.data.unionIdStatus === '0' ? this.data.wxInfo.iv : '', |
|
|
|
|
|
status: '1' |
|
|
} |
|
|
} |
|
|
console.log(para) |
|
|
console.log(para) |
|
|
api.completeResidentInfoV2(para).then(res => { |
|
|
api.completeResidentInfoV2(para).then(res => { |
|
|
wx.reLaunch({ |
|
|
// wx.reLaunch({
|
|
|
url: `../index/index?roomCode=${!this.data.roomCode ? this.data.houseInfo.roomNo : this.data.roomCode}` |
|
|
// url: `../index/index?roomCode=${!this.data.roomCode ? this.data.houseInfo.roomNo : this.data.roomCode}`
|
|
|
}) |
|
|
// })
|
|
|
|
|
|
this.getUserInfoById2() |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
// 提交完善信息,手机号输入方式
|
|
|
// 提交完善信息,手机号输入方式
|
|
@ -545,7 +728,7 @@ Page({ |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
if (!this.data.fmData.road) { |
|
|
if (!this.data.fmData.road) { |
|
|
this.showToast('请填写所在街道') |
|
|
this.showToast('请填写路牌号') |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
const para = { |
|
|
const para = { |
|
@ -561,13 +744,15 @@ Page({ |
|
|
gridId: this.data.gridInfo.gridId ? this.data.gridInfo.gridId : this.data.houseInfo.gridId, |
|
|
gridId: this.data.gridInfo.gridId ? this.data.gridInfo.gridId : this.data.houseInfo.gridId, |
|
|
wxCode: this.data.unionIdStatus === '0' ? this.data.wxInfo.wxCode : '', |
|
|
wxCode: this.data.unionIdStatus === '0' ? this.data.wxInfo.wxCode : '', |
|
|
encryptedData: this.data.unionIdStatus === '0' ? this.data.wxInfo.encryptedData : '', |
|
|
encryptedData: this.data.unionIdStatus === '0' ? this.data.wxInfo.encryptedData : '', |
|
|
iv: this.data.unionIdStatus === '0' ? this.data.wxInfo.iv : '' |
|
|
iv: this.data.unionIdStatus === '0' ? this.data.wxInfo.iv : '', |
|
|
|
|
|
status: '1' |
|
|
} |
|
|
} |
|
|
console.log(para) |
|
|
console.log(para) |
|
|
api.completeResidentInfo(para).then(res => { |
|
|
api.completeResidentInfo(para).then(res => { |
|
|
wx.reLaunch({ |
|
|
// wx.reLaunch({
|
|
|
url: `../index/index?roomCode=${!this.data.roomCode ? this.data.houseInfo.roomNo : this.data.roomCode}` |
|
|
// url: `../index/index?roomCode=${!this.data.roomCode ? this.data.houseInfo.roomNo : this.data.roomCode}`
|
|
|
}) |
|
|
// })
|
|
|
|
|
|
this.getUserInfoById2() |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
submitHouseInfo () { |
|
|
submitHouseInfo () { |
|
@ -597,6 +782,7 @@ Page({ |
|
|
unitId: this.data.houseInfo.id, |
|
|
unitId: this.data.houseInfo.id, |
|
|
userName: this.data.fmData.realName, |
|
|
userName: this.data.fmData.realName, |
|
|
idCard: this.data.fmData.identityNo, |
|
|
idCard: this.data.fmData.identityNo, |
|
|
|
|
|
gender: this.data.fmData.sex, |
|
|
mobile: this.data.fmData.mobile, |
|
|
mobile: this.data.fmData.mobile, |
|
|
houseAddress: houseAddress, |
|
|
houseAddress: houseAddress, |
|
|
community: this.data.houseInfo.communityName, |
|
|
community: this.data.houseInfo.communityName, |
|
|