diff --git a/app.json b/app.json
index 3013e07..a7cd317 100644
--- a/app.json
+++ b/app.json
@@ -10,7 +10,8 @@
"pages/mine/mine",
"pages/censusinput/censusinput",
"pages/chooseArea/chooseArea",
- "pages/censusDetail/censusDetail"
+ "pages/censusDetail/censusDetail",
+ "pages/censusEdit/censusEdit"
],
"window": {
"backgroundTextStyle": "light",
diff --git a/pages/censusDetail/censusDetail.js b/pages/censusDetail/censusDetail.js
index f3f9a37..957403b 100644
--- a/pages/censusDetail/censusDetail.js
+++ b/pages/censusDetail/censusDetail.js
@@ -48,6 +48,7 @@ Page({
bean: data
});
}, (code, error) => {
+ console.log(error);
wx.hideLoading();
wx.showToast({
title: '加载失败',
@@ -57,7 +58,15 @@ Page({
},
//编辑
doEdit() {
-
+ var _self = this;
+ wx.navigateTo({
+ url: '/pages/censusEdit/censusEdit?id=' + _self.data.id,
+ events: {
+ doNeedRefresh: (data) => {
+ _self.getDetailData();
+ }
+ }
+ })
},
//删除
doDel() {
diff --git a/pages/censusEdit/censusEdit.js b/pages/censusEdit/censusEdit.js
new file mode 100644
index 0000000..bd40b48
--- /dev/null
+++ b/pages/censusEdit/censusEdit.js
@@ -0,0 +1,1057 @@
+// pages/censusEdit/censusEdit.js
+const app = getApp();
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ token: '',
+ id: '',
+ name: '',//名字
+ cardType: null,//证件类型
+ cardNum: '',//证件号码
+ birthDay: '',//生日
+ gender: null,//性别
+ nation: null,//民族
+ edu: null,//学历
+ relation: null,//与户主关系
+ phoneNum: '',
+ keys: {
+ value: 'dictionaryId',
+ label: 'dictionaryName'
+ },
+ showPicker: false,
+ dicList: [],
+ currentDicType: -1,
+ date: new Date().getTime(),
+ showDate: false,
+ dateType: -1,
+ academy: '',//就读院校
+ political: null,//所属党派
+ religion: null,//宗教信仰
+ marry: null,//婚姻状况
+ marryChangeDate: '',//婚变日期
+ marryDate: '',//初婚日期
+ insure: null,//社保情况
+ health: null,//健康状况
+ jobStatus: '已就业',//就业状况
+ workPlace: '',//工作单位
+ jobTitle: '',//工作职务
+ technical: '',//专业技术职称
+ speciality: '',//专长
+ fatherName: '',//父亲
+ fatherCardNum: '',
+ fatherPhone: '',
+ matherName: '',
+ matherCardNum: '',
+ matherPhone: '',
+ censusAddress: null,//户籍地址
+ censusDetail: '',//户籍详细地址
+ nativeAddress: '',//籍贯地址
+ flowDate: '',//流动日期
+ flowReason: null,//流动原因
+ flowOtherReason: '',//流动其他原因
+ isOld: '否',//是否老年人
+ oldType: null,
+ retireWorkUnit: '',//离退休前单位
+ liveTakeCare: null,//生活照料情况
+ oldHealthStatus: null,//老年人健康状况
+ oldSelfCare: null,//老年人生活自理能力
+ oldLiveStatus: null,//老年人居住状况
+ isDeformity: '否',//是否为残疾人
+ deformityType: null,//残疾人类型
+ deformityLevel: null,//残疾人等级
+ deformityCardNum: '',//残疾证号
+ deformityCarNum: '',//残疾车牌
+ deformityLiveAddress: null,//残疾人居住地址
+ deformityEarning: null,//残疾人收入情况
+ deformityHouseSource: null,//残疾人住房来源
+ cerDate: '',//残疾人办证时间
+ deformityGuarder: '',//残疾人监护人
+ deformityGuarderPhone: '',//监护人电话
+ deformityGuarderRelation: null,//监护人关系
+ isSoldier: '否',//是否退役
+ soldierRetireDate: '',//退役日期
+ soldierRetireLevel: null,//退役时职级
+ isSocial: '否',//是否社会救助
+ isLow: '否',//是否低保户
+ isMedical: '否',//是否医疗救助
+ isHard: '否',//是否困难
+ isSubsidy: '否',//是否老龄补贴
+ isPartyMember: '否',//是否党员
+ partyName: '',//党组织名称
+ intoPartyDate: '',//入党时间
+ partyMemberDesc: '',//党员其他说明
+ scrollHeight: 0,
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad(options) {
+ var _self = this;
+ wx.getStorage({
+ key: 'token',
+ success: function (res) {
+ _self.setData({
+ token: res.data,
+ id: options.id
+ })
+ //获取详情
+ _self.getDetailData();
+ }
+ })
+ let screenHeight = wx.getSystemInfoSync().windowHeight;
+ this.setData({
+ scrollHeight: screenHeight
+ })
+ },
+ //获取详情
+ getDetailData() {
+ var _self = this;
+ wx.showLoading({
+ title: '加载中...',
+ })
+ app.restAjax.get(app.restAjax.path('{reqesutUrl}app/populationinfo/get/' + _self.data.id, [app.personUrl]), null, {
+ headers: {
+ token: _self.data.token
+ }
+ }, function (code, data) {
+ wx.hideLoading();
+ _self.setDataToView(data);
+ }, function (code, error) {
+ wx.hideLoading();
+ wx.showToast({
+ title: '加载失败',
+ success: () => {
+ wx.navigateBack();
+ }
+ })
+ });
+ },
+ //回显数据
+ setDataToView(b) {
+ var _self = this;
+ _self.setData({
+ name: b.name,//姓名
+ cardType: { label: b.idcardType },//证件类型
+ cardNum: b.idcard,//证件号码
+ birthDay: b.birthday,//出生日期
+ gender: { label: b.sex },//性别
+ nation: { label: b.nation },//民族
+ edu: { label: b.education },//文化程度
+ relation: { label: b.relationship },//与户主关系
+ phoneNum: b.phone,//联系电话
+ academy: b.description,//就读院校及专业
+ political: { label: b.organization },//所属党派
+ religion: { label: b.religion },//宗教信仰
+ marry: { label: b.marriageStatus },//婚姻状况
+ marryChangeDate: b.marriageChangeTime,//婚变日期
+ marryDate: b.marriageFirstTime,//首次结婚日期
+ insure: { label: b.socialSecurity },//社保情况
+ health: { label: b.healthStatus },//健康状况
+ jobStatus: b.departmentType,//就业状况
+ workPlace: b.department,//工作单位
+ jobTitle: b.pastion,//工作职务
+ technical: b.pastionTitle,//专业技术职称
+ speciality: b.expertise,//专长
+ fatherName: b.fatherName,
+ fatherCardNum: b.fatherIdcard,
+ fatherPhone: b.fatherPhone,
+ matherName: b.motherName,
+ matherCardNum: b.motherIdcard,
+ matherPhone: b.motherPhone,
+ censusAddress: {
+ name: b.domicileAreaName,
+ code: b.domicileAreaCode
+ },//户籍地址
+ censusDetail: b.domicileAddress,//户籍详细地址
+ nativeAddress: b.originAddress,//籍贯地址
+ flowDate: _self.checkEmpty(b.flowTime) ? '' : b.flowTime,//流动日期
+ flowReason: _self.checkEmpty(b.flowReason) ? null : { label: b.flowReason },//流动原因
+ flowOtherReason: b.flowReasontext,//流动其他原因
+ isOld: b.isOldage,//是否老年人
+ oldType: _self.checkEmpty(b.oldageType) ? null : { label: b.oldageType },//老年人类别
+ retireWorkUnit: b.oldageDepartment,//离退休前单位
+ liveTakeCare: _self.checkEmpty(b.oldageLift) ? null : { label: b.oldageLift },//生活照料情况
+ oldHealthStatus: _self.checkEmpty(b.oldageHealthStatus) ? null : { label: b.oldageHealthStatus },//老年人健康状况
+ oldSelfCare: _self.checkEmpty(b.oldageSelfcare) ? null : { label: b.oldageSelfcare },//生活自理能力
+ oldLiveStatus: _self.checkEmpty(b.oldageLive) ? null : { label: b.oldageLive },//居住状况
+ isDeformity: b.isDisability,//是否残疾人
+ deformityType: _self.checkEmpty(b.disabilityType) ? null : { label: b.disabilityType },//残疾人类别
+ deformityLevel: _self.checkEmpty(b.disabilityLevel) ? null : { label: b.deformityLevel },//残疾等级
+ deformityCardNum: b.disabilityNumber,//残疾证号
+ deformityCarNum: b.disabilityCarnumber,//残疾车牌号
+ deformityLiveAddress: _self.checkEmpty(b.disabilityAreaCode) ? null : {
+ name: b.disabilityAreaName,
+ code: b.disabilityAreaCode
+ },//残疾居住地址
+ deformityEarning: _self.checkEmpty(b.disabilityIncome) ? null : { label: b.disabilityIncome },//残疾收入情况
+ deformityHouseSource: _self.checkEmpty(b.disabilityHouse) ? null : { label: b.disabilityHouse },//残疾住房来源
+ cerDate: _self.checkEmpty(b.disabilityTime) ? '' : b.disabilityTime,//办证时间
+ deformityGuarder: b.disabilityGuardian,//监护人
+ deformityGuarderPhone: b.disabilityGuardianPhone,//监护人联系电话
+ deformityGuarderRelation: _self.checkEmpty(b.disabilityGuardianRelation) ? null : { label: b.disabilityGuardianRelation },//监护人关系
+ isSoldier: b.isMilitary,//是否服役
+ soldierRetireDate: _self.checkEmpty(b.militaryTime) ? '' : b.militaryTime,//退役时间
+ soldierRetireLevel: _self.checkEmpty(b.militaryPosition) ? null : { label: b.militaryPosition },//服役等级
+ isSocial: b.isSuccour,//是否社会救助
+ isLow: b.succourDibao,//是否低保
+ isMedical: b.succourHelp,//是否医疗救助
+ isHard: b.succourDifficulty,//是否困难职工
+ isSubsidy: b.succourSubsidy,//是否老龄补贴
+ isPartyMember: b.isParty,//是否党员
+ partyName: b.partyOrganization,//党组织名称
+ intoPartyDate: _self.checkEmpty(b.partyTime) ? '' : b.partyTime,//入党时间
+ partyMemberDesc: b.othertext,//入党其他说
+
+ })
+ },
+
+ //姓名
+ inputName(e) {
+ this.setData({
+ name: e.detail.value
+ })
+ },
+ //证件类型
+ onShowCardType() {
+ var _self = this;
+ _self.getDicList(1, app.dics.dics.DIC_CARD_TYPE);
+ },
+ //证件号码
+ inputCardNum(e) {
+ this.setData({
+ cardNum: e.detail.value
+ })
+ },
+ //出生日期
+ onShowBirthDay() {
+ console.log('点击了')
+ this.setData({
+ showDate: true,
+ dateType: 1
+ })
+ },
+ //性别
+ onShowGender() {
+ var _self = this;
+ _self.getDicList(2, app.dics.dics.DIC_GENDER);
+ },
+ //民族
+ onShowNation() {
+ this.getDicList(3, app.dics.dics.DIC_NATION);
+ },
+ //文化程度
+ onShowEdu() {
+ this.getDicList(4, app.dics.dics.DIC_EDU);
+ },
+ //与户主关系
+ onShowRelation() {
+ this.getDicList(5, app.dics.dics.DIC_RELATION);
+ },
+ //联系电话
+ inputPhoneNum(e) {
+ this.setData({
+ phoneNum: e.detail.value
+ })
+ },
+ //就读院校
+ inputAcademy(e) {
+ this.setData({
+ academy: e.detail.value
+ })
+ },
+ //所属党派
+ onShowPolitical() {
+ this.getDicList(6, app.dics.dics.DIC_POLITICS);
+ },
+ //宗教信仰
+ onShowReligion() {
+ this.getDicList(7, app.dics.dics.DIC_RELIGION);
+ },
+ onShowMarry() {
+ this.getDicList(8, app.dics.dics.DIC_MARRIAGE);
+ },
+ //婚变日期
+ onShowMarryChangeDate() {
+ this.setData({
+ showDate: true,
+ dateType: 2
+ })
+ },
+ //初婚日期
+ onShowMarryDate() {
+ this.setData({
+ showDate: true,
+ dateType: 3
+ })
+ },
+ //社保情况
+ onShowInsure() {
+ this.getDicList(9, app.dics.dics.DIC_INSURE);
+ },
+ onShowHealth() {
+ this.getDicList(10, app.dics.dics.DIC_HEALTH);
+ },
+ //就业状况
+ onSelJobStatus(e) {
+ this.setData({
+ jobStatus: e.detail.value
+ })
+ },
+ //工作单位
+ inputWorkPlace(e) {
+ this.setData({
+ workPlace: e.detail.value
+ })
+ },
+ //工作职务
+ inputJobTitle(e) {
+ this.setData({
+ jobTitle: e.detail.value
+ })
+ },
+ //技术职称
+ inputTechnical(e) {
+ this.setData({
+ technical: e.detail.value
+ })
+ },
+ //专长
+ inputSpeciality(e) {
+ this.setData({
+ speciality: e.detail.value
+ })
+ },
+ //父亲
+ inputFather(e) {
+ this.setData({
+ fatherName: e.detail.value
+ })
+ },
+ inputFatherCardNum(e) {
+ this.setData({
+ fatherCardNum: e.detail.value
+ })
+ },
+ inputFatherPhone(e) {
+ this.setData({
+ fatherPhone: e.detail.value
+ })
+ },
+ //母亲
+ inputMather(e) {
+ this.setData({
+ matherName: e.detail.value
+ })
+ },
+ inputMatherCardNum(e) {
+ this.setData({
+ matherCardNum: e.detail.value
+ })
+ },
+ inputMatherPhone(e) {
+ this.setData({
+ matherPhone: e.detail.value
+ })
+ },
+ //户籍地址
+ onShowCensus() {
+ wx.navigateTo({
+ url: '/pages/chooseArea/chooseArea',
+ events: {
+ getBackData: res => {
+ this.setData({
+ censusAddress: res.backData
+ })
+ }
+ }
+ })
+ },
+ //户籍详细地址
+ inputCensusDetail(e) {
+ this.setData({
+ censusDetail: e.detail.value
+ })
+ },
+ //籍贯地址
+ inputNative(e) {
+ this.setData({
+ nativeAddress: e.detail.value
+ })
+ },
+ //流动日期
+ onShowFlowDate() {
+ this.setData({
+ showDate: true,
+ dateType: 4
+ })
+ },
+ //流动原因
+ onShowFlowReason() {
+ this.getDicList(11, app.dics.dics.DIC_FLOW_CAUSE);
+ },
+ //流动其他原因
+ inputFlowOtherReason(e) {
+ this.setData({
+ flowOtherReason: e.detail.value
+ })
+ },
+ //是否老人
+ onSelIsOld(e) {
+ this.setData({
+ isOld: e.detail.value ? '是' : '否'
+ })
+ },
+ onShowOldType() {
+ this.getDicList(12, app.dics.dics.DIC_OLD_TYPE);
+ },
+ //离退休前单位
+ inputRetireWorkUnit(e) {
+ this.setData({
+ retireWorkUnit: e.detail.value
+ })
+ },
+ //生活照料情况
+ onShowLiveTakeCare() {
+ this.getDicList(13, app.dics.dics.DIC_OLD_LIVE_CARE);
+ },
+ //老年人健康情况
+ onShowOldHealthStatus() {
+ this.getDicList(14, app.dics.dics.DIC_HEALTH);
+ },
+ //老年人生活自理能力
+ onShowOldSelfCare() {
+ this.getDicList(15, app.dics.dics.DIC_OLD_LIVE_ABILITY);
+ },
+ //老年人居住状况
+ onShowOldLiveStatus() {
+ this.getDicList(16, app.dics.dics.DIC_OLD_LIVE_HOUSE);
+ },
+ //是否为残疾人
+ onSelIsDeformity(e) {
+ this.setData({
+ isDeformity: e.detail.value ? '是' : '否'
+ })
+ },
+ //残疾类别
+ onShowDeformityType() {
+ this.getDicList(17, app.dics.dics.DIC_DEF_TYPE);
+ },
+ //残疾等级
+ onShowDeformityLevel() {
+ this.getDicList(18, app.dics.dics.DIC_DEF_LEVEL);
+ },
+ //残疾证号
+ inputDeformityCardNum(e) {
+ this.setData({
+ deformityCardNum: e.detail.value
+ })
+ },
+ //残疾车牌
+ inputDeformityCarNum(e) {
+ this.setData({
+ deformityCarNum: e.detail.value
+ })
+ },
+ //残疾人居住地址
+ onShowDeformityLiveAddress() {
+ wx.navigateTo({
+ url: '/pages/chooseArea/chooseArea?isDefault=true',
+ events: {
+ getDeformityLiveAddress: res => {
+ this.setData({
+ deformityLiveAddress: res.backData
+ })
+ }
+ }
+ })
+ },
+ //残疾人收入情况
+ onShowDeformityEarning() {
+ this.getDicList(19, app.dics.dics.DIC_DEF_EARNING);
+ },
+ //住房来源
+ onShowDeformityHouseSource() {
+ this.getDicList(20, app.dics.dics.DIC_DEF_HOUSE_SOURCE);
+ },
+ //残疾人办证时间
+ onShowCerDate() {
+ this.setData({
+ showDate: true,
+ dateType: 5
+ })
+ },
+ //残疾人监护人
+ inputGuarder(e) {
+ this.setData({
+ deformityGuarder: e.detail.value
+ })
+ },
+ //监护人联系电话
+ inputGuarderPhone(e) {
+ this.setData({
+ deformityGuarderPhone: e.detail.value
+ })
+ },
+ //残疾人监护人关系
+ onShowGuarderRelation() {
+ this.getDicList(21, app.dics.dics.DIC_GUARDER_RELATION);
+ },
+ //是否服役/现役
+ onSelIsSoldier(e) {
+ this.setData({
+ isSoldier: e.detail.value ? '是' : '否'
+ })
+ },
+ //退役日期
+ onShowSoldierRetireDate() {
+ this.setData({
+ showDate: true,
+ dateType: 6,
+ })
+ },
+ //退役时职级
+ onShowSoldierRetireLevel() {
+ this.getDicList(22, app.dics.dics.DIC_SOLDIER_LEVEL);
+ },
+ //是否社会救助
+ onSelIsSocial(e) {
+ this.setData({
+ isSocial: e.detail.value ? '是' : '否'
+ })
+ },
+ //是否低保户
+ onShowIsLow(e) {
+ this.setData({
+ isLow: e.detail.value ? '是' : '否'
+ })
+ },
+ //是否医疗救助
+ onSelIsMedical(e) {
+ this.setData({
+ isMedical: e.detail.value ? '是' : '否'
+ })
+ },
+ //是否困难职工
+ onSelIsHard(e) {
+ this.setData({
+ isHard: e.detail.value ? '是' : '否'
+ })
+ },
+ //是否老龄补贴
+ onSelIsSubsidy(e) {
+ this.setData({
+ isSubsidy: e.detail.value ? '是' : '否'
+ })
+ },
+ //是否党员
+ onSelIsPartyMember(e) {
+ this.setData({
+ isPartyMember: e.detail.value ? '是' : '否'
+ })
+ },
+ //党组织名称
+ inputPartyName(e) {
+ this.setData({
+ partyName: e.detail.value
+ })
+ },
+ //入党时间
+ onShowIntoPartyDate() {
+ this.setData({
+ showDate: true,
+ dateType: 7,
+ })
+ },
+ //党员其他说明
+ inputPartyMemberDesc(e) {
+ this.setData({
+ partyMemberDesc: e.detail.value
+ })
+ },
+ //字典确定
+ onDicPickerChange(e) {
+ console.log(e)
+ var type = e.target.dataset.type;
+ var label = e.detail.label[0];
+ var value = e.detail.value[0];
+ var _self = this;
+ var temp = {};
+ temp.label = label;
+ temp.value = value;
+ switch (type) {
+ case 1://证件类型
+ _self.setData({
+ cardType: temp,
+ showPicker: false,
+ currentDicType: -1,
+ })
+ break;
+ case 2://性别
+ _self.setData({
+ gender: temp,
+ showPicker: false,
+ currentDicType: -1,
+ })
+ break;
+ case 3://民族
+ _self.setData({
+ nation: temp,
+ showPicker: false,
+ currentDicType: -1,
+ })
+ break;
+ case 4://学历
+ _self.setData({
+ edu: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 5://户主关系
+ _self.setData({
+ relation: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 6://党派
+ _self.setData({
+ political: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 7://宗教信仰
+ _self.setData({
+ religion: temp,
+ showPicker: false,
+ currentDicType: -1
+ });
+ break;
+ case 8://婚姻状况
+ _self.setData({
+ marry: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 9://社保情况
+ _self.setData({
+ insure: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 10://健康状况
+ _self.setData({
+ health: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 11://流动原因
+ _self.setData({
+ flowReason: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 12://老人类别
+ _self.setData({
+ oldType: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 13://生活照料情况
+ _self.setData({
+ liveTakeCare: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 14://老年人健康状况
+ _self.setData({
+ oldHealthStatus: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 15://老年人生活自理能力
+ _self.setData({
+ oldSelfCare: temp,
+ showPicker: false,
+ currentDicType: -1,
+ })
+ break;
+ case 16://老年人居住状况
+ _self.setData({
+ oldLiveStatus: temp,
+ showPicker: false,
+ currentDicType: -1,
+ })
+ break;
+ case 17://残疾类别
+ _self.setData({
+ deformityType: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 18://残疾等级
+ _self.setData({
+ deformityLevel: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 19://收入情况
+ _self.setData({
+ deformityEarning: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 20://住房来源
+ _self.setData({
+ deformityHouseSource: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 21://残疾人监护人关系
+ _self.setData({
+ deformityGuarderRelation: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ case 22://服役时等级
+ _self.setData({
+ soldierRetireLevel: temp,
+ showPicker: false,
+ currentDicType: -1
+ })
+ break;
+ }
+
+ },
+ //日期确定
+ onConfirmDate(e) {
+ var _self = this;
+ var type = e.target.dataset.type;
+ switch (type) {
+ case 1://出生日期
+ _self.setData({
+ birthDay: e.detail.value,
+ dateType: -1,
+ showDate: false
+ })
+ break;
+ case 2://婚变日期
+ _self.setData({
+ marryChangeDate: e.detail.value,
+ dateType: -1,
+ showDate: false,
+ })
+ break;
+ case 3://初婚日期
+ _self.setData({
+ marryDate: e.detail.value,
+ dateType: -1,
+ showDate: false
+ })
+ break;
+ case 4:
+ _self.setData({
+ flowDate: e.detail.value,
+ dateType: -1,
+ showDate: false
+ })
+ break;
+ case 5:
+ _self.setData({
+ cerDate: e.detail.value,
+ dateType: -1,
+ showDate: false
+ })
+ break;
+ case 6:
+ _self.setData({
+ soldierRetireDate: e.detail.value,
+ dateType: -1,
+ showDate: false
+ })
+ break;
+ case 7://入党时间
+ _self.setData({
+ intoPartyDate: e.detail.value,
+ dateType: -1,
+ showDate: false
+ })
+ break;
+ }
+ },
+ onDicPickerCancel() {
+ this.setData({
+ showPicker: false,
+ })
+ },
+ onCardTypePick(e) { },
+ onDateChange(e) { },
+ hideDatePicker() {
+ this.setData({
+ dateVisibel: false
+ })
+ },
+ getDicList(type, id) {
+ console.log(type + "" + id)
+ var _self = this;
+ wx.showLoading({
+ title: '加载中...',
+ })
+ _self.setData({
+ dicList: []
+ })
+ app.restAjax.get(app.restAjax.path('{reqesutUrl}app/datadictionary/listdictionarybyparentid/' + id, [app.personUrl]), null, {
+ headers: {
+ token: _self.data.token
+ }
+ }, function (code, data) {
+ wx.hideLoading();
+ if (data && data.length > 0) {
+ _self.setData({
+ dicList: data,
+ showPicker: true,
+ currentDicType: type
+ })
+ } else {
+ wx.showToast({
+ title: '暂无数据',
+ icon: 'error'
+ })
+ }
+ });
+ },
+ //提交
+ doConfirm() {
+ var _self = this;
+ var isLegal = _self.checkParams();
+ if (isLegal) {
+ wx.showLoading({
+ title: '保存中...',
+ })
+ var body = {
+ name: _self.data.name,//姓名
+ idcardType: _self.data.cardType.label,//证件类型
+ idcard: _self.data.cardNum,//证件号码
+ birthday: _self.data.birthDay,//出生日期
+ sex: _self.data.gender.label,//性别
+ nation: _self.data.nation.label,//民族
+ education: _self.data.edu.label,//文化程度
+ relationship: _self.data.relation.label,//与户主关系
+ phone: _self.data.phoneNum,//联系电话
+ description: _self.data.academy,//就读院校及专业
+ organization: _self.data.political.label,//所属党派
+ religion: _self.data.religion.label,//宗教信仰
+ marriageStatus: _self.data.marry.label,//婚姻状况
+ marriageChangeTime: _self.data.marryChangeDate,//婚变日期
+ marriageFirstTime: _self.data.marryDate,//初婚日期
+ socialSecurity: _self.data.insure.label,//社保情况
+ healthStatus: _self.data.health.label,//健康状态
+ departmentType: _self.data.jobStatus,//就业状况
+ department: _self.data.workPlace,//工作单位
+ pastion: _self.data.jobTitle,//工作职务
+ pastionTitle: _self.data.technical,//专业技术职称
+ expertise: _self.data.speciality,//专长
+ fatherName: _self.data.fatherName,//父亲
+ fatherIdcard: _self.data.fatherCardNum,
+ fatherPhone: _self.data.fatherPhone,
+ motherName: _self.data.matherName,
+ motherIdcard: _self.data.matherCardNum,
+ motherPhone: _self.data.matherPhone,
+ domicileAreaName: _self.data.censusAddress.name,//户籍地址
+ domicileAreaCode: _self.data.censusAddress.code,//户籍地址
+ domicileAddress: _self.data.censusDetail,//户籍详细地址
+ originAddress: _self.data.nativeAddress,//籍贯地址
+ flowTime: _self.data.flowDate,//流动日期
+ flowReason: _self.data.flowReason == null ? '' : _self.data.flowReason.label,//流动原因
+ flowReasontext: _self.data.flowOtherReason,//流动其他原因
+ isOldage: _self.data.isOld,//是否老年人
+ oldageType: _self.data.oldType == null ? '' : _self.data.oldType.label,//老年人类别
+ oldageDepartment: _self.data.retireWorkUnit,//离退休前单位
+ oldageLift: _self.data.liveTakeCare == null ? '' : _self.data.liveTakeCare.label,//生活照料情况
+ oldageHealthStatus: _self.data.oldHealthStatus == null ? '' : _self.data.oldHealthStatus.label,//老年人健康状况
+ oldageSelfcare: _self.data.oldSelfCare == null ? '' : _self.data.oldSelfCare.label,//生活自理能力
+ oldageLive: _self.data.oldLiveStatus == null ? '' : _self.data.oldLiveStatus.label,//居住状况
+ isDisability: _self.data.isDeformity,//是否残疾人
+ disabilityType: _self.data.deformityType == null ? '' : _self.data.deformityType.label,//残疾人类别
+ disabilityLevel: _self.data.deformityLevel == null ? '' : _self.data.deformityLevel.label,//残疾人等级
+ disabilityNumber: _self.data.deformityCardNum,//残疾证号
+ disabilityCarnumber: _self.data.deformityCarNum,//残疾车牌
+ disabilityAddress: _self.data.deformityLiveAddress == null ? '' : _self.data.deformityLiveAddress.name,
+ disabilityAreaName: _self.data.deformityLiveAddress == null ? '' : _self.data.deformityLiveAddress.name,
+ disabilityAreaCode: _self.data.deformityLiveAddress == null ? '' : _self.data.deformityLiveAddress.code,
+ disabilityIncome: _self.data.deformityEarning == null ? '' : _self.data.deformityEarning.label,//收入情况
+ disabilityHouse: _self.data.deformityHouseSource == null ? '' : _self.data.deformityHouseSource.label,//住房来源
+ disabilityTime: _self.data.cerDate,//残疾人办证时间
+ disabilityGuardian: _self.data.deformityGuarder,//残疾人监护人
+ disabilityGuardianPhone: _self.data.deformityGuarderPhone,//监护人联系电话
+ disabilityGuardianRelation: _self.data.deformityGuarderRelation == null ? '' : _self.data.deformityGuarderRelation.label,//监护人关系
+ isMilitary: _self.data.isSoldier,//是否服役
+ militaryTime: _self.data.soldierRetireDate,//退役日期
+ militaryPosition: _self.data.soldierRetireLevel == null ? '' : _self.data.soldierRetireLevel.label,//服役等级
+ isSuccour: _self.data.isSocial,//是否社会救助
+ succourDibao: _self.data.isLow,//是否低保
+ succourHelp: _self.data.isMedical,//是否医疗救助
+ succourDifficulty: _self.data.isHard,//是否困难职工
+ succourSubsidy: _self.data.isSubsidy,//是否老龄补贴
+ isParty: _self.data.isPartyMember,//是否党员
+ partyOrganization: _self.data.partyName,//党组织名称
+ partyTime: _self.data.intoPartyDate,//入党时间
+ othertext: _self.data.partyMemberDesc,//党员其他说明
+ }
+
+ app.restAjax.put(app.restAjax.path('{url}app/populationinfo/updatepopulationinfo/' + _self.data.id, [app.personUrl]), body, {
+ headers: {
+ token: _self.data.token
+ }
+ }, function (code, data) {
+ wx.hideLoading()
+ wx.showToast({
+ title: '保存成功',
+ icon: 'success'
+ })
+ const eventChannel = _self.getOpenerEventChannel();
+ eventChannel.emit('doNeedRefresh', { data: true });
+ wx.navigateBack();
+ }, (code, data) => {
+ wx.hideLoading()
+ wx.showToast({
+ title: data.msg ? data.msg : '保存失败',
+ icon: 'error'
+ })
+ console.log(data)
+ });
+ }
+ },
+ //校验参数
+ checkParams() {
+ var _self = this;
+ var data = _self.data;
+ if (data.name == '') {
+ wx.showToast({
+ title: '请输入姓名',
+ icon: 'error'
+ })
+ return false;
+ }
+ if (data.cardType == null) {
+ wx.showToast({
+ title: '请选择证件类型',
+ icon: 'error'
+ })
+ return false;
+ }
+ if (data.cardNum == '') {
+ wx.showToast({
+ title: '请输入证件号码',
+ icon: 'error'
+ })
+ return false;
+ }
+ if (data.birthDay == '') {
+ wx.showToast({
+ title: '请选择出生日期',
+ icon: 'error'
+ })
+ return false;
+ }
+ if (data.gender == null) {
+ wx.showToast({
+ title: '请选择性别',
+ icon: 'error'
+ })
+ return false;
+ }
+ if (data.nation == null) {
+ wx.showToast({
+ title: '请选择民族',
+ icon: 'error'
+ })
+ return false;
+ }
+ if (data.edu == null) {
+ wx.showToast({
+ title: '请选择文化程度',
+ icon: 'error'
+ })
+ return false;
+ }
+ if (data.relation == null) {
+ wx.showToast({
+ title: '请选择与户主关系',
+ icon: 'none'
+ })
+ return false;
+ }
+ if (data.phoneNum == '') {
+ wx.showToast({
+ title: '请输入联系电话',
+ icon: 'error'
+ })
+ return false;
+ }
+ if (data.political == null) {
+ wx.showToast({
+ title: '请选择所属党派',
+ icon: 'error'
+ })
+ return false;
+ }
+ if (data.religion == null) {
+ wx.showToast({
+ title: '请选择宗教信仰',
+ icon: 'error'
+ })
+ return false;
+ }
+ if (data.marry == null) {
+ wx.showToast({
+ title: '请选择婚姻状况',
+ icon: 'error'
+ })
+ return false;
+ }
+ if (data.insure == null) {
+ wx.showToast({
+ title: '请选择社保情况',
+ icon: 'error'
+ })
+ return false;
+ }
+ if (data.health == null) {
+ wx.showToast({
+ title: '请选择健康状况',
+ icon: 'error'
+ })
+ return false;
+ }
+ if (data.censusAddress == null) {
+ wx.showToast({
+ title: '请选择户籍地址',
+ icon: 'error'
+ })
+ return false;
+ }
+ return true;
+ },
+ //空值
+ checkEmpty(str) {
+ return str == null || str == '';
+ },
+})
\ No newline at end of file
diff --git a/pages/censusEdit/censusEdit.json b/pages/censusEdit/censusEdit.json
new file mode 100644
index 0000000..34333c4
--- /dev/null
+++ b/pages/censusEdit/censusEdit.json
@@ -0,0 +1,11 @@
+{
+ "usingComponents": {
+ "t-picker": "/miniprogram_npm/tdesign-miniprogram/picker/picker",
+ "t-picker-item": "/miniprogram_npm/tdesign-miniprogram/picker-item/picker-item",
+ "t-date-time-picker": "/miniprogram_npm/tdesign-miniprogram/date-time-picker/date-time-picker"
+
+ },
+ "navigationBarBackgroundColor": "#ffffff",
+ "navigationBarTextStyle": "black",
+ "navigationBarTitleText": "户籍信息编辑"
+}
\ No newline at end of file
diff --git a/pages/censusEdit/censusEdit.wxml b/pages/censusEdit/censusEdit.wxml
new file mode 100644
index 0000000..c82ec01
--- /dev/null
+++ b/pages/censusEdit/censusEdit.wxml
@@ -0,0 +1,341 @@
+
+
+
+
+
+
+ 基础信息
+
+
+
+ 姓名
+
+
+
+ 证件类型
+ {{cardType==null?'请选择证件类型':cardType.label}}
+
+
+ 证件号码
+
+
+
+ 出生日期
+ {{birthDay==''?'请选择出生日期':birthDay}}
+
+
+ 性别
+ {{gender==null?'请选择性别':gender.label}}
+
+
+ 民族
+ {{nation==null?'请选择民族':nation.label}}
+
+
+ 文化程度
+ {{edu==null?'请选择文化程度':edu.label}}
+
+
+ 与户主关系
+ {{relation==null?'请选择与户主关系':relation.label}}
+
+
+ 联系电话
+
+
+
+
+
+
+
+ 宗教、学历、工作等信息
+
+
+
+
+ 就读院校及专业
+
+
+
+ 所属党派
+ {{political==null? '请选择所属党派':political.label}}
+
+
+ 宗教信仰
+ {{religion== null? '请选择宗教信仰':religion.label}}
+
+
+ 婚姻状况
+ {{marry== null?'请选择婚姻状况':marry.label}}
+
+
+ 婚变日期
+ {{marryChangeDate== "" ? '请选择婚变日期':marryChangeDate}}
+
+
+ 初婚日期
+ {{marryDate=="" ? '请选择与初婚日期':marryDate}}
+
+
+ 社会保险情况
+ {{insure==null ? '请选择社会保险情况':insure.label}}
+
+
+ 健康状况
+ {{health==null ? '请选择健康状况':health.label}}
+
+
+ 就业状况
+
+ 已就业
+ 未就业
+ 灵活就业
+ 退休
+
+
+
+ 工作单位
+
+
+
+ 工作职务
+
+
+
+ 专业技术职称
+
+
+
+ 专长
+
+
+
+
+
+
+
+
+ 家庭信息
+
+
+
+ 父亲姓名
+
+
+
+ 父亲证件
+
+
+
+ 父亲电话
+
+
+
+ 母亲姓名
+
+
+
+ 母亲证件
+
+
+
+ 母亲电话
+
+
+
+ 户籍地址
+ {{censusAddress==null?'请选择户籍地址':censusAddress.name}}
+
+
+ 户籍详细地址
+
+
+
+ 籍贯地址
+
+
+
+ 流动日期
+ {{flowDate=="" ? '请选择流动日期':flowDate}}
+
+
+ 流动原因
+ {{flowReason== null ? '请选择流动原因':flowReason.label}}
+
+
+ 其他原因
+
+
+
+
+
+
+
+ 老年人
+
+
+
+
+
+ 是否为老年人
+
+
+
+ 老人类别
+ {{oldType==null?'请选择老人类别':oldType.label}}
+
+
+ 离退休前单位
+
+
+
+ 生活照料情况
+ {{liveTakeCare==null?'请选择生活照料情况':liveTakeCare.label}}
+
+
+ 健康情况
+ {{oldHealthStatus==null?'请选择健康情况':oldHealthStatus.label}}
+
+
+ 生活自理能力
+ {{oldSelfCare==null?'请选择生活自理能力':oldSelfCare.label}}
+
+
+ 居住状况
+ {{oldLiveStatus==null?'请选择居住状况':oldLiveStatus.label}}
+
+
+
+
+
+ 残疾人
+
+
+
+ 是否为残疾人
+
+
+
+ 残疾类别
+ {{deformityType==null?'请选择残疾类别':deformityType.label}}
+
+
+ 残疾等级
+ {{deformityLevel==null?'请选择残疾等级':deformityLevel.label}}
+
+
+ 残疾证号
+
+
+
+ 残疾车牌号
+
+
+
+ 居住地址
+ {{deformityLiveAddress==null?'请选择居住地址':deformityLiveAddress.name}}
+
+
+ 收入情况
+ {{deformityEarning== null? '请选择收入情况':deformityEarning.label}}
+
+
+ 住房来源
+ {{deformityHouseSource==null?'请选择住房来源':deformityHouseSource.label}}
+
+
+ 办证时间
+ {{cerDate==""?'请选择办证时间':cerDate}}
+
+
+ 监护人或配偶姓名
+
+
+
+ 监护人电话
+
+
+
+ 监护人关系
+ {{deformityGuarderRelation==null?'请选择监护人关系':deformityGuarderRelation.label}}
+
+
+
+
+
+ 服役/退役
+
+
+
+ 是否为服役/退役
+
+
+
+ 批准退出现役日期
+ {{soldierRetireDate==""?'请选择批准退出现役日期':soldierRetireDate}}
+
+
+ 退出现役时职级
+ {{soldierRetireLevel==null?'请选择批准退出现役时职级':soldierRetireLevel.label}}
+
+
+
+
+
+
+ 社会救助
+
+
+
+ 是否为社会救助
+
+
+
+ 低保户
+
+
+
+ 医疗救助
+
+
+
+ 困难职工
+
+
+
+ 老龄补贴
+
+
+
+
+
+
+ 党员
+
+
+
+ 是否为党员
+
+
+
+ 党组织名称
+
+
+
+ 入党时间
+ {{intoPartyDate==""?'请选择入党时间':intoPartyDate}}
+
+
+ 其他说明
+
+
+
+
+
+
+
+
+
+
+
+保存
\ No newline at end of file
diff --git a/pages/censusEdit/censusEdit.wxss b/pages/censusEdit/censusEdit.wxss
new file mode 100644
index 0000000..ebad49c
--- /dev/null
+++ b/pages/censusEdit/censusEdit.wxss
@@ -0,0 +1,121 @@
+/* pages/censusinput/censusinput.wxss */
+page {
+ background-color: #efefef;
+}
+
+.page-container {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: flex-start;
+ margin-top: 5px;
+ border-radius: 10px;
+ flex-basis: 100%;
+ padding: 10px;
+}
+
+.box-container {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: flex-start;
+ border-radius: 10px;
+ background-color: white;
+ flex-basis: 100%;
+ padding-left: 10px;
+ padding-right: 10px;
+ margin-top: 10px;
+ width: 94%;
+ margin-bottom: 10px;
+}
+
+.form-item {
+ display: flex;
+ flex-direction: row;
+ justify-content: center;
+ align-items: center;
+ padding: 5px;
+ width: fit-content;
+ width: 97%;
+}
+
+.ver {
+ flex-direction: column;
+ justify-content: flex-start;
+ align-items: flex-start;
+}
+
+.form-textarea {
+ background-color: #EFEFEF;
+ width: 95%;
+ margin-top: 5px;
+ padding: 5px;
+ font-size: 14px;
+ height: 100px;
+ border-radius: 5px;
+}
+
+
+.form-title {
+ font-size: 14px;
+ flex: .4;
+}
+
+.must::after {
+ content: "*";
+ color: red;
+}
+
+.select::after {
+ content: "\25BC";
+ color: #6d6d6d;
+ font-size: 12px;
+ padding-left: 5px;
+}
+
+.form-content {
+ font-size: 14px;
+ flex: .6;
+ text-align: right;
+ padding: 5px;
+}
+
+.form-head {
+ display: flex;
+ flex-direction: row;
+ justify-content: flex-start;
+ align-items: center;
+ font-size: 15px;
+ color: black;
+ font-weight: bold;
+}
+
+.form-head-line {
+ height: 15px;
+ width: 6px;
+ background-color: #4985f8;
+ margin-right: 5px;
+}
+
+radio {
+ transform: scale(0.7);
+ font-size: 18px;
+}
+
+.btn-submit {
+ width: 100%;
+ position: fixed;
+ bottom: 0;
+ height: 48px;
+ background-color: #4985f8;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ align-self: center;
+ color: #FFFFFF;
+ z-index: 23;
+}
+
+.btn-submit:active {
+ transform: scale(0.9);
+}
\ No newline at end of file
diff --git a/pages/censusinput/censusinput.js b/pages/censusinput/censusinput.js
index ce27798..7d10c56 100644
--- a/pages/censusinput/censusinput.js
+++ b/pages/censusinput/censusinput.js
@@ -830,7 +830,8 @@ Page({
}, function (code, data) {
wx.hideLoading()
wx.showToast({
- title: '保存失败',
+ title: data.msg ? data.msg : '保存失败',
+ icon: 'error'
})
});
}
diff --git a/pages/censusinput/censusinput.json b/pages/censusinput/censusinput.json
index 8feb3bc..93ea00b 100644
--- a/pages/censusinput/censusinput.json
+++ b/pages/censusinput/censusinput.json
@@ -6,5 +6,6 @@
},
"navigationBarBackgroundColor": "#ffffff",
- "navigationBarTextStyle": "black"
+ "navigationBarTextStyle": "black",
+ "navigationBarTitleText": "户籍信息录入"
}
\ No newline at end of file
diff --git a/pages/censusinput/censusinput.wxss b/pages/censusinput/censusinput.wxss
index 74f73cb..6d01256 100644
--- a/pages/censusinput/censusinput.wxss
+++ b/pages/censusinput/censusinput.wxss
@@ -114,4 +114,7 @@ radio {
align-self: center;
color: #FFFFFF;
z-index: 23;
+}
+.btn-submit:active {
+ transform: scale(0.9);
}
\ No newline at end of file
diff --git a/utils/restAjax.js b/utils/restAjax.js
index c818e8d..1dde91a 100644
--- a/utils/restAjax.js
+++ b/utils/restAjax.js
@@ -1,8 +1,8 @@
var methods = {
- POST_METHOD: 'POST',
- DELETE_METHOD: 'DELETE',
- PUT_METHOD: 'PUT',
- GET_METHOD: 'GET'
+ POST_METHOD: 'POST',
+ DELETE_METHOD: 'DELETE',
+ PUT_METHOD: 'PUT',
+ GET_METHOD: 'GET'
};
/**
@@ -15,7 +15,7 @@ var methods = {
* @param completeCallback
*/
function postJson(url, dataObj, args, successCallback, errorCallback, completeCallback) {
- doAjax(url, methods.POST_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
+ doAjax(url, methods.POST_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
}
/**
@@ -28,7 +28,7 @@ function postJson(url, dataObj, args, successCallback, errorCallback, completeCa
* @param completeCallback
*/
function deleteForm(url, dataObj, args, successCallback, errorCallback, completeCallback) {
- doAjax(url, methods.DELETE_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
+ doAjax(url, methods.DELETE_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
}
/**
@@ -41,7 +41,7 @@ function deleteForm(url, dataObj, args, successCallback, errorCallback, complete
* @param completeCallback
*/
function putJson(url, dataObj, args, successCallback, errorCallback, completeCallback) {
- doAjax(url, methods.PUT_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
+ doAjax(url, methods.PUT_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
}
/**
@@ -54,7 +54,7 @@ function putJson(url, dataObj, args, successCallback, errorCallback, completeCal
* @param completeCallback
*/
function getForm(url, dataObj, args, successCallback, errorCallback, completeCallback) {
- doAjax(url, methods.GET_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
+ doAjax(url, methods.GET_METHOD, dataObj, args, successCallback, errorCallback, completeCallback);
}
/**
@@ -68,34 +68,40 @@ function getForm(url, dataObj, args, successCallback, errorCallback, completeCal
* @param completeCallback
*/
function doAjax(url, method, dataObj, args, successCallback, errorCallback, completeCallback) {
- var headers = {};
- if (args != null && typeof (args.headers) != 'undefined' && args.headers != null) {
- headers = args.headers;
- }
- wx.request({
- url: url,
- method: method,
- data: dataObj,
- header: headers,
- dataType: 'json',
- success: function (response) {
- if (response.statusCode == 200) {
- successCallback(response.statusCode, response.data, args);
- } else {
- if (errorCallback && typeof (errorCallback) == 'function') {
- errorCallback(response.statusCode, response.data);
- }
- }
- },
- fail: function (response) {
- console.log(response);
- },
- complete: function () {
- if (completeCallback && typeof (completeCallback) == 'function') {
- completeCallback();
- }
- }
- })
+ var headers = {};
+ if (args != null && typeof (args.headers) != 'undefined' && args.headers != null) {
+ headers = args.headers;
+ }
+ wx.request({
+ url: url,
+ method: method,
+ data: dataObj,
+ header: headers,
+ dataType: 'json',
+ success: function (response) {
+ if (response.statusCode == 200) {
+ successCallback(response.statusCode, response.data, args);
+ } else {
+ console.log(response)
+ if (errorCallback && typeof errorCallback == 'function') {
+ console.log('走走');
+ errorCallback(response.statusCode, response.data);
+ }
+ }
+ },
+ fail: function (response) {
+ console.log(response);
+ if (errorCallback) {
+ console.log(response);
+ errorCallback(response.statusCode, response.data);
+ }
+ },
+ complete: function () {
+ if (completeCallback && typeof (completeCallback) == 'function') {
+ completeCallback();
+ }
+ }
+ })
}
/**
@@ -104,18 +110,18 @@ function doAjax(url, method, dataObj, args, successCallback, errorCallback, comp
* @returns {boolean}
*/
function pathArgsHasSameValue(pathArgArray) {
- var tempArgIndex = 0;
- var tempArgs = pathArgArray[tempArgIndex];
- for (var i = (tempArgIndex + 1), item; item = pathArgArray[i]; i++) {
- if (tempArgs == item) {
- throw new Error('参数' + item + '有重复值!!!');
- }
- if (i == pathArgArray.length - 1) {
- tempArgs = pathArgArray[++tempArgIndex];
- i = tempArgIndex;
- continue;
- }
- }
+ var tempArgIndex = 0;
+ var tempArgs = pathArgArray[tempArgIndex];
+ for (var i = (tempArgIndex + 1), item; item = pathArgArray[i]; i++) {
+ if (tempArgs == item) {
+ throw new Error('参数' + item + '有重复值!!!');
+ }
+ if (i == pathArgArray.length - 1) {
+ tempArgs = pathArgArray[++tempArgIndex];
+ i = tempArgIndex;
+ continue;
+ }
+ }
}
/**
@@ -123,22 +129,22 @@ function pathArgsHasSameValue(pathArgArray) {
* @param url
*/
function getParamsArg(url) {
- var params = url.split('?')[1];
- var paramsObj = {};
- if (typeof (params) == 'undefined' || params == null) {
- return paramsObj;
- }
- var paramsKVs = params.split('&');
- for (var i = 0, item = null; item = paramsKVs[i++];) {
- var kvs = item.split('=');
- if (kvs.length == 1) {
- paramsObj[kvs[0]] = null;
- }
- if (kvs.length == 2) {
- paramsObj[kvs[0]] = decodeURI(kvs[1]);
- }
- }
- return paramsObj;
+ var params = url.split('?')[1];
+ var paramsObj = {};
+ if (typeof (params) == 'undefined' || params == null) {
+ return paramsObj;
+ }
+ var paramsKVs = params.split('&');
+ for (var i = 0, item = null; item = paramsKVs[i++];) {
+ var kvs = item.split('=');
+ if (kvs.length == 1) {
+ paramsObj[kvs[0]] = null;
+ }
+ if (kvs.length == 2) {
+ paramsObj[kvs[0]] = decodeURI(kvs[1]);
+ }
+ }
+ return paramsObj;
}
/**
@@ -148,22 +154,22 @@ function getParamsArg(url) {
* @returns {*}
*/
function buildPath(basePath, pathArgs) {
- var path = basePath;
- if (!basePath || !(typeof (basePath) == 'string')) {
- throw new Error('basePath必须为字符串!!!');
- }
- if (!pathArgs || !Array.isArray(pathArgs)) {
- throw new Error('pathArgs必须为数组!!!');
- }
- var pathArgArray = basePath.match(/\{\w+\}/g);
- if (!pathArgArray) {
- return path;
- }
- pathArgsHasSameValue(pathArgArray);
- for (var i = 0, item; item = pathArgArray[i]; i++) {
- path = path.replace(item, pathArgs[i]);
- }
- return path;
+ var path = basePath;
+ if (!basePath || !(typeof (basePath) == 'string')) {
+ throw new Error('basePath必须为字符串!!!');
+ }
+ if (!pathArgs || !Array.isArray(pathArgs)) {
+ throw new Error('pathArgs必须为数组!!!');
+ }
+ var pathArgArray = basePath.match(/\{\w+\}/g);
+ if (!pathArgArray) {
+ return path;
+ }
+ pathArgsHasSameValue(pathArgArray);
+ for (var i = 0, item; item = pathArgArray[i]; i++) {
+ path = path.replace(item, pathArgs[i]);
+ }
+ return path;
}
/**
@@ -177,33 +183,33 @@ function buildPath(basePath, pathArgs) {
* @param completeCallback
*/
function postFile(url, path, name, args, successCallback, errorCallback, completeCallback) {
- var headers = {};
- if (args != null && typeof (args.headers) != 'undefined' && args.headers != null) {
- headers = args.headers;
- }
- wx.uploadFile({
- filePath: path,
- name: name,
- url: url,
- header: headers,
- success: function (response) {
- if (response.statusCode == 200) {
- successCallback(response.statusCode, response.data, args);
- } else {
- if (errorCallback && typeof (errorCallback) == 'function') {
- errorCallback(response.statusCode, response.data);
- }
- }
- },
- fail: function (response) {
- console.log(response);
- },
- complete: function () {
- if (completeCallback && typeof (completeCallback) == 'function') {
- completeCallback();
- }
- }
- })
+ var headers = {};
+ if (args != null && typeof (args.headers) != 'undefined' && args.headers != null) {
+ headers = args.headers;
+ }
+ wx.uploadFile({
+ filePath: path,
+ name: name,
+ url: url,
+ header: headers,
+ success: function (response) {
+ if (response.statusCode == 200) {
+ successCallback(response.statusCode, response.data, args);
+ } else {
+ if (errorCallback && typeof (errorCallback) == 'function') {
+ errorCallback(response.statusCode, response.data);
+ }
+ }
+ },
+ fail: function (response) {
+ console.log(response);
+ },
+ complete: function () {
+ if (completeCallback && typeof (completeCallback) == 'function') {
+ completeCallback();
+ }
+ }
+ })
};
/**
@@ -212,9 +218,9 @@ function postFile(url, path, name, args, successCallback, errorCallback, complet
* @returns {string}
*/
function escape(html) {
- return String(html || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&')
- .replace(//g, '>')
- .replace(/'/g, ''').replace(/"/g, '"');
+ return String(html || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&')
+ .replace(//g, '>')
+ .replace(/'/g, ''').replace(/"/g, '"');
}
module.exports.post = postJson;