|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635 |
- const reqInterface = require("../../../api/models");
- const reg = require("../../../utils/regHelper");
- const {matchValue, imagePrefix} = require("../../../utils/dataHelper");
-
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- api: '',
- id: '',
- info: {
- // 基本信息
- name: '',
- gender: '',
- pid: '',
- birthday: '',
- phone: '',
- degree: '',
- homeAddress: '',
- workName: '',
- workAddress: '',
- // 银行
- bankNumber: '',
- bankName: '',
- bankBranch: '',
- carAmount: '',
- socialAmount: '',
- workAmount: '',
- askType: '',
- // 照片
- pidPath: '',
- bookletPath: '',
- personPath: '',
- bankPath: '',
- insuredPath: '',
- jobPath: '',
-
- // 签名
- signPath: '',
-
- status: 0
- },
- showInfo: {
- gender: '',
- degree: '',
- askType: '',
- pidFrontPhoto: '',
- pidLaterPhoto: '',
- bookletPhoto: '',
- personPathPhoto: '',
- bankPhoto: '',
- insuredPhoto: '',
- jobPhoto: [],
- pidFrontPath: '',
- pidLaterPath: '',
- retire_age_man: 0,
- retire_age_women: 0
- },
- steps: [{
- text: '填写资料一'
- },
- {
- text: '填写资料二'
- },
- {
- text: '补充资料'
- },
- {
- text: '签名'
- }
- ],
- active: 0,
- curActive: 0,
- },
-
- onLoad(opt) {
- if (opt.id) {
- this.setData({
- id: opt.id
- })
- }
- if (opt.id || wx.getStorageSync('id')) {
- this.getDetail()
- }
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- let self = this;
- self.setData({
- api: imagePrefix()
- })
-
- // 获取退休年龄
- reqInterface.GetBladeSystemDictDictionary({
- code: 'retire_age'
- }).then(res => {
- self.setData({
- 'showInfo.retire_age_man': res[0].dictKey,
- 'showInfo.retire_age_women': res[1].dictKey
- })
- })
- },
-
- getDetail() {
- let self = this;
- reqInterface.GetConsumerinfoCheckDetail({
- consumerInfoId: self.data.id ? self.data.id : wx.getStorageSync('id')
- }).then(res => {
- self.data.showInfo.jobPhoto = res.jobPath.split(",")
- for (let i = 0; i < self.data.showInfo.jobPhoto.length; i++) {
- self.data.showInfo.jobPhoto[i] = self.data.api + self.data.showInfo.jobPhoto[i];
- }
- self.setData({
- info: res,
- 'info.status': 0,
- 'showInfo.pidFrontPhoto': res.pidPath ? self.data.api + res.pidPath.split(',')[0] : '',
- 'showInfo.pidLaterPhoto': res.pidPath ? self.data.api + res.pidPath.split(',')[1] : '',
- 'showInfo.bookletPhoto': res.bookletPath ? self.data.api + res.bookletPath : '',
- 'showInfo.personPathPhoto': res.personPath ? self.data.api + res.personPath : '',
- 'showInfo.bankPhoto': res.bankPath ? self.data.api + res.bankPath : '',
- 'showInfo.insuredPhoto': res.insuredPath ? self.data.api + res.insuredPath : '',
- 'showInfo.jobPhoto': self.data.showInfo.jobPhoto,
- })
-
- })
- },
-
- errorCheck() {
- return new Promise((resolve, reject) => {
- let self = this;
- switch (self.data.curActive) {
- case 0:
- if (!self.data.showInfo.pidFrontPhoto) {
- self.errorInfo('请上传身份证人像面');
- reject(false)
- return false;
- }
- if (!self.data.showInfo.pidLaterPhoto) {
- self.errorInfo('请上传身份证国徽面');
- reject(false)
- return false;
- }
- if (!self.data.info.name) {
- self.errorInfo('请填写姓名');
- reject(false)
- return false;
- }
- if (!self.data.info.gender) {
- self.errorInfo('请选择性别');
- reject(false)
- return false;
-
- }
- if (!self.data.info.pid) {
- self.errorInfo('请填写身份证号');
- reject(false)
- return false;
- }
- if (!self.data.info.phone) {
- self.errorInfo('请填写联系电话');
- reject(false)
- return false;
- }
- if (!self.data.info.degree) {
- self.errorInfo('请选择文化程度');
- reject(false)
- return false;
- }
- if (!self.data.info.homeAddress) {
- self.errorInfo('请填写家庭住址');
- reject(false)
- return false;
- }
- if (!self.data.info.workName) {
- self.errorInfo('请填写务工单位');
- reject(false)
- return false;
- }
- if (!self.data.info.workAddress) {
- self.errorInfo('请填写单位地址');
- reject(false)
- return false;
- }
- break;
- case 1:
- if (!self.data.showInfo.bankPhoto) {
- self.errorInfo('请上传银行卡照片');
- reject(false)
- return false;
- }
- if (!self.data.info.bankNumber) {
- self.errorInfo('请填写银行卡号');
- reject(false)
- return false;
- }
- if (!self.data.info.bankName) {
- self.errorInfo('请填写开户银行');
- reject(false)
- return false;
- }
- if (self.data.info.carAmount === '') {
- self.errorInfo('请选择一次性交通补贴');
- reject(false)
- return false;
- }
- if (self.data.info.socialAmount === '') {
- self.errorInfo('请选择个人社保补贴');
- reject(false)
- return false;
- }
- if (self.data.info.workAmount === '') {
- self.errorInfo('请选择就业补贴');
- reject(false)
- return false;
- }
- if (!self.data.info.askType) {
- self.errorInfo('请选择补贴对象');
- reject(false)
- return false;
- }
- break;
- case 2:
- if (!self.data.showInfo.bookletPhoto) {
- self.errorInfo('请上传户口本户主页');
- reject(false)
- return false;
- }
- if (!self.data.showInfo.personPathPhoto) {
- self.errorInfo('请上传户口本本人页');
- reject(false)
- return false;
- }
- if (!self.data.showInfo.insuredPhoto) {
- self.errorInfo('请上传参保证明');
- reject(false)
- return false;
- }
- if (!self.data.showInfo.jobPhoto) {
- self.errorInfo('请上传工作证明');
- reject(false)
- return false;
- }
- break;
- }
- resolve(true)
- })
- },
-
- errorInfo(val) {
- wx.showToast({
- title: val,
- icon: 'none'
- })
- },
-
- toNext(e) {
- let self = this;
- self.errorCheck().then(() => {
- switch (self.data.curActive) {
- case 0:
- reqInterface.PostConsumerinfoSubmit(self.data.info).then(res => {
- if (!self.data.id) {
- wx.setStorageSync('id', res.id)
- }
- self.setData({
- 'info.id': res.id,
- id: res.id,
- active: 1,
- curActive: 1,
- })
- })
- break;
- case 1:
- reqInterface.PostConsumerinfoSubmit(self.data.info).then(res => {
- self.setData({
- 'info.id': res.id,
- id: res.id,
- active: 2,
- curActive: 2,
- })
- })
- break;
- case 2:
- reqInterface.PostConsumerinfoSubmit(self.data.info).then(res => {
- self.setData({
- 'info.id': res.id,
- id: res.id,
- active: 3,
- curActive: 3,
- })
- })
- break;
- }
- })
-
- },
-
- toFront() {
- let self = this;
- // self.getDetail()
- if (self.data.active == 1) {
- self.setData({
- active: 0,
- curActive: 0,
- })
- }
- if (self.data.active == 2) {
- self.setData({
- active: 1,
- curActive: 1,
- })
- }
- if (self.data.active == 3) {
- self.setData({
- active: 2,
- curActive: 2,
- })
- }
- },
-
-
- async ocrCheckIdCardFront(e) {
- let self = this;
- // 计算年纪
- const startdate = new Date(e.detail.birth.text);
- const now = new Date();
- const year = now.getFullYear();
- const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始,所以加1,并补零
- const day = String(now.getDate()).padStart(2, '0'); // 补零
- const enddate = new Date(`${year}-${month}-${day}`);
- const timeDifference = enddate.getTime() - startdate.getTime();
- const age = Math.floor(timeDifference / (1000 * 60 * 60 * 24 * 365));
- // 判断是否满足申请年龄
- if (e.detail.gender.text == '男' && age > self.data.showInfo.retire_age_man) {
- wx.showModal({
- title: '无法申请',
- content: '已超出申请年龄,无法申请',
- confirmText: '退出申请',
- showCancel: false,
- success(res1) {
- if (res1.confirm) {
- wx.reLaunch({
- url: '/pages/my/index/index',
- })
- }
- }
- })
- } else if (e.detail.gender.text == '女' && age > self.data.showInfo.retire_age_women) {
- wx.showModal({
- title: '无法申请',
- content: '已超出申请年龄,无法申请',
- confirmText: '退出申请',
- showCancel: false,
- success(res1) {
- if (res1.confirm) {
- wx.reLaunch({
- url: '/pages/my/index/index',
- })
- }
- }
- })
- } else {
- try {
- self.setData({
- 'info.name': e.detail.name.text,
- 'info.gender': e.detail.gender.text == '男' ? 1 : 2,
- 'showInfo.gender': e.detail.gender.text,
- 'info.pid': e.detail.id.text,
- 'info.birthday': e.detail.birth.text,
- 'info.homeAddress': e.detail.address.text,
- })
- let res = await reqInterface.PostImageUpload(e.detail.image_path);
- self.setData({
- 'showInfo.pidFrontPhoto': res.data.url,
- 'showInfo.pidFrontPath': res.data.path
- })
- if (self.data.showInfo.pidFrontPath) {
- self.setData({
- 'info.pidPath': self.data.showInfo.pidFrontPath + ',' + self.data.showInfo.pidLaterPath
- })
- }
- } catch {
-
- }
-
- }
- },
-
- async ocrCheckIdCardLater(e) {
- try {
- let self = this;
- let res = await reqInterface.PostImageUpload(e.detail.image_path);
- self.setData({
- 'showInfo.pidLaterPhoto': res.data.url,
- 'showInfo.pidLaterPath': res.data.path
- })
- if (self.data.showInfo.pidLaterPath) {
- self.setData({
- 'info.pidPath': self.data.showInfo.pidFrontPath + ',' + self.data.showInfo.pidLaterPath
- })
- }
- } catch {
-
- }
- },
-
- nameValue(e) {
- let self = this;
- if (!e.detail.val) {
- self.errorInfo('请填写姓名');
- return false;
- }
- self.setData({
- 'info.name': e.detail.val
- })
- },
-
- genderValue(e) {
- let self = this;
- self.setData({
- 'info.gender': e.detail.val
- })
- },
-
- idNumberValue(e) {
- let self = this;
- console.log(e.detail.val)
- reg.IDCard(e.detail.val).then(res => {
- if (res) {
- self.setData({
- 'info.pid': e.detail.val
- })
- }
- }).catch(() => {
- self.setData({
- 'info.pid': ''
- })
- })
- },
-
- // 联系电话
- phoneValue(e) {
- let self = this;
- reg.phone(e.detail.val).then(res => {
- if (res) {
- self.setData({
- 'info.phone': e.detail.val
- })
- }
- }).catch(err => {
- self.setData({
- 'info.phone': ''
- })
- })
- },
-
- // 文化程度
- degreeValue(e) {
- let self = this;
- self.setData({
- 'info.degree': e.detail.val
- })
- },
-
- // 家庭住址
- homeAddressValue(e) {
- let self = this;
- if (!e.detail.val) {
- self.errorInfo('请填写家庭住址');
- return false;
- }
- self.setData({
- 'info.homeAddress': e.detail.val
- })
-
- },
- // 务工单位
- workNameValue(e) {
- let self = this;
- if (!e.detail.val) {
- self.errorInfo('请填写务工单位');
- return false;
- }
- self.setData({
- 'info.workName': e.detail.val
- })
- },
- // 单位地址
- workAddressValue(e) {
- let self = this;
- if (!e.detail.val) {
- self.errorInfo('请填写单位地址');
- return false;
- }
- self.setData({
- 'info.workAddress': e.detail.val
- })
- },
-
-
-
- // 银行卡识别
- async ocrCheckBankCard(e) {
- let self = this;
- self.setData({
- 'info.bankNumber': e.detail.number.text,
- })
- let res = await reqInterface.PostImageUpload(e.detail.image_path);
- self.setData({
- 'showInfo.bankPhoto': res.data.url,
- 'info.bankPath': res.data.path
- })
- },
-
- // 银行卡号
- bankNumberValue(e) {
- let self = this;
- if (!e.detail.val) {
- self.errorInfo('请填写银行卡号');
- return false;
- }
- self.setData({
- 'info.bankNumber': e.detail.val
- })
- },
-
- // 开户银行
- bankNameValue(e) {
- let self = this;
- if (!e.detail.val) {
- self.errorInfo('请填写开户银行');
- return false;
- }
- self.setData({
- 'info.bankName': e.detail.val
- })
- },
- // 支行名称
- bankBranchValue(e) {
- let self = this;
- self.setData({
- 'info.bankBranch': e.detail.val
- })
- },
-
- // 一次性交通补贴
- carAmountValue(e) {
- let self = this;
- self.setData({
- 'info.carAmount': e.detail.val
- })
- },
-
- // 个人社保补贴
- socialAmountValue(e) {
- let self = this;
- self.setData({
- 'info.socialAmount': e.detail.val
- })
- },
- // 就业补贴
- workAmountValue(e) {
- let self = this;
- self.setData({
- 'info.workAmount': e.detail.val
- })
- },
-
- // 性质
- askTypeValue(e) {
- let self = this;
- self.setData({
- 'info.askType': e.detail.val
- })
- },
-
- // 户口本
- bookletPhotoValue(data) {
- let self = this;
- self.setData({
- 'showInfo.bookletPhoto': data.detail.url,
- 'info.bookletPath': data.detail.path
- })
-
- },
-
- // 户口本本人
- personPathValue(data) {
- let self = this;
- self.setData({
- 'showInfo.personPathPhoto': data.detail.url,
- 'info.personPath': data.detail.path
- })
-
- },
-
- // 参保证明
- insuredPhotoValue(data) {
- let self = this;
- self.setData({
- 'showInfo.insuredPhoto': data.detail.url,
- 'info.insuredPath': data.detail.path
- })
-
- },
-
- // 工作证明
- jobPhotoValue(data) {
- let self = this;
- console.log(data)
- self.data.info.jobPath = data.detail.imagesPath.join(",")
- self.setData({
- 'showInfo.jobPhoto': data.detail.images,
- 'info.jobPath': self.data.info.jobPath
- })
- },
-
- toSign(e) {
- console.log(e)
- wx.navigateTo({
- url: '/pages/info/sign/index?id=' + e.currentTarget.dataset.id,
- })
- },
-
- imageError(e) {
- this.setData({
- [e.currentTarget.dataset.imgkey]: e.currentTarget.dataset.errimage,
- })
- },
- })
|