diff --git a/epdc-resident-mp-yushan/images/my-home.png b/epdc-resident-mp-yushan/images/my-home.png new file mode 100644 index 0000000..4ba48ba Binary files /dev/null and b/epdc-resident-mp-yushan/images/my-home.png differ diff --git a/epdc-resident-mp-yushan/pages/complete/components/personalInfo/personalInfo.js b/epdc-resident-mp-yushan/pages/complete/components/personalInfo/personalInfo.js index fa48866..4a66d3a 100644 --- a/epdc-resident-mp-yushan/pages/complete/components/personalInfo/personalInfo.js +++ b/epdc-resident-mp-yushan/pages/complete/components/personalInfo/personalInfo.js @@ -515,7 +515,7 @@ Component({ content: res.data.resultMsg, success: () => { wx.reLaunch({ - url: "/pages/indexNew/indexNew" + url: "/pages/index/index" }) } }) @@ -527,7 +527,7 @@ Component({ complete: () => { setTimeout(() => { wx.reLaunch({ - url: "/pages/indexNew/indexNew" + url: "/pages/index/index" }) }, 2000) } @@ -544,7 +544,7 @@ Component({ content: res.data.resultMsg, success: () => { wx.reLaunch({ - url: "/pages/indexNew/indexNew" + url: "/pages/index/index" }) } }) @@ -556,7 +556,7 @@ Component({ complete: () => { setTimeout(() => { wx.reLaunch({ - url: "/pages/indexNew/indexNew" + url: "/pages/index/index" }) }, 2000) } diff --git a/epdc-resident-mp-yushan/pages/index/index.js b/epdc-resident-mp-yushan/pages/index/index.js index 1d3ebad..06df44c 100644 --- a/epdc-resident-mp-yushan/pages/index/index.js +++ b/epdc-resident-mp-yushan/pages/index/index.js @@ -82,6 +82,7 @@ Page({ signCode: 0, isSignUp: 0, visible: false, + identityNo: '' }, onLoad(options) { if (options.scene) { @@ -411,8 +412,29 @@ Page({ }, // 绑定家庭入口 toFamily() { - wx.navigateTo({ - url: '/subpages/family/pages/bindFamily/bindFamily', + if (!this.data.identityNo) { + wx.showToast({ + title: '请先扫描房屋码,绑定家庭', + icon: 'none', + duration: 2500 + }) + return + } + const params = { + idCard: this.data.identityNo + } + api.getRoomCodeByIdCard(params).then(res => { + if (res.data && res.data.roomCode) { + wx.navigateTo({ + url: `/subpages/family/pages/index/index?roomCode=${res.data.roomCode}`, + }) + } else { + wx.showToast({ + title: '请扫房屋码绑定房屋', + icon: 'none', + duration: 2500 + }) + } }) }, // 获取最新社区资讯 @@ -613,7 +635,8 @@ Page({ api.getUserInfo().then(res => { console.log("用户信息", res) this.setData({ - isSignUp: res.data.isSignUp + isSignUp: res.data.isSignUp, + identityNo: res.data.identityNo }) }).catch(err => { this.setData({ diff --git a/epdc-resident-mp-yushan/pages/index/index.wxml b/epdc-resident-mp-yushan/pages/index/index.wxml index 6d34d96..6bc0c60 100644 --- a/epdc-resident-mp-yushan/pages/index/index.wxml +++ b/epdc-resident-mp-yushan/pages/index/index.wxml @@ -156,10 +156,10 @@ - + - - + + diff --git a/epdc-resident-mp-yushan/pages/toRegister/toRegister.js b/epdc-resident-mp-yushan/pages/toRegister/toRegister.js index 897745f..9442b91 100644 --- a/epdc-resident-mp-yushan/pages/toRegister/toRegister.js +++ b/epdc-resident-mp-yushan/pages/toRegister/toRegister.js @@ -21,7 +21,7 @@ Page({ } }) let that = this - const versionNum = '1.2.32' + const versionNum = '1.2.33' api.getScanSwitch(versionNum).then(function (res) { console.log(res.data) let state = res.data ? res.data.scanFlag : '1' diff --git a/epdc-resident-mp-yushan/subpages/family/pages/bindFamily/bindFamily.js b/epdc-resident-mp-yushan/subpages/family/pages/bindFamily/bindFamily.js index dfdf2bf..8bdf8a4 100644 --- a/epdc-resident-mp-yushan/subpages/family/pages/bindFamily/bindFamily.js +++ b/epdc-resident-mp-yushan/subpages/family/pages/bindFamily/bindFamily.js @@ -44,6 +44,7 @@ Page({ houseInfo: {}, // 通过roomCode获取的房屋信息 inputDisabled: false, // 输入身份证号,查询到信息的话,禁止修改 selectBuildingId: '', // 选择的楼栋id + userState: '' }, /** @@ -58,14 +59,6 @@ Page({ }) } this.getUserState() - this.checkWxUnionId() - this.getWxCode() - wx.hideToast() - if (!this.data.roomCode) { - this.getPersonalInfo().then(res => { - this.getVillageList() - }) - } }, getVillageList () { const params = { @@ -187,11 +180,22 @@ Page({ if (res.code) { let code = res.code api.getToken(code).then(res => { - const state = res.data.userState - app.globalData.infoCompleted = state - wx.setStorageSync('topGridName', res.data.grid) - wx.setStorageSync('token', res.data.token) - _this.getUserInfoById() + _this.data.userState = res.data.userState + if (_this.data.userState == '4') { + _this.getHouseInfo() + } else { + 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 { 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 () { api.getUserInfo().then(res => { console.log("用户信息", res) if (res.data.identityNo) { - wx.reLaunch({ - url: `../index/index?roomCode=${this.data.roomCode}` + 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.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 => { console.log(err) }) @@ -222,20 +345,28 @@ Page({ roomCode: this.data.roomCode } api.getHouseInfo(params).then(res => { - console.log(res.data) + console.log('getHouseInfo: ', res.data) if (res.code == 0) { this.setData({ houseInfo: res.data }) + if (this.data.userState == '4') { + this.getTokenByGridId() + } } }) }, // 获取成员信息 getFamilyMember () { - if (!this.data.fmData.identityNo) { - return - } - if (this.data.fmData.identityNo.length < 16) { + if (!this.identityCodeValid(this.data.fmData.identityNo)) { + wx.showToast({ + title: '身份证不合法', + icon: 'none', + duration: 2500 + }) + this.setData({ + 'fmData.identityNo': '' + }) return } 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) { this.setData({ @@ -269,7 +450,7 @@ Page({ this.setData({ 'fmData.identityNo': e.detail.value }) - this.getFamilyMember() + // this.getFamilyMember() }, // 姓名 双向绑定 bindRealNameInput (e) { @@ -472,7 +653,7 @@ Page({ } else if (this.data.getMobileType === 'self') { this.submitPersonalInfoBySelf() } - this.submitHouseInfo() + // this.submitHouseInfo() }, // 提交完善信息-从微信获取手机号方式 submitPersonalInfoByWx () { @@ -493,7 +674,7 @@ Page({ return false } if (!this.data.fmData.road) { - this.showToast('请填写所在街道') + this.showToast('请填写路牌号') return false } // if (!this.data.fmData.smsCode) { @@ -513,13 +694,15 @@ Page({ gridId: this.data.gridInfo.gridId ? this.data.gridInfo.gridId : this.data.houseInfo.gridId, wxCode: this.data.unionIdStatus === '0' ? this.data.wxInfo.wxCode : '', 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) api.completeResidentInfoV2(para).then(res => { - wx.reLaunch({ - url: `../index/index?roomCode=${!this.data.roomCode ? this.data.houseInfo.roomNo : this.data.roomCode}` - }) + // wx.reLaunch({ + // url: `../index/index?roomCode=${!this.data.roomCode ? this.data.houseInfo.roomNo : this.data.roomCode}` + // }) + this.getUserInfoById2() }) }, // 提交完善信息,手机号输入方式 @@ -545,7 +728,7 @@ Page({ return false } if (!this.data.fmData.road) { - this.showToast('请填写所在街道') + this.showToast('请填写路牌号') return false } const para = { @@ -561,13 +744,15 @@ Page({ gridId: this.data.gridInfo.gridId ? this.data.gridInfo.gridId : this.data.houseInfo.gridId, wxCode: this.data.unionIdStatus === '0' ? this.data.wxInfo.wxCode : '', 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) api.completeResidentInfo(para).then(res => { - wx.reLaunch({ - url: `../index/index?roomCode=${!this.data.roomCode ? this.data.houseInfo.roomNo : this.data.roomCode}` - }) + // wx.reLaunch({ + // url: `../index/index?roomCode=${!this.data.roomCode ? this.data.houseInfo.roomNo : this.data.roomCode}` + // }) + this.getUserInfoById2() }) }, submitHouseInfo () { @@ -597,6 +782,7 @@ Page({ unitId: this.data.houseInfo.id, userName: this.data.fmData.realName, idCard: this.data.fmData.identityNo, + gender: this.data.fmData.sex, mobile: this.data.fmData.mobile, houseAddress: houseAddress, community: this.data.houseInfo.communityName, diff --git a/epdc-resident-mp-yushan/subpages/family/pages/bindFamily/bindFamily.wxml b/epdc-resident-mp-yushan/subpages/family/pages/bindFamily/bindFamily.wxml index d9d8bdb..0f7932e 100644 --- a/epdc-resident-mp-yushan/subpages/family/pages/bindFamily/bindFamily.wxml +++ b/epdc-resident-mp-yushan/subpages/family/pages/bindFamily/bindFamily.wxml @@ -40,6 +40,15 @@ + + + * + 路牌号 + + + + + * @@ -85,7 +94,7 @@ - + * @@ -152,7 +161,7 @@ - + * diff --git a/epdc-resident-mp-yushan/subpages/family/pages/familyInfo/familyInfo.js b/epdc-resident-mp-yushan/subpages/family/pages/familyInfo/familyInfo.js index d23863b..c823cc1 100644 --- a/epdc-resident-mp-yushan/subpages/family/pages/familyInfo/familyInfo.js +++ b/epdc-resident-mp-yushan/subpages/family/pages/familyInfo/familyInfo.js @@ -58,11 +58,19 @@ Page({ async getMemberInfo(idCard){ const res = await getFamilyMember({idCard:idCard}) if(res.msg === 'success' && res.code === 0){ - this.setData({ - 'fmData':res.data, - }) - if (idCard) { - this.handleValidBlur('',idCard) + if (res.data) { + this.setData({ + 'fmData':res.data, + }) + if (idCard) { + this.handleValidBlur('',idCard) + } + } else { + wx.showToast({ + title: '个人信息为空', + icon: 'none', + duration: 2500 + }) } } }, @@ -231,7 +239,7 @@ Page({ if (fmData.gender === '男') { fmData.gender = '1' } else if (fmData.gender === '女') { - fmData.gender = '2' + fmData.gender = '0' } this.setData({ fmData }) wx.showLoading({ @@ -262,7 +270,7 @@ Page({ if (fmData.gender === '男') { fmData.gender = '1' } else if (fmData.gender === '女') { - fmData.gender = '2' + fmData.gender = '0' } this.setData({ fmData }) wx.showLoading({ diff --git a/epdc-resident-mp-yushan/subpages/family/pages/familyInfo/familyInfo.json b/epdc-resident-mp-yushan/subpages/family/pages/familyInfo/familyInfo.json index 8835af0..346ad6d 100644 --- a/epdc-resident-mp-yushan/subpages/family/pages/familyInfo/familyInfo.json +++ b/epdc-resident-mp-yushan/subpages/family/pages/familyInfo/familyInfo.json @@ -1,3 +1,4 @@ { + "navigationBarTitleText": "详细信息", "usingComponents": {} } \ No newline at end of file diff --git a/epdc-resident-mp-yushan/subpages/family/pages/familyInfo/familyInfo.wxml b/epdc-resident-mp-yushan/subpages/family/pages/familyInfo/familyInfo.wxml index 1465ed8..4824b76 100644 --- a/epdc-resident-mp-yushan/subpages/family/pages/familyInfo/familyInfo.wxml +++ b/epdc-resident-mp-yushan/subpages/family/pages/familyInfo/familyInfo.wxml @@ -32,7 +32,7 @@ 性别 - {{fmData.gender}} + {{fmData.gender == '0' ? '女' : fmData.gender == '1' ? '男' : fmData.gender}} @@ -85,7 +85,7 @@ - {{fmData.gender === '1' ? '男' : fmData.gender === '2' ? '女' : fmData.gender === '0' ? '' : fmData.gender}} + {{fmData.gender == '0' ? '女' : fmData.gender == '1' ? '男' : fmData.gender}} diff --git a/epdc-resident-mp-yushan/subpages/family/pages/index/index.json b/epdc-resident-mp-yushan/subpages/family/pages/index/index.json index 8835af0..94b31bc 100644 --- a/epdc-resident-mp-yushan/subpages/family/pages/index/index.json +++ b/epdc-resident-mp-yushan/subpages/family/pages/index/index.json @@ -1,3 +1,4 @@ { + "navigationBarTitleText": "我的家庭", "usingComponents": {} } \ No newline at end of file diff --git a/epdc-resident-mp-yushan/subpages/family/pages/noAccess/noAccess.json b/epdc-resident-mp-yushan/subpages/family/pages/noAccess/noAccess.json index 8835af0..94b31bc 100644 --- a/epdc-resident-mp-yushan/subpages/family/pages/noAccess/noAccess.json +++ b/epdc-resident-mp-yushan/subpages/family/pages/noAccess/noAccess.json @@ -1,3 +1,4 @@ { + "navigationBarTitleText": "我的家庭", "usingComponents": {} } \ No newline at end of file diff --git a/epdc-resident-mp-yushan/utils/api.js b/epdc-resident-mp-yushan/utils/api.js index 87be1fe..a0fd4c5 100644 --- a/epdc-resident-mp-yushan/utils/api.js +++ b/epdc-resident-mp-yushan/utils/api.js @@ -11,6 +11,7 @@ module.exports = { getGridList: getGridList, changeGrid: changeGrid, completeInfo: completeInfo, + completeResidentInfo: completeResidentInfo, completeResidentInfoV2: completeResidentInfoV2, completePartyInfoV2: completePartyInfoV2, completeCompanyInfo: completeCompanyInfo, @@ -82,7 +83,9 @@ module.exports = { getUnitOption, getHouseOption, bindingFamily, - getFamilyMember + getFamilyMember, + getSkipDirection, + getRoomCodeByIdCard } function getToken(wxCode) { @@ -164,6 +167,10 @@ function gridLeaderRegister(mobile, smsCode, wxCode) { function completeInfo(data) { return fly.post('app-user/user/completeInfo', data) } +// 居民 完善个人信息 传验证码 +function completeResidentInfo(para) { + return fly.post("app-user/user/completeResidentInfo", para) +} // 居民 完善个人信息v2 不需要穿验证码 function completeResidentInfoV2(para) { return fly.post("app-user/user/v2/completeResidentInfo", para) @@ -612,4 +619,13 @@ function bindingFamily(params) { // 获取成员信息 function getFamilyMember (params) { return fly.get('custom/personroom/getFamilyMember', params) +} + +// +function getSkipDirection (params) { + return fly.get('custom/personroom/getSkipDirection', params) +} +// +function getRoomCodeByIdCard (params) { + return fly.get('custom/personroom/getRoomCodeByIdCard', params) } \ No newline at end of file