14 changed files with 1229 additions and 129 deletions
@ -1,66 +0,0 @@ |
|||
// subpages/family/pages/bindFamily/bindFamily.js
|
|||
Page({ |
|||
|
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad(options) { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
onReady() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom() { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage() { |
|||
|
|||
} |
|||
}) |
@ -1,2 +0,0 @@ |
|||
<!--subpages/family/pages/bindFamily/bindFamily.wxml--> |
|||
<text>subpages/family/pages/bindFamily/bindFamily.wxml</text> |
@ -1 +0,0 @@ |
|||
/* subpages/family/pages/bindFamily/bindFamily.wxss */ |
@ -0,0 +1,335 @@ |
|||
// @ts-nocheck
|
|||
import { |
|||
wxShowToast, |
|||
wxRequestPost, |
|||
wxNavigateTo, |
|||
} from '../../utils/api.js'; |
|||
import validate from "../../utils/validate/index.js"; |
|||
Page({ |
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
submitBtnIsAllowed: false, |
|||
iniLoaded: false, |
|||
info: { |
|||
icResiUserId: '', |
|||
houseName: '', |
|||
houseCode: '3702030050150000700002', |
|||
qrCodeUrl: '', |
|||
}, |
|||
fmData: { |
|||
houseId:'', |
|||
ownerName:'', // 房主姓名
|
|||
ownerIdCard: '', // 身份证
|
|||
ownerPhone:'', // 房主电话
|
|||
remark:'' // 备注
|
|||
}, |
|||
buildingunitlist: [], // 单元
|
|||
houseType: [ // 房屋类型
|
|||
{ |
|||
value: "1", |
|||
label: "楼房", |
|||
}, |
|||
{ |
|||
value: "2", |
|||
label: "平房", |
|||
}, |
|||
{ |
|||
value: "3", |
|||
label: "别墅", |
|||
} |
|||
], |
|||
purposeArr: [ // 房屋用途
|
|||
{ value: '1', label: '住宅' }, |
|||
{ value: '2', label: '商业' }, |
|||
{ value: '3', label: '办公' }, |
|||
{ value: '4', label: '工业' }, |
|||
{ value: '5', label: '仓储' }, |
|||
{ value: '6', label: '商住混用' }, |
|||
{ value: '7', label: '其他' } |
|||
], |
|||
rentFlagArr: [ // 居住情况
|
|||
{ value: '1', label: '出租' }, |
|||
{ value: '2', label: '闲置' }, |
|||
{ value: '0', label: '自住' } |
|||
] |
|||
}, |
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
async onLoad(options) { |
|||
this.setData({ |
|||
fmData: options, |
|||
iniLoaded: true, |
|||
}); |
|||
await this.getBuildingunitlist(); |
|||
}, |
|||
|
|||
// 单元
|
|||
async getBuildingunitlist() { |
|||
const { fmData } = this.data; |
|||
if (!fmData.buildingId) return |
|||
const { |
|||
data: { |
|||
data: { code, data }, |
|||
}, |
|||
msg, |
|||
} = await wxRequestPost( |
|||
`gov/org/building/buildingunitlist`, |
|||
{buildingId: fmData.buildingId}, |
|||
{ |
|||
// isMock: true,
|
|||
isQuiet: false, |
|||
} |
|||
); |
|||
|
|||
if (msg === 'success' && code === 0) { |
|||
let buildingunitlist = [] |
|||
data.forEach(element => { |
|||
buildingunitlist.push({ |
|||
value: element.id, |
|||
label: element.unitName |
|||
}) |
|||
}); |
|||
this.setData({ |
|||
buildingunitlist: buildingunitlist |
|||
}) |
|||
} |
|||
}, |
|||
ownerNameSync(e){ |
|||
this.setData({ |
|||
'fmData.ownerName' : e.detail.value |
|||
}) |
|||
}, |
|||
ownerIdCardSync(e){ |
|||
this.setData({ |
|||
'fmData.ownerIdCard' : e.detail.value |
|||
}) |
|||
}, |
|||
ownerPhoneSync(e){ |
|||
this.setData({ |
|||
'fmData.ownerPhone' : e.detail.value |
|||
}) |
|||
}, |
|||
remarkSync(e){ |
|||
this.setData({ |
|||
'fmData.remark' : e.detail.value |
|||
}) |
|||
}, |
|||
// 房屋类型
|
|||
houseTypePicker(e){ |
|||
this.setData({ |
|||
'fmData.houseTypeName' : this.data.houseType[e.detail.value].label |
|||
}) |
|||
}, |
|||
// 房屋途径
|
|||
housePurposePicker(e){ |
|||
this.setData({ |
|||
'fmData.purposeName' : this.data.purposeArr[e.detail.value].label |
|||
}) |
|||
}, |
|||
// 房屋状态
|
|||
houseStatePicker(e){ |
|||
this.setData({ |
|||
'fmData.rentName' : this.data.rentFlagArr[e.detail.value].label |
|||
}) |
|||
}, |
|||
|
|||
// 身份证失去焦点
|
|||
handleValidBlur(e) { |
|||
let { fmData } = this.data; |
|||
const right = this.identityCodeValid(e.detail.value) |
|||
if (right) { |
|||
console.log('输入正确就没什么::::'); |
|||
} else { |
|||
fmData.gender = '' |
|||
this.setData({ fmData }) |
|||
wx.showToast({ |
|||
title: '身份证号不正确,请重新输入', |
|||
icon: "none", |
|||
duration: 1500, |
|||
}); |
|||
} |
|||
}, |
|||
|
|||
|
|||
// 校验身份证是否正确
|
|||
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) |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
onReady() {}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
async onShow() { |
|||
}, |
|||
// 修改提交
|
|||
async editSubmit () { |
|||
if (!this.computeSubmitBtnIsAllowed(false)) return; |
|||
|
|||
const { fmData } = this.data; |
|||
wx.showLoading({ |
|||
title: "提交中", |
|||
mask: true, |
|||
}); |
|||
const { |
|||
data: { |
|||
data: { code, data }, |
|||
}, |
|||
msg, |
|||
} = await wxRequestPost( |
|||
"gov/org/house/houseupdate", |
|||
{ |
|||
...fmData, |
|||
}, |
|||
{ |
|||
// isMock: true,
|
|||
isQuiet: false, |
|||
} |
|||
); |
|||
wx.hideLoading(); |
|||
|
|||
if (msg === "success" && code === 0) { |
|||
wxShowToast({ |
|||
title: "修改成功", |
|||
duration: 2000, |
|||
}); |
|||
setTimeout(()=>{ |
|||
wx.navigateBack() |
|||
},2000) |
|||
|
|||
} |
|||
}, |
|||
// 更新data数据后需主动触发
|
|||
$afterUpdateData() { |
|||
this.computeSubmitBtnIsAllowed(); |
|||
}, |
|||
// 校验
|
|||
computeSubmitBtnIsAllowed(isQuiet = true) { |
|||
const { fmData } = this.data, |
|||
vlt = validate(fmData, { |
|||
buildingUnitId: [ |
|||
{ |
|||
rule: "required", |
|||
message: "请先选择【单元号】", |
|||
}, |
|||
], |
|||
|
|||
doorName: [ |
|||
{ |
|||
rule: "required", |
|||
message: "请先输入【门牌号】", |
|||
}, |
|||
], |
|||
|
|||
houseType: [ |
|||
{ |
|||
rule: "required", |
|||
message: "请先选择【房屋类型】", |
|||
}, |
|||
], |
|||
|
|||
purpose: [ |
|||
{ |
|||
rule: "required", |
|||
message: "请先选择【房屋用途】", |
|||
}, |
|||
], |
|||
|
|||
rentFlag: [ |
|||
{ |
|||
rule: "required", |
|||
message: "请先选择【房屋状态】", |
|||
}, |
|||
] |
|||
}); |
|||
if (!vlt.valid) { |
|||
if (!isQuiet) { |
|||
wx.showToast({ |
|||
title: vlt.error, |
|||
icon: "none", |
|||
duration: 1500, |
|||
}); |
|||
} |
|||
this.setData({ |
|||
submitBtnIsAllowed: false, |
|||
}); |
|||
return false; |
|||
} else { |
|||
this.setData({ |
|||
submitBtnIsAllowed: true, |
|||
}); |
|||
return true; |
|||
} |
|||
}, |
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide() {}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload() {}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh() {}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom() {}, |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage() {}, |
|||
}); |
@ -0,0 +1,245 @@ |
|||
<view class="g-bd" wx:if="{{ iniLoaded }}"> |
|||
<view class="m-fm"> |
|||
<view class="fm"> |
|||
<view class="fm-title">家庭房屋基本信息</view> |
|||
<view class="item-list"> |
|||
|
|||
<!-- 所属组织 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">所属组织</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
{{fmData.agencyName ? fmData.agencyName : ''}} |
|||
</view> |
|||
</view> |
|||
</view> |
|||
|
|||
<!-- 网格 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">网格</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
{{fmData.gridName ? fmData.gridName : ''}} |
|||
</view> |
|||
</view> |
|||
</view> |
|||
|
|||
<!-- 小区 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">小区</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
{{fmData.neighborHoodName ? fmData.neighborHoodName : ''}} |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<!-- 楼栋 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">楼栋</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
{{fmData.buildingName ? fmData.buildingName : ''}} |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<!-- 单元号 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">单元号</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
{{fmData.unitName ? fmData.unitName : ''}} |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<!-- <view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">单元号</view> |
|||
</view> |
|||
<view class="value"> |
|||
<picker class="picker" |
|||
range="{{buildingunitlist}}" |
|||
range-key="label" |
|||
bindchange="inputSyncPicker"> |
|||
<view class="picker-text" wx:if="{{fmData.unitName}}">{{fmData.unitName}}</view> |
|||
<view class="picker-text z-weak" wx:else>请选择</view> |
|||
<image class="menu-arrow" src="/subpages/family/images/arrow.png" mode="aspectFit" /> |
|||
</picker> |
|||
</view> |
|||
</view> --> |
|||
<!-- 门牌号 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">门牌号</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
{{fmData.doorName ? fmData.doorName : ''}} |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<!-- <view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">门牌号</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
<input type="text" |
|||
value="{{ fmData.doorName }}" |
|||
placeholder="请输入" |
|||
placeholder-class="z-ph" |
|||
data-fm="fmData" |
|||
data-name="doorName" |
|||
bindinput="inputSync" |
|||
cursor-spacing="14" |
|||
maxlength="100" /> |
|||
</view> |
|||
</view> |
|||
</view> --> |
|||
</view> |
|||
</view> |
|||
|
|||
<view class="fm"> |
|||
<view class="item-list"> |
|||
<!-- 房屋类型 --> |
|||
<view class="item" style="border-top: 0rpx"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">房屋类型</view> |
|||
</view> |
|||
<view class="value"> |
|||
<picker class="picker" |
|||
range="{{houseType}}" |
|||
range-key="label" |
|||
bindchange="houseTypePicker"> |
|||
<view class="picker-text" wx:if="{{fmData.houseTypeName}}">{{fmData.houseTypeName}}</view> |
|||
<view class="picker-text z-weak" wx:else>请选择</view> |
|||
<image class="menu-arrow" src="/subpages/family/images/arrow.png" mode="aspectFit" /> |
|||
</picker> |
|||
</view> |
|||
</view> |
|||
<!-- 房屋用途 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">房屋用途</view> |
|||
</view> |
|||
<view class="value"> |
|||
<picker class="picker" |
|||
range="{{purposeArr}}" |
|||
range-key="label" |
|||
bindchange="housePurposePicker"> |
|||
<view class="picker-text" wx:if="{{fmData.purposeName}}">{{fmData.purposeName}}</view> |
|||
<view class="picker-text z-weak" wx:else>请选择</view> |
|||
<image class="menu-arrow" src="/subpages/family/images/arrow.png" mode="aspectFit" /> |
|||
</picker> |
|||
</view> |
|||
</view> |
|||
<!-- 房屋状态 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">房屋状态</view> |
|||
</view> |
|||
<view class="value"> |
|||
<picker class="picker" |
|||
range="{{rentFlagArr}}" |
|||
range-key="label" |
|||
bindchange="houseStatePicker"> |
|||
<view class="picker-text" wx:if="{{fmData.rentName}}">{{fmData.rentName}}</view> |
|||
<view class="picker-text z-weak" wx:else>请选择</view> |
|||
<image class="menu-arrow" src="/subpages/family/images/arrow.png" mode="aspectFit" /> |
|||
</picker> |
|||
</view> |
|||
</view> |
|||
<!-- 姓名 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">房主姓名</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
<input type="text" |
|||
value="{{ fmData.ownerName }}" |
|||
placeholder="请输入" |
|||
placeholder-class="z-ph" |
|||
bindinput="ownerNameSync" |
|||
cursor-spacing="14" |
|||
maxlength="100" /> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<!-- 身份证号 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">身份证号</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
<input type="text" |
|||
value="{{ fmData.ownerIdCard }}" |
|||
placeholder="请输入" |
|||
placeholder-class="z-ph" |
|||
bindinput="ownerIdCardSync" |
|||
cursor-spacing="14" |
|||
maxlength="100" |
|||
bindblur="handleValidBlur" /> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<!-- 联系电话 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">联系电话</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
<input type="text" |
|||
value="{{ fmData.ownerPhone ? fmData.ownerPhone : '' }}" |
|||
placeholder="请输入" |
|||
placeholder-class="z-ph" |
|||
bindinput="ownerPhoneSync" |
|||
cursor-spacing="14" |
|||
maxlength="100" /> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<!-- 备注 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">备注</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
<input type="text" |
|||
value="{{ fmData.remark && fmData.remark != 'null' ? fmData.remark : '' }}" |
|||
placeholder="请输入" |
|||
placeholder-class="z-ph" |
|||
bindinput="remarkSync" |
|||
cursor-spacing="14" |
|||
maxlength="100" /> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
|
|||
<view class="operate"> |
|||
<view class="btn {{ submitBtnIsAllowed ? '' : 'z-disabled'}}" bind:tap="editSubmit">确认修改</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<loading id="loading"></loading> |
@ -0,0 +1 @@ |
|||
@import '../../assets/wxss/familyInfo.wxss'; |
@ -1,66 +1,397 @@ |
|||
// subpages/family/pages/familyInfo/familyInfo.js
|
|||
import { |
|||
addFamilyMember, |
|||
updateFamilyMember, |
|||
getFamilyMember, |
|||
householderRelation |
|||
} from '../../utils/api.js' |
|||
import validate from "../../utils/validate/index.js"; |
|||
|
|||
Page({ |
|||
|
|||
/** |
|||
* 页面的初始数据 |
|||
*/ |
|||
data: { |
|||
|
|||
submitBtnIsAllowed: false, |
|||
isShowDialog: false, |
|||
pageType: null, // add 新增 edit 编辑 look 查看
|
|||
fmData: { |
|||
userName: '', |
|||
idCard: '', |
|||
gender: '', |
|||
birthday: '', |
|||
mobile: '', |
|||
nationValue: '', |
|||
nation: '', |
|||
householdRegisterName: "", |
|||
relation: "", |
|||
outLiveAddressName: "", |
|||
outLiveAddressDetail: "", |
|||
}, |
|||
nationList: [], |
|||
houseRelationList: [] |
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面加载 |
|||
*/ |
|||
onLoad(options) { |
|||
async onLoad (options) { |
|||
wx.showLoading({ |
|||
title: "加载中", |
|||
mask: true, |
|||
}); |
|||
let idCard = options.idCard |
|||
this.setData({ |
|||
pageType:options.pageType |
|||
}) |
|||
if(options.pageType !== 'add'){ |
|||
await this.getMemberInfo(idCard) |
|||
}else{ |
|||
this.setData({ |
|||
'fmData.unitId':options.id |
|||
}) |
|||
} |
|||
await this.householderRelationFun() |
|||
wx.hideLoading() |
|||
}, |
|||
// 获取成员详情信息
|
|||
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) |
|||
} |
|||
} |
|||
}, |
|||
// 获取与户主关系
|
|||
async householderRelationFun(){ |
|||
const res = await householderRelation() |
|||
if(res.msg === 'success' && res.code === 0){ |
|||
this.setData({ |
|||
'houseRelationList':res.data, |
|||
}) |
|||
} |
|||
}, |
|||
nameSync(e){ |
|||
this.setData({ |
|||
'fmData.userName' : e.detail.value |
|||
}) |
|||
}, |
|||
idCardSync(e){ |
|||
this.setData({ |
|||
'fmData.idCard' : e.detail.value |
|||
}) |
|||
}, |
|||
mobileSync(e){ |
|||
this.setData({ |
|||
'fmData.mobile' : e.detail.value |
|||
}) |
|||
}, |
|||
nationSync(e){ |
|||
this.setData({ |
|||
'fmData.nation' : e.detail.value |
|||
}) |
|||
}, |
|||
nationSyncPicker(e){ |
|||
this.setData({ |
|||
'fmData.nationValue' : this.data.nationList[e.detail.value].dictValue, |
|||
'fmData.nation' : this.data.nationList[e.detail.value].dictName |
|||
}) |
|||
}, |
|||
houseSyncPicker(e){ |
|||
this.setData({ |
|||
'fmData.houseRelation' : this.data.houseRelationList[e.detail.value].dictValue, |
|||
'fmData.relation' : this.data.houseRelationList[e.detail.value].dictName |
|||
}) |
|||
}, |
|||
householdRegisterSync(e){ |
|||
this.setData({ |
|||
'fmData.householdRegisterName' : e.detail.value |
|||
}) |
|||
}, |
|||
outLiveAddressSync(e){ |
|||
this.setData({ |
|||
'fmData.outLiveAddressName' : e.detail.value |
|||
}) |
|||
}, |
|||
addressSync(e){ |
|||
this.setData({ |
|||
'fmData.outLiveAddressDetail' : e.detail.value |
|||
}) |
|||
}, |
|||
handleValidBlur (e,val) { |
|||
var fmData = this.data.fmData; |
|||
var right = this.identityCodeValid(val ? val : e.detail.value); |
|||
if (right) { |
|||
fmData.birthday = this.getBirthday(this.data.fmData.idCard); |
|||
fmData.gender = this.getGender(this.data.fmData.idCard); |
|||
this.setData({ fmData }); |
|||
}else { |
|||
fmData.idCard = ''; |
|||
this.setData({ fmData }); |
|||
wx.showToast({ |
|||
title: '身份证号不正确,请重新输入', |
|||
icon: "none", |
|||
duration: 1500, |
|||
}); |
|||
} |
|||
}, |
|||
// 校验身份证是否正确
|
|||
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) |
|||
}, |
|||
getBirthday: function (psidno) { |
|||
var birthdayno, birthdaytemp; |
|||
if (psidno.length === 18) { |
|||
birthdayno = psidno.substring(6, 14); |
|||
} |
|||
else if (psidno.length === 15) { |
|||
birthdaytemp = psidno.substring(6, 12); |
|||
birthdayno = '19' + birthdaytemp; |
|||
} |
|||
else { |
|||
return ''; |
|||
} |
|||
var birthday = birthdayno.substring(0, 4) + '-' + birthdayno.substring(4, 6) + '-' + birthdayno.substring(6, 8); |
|||
return birthday; |
|||
}, |
|||
getGender (psidno) { |
|||
var num = psidno.charAt(16); |
|||
if (num % 2 == 0) { |
|||
return '女'; |
|||
}else { |
|||
return '男'; |
|||
} |
|||
}, |
|||
|
|||
// 编辑按钮点击事件
|
|||
editTap () { |
|||
if (this.data.fmData.idCard) { |
|||
this.handleValidBlur('',this.data.fmData.idCard) |
|||
} |
|||
this.setData({ |
|||
pageType: 'edit' |
|||
}) |
|||
}, |
|||
// 取消编辑
|
|||
closeEditTap () { |
|||
this.setData({ |
|||
pageType: 'look' |
|||
}) |
|||
}, |
|||
|
|||
|
|||
// 注册
|
|||
async submit() { |
|||
if (!this.computeSubmitBtnIsAllowed(false)) return; |
|||
|
|||
const { fmData } = this.data; |
|||
if (fmData.gender === '男') { |
|||
fmData.gender = '1' |
|||
} else if (fmData.gender === '女') { |
|||
fmData.gender = '2' |
|||
} |
|||
this.setData({ fmData }) |
|||
wx.showLoading({ |
|||
title: "提交中", |
|||
mask: true, |
|||
}); |
|||
const res = await addFamilyMember({...fmData}) |
|||
wx.hideLoading(); |
|||
|
|||
if (res.msg === "success" && res.code === 0) { |
|||
wx.showToast({ |
|||
title: "提交成功", |
|||
duration: 2000, |
|||
}); |
|||
setTimeout(function () { |
|||
wx.navigateBack() |
|||
}, 1000) |
|||
|
|||
// wxRedirectTo("../index", {});
|
|||
} |
|||
}, |
|||
|
|||
// 修改提交
|
|||
async editSubmit () { |
|||
if (!this.computeSubmitBtnIsAllowed(false)) return; |
|||
|
|||
const { fmData } = this.data; |
|||
if (fmData.gender === '男') { |
|||
fmData.gender = '1' |
|||
} else if (fmData.gender === '女') { |
|||
fmData.gender = '2' |
|||
} |
|||
this.setData({ fmData }) |
|||
wx.showLoading({ |
|||
title: "提交中", |
|||
mask: true, |
|||
}); |
|||
const res = await updateFamilyMember({...fmData}) |
|||
wx.hideLoading(); |
|||
|
|||
if (res.msg === "success" && res.code === 0) { |
|||
wx.showToast({ |
|||
title: "提交成功", |
|||
duration: 2000, |
|||
}); |
|||
|
|||
setTimeout(function () { |
|||
wx.navigateBack() |
|||
}, 1000) |
|||
} |
|||
}, |
|||
|
|||
|
|||
// 更新data数据后需主动触发
|
|||
$afterUpdateData() { |
|||
this.computeSubmitBtnIsAllowed(); |
|||
}, |
|||
|
|||
|
|||
// 校验
|
|||
computeSubmitBtnIsAllowed(isQuiet = true) { |
|||
const { fmData } = this.data, |
|||
vlt = validate(fmData, { |
|||
// surname: [
|
|||
// {
|
|||
// rule: "required",
|
|||
// message: "请先输入成员【姓】",
|
|||
// },
|
|||
// ],
|
|||
|
|||
userName: [ |
|||
{ |
|||
rule: "required", |
|||
message: "请先输入成员【姓名】", |
|||
}, |
|||
], |
|||
|
|||
idCard: [ |
|||
{ |
|||
rule: "required", |
|||
message: "请先输入成员【身份证号】", |
|||
}, |
|||
], |
|||
|
|||
mobile: [ |
|||
{ |
|||
rule: "required", |
|||
message: "请先输入成员【手机号】", |
|||
}, |
|||
{ |
|||
rule: "mobile", |
|||
message: "【手机号】格式不正确", |
|||
}, |
|||
] |
|||
}); |
|||
if (!vlt.valid) { |
|||
if (!isQuiet) { |
|||
wx.showToast({ |
|||
title: vlt.error, |
|||
icon: "none", |
|||
duration: 1500, |
|||
}); |
|||
} |
|||
this.setData({ |
|||
submitBtnIsAllowed: false, |
|||
}); |
|||
return false; |
|||
} else { |
|||
this.setData({ |
|||
submitBtnIsAllowed: true, |
|||
}); |
|||
return true; |
|||
} |
|||
}, |
|||
/** |
|||
* 生命周期函数--监听页面初次渲染完成 |
|||
*/ |
|||
onReady() { |
|||
onReady: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面显示 |
|||
*/ |
|||
onShow() { |
|||
onShow: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面隐藏 |
|||
*/ |
|||
onHide() { |
|||
onHide: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 生命周期函数--监听页面卸载 |
|||
*/ |
|||
onUnload() { |
|||
onUnload: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面相关事件处理函数--监听用户下拉动作 |
|||
*/ |
|||
onPullDownRefresh() { |
|||
onPullDownRefresh: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 页面上拉触底事件的处理函数 |
|||
*/ |
|||
onReachBottom() { |
|||
onReachBottom: function () { |
|||
|
|||
}, |
|||
|
|||
/** |
|||
* 用户点击右上角分享 |
|||
*/ |
|||
onShareAppMessage() { |
|||
onShareAppMessage: function () { |
|||
|
|||
} |
|||
}) |
@ -1,2 +1,263 @@ |
|||
<!--subpages/family/pages/familyInfo/familyInfo.wxml--> |
|||
<text>subpages/family/pages/familyInfo/familyInfo.wxml</text> |
|||
<view class="g-bd"> |
|||
<view class="m-fm"> |
|||
<view class="fm"> |
|||
<view class="fm-title">基本信息</view> |
|||
<view class="item-list"> |
|||
<view wx:if="{{pageType === 'add' || pageType === 'edit'}}"> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">姓名</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
<input type="text" value="{{ fmData.userName }}" placeholder="请输入" placeholder-class="z-ph" bindinput="nameSync" cursor-spacing="14" maxlength="100" /> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">身份证号</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
<input type="text" value="{{ fmData.idCard }}" placeholder="请输入上报人身份证号" placeholder-class="z-ph" bindinput="idCardSync" cursor-spacing="14" maxlength="18" bindblur="handleValidBlur" /> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">性别</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input">{{fmData.gender}}</view> |
|||
</view> |
|||
</view> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">出生日期</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input">{{fmData.birthday}}</view> |
|||
</view> |
|||
</view> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">联系电话</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
<input type="text" value="{{ fmData.mobile }}" placeholder="请输入联系电话" placeholder-class="z-ph" data-fm="fmData" data-name="mobile" bindinput="mobileSync" cursor-spacing="14" maxlength="11" /> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view wx:if="{{pageType === 'look'}}"> |
|||
<!-- 姓名 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">姓名</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input">{{fmData.userName}}</view> |
|||
</view> |
|||
</view> |
|||
<!-- 身份证号 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">身份证号</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input">{{fmData.idCard}}</view> |
|||
</view> |
|||
</view> |
|||
<!-- 性别 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">性别</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
{{fmData.gender === '1' ? '男' : fmData.gender === '2' ? '女' : fmData.gender === '0' ? '' : fmData.gender}} |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<!-- 出生日期 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">出生日期</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input">{{fmData.birthday ? fmData.birthday : ''}}</view> |
|||
</view> |
|||
</view> |
|||
<!-- 联系电话 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="must">*</view> |
|||
<view class="field-text">联系电话</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input">{{fmData.mobile ? fmData.mobile : ''}}</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view class="fm"> |
|||
<view class="item-list"> |
|||
<view wx:if="{{pageType === 'add' || pageType === 'edit'}}"> |
|||
<view class="item" style="border-top: 0rpx"> |
|||
<view class="field"> |
|||
<view class="field-text">民族</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
<input type="text" value="{{ fmData.nation }}" placeholder="请输入民族" |
|||
bindinput="nationSync" |
|||
placeholder-class="z-ph" data-fm="fmData" data-name="nation" cursor-spacing="14" maxlength="100" /> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<!-- <view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">户籍地</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="picker" bind:tap="select5Addr"> |
|||
<view class="picker-text" wx:if="{{fmData.presentAddress}}"> |
|||
{{fmData.presentAddress}} |
|||
</view> |
|||
<view class="picker-text z-weak" wx:else>请选择</view> |
|||
<image class="menu-arrow" src="/subpages/family/images/arrow.png" mode="aspectFit" /> |
|||
</view> |
|||
</view> |
|||
</view> --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">户籍地</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
<input type="text" value="{{ fmData.householdRegisterName }}" placeholder="xx省x市x区(县)x街道" placeholder-class="z-ph" bindinput="householdRegisterSync" cursor-spacing="14" maxlength="100" /> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">与户主关系</view> |
|||
</view> |
|||
<view class="value"> |
|||
<picker class="picker" range="{{houseRelationList}}" range-key="dictName" bindchange="houseSyncPicker"> |
|||
<view class="picker-text" wx:if="{{fmData.relation}}">{{fmData.relation}}</view> |
|||
<view class="picker-text z-weak" wx:else>请选择</view> |
|||
<image class="menu-arrow" src="/subpages/family/images/arrow.png" mode="aspectFit" /> |
|||
</picker> |
|||
</view> |
|||
</view> |
|||
<!-- <view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">现居住地</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="picker" bind:tap="select5Addr"> |
|||
<view class="picker-text" wx:if="{{fmData.presentAddress}}"> |
|||
{{fmData.presentAddress}} |
|||
</view> |
|||
<view class="picker-text z-weak" wx:else>请选择</view> |
|||
<image class="menu-arrow" src="/subpages/family/images/arrow.png" mode="aspectFit" /> |
|||
</view> |
|||
</view> |
|||
</view> --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">现居住地</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
<input type="text" value="{{ fmData.outLiveAddressName }}" placeholder="xx省x市x区(县)x街道" placeholder-class="z-ph" bindinput="outLiveAddressSync" cursor-spacing="14" maxlength="100" /> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">详细地址</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input"> |
|||
<input type="text" value="{{ fmData.outLiveAddressDetail }}" placeholder="xx小区(号)x号楼x单元x户" placeholder-class="z-ph" bindinput="addressSync" cursor-spacing="14" maxlength="100" /> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view wx:if="{{pageType === 'look'}}"> |
|||
<!-- 民族 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">民族</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input">{{fmData.nation ? fmData.nation : ''}}</view> |
|||
</view> |
|||
</view> |
|||
<!-- 户籍地 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">户籍地</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input">{{fmData.householdRegisterName ? fmData.householdRegisterName : ''}}</view> |
|||
</view> |
|||
</view> |
|||
<!-- 与户主关系 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">与户主关系</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input">{{fmData.relation ? fmData.relation : ''}}</view> |
|||
</view> |
|||
</view> |
|||
<!-- 现居住地 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">现居住地</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input">{{fmData.outLiveAddressName ? fmData.outLiveAddressName : ''}}</view> |
|||
</view> |
|||
</view> |
|||
<!-- 详细地址 --> |
|||
<view class="item"> |
|||
<view class="field"> |
|||
<view class="field-text">详细地址</view> |
|||
</view> |
|||
<view class="value"> |
|||
<view class="input">{{fmData.outLiveAddressDetail ? fmData.outLiveAddressDetail : ''}}</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view class="operate" wx:if="{{pageType === 'add'}}"> |
|||
<view class="btn" style="opacity: 1;" bind:tap="submit">确认提交</view> |
|||
</view> |
|||
<view class="edit" wx:if="{{pageType === 'look'}}"> |
|||
<view class="editbtn" bindtap="editTap">编辑</view> |
|||
</view> |
|||
<view class="edit-two" wx:if="{{pageType === 'edit'}}"> |
|||
<view class="editbtn" bindtap="closeEditTap">取消编辑</view> |
|||
<view class="btn {{ submitBtnIsAllowed ? '' : 'z-disabled'}} right" bindtap="editSubmit"> |
|||
提交 |
|||
</view> |
|||
</view> |
|||
</view> |
|||
</view> |
@ -1 +1,16 @@ |
|||
/* subpages/family/pages/familyInfo/familyInfo.wxss */ |
|||
@import '../../wxss/familyInfo.wxss'; |
|||
|
|||
|
|||
.editbtn{ |
|||
margin:100rpx auto; |
|||
width:240rpx; |
|||
height:80rpx; |
|||
line-height:80rpx; |
|||
border-radius:40rpx; |
|||
text-align:center; |
|||
font-size:32rpx; |
|||
font-family:Source Han Serif SC; |
|||
font-weight:400; |
|||
color:#fff; |
|||
background-color: #0399d8; |
|||
} |
@ -1 +1,3 @@ |
|||
/* subpages/family/pages/index/index.wxss */ |
|||
@import '../../wxss/family.wxss'; |
|||
|
|||
@import '../../wxss/c-popForm.wxss'; |
@ -1 +1,23 @@ |
|||
/* subpages/family/pages/noAccess/noAccess.wxss */ |
|||
.no-family { |
|||
padding-top: 200rpx; |
|||
} |
|||
.no-family image { |
|||
display: block; |
|||
width: 506rpx; |
|||
margin: 0 auto; |
|||
} |
|||
.no-family .no-btn { |
|||
width: 220rpx; |
|||
height: 66rpx; |
|||
margin: 60rpx auto 0; |
|||
font-size: 32rpx; |
|||
color: #fff; |
|||
text-align: center; |
|||
line-height: 66rpx; |
|||
background-image: linear-gradient(90deg, #ca151d 0%, #e11c13 100%); |
|||
border-radius: 30rpx; |
|||
-webkit-border-radius: 30rpx; |
|||
-moz-border-radius: 30rpx; |
|||
-ms-border-radius: 30rpx; |
|||
-o-border-radius: 30rpx; |
|||
} |
Loading…
Reference in new issue