zoujiandong b496603f7c 111
2025-06-17 17:58:29 +08:00

322 lines
7.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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 <value.length; i++) {
if(value[i]){
cityName+=value[i].name
};
};
this.setData({
provId:provId,
cityId:cityId,
countyId:countyId,
cityName:cityName,
showArea:false
});
},
cancelArea(){
this.setData({
showArea:false
})
},
confirmHospital(event){
let {value}=event.detail;
this.setData({
showHospital:false,
hospital_uuid:value.uuid,
hospital_name:value.name
})
},
cancelHospital(){
this.setData({
showHospital:false
})
},
handleAddBank:throttle(function(){
let {signImg,bankCardNo,bankName,cityId,countyId,idCardNo,name,provId}=this.data;
if (!/^([\u4e00-\u9fa5\·]{2,10})$/.test(name)) {
wx.showToast({
title: `姓名要求在2-10个汉字`,
icon: 'none',
});
return false;
};
if (!/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(idCardNo)){
wx.showToast({
title: `请输入有效的身份证号`,
icon: 'none',
});
return false;
};
if(!provId){
wx.showToast({
title: `请选择开户行所在城市`,
icon: 'none',
});
return false;
}
if(!bankName){
wx.showToast({
title: `请输入开户行`,
icon: 'none',
});
return false;
}
if(!this.luhnCheck(bankCardNo)){
wx.showToast({
title: `请输入有效银行卡号`,
icon: 'none',
});
return false;
};
if(!signImg){
wx.showToast({
title: `请添加签名`,
icon: 'none',
});
return false;
}
addBank({
signImg,
bankCardNo,
bankName,
cityId,
countyId,
idCardNo,
name,
provId
}).then(res=>{
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() {
// }
})