// pages/fnSubscribeDocument/fnSubscribeDocument.js import {AreaPicker} from "../../utils/areaSelector/selector"; import locaData from "../../utils/locationData"; import api from "../../utils/apiFile"; var networkUtil = require('../../utils/network_util.js') Page(Object.assign({}, AreaPicker, { data: { nationality: [{ id: "0da4334f-49e7-4180-b690-5cea668f75e9", name: "中国" }], nationalityEntity: { id: "0da4334f-49e7-4180-b690-5cea668f75e9", name: "中国" }, national: locaData.nation, nationalEntity: { id: "57cfd82b231aab0fa8b096e7", name: "汉族" }, sexList: [{ id: "5d0b782f-b61b-441b-b8c5-4bf55eece273", name: "男" }, { id: "c23779f1-cb6e-44d0-9fc8-0a990bf6184c", name: "女" }], marriageStatus: [{ id: "d75d1902-61a5-4a17-a68a-5b8a9826537b", name: "已婚" }, { id: "d049eaaa-7265-4cdb-879f-992ab6320a3a", name: "未婚" }], educationLevel: [{ id: "b4157251-2fbc-4d70-b32f-d78e1b4f9251", name: "文盲或半文盲" }, { id: "b819b01b-fc48-4ce7-b623-c2a3b56ffc91", name: "博士后" }, { id: "315555f3c-4f11-4473-b289-ba20b2e37161", name: "博士" }, { id: "c88bb1f0-9a75-4ad4-9ac8-0b04fa2701c7", name: "硕士" }, { id: "11b87441-c63c-419b-b2d0-d968a002f4ce", name: "本科" }, {id: "7e49120b-ec92-44c4-b77c-5fb151a7bdd4", name: "大专"}, { id: "ec0fd0b3-f404-4c50-887f-28baa31b3870", name: "中专和中技" }, { id: "6c95f456-3e9e-45f4-bdef-04fd0ce4daf7", name: "技工学校" }, { id: "baa86f20-535a-4874-b09d-9f5ae8d89a5d", name: "高中" }, {id: "7a8f2edf-ef69-494f-95a3-c98149c35978", name: "初中"}, { id: "4250cdba-2d25-41ef-acf8-ebbde48156b2", name: "小学" }], educationLevelEntity: 0, accountType: [{ id: "57624bf90cf23d4631523e9e", name: "非农业户口" }, { id: "57624c090cf23d4631523e9f", name: "农业户口" }], accountTypeEntity: 0, resideType: [{"id" : "57624c440cf23d4631523ea1","name" : "常住"}, {"id" : "57624c5e0cf23d4631523ea2", "name" : "流动"}, {"id" : "5a371bce0cf2ab082ac30433", "name" : "暂住"}, {"id" : "62270e679932d29c07242e4f", "name" : "有居住证"}], resideTypeEntity: 0, job: [{"id" : "1de89c7e-0675-47d0-ac9a-6d901a841913","name" : "国家机关人员"}, {"id" : "367e9761-32e3-495a-8e2c-0a872303f932", "name" : "党群组织负责人"}, {"id" : "c1b00aab-34c5-43fb-89e9-64bb96bc0082", "name" : "事业单位负责人"}, {"id" : "e79d77cc-6c2b-468e-860a-af966c2600e0", "name" : "医生"}, {"id" : "5570653c-693b-4ce2-bd91-650045c03c5a", "name" : "教师"}, {"id" : "1034e8c0-fc6e-46c1-9125-1c682d72de2e", "name" : "护士"}, {"id" : "e86de68d-80be-4b10-a3c3-ed6df54135ec", "name" : "办公文员"}, {"id" : "cbe91757-485d-4086-a67b-4ed9176e2cc9", "name" : "商业、服务业人员"}, {"id" : "7aa7c580-c5f6-4c5b-8346-3919e91aa438", "name" : "农、林、牧、渔、水利业生产人员"}, {"id" : "abd6c1d1-9ced-4073-9265-e2b11016f442", "name" : "司机"}, {"id" : "5b9157a6-b99b-4422-ba5f-a5bfbf34d77f", "name" : "军人"}, {"id" : "1b7ade51-86ea-435c-b040-c266393b0826", "name" : "法官"}, {"id" : "f64aa542-660c-4c87-8f9c-1fa0f6a061c4", "name" : "律师"}, {"id" : "0972bd72-0df0-4197-9b43-e1534b2fcff3", "name" : "检察官"}, {"id" : "1149b87a-5116-4f70-bf3c-29b5ab8a23b6", "name" : "警察"}, {"id" : "e0a8b7f4-cda9-44eb-aabb-54be798b7113", "name" : "金融从业人员"}, {"id" : "46d07c85-3211-4bea-8444-15df417c5e9c", "name" : "校长"}, {"id" : "bf0c0786-c576-4df9-a588-865b786f8e4d", "name" : "卫生单位负责人"}, {"id" : "8ba98a54-d484-44c2-b7e8-3e2fc53870ed", "name" : "企业经理"}, {"id" : "aab46483-610f-47d9-bcf8-26b8557fa5ce", "name" : "经济业务人员"}, {"id" : "35c59051-a5fe-41ef-9024-89a85d74646c", "name" : "运动员"}, {"id" : "939b5ddd-3537-4930-934d-e5641ad96a6b", "name" : "科学研究人员"}, {"id" : "063c68aa-faf0-4357-aaf2-e75c6b26061c", "name" : "工程技术人员"}, {"id" : "3525c5e4-a093-4d90-9ef1-3cf00b3a61f4", "name" : "设计师"}, {"id" : "3686bf29-b3b8-462f-819a-b10f61fbc61d", "name" : "航天员"}, {"id" : "030c5ff8-bf2a-4cc5-9cbf-e01babe5a9e0", "name" : "其他"}], jobEntity: 0, typeList: [{ id: "1", name: "婚检" }, { id: "2", name: "孕前优生" },{ id: "3", name: "婚检孕前优生" }, { id: "4", name: "两癌筛查" }], yesOrNoList: [{ id: "no", name: "无" }, { id: "yes", name: "有" }], defaultInfo: {}, currentAddress: {}, permanentAddress: {}, mustInputData: { must_name: true, must_sex: true, must_idcard: true, must_phone: true, must_workUnit: true, must_nationality: true, must_national: true, must_birthday:true, must_educationLevel: true, must_job: true, must_currentAddress: true, must_type: true, must_marriage:true }, items: [{value: '1', name: '循环系统类'}, {value: '2', name: '呼吸系统类'}, {value: '3', name: '泌尿系统类'}, {value: '4', name: '消化系统类'}, {value: '5', name: '血液系统类'}, {value: '6', name: '内分泌系统类'}, {value: '7', name: '代谢营养类'}, {value: '8', name: '其他'}], items1: [{value: '1', name: '遗传性疾病史'}, {value: '2', name: '精神疾病史'}, {value: '3', name: '先天畸形'}, {value: '4', name: '先天愚型'}, {value: '5', name: '聋哑'}, {value: '6', name: '盲人'}, {value: '7', name: '唇腭裂'}, {value: '8', name: '血友病'}, {value: '9', name: '色盲'}, {value: '10', name: '色盲牛皮癣'}, {value: '11', name: '双胎'}, {value: '12', name: '肝病'}, {value: '13', name: '结核'}, {value: '14', name: '其他'},], items2: [{value: '1', name: '吸烟'}, {value: '2', name: '饮酒'}, {value: '3', name: '服用药物'}, {value: '4', name: '接触有毒有害物质'}, {value: '5', name: '接触放射线'}, {value: '6', name: '其他'},], items3: [{value: '1', name: '青霉素过敏'}, {value: '2', name: '先锋霉素过敏'}, {value: '3', name: '磺胺类药物过敏'}, {value: '4', name: '其他'},], jwsArr: [], jzsArr: [], grsArr: [], gmArr: [], showJw: false, showJz: false, showGr: false, showGm: false, }, getCard: function (e) { var data = e.detail; console.log(data) var defaultInfo = this.data.defaultInfo; defaultInfo.username = data.name.text; defaultInfo.certificateNum = data.id.text; this.data.birthday = this.getBirth(defaultInfo.certificateNum); this.data.sex = this.getSex(defaultInfo.certificateNum); this.setData({ defaultInfo: defaultInfo, birthday: this.data.birthday, sex: this.data.sex }) }, formSubmit(e) { var sData = {} sData.hospitalId = '' var hospitalId = getApp().globalData.hospitalId if (hospitalId!==null&&hospitalId!==undefined&&hospitalId!=="") { sData.hospitalId = hospitalId; } else { sData.hospitalId = wx.getStorageSync('yyHospitalId') } if (e.detail.value.certificateNum) { sData.cardNo = e.detail.value.certificateNum } var saveData = {} if (e.detail.value.username) { saveData.username = e.detail.value.username } if (this.data.sex && this.data.sex.id) { saveData.sex = this.data.sex.id } if (this.data.birthday) { saveData.birthday = this.data.birthday } if (this.data.nationalityEntity && this.data.nationalityEntity.id) { saveData.countryId = this.data.nationalityEntity.id } if (this.data.nationalEntity && this.data.nationalEntity.id) { saveData.nationId = this.data.nationalEntity.id } if (this.data.marriageId && this.data.marriageId.id) { saveData.marriageId = this.data.marriageId.id } saveData.certificateTypeId = '70ae1d93-2964-46bc-83fa-bec9ff605b1c' if (this.data.type && this.data.type.id) { saveData.type = this.data.type.id } if (this.data.accountTypeEntity && this.data.accountTypeEntity.id) { saveData.censusTypeId = this.data.accountTypeEntity.id } if (this.data.resideTypeEntity && this.data.resideTypeEntity.id) { saveData.liveTypeId = this.data.resideTypeEntity.id } if (this.data.educationLevelEntity && this.data.educationLevelEntity.id) { saveData.levelTypeId = this.data.educationLevelEntity.id } if (this.data.jobEntity && this.data.jobEntity.id) { saveData.professionTypeId = this.data.jobEntity.id } if (e.detail.value.phone) { saveData.phone = e.detail.value.phone } if (e.detail.value.workUnit) { saveData.workUnit = e.detail.value.workUnit } if (this.data.currentAddress.addEntry) { if (this.data.currentAddress.addEntry[0]) { saveData.provinceId = this.data.currentAddress.addEntry[0].id } if (this.data.currentAddress.addEntry[1]) { saveData.cityId = this.data.currentAddress.addEntry[1].id } if (this.data.currentAddress.addEntry[2]) { saveData.areaId = this.data.currentAddress.addEntry[2].id } if (this.data.currentAddress.addEntry[3]) { saveData.streetId = this.data.currentAddress.addEntry[3].id } if (e.detail.value.currentAddress_input) { saveData.address = e.detail.value.currentAddress_input } } if (this.data.permanentAddress.addEntry) { if (this.data.permanentAddress.addEntry[0]) { saveData.provinceRegisterId = this.data.permanentAddress.addEntry[0].id } if (this.data.permanentAddress.addEntry[1]) { saveData.cityRegisterId = this.data.permanentAddress.addEntry[1].id } if (this.data.permanentAddress.addEntry[2]) { saveData.areaRegisterId = this.data.permanentAddress.addEntry[2].id } if (this.data.permanentAddress.addEntry[3]) { saveData.streetRegisterId = this.data.permanentAddress.addEntry[3].id } if (e.detail.value.permanentAddress_input) { saveData.addressRegister = e.detail.value.permanentAddress_input } } saveData.pastHistory = {} if (this.data.pastHistory && this.data.pastHistory.id) { saveData.pastHistory.yesOrNo = this.data.pastHistory.id if (this.data.jwsArr) { saveData.pastHistory.selArr = this.data.jwsArr } if (this.data.jwsArr.indexOf("7")!==-1) { if (e.detail.value.jwQtText) { saveData.pastHistory.jwQtText = e.detail.value.jwQtText } else { saveData.pastHistory.jwQtText = "" } } } saveData.familyHistory = {} if (this.data.familyHistory && this.data.familyHistory.id) { saveData.familyHistory.yesOrNo = this.data.familyHistory.id if (this.data.jzsArr) { saveData.familyHistory.selArr = this.data.jzsArr } if (this.data.jzsArr.indexOf("14")!==-1) { if (e.detail.value.jzQtText) { saveData.familyHistory.jzQtText = e.detail.value.jzQtText } else { saveData.familyHistory.jzQtText = '' } } } saveData.personalHistory = {} if (this.data.personalHistory && this.data.personalHistory.id) { saveData.personalHistory.yesOrNo = this.data.personalHistory.id if (this.data.grsArr) { saveData.personalHistory.selArr = this.data.grsArr } if (this.data.grsArr.indexOf("6")!==-1) { if (e.detail.value.grQtText) { saveData.personalHistory.grQtText = e.detail.value.grQtText } else { saveData.personalHistory.grQtText = '' } } } saveData.ywgmHistory = {} if (this.data.ywgmHistory && this.data.ywgmHistory.id) { saveData.ywgmHistory.yesOrNo = this.data.ywgmHistory.id if (this.data.gmArr) { saveData.ywgmHistory.selArr = this.data.gmArr } if (this.data.gmArr.indexOf("4")!==-1) { if (e.detail.value.gmQtText) { saveData.ywgmHistory.gmQtText = e.detail.value.gmQtText } else { saveData.ywgmHistory.gmQtText = '' } } } saveData.presentHistory = {} if (this.data.presentHistory && this.data.presentHistory.id) { saveData.presentHistory.yesOrNo = this.data.presentHistory.id if (this.data.presentHistory.id==='2') { if (e.detail.value.xbQtText) { saveData.presentHistory.xbQtText = e.detail.value.xbQtText } else { saveData.presentHistory.xbQtText = '' } } } sData.data = saveData if (sData.data.username === '' || sData.data.username === null || sData.data.username === undefined) { wx.showModal({ title: '提示', content: '请填写姓名', showCancel: false, success: function (res) { } }) return } if (sData.cardNo === '' || sData.cardNo === null || sData.cardNo === undefined) { wx.showModal({ title: '提示', content: '请填写身份证号码', showCancel: false, success: function (res) { } }) return } if (sData.data.sex === '' || sData.data.sex === null || sData.data.sex === undefined) { wx.showModal({ title: '提示', content: '请选择性别', showCancel: false, success: function (res) { } }) return } if (sData.data.birthday === '' || sData.data.birthday === null || sData.data.birthday === undefined) { wx.showModal({ title: '提示', content: '请选择出生日期', showCancel: false, success: function (res) { } }) return } if (sData.data.countryId === '' || sData.data.countryId === null || sData.data.countryId === undefined) { wx.showModal({ title: '提示', content: '请选择国籍', showCancel: false, success: function (res) { } }) return } if (sData.data.nationId === '' || sData.data.nationId === null || sData.data.nationId === undefined) { wx.showModal({ title: '提示', content: '请选择民族', showCancel: false, success: function (res) { } }) return } /*if (sData.data.type === '' || sData.data.type === null || sData.data.type === undefined) { wx.showModal({ title: '提示', content: '请选择检查类型', showCancel: false, success: function (res) { } }) return }*/ /*if (sData.data.levelTypeId === '' || sData.data.levelTypeId === null || sData.data.levelTypeId === undefined) { wx.showModal({ title: '提示', content: '请选择文化程度', showCancel: false, success: function (res) { } }) return } if (sData.data.professionTypeId === '' || sData.data.professionTypeId === null || sData.data.professionTypeId === undefined) { wx.showModal({ title: '提示', content: '请选择职业类别', showCancel: false, success: function (res) { } }) return } if (sData.data.workUnit === '' || sData.data.workUnit === null || sData.data.workUnit === undefined) { wx.showModal({ title: '提示', content: '请填写工作单位', showCancel: false, success: function (res) { } }) return }*/ if (sData.data.phone === '' || sData.data.phone === null || sData.data.phone === undefined) { wx.showModal({ title: '提示', content: '请填写联系方式', showCancel: false, success: function (res) { } }) return } if (sData.data.provinceId === '' || sData.data.provinceId === null || sData.data.provinceId === undefined) { wx.showModal({ title: '提示', content: '请选择居住地', showCancel: false, success: function (res) { } }) return } if (sData.data.address === '' || sData.data.address === null || sData.data.address === undefined) { wx.showModal({ title: '提示', content: '请选择居住地', showCancel: false, success: function (res) { } }) return } var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; if(reg.test(sData.cardNo) === false) { wx.showModal({ title: '提示', content: '身份证输入不合法', showCancel: false, success: function (res) { } }) return } var regex = /^(13[0-9]{9})|(15[0-9]{9})|(17[0-9]{9})|(18[0-9]{9})|(19[0-9]{9})$/; if (!regex.test(sData.data.phone)) { wx.showModal({ title: '提示', content: '请录入正确的手机号码', showCancel: false, success: function (res) { } }) return } sData.data.type = '1'; networkUtil._post(api.womanBookArchive, sData, function (res) { console.log(res) if (res.data.errorcode===0){ wx.showModal({ title: '提示', content: '保存成功', showCancel:false, success: function(resu) { wx.navigateTo({ url: '../../pages/home/home' }) } }) } else { wx.showModal({ title: '提示', content: res.data.errormsg, showCancel:false, success: function(err) { } }) } }, function (res) { networkUtil.showErrorToast('保存失败,请稍后再试!') }, 'application/json') }, inputText(e) { var id = e.currentTarget.dataset.ids var defaultInfo = this.data.defaultInfo defaultInfo[id] = e.detail.value console.log(id) console.log(defaultInfo[id]) if (id === 'certificateNum') { var cardNo = defaultInfo[id] this.data.birthday = this.getBirth(cardNo); this.data.sex = this.getSex(cardNo); this.setData({ birthday: this.data.birthday, sex: this.data.sex, }) } this.setData({ defaultInfo: defaultInfo }) }, getBirth(idCard) { var birthday = ""; if(idCard != null && idCard != ""){ if(idCard.length == 15){ birthday = "19"+idCard.slice(6,12); } else if(idCard.length == 18){ birthday = idCard.slice(6,14); } birthday = birthday.replace(/(.{4})(.{2})/,"$1-$2-"); //通过正则表达式来指定输出格式为:1990-01-01 } return birthday; }, getSex(idCard) { let sexStr; if (parseInt(idCard.slice(-2, -1)) % 2 == 1) { sexStr = this.data.sexList[0]; } else { sexStr = this.data.sexList[1]; } return sexStr; }, bindSex (e) { this.setData({ sex: this.data.sexList[e.detail.value] }) }, bindType(e) { this.setData({ type: this.data.typeList[e.detail.value] }) }, bindMarriage (e) { this.setData({ marriageId: this.data.marriageStatus[e.detail.value] }) }, // 选择国籍 bindPickerNationality: function (e) { this.setData({ nationalityEntity: this.data.nationality[e.detail.value], }) }, // 选择民族 bindPickerNational: function (e) { this.setData({ nationalEntity: this.data.national[e.detail.value] }) }, bindBirthday (e) { this.setData({ birthday: e.detail.value }) }, // 选择户口类别 bindAccountType: function (e) { this.setData({ accountTypeEntity: this.data.accountType[e.detail.value] }) }, // 选择居住类别 bindResideType: function (e) { this.setData({ resideTypeEntity: this.data.resideType[e.detail.value] }) }, // 选择文化程度 bindEducationLevel: function (e) { this.setData({ educationLevelEntity: this.data.educationLevel[e.detail.value] }) }, // 选择职业类别 bindJob: function (e) { this.setData({ jobEntity: this.data.job[e.detail.value] }) }, onAreaCommit(locationList, e) {//当用户更换地区 console.log('选择地址后', locationList) var self = this; self.addrInfo = { province: locationList[0] || {}, city: locationList[1] || {}, area: locationList[2] || {}, street: locationList[3] || {}, } var address = {} address.details = '' for (var i in locationList){ address.details += locationList[i].name } address.addEntry = locationList if (e.target.dataset.name == 'permanentAddress') { self.setData({ isShow: 0, permanentAddress: address }); } else if (e.target.dataset.name == 'currentAddress') { self.setData({ isShow: 0, currentAddress: address }); } else if (e.target.dataset.name == 'healthResort') { self.setData({ isShow: 0, healthResort: address }); } }, inputAddress(e) { var id = e.currentTarget.dataset.ids var defaultInfo = this.data.defaultInfo if (id == 'jz') { defaultInfo.currentAddress_input = e.detail.value } if (id == 'hj') { defaultInfo.permanentAddress_input = e.detail.value } this.setData({ defaultInfo: defaultInfo }) }, getFocus: function (e) { var id = e.currentTarget.dataset.ids var showIdDel = id == 'idCard' var showPhoneDel = id == 'phone' this.setData({ showPhoneDel: showPhoneDel, showIdDel: showIdDel }) }, tongshang(e) { // 居住地址 var id = e.currentTarget.dataset.ids var currentAddress = this.data.currentAddress var defaultInfo = this.data.defaultInfo // if (!this.data.defaultInfo.addressInfo) { // this.data.defaultInfo.addressInfo = {} // } if (!defaultInfo.addressInfo) { defaultInfo.addressInfo = {} } console.log(e, currentAddress) if (id == 'hj') { // 户籍地址 var permanentAddress = {} permanentAddress.details = currentAddress.details permanentAddress.addEntry = currentAddress.addEntry defaultInfo.permanentAddress_input = defaultInfo.currentAddress_input defaultInfo.addressInfo.permanentAddress = this.data.defaultInfo.addressInfo.currentAddress this.setData({ permanentAddress: permanentAddress, defaultInfo: defaultInfo }) } }, bindPastHistory(e) { this.setData({ pastHistory: this.data.yesOrNoList[e.detail.value] }) }, bindFamilyHistory(e) { this.setData({ familyHistory: this.data.yesOrNoList[e.detail.value] }) }, bindPersonalHistory(e) { this.setData({ personalHistory: this.data.yesOrNoList[e.detail.value] }) }, bindYwgmHistory(e) { this.setData({ ywgmHistory: this.data.yesOrNoList[e.detail.value] }) }, bindPresentHistory(e) { this.setData({ presentHistory: this.data.yesOrNoList[e.detail.value] }) }, checkboxChange(e) { console.log('checkbox发生change事件,携带value值为:', e.detail.value) const items = this.data.items const values = e.detail.value this.data.jwsArr = e.detail.value if (this.data.jwsArr.indexOf("7")!==-1) { this.data.showJw = true } else { this.data.showJw = false } for (let i = 0, lenI = items.length; i < lenI; ++i) { items[i].checked = false for (let j = 0, lenJ = values.length; j < lenJ; ++j) { if (items[i].value === values[j]) { items[i].checked = true break } } } this.setData({ items, showJw: this.data.showJw }) }, checkboxChange1(e) { console.log('checkbox发生change事件,携带value值为:', e.detail.value) const items = this.data.items1 const values = e.detail.value this.data.jzsArr = e.detail.value if (this.data.jzsArr.indexOf("14")!==-1) { this.data.showJz = true } else { this.data.showJz = false } for (let i = 0, lenI = items.length; i < lenI; ++i) { items[i].checked = false for (let j = 0, lenJ = values.length; j < lenJ; ++j) { if (items[i].value === values[j]) { items[i].checked = true break } } } this.setData({ items, showJz: this.data.showJz }) }, checkboxChange2(e) { console.log('checkbox发生change事件,携带value值为:', e.detail.value) const items = this.data.items2 const values = e.detail.value this.data.grsArr = e.detail.value if (this.data.grsArr.indexOf("6")!==-1) { this.data.showGr = true } else { this.data.showGr = false } for (let i = 0, lenI = items.length; i < lenI; ++i) { items[i].checked = false for (let j = 0, lenJ = values.length; j < lenJ; ++j) { if (items[i].value === values[j]) { items[i].checked = true break } } } this.setData({ items, showGr: this.data.showGr }) }, checkboxChange3(e) { console.log('checkbox发生change事件,携带value值为:', e.detail.value) const items = this.data.items3 const values = e.detail.value this.data.gmArr = e.detail.value if (this.data.gmArr.indexOf("4")!==-1) { this.data.showGm = true } else { this.data.showGm = false } for (let i = 0, lenI = items.length; i < lenI; ++i) { items[i].checked = false for (let j = 0, lenJ = values.length; j < lenJ; ++j) { if (items[i].value === values[j]) { items[i].checked = true break } } } this.setData({ items, showGm: this.data.showGm }) }, onShow() { console.log(getApp().globalData.hospitalId) } }))