// case/pages/improveInfo/improveInfo.js // case/pages/register/register.js import {throttle} from "../../../utils/util" import {hostConfig} from "../../../utils/config" import {getArea,addBank} from "../../../api/api" const host=hostConfig().host; const app=getApp(); Page({ /** * 页面的初始数据 */ data: { 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:'', name:'', idCardNo:'', signImg:'', }, opeArea(){ 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 { wx.showToast({ title: '绑定成功', icon:'none', duration:2000, success:function(){ 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 }) } }).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) { this.handleGetArea('',1); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ // onShareAppMessage() { // } })