var businessT = require('../../../tool/business-tool.js') var sysT = require('../../../tool/sys-tool.js') var url = require('../../../constant/url.js') var verify = require('../../../tool/verify.js') import Net from '../../../tool/net.js' var net = new Net() var app = getApp() var wxyj = require('../../../public/wxyj.js') Page({ data: { firstImgPath: '../../../icon/home/idcard_front.png', secondImgPath: '../../../icon/home/idcard_back.png', events: [{ e: 'goCamrea', t: '上传身份证正面' }, { e: 'goCamrea', t: '上传身份证反面' }], personInfo: {} }, openModal() { this.cameramodal = this.selectComponent("#camera-modal"); this.cameramodal.openModal(); }, goCamrea(e) { //513022199610170018 13350283559 var idCard = this.data.personInfo.id_card if (idCard) { if (idCard.length != 18 || !verify.isIdentityCard(idCard)) { swan.showToast({ title: '请填写正确的身份证号', icon: 'none', }); } else if (e.currentTarget.id == 'front' || e.currentTarget.id == 'back') { swan.navigateTo({ url: '../../../public/pages/camera/camera?type=' + e.currentTarget.id + '&idCard=' + idCard, }) } else if (e.currentTarget.id == 'first') { swan.navigateTo({ url: '../../../public/pages/camera/camera?type=front' + '&idCard=' + idCard, }) } else if (e.currentTarget.id == 'second') { swan.navigateTo({ url: '../../../public/pages/camera/camera?type=back' + '&idCard=' + idCard, }) } } else { swan.showToast({ title: '请填写正确的身份证号', icon: 'none', }) } }, inputAction(e) { switch (e.currentTarget.dataset.type) { case "name": { this.data.personInfo.user_name = e.detail.value break } case "nation": { this.data.personInfo.nation = e.detail.value break } case "id_card": { this.data.personInfo.id_card = e.detail.value break } case "hk_address": { this.data.personInfo.hk_address = e.detail.value break } case "phone": { this.data.personInfo.phone = e.detail.value break } } }, btnAction() { const gender=verify.getIdentityCardGender(this.data.personInfo.id_card), age=verify.getIdentityCardAge(this.data.personInfo.id_card) var tips1=false,tips2=false if(gender ==1){ if(age>58||age<18){ tips1=true } }else{ if(age>48||age<18){ tips2=true } } if (!this.data.personInfo.user_name) { swan.showToast({ title: '请正确输入姓名', icon: 'none', }); } else if (!this.data.personInfo.nation) { swan.showToast({ title: '请输入民族', icon: 'none', }) } else if (!verify.isIdentityCard(this.data.personInfo.id_card)) { console.log(this.data.personInfo.id_card) swan.showToast({ title: '请填写正确的身份证号', icon: 'none', }); } else if (tips1) { swan.showToast({ title: '暂时只受理18-58岁的男性用户哦', icon: 'none', }) }else if (tips2) { swan.showToast({ title: '暂时只受理18-48岁的女性用户哦', icon: 'none', }) } else if (!this.data.personInfo.hk_address) { swan.showToast({ title: '请正确输入户籍地址', icon: 'none', }) } else if (!verify.isPhoneNum(this.data.personInfo.phone)) { swan.showToast({ title: '请填写正确的手机号', icon: 'none', }) } else if (!this.data.personInfo.id_card_img) { swan.showToast({ title: '请拍摄身份证正面', icon: 'none', }) } else if (!this.data.personInfo.id_card_img1) { swan.showToast({ title: '请拍摄身份证反面', icon: 'none', }) } else { swan.showLoading({ title: '正在生成参保人', mask: true, }) net.connectNeedLogin({ url: url.app_host + url.modifyCustomer, data: this.data.personInfo, success: (err, res) => { swan.hideLoading() wxyj.wxyjData.order.sbuId = res.data.id net.connectNeedLogin({ url: url.app_host + url.getCustomerList, data: {}, success: (err, res) => { app.globalData.customerList = res.data if (this.data.goOrder) { var page = getCurrentPages() var prevPage = page[page.length - 2] prevPage.goNext() } else { swan.navigateBack() } swan.hideLoading(); }, fail: (err, res) => { swan.hideLoading(); businessT.showFailTips(err) } }, true) }, fail: (err, res) => { swan.hideLoading(); businessT.showFailTips(err, '生成参保人信息失败') } }, true) app.idCard.front= "" app.idCard.back= "" } }, idCardImg() { this.data.personInfo.id_card_img = app.idCard.front this.data.personInfo.id_card_img1 = app.idCard.back if (app.idCard.front) { this.setData({ firstImgPath: app.idCard.front }) this.data.events[0].e = 'previewImg' this.data.events[0].t = '重拍正面' this.setData({ events: this.data.events }) } if (app.idCard.back) { this.setData({ secondImgPath: app.idCard.back }) this.data.events[1].e = 'previewImg' this.data.events[1].t = '重拍反面' this.setData({ events: this.data.events }) } if (!app.idCard.front && !app.idCard.back) { this.setData({ firstImgPath: '../../../icon/home/idcard_front.png', secondImgPath: '../../../icon/home/idcard_back.png', events: [{ e: 'goCamrea', t: '上传身份证正面' }, { e: 'goCamrea', t: '上传身份证反面' }] }) } }, previewImg(e) { console.log(this.data.firstImgPath) if (e.currentTarget.id == 'first') { swan.previewImage({ urls: [this.data.firstImgPath] }); } if (e.currentTarget.id == 'second') { swan.previewImage({ urls: [this.data.secondImgPath] }); } }, onLoad: function (res) { // 监听页面加载的生命周期函数 swan.setPageInfo && swan.setPageInfo({ title: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页', keywords: '我的社保,我的社保网,我的社保APP,社会保障,社保,社保代缴,公积金代缴,社会保险,五险一金,医保,医疗保险,公积金,养老,生育,工伤,失业,住房公积金,社保代理,代缴社保,公积金代理,查悦社保,大社保,亲亲小保,社保掌上通,招聘求职,创业,买房,贷款,计算器,人社局,摇号', description: '我的社保APP是为个人、企业提供社保代缴代扣、公积金代扣代缴、社保查询、公积金查询服务的名牌产品。解决个体工商户、自由职业者、待业人员、全职妈妈、创业者等的个人社保公积金断缴难题,同时解决贷款, 买房, 买车, 养老, 医疗, 生育, 医疗报销等难题。同时为企业提供全国专业社保代理和公积金代理。', articleTitle: '【我的社保】官方APP-社保挂靠公积金代理全国自助缴纳查询社保公积金_主页', release_date: '2019-02-23 20:00:00', success: function () { console.log('页面基础信息设置完成'); }, fail: function (res) { console.log('设置失败'); }, }) this.setData({ suffix: sysT.suffixOfClass(), goOrder: res.goOrder }) }, onReady: function () { // 监听页面初次渲染完成的生命周期函数 }, onShow: function () { // 监听页面显示的生命周期函数 this.idCardImg() }, onHide: function () { // 监听页面隐藏的生命周期函数 }, onUnload: function () { // 监听页面卸载的生命周期函数 app.idCard.front='' app.idCard.back='' }, onPullDownRefresh: function () { // 监听用户下拉动作 }, onReachBottom: function () { // 页面上拉触底事件的处理函数 }, onShareAppMessage: function () { // 用户点击右上角转发 } });