// case/pages/improveInfo/improveInfo.js // case/pages/register/register.js import {throttle} from "../../../utils/util" import {hostConfig} from "../../../utils/config" import {getArea,addBank,getExpertSign,getBankInfo,getfangxinSite,ocrIdCard} from "../../../api/api" const host=hostConfig().host; const app=getApp(); Page({ /** * 页面的初始数据 */ data: { isCanEdit:true, showSuccess:false, img_host:app.hostConfig().imghost, showArea:false, cityName:'', areaColumns:[ { values: [1,2], className: 'column1', }, { values: [3,4], className: 'column2', defaultIndex: 0 }, { values: [3,4], className: 'column3', defaultIndex: 0 }, ], showArea:false, bankCardNo:'', bankName:'', cityId:'', countyId:'', provId:'', idCardName:'', idCardNo:'', signImg:'', }, seeIdCard(frontFile){ ocrIdCard({ frontBase64:frontFile }).then(res=>{ wx.hideLoading() if(res.idCardNo){ this.setData({ idCardNo:res.idCardNo }) } }) }, afterRead(event){ const { file } = event.detail; console.log(file); wx.getFileSystemManager().readFile({ filePath:file.url, encoding:'base64', success:res=>{ console.log(res.data) wx.showLoading({ title: '正在识别中...', mask: true }) this.seeIdCard(res.data) } }) }, getBank(){ getBankInfo().then(res=>{ let hasBank=false; if(res){ hasBank=true; for (const key in res) { this.setData({ [key]:res[key] }) } let {provId,cityId,countyId,areaColumns}=this.data; let areaName=''; if(provId){ for (let i = 0; i < areaColumns[0].values.length; i++) { if(areaColumns[0].values[i].id==provId){ areaName+=areaColumns[0].values[i].name; break; } } }; console.log(areaColumns[1].values) if(cityId){ for (let i = 0; i < areaColumns[1].values.length; i++) { console.log((areaColumns[1].values)[i].id) if(areaColumns[1].values[i].id==cityId){ console.log(1111) console.log(areaColumns[1].values[i]) areaName+=areaColumns[1].values[i].name; break; } } }; if(countyId){ for (let i = 0; i < areaColumns[2].values.length; i++) { if(areaColumns[2].values[i].id==countyId){ areaName+=areaColumns[2].values[i].name; break; } } }; this.setData({ cityName:areaName }) }; this.handleGetSign(hasBank); }) }, getSite(){ getfangxinSite().then(res=>{ app.method.navigateTo({ url:'/case/pages/webSign/webSign?src='+encodeURIComponent(res.linkUrl) }) }) }, handleGetSign(hasBank){ getExpertSign().then(res=>{ //有银行卡,已签署 if(hasBank && res.taskStatus==1){ this.setData({ isCanEdit:false }) } //有银行卡,未签署 if(hasBank && res.taskStatus==2){ //跳转签署地址 //this.getSite(); } //无银行卡,未签署 if(!hasBank && res.taskStatus==2){ //跳转签署地址 } }).catch(error=>{ if(error.code==30007){ wx.showToast({ title: '您未登录', icon:'none', duration:4000 }) app.method.navigateTo({ url: '/case/pages/mobileLogin/mobileLogin', }) } }) }, opeArea(){ if(!this.data.isCanEdit) return false; this.setData({ showArea:true }) }, openOffice(){ this.setData({ showOffice:true, }) }, openPosition(){ this.setData({ showPosition:true, }) }, onChange(e){ const {value} = e.detail; const {id}=e.currentTarget.dataset; // console.log(value,id) this.setData({ [id]: value }); }, onChangeArea(event){ const { picker, value, index } = event.detail; const provinceId=value[0].id; const cityId=value[1].id; if(index==0){ this.handleGetArea(provinceId,2); }else if(index==1){ this.handleGetArea(cityId,3) } }, confirmArea(event){ const {value} = event.detail; console.log(value); let provId=value[0].id; let cityId=value[1].id; let countyId=value[2]?value[2].id:value[1].id; let cityName=''; for (let i = 0; i { let that=this; wx.showToast({ title: '绑定成功', icon:'none', duration:2000, success:function(){ that.getBank(); // let timer=setTimeout(()=>{ // wx.switchTab({ // url: '/pages/index/index', // }) // clearTimeout(timer) // },1000) } }) }) }), luhnCheck(cardNumber) { var sum = 0; var shouldDouble = false; var digit; // 去除任何非数字字符 cardNumber = cardNumber.replace(/\D/g, ''); // 从右向左遍历数字 for (var i = cardNumber.length - 1; i >= 0; i--) { digit = parseInt(cardNumber.charAt(i), 10); if (shouldDouble) { if ((digit *= 2) > 9) digit -= 9; } sum += digit; shouldDouble = !shouldDouble; } // 如果校验和能被10整除,则卡号有效 return (sum % 10) === 0; }, goSign:throttle(function(){ app.method.navigateTo({ url:'/case/pages/signcanvas/signcanvas' }) }), handleGetArea(id,type){ getArea({ parent:id }).then(res=>{ if(type==1){ let obj='areaColumns[0].values'; this.setData({ [obj]:res }) this.handleGetArea(res[0].id,2) }else if(type==2){ let obj='areaColumns[1].values'; this.setData({ [obj]:res }) this.handleGetArea(res[0].id,3) }else{ let obj='areaColumns[2].values'; this.setData({ [obj]:res }) this.getBank(); } }).catch(error=>{ console.log(error) }) }, handleGetOffice(){ getOfficeList({}).then(res=>{ this.setData({ officeColumns:res }) }).catch(error=>{ console.log(error) }) }, handleGetPosition(){ getPosition().then(res=>{ this.setData({ positionColumns:res }) this.handleNeedInfo(); }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { this.handleGetArea('',1); // app.method.navigateTo({ // url:'/case/pages/webSign/webSign?src='+encodeURIComponent("https://mobile.fangxinqian.cn/contractedit?sid=A2378423BDBED02430A89F5E26E35B4B&rid=45489629134796B315C1DFE27BE72C57&tno=1938884566517420032"), // complete(e){ // console.log(e); // } // }) }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ // onShareAppMessage() { // } })