Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

index.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. const reqInterface = require("../../../api/models");
  2. const reg = require("../../../utils/regHelper");
  3. import {
  4. matchValue
  5. } from '../../../utils/dataHelper'
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. id: '',
  12. info: {
  13. // 基本信息
  14. name: '',
  15. gender: '',
  16. pid: '',
  17. birthday: '',
  18. phone: '',
  19. degree: '',
  20. homeAddress: '',
  21. workName: '',
  22. workAddress: '',
  23. // 银行
  24. bankNumber: '',
  25. bankName: '',
  26. bankBranch: '',
  27. carAmount: '',
  28. socialAmount: '',
  29. workAmount: '',
  30. askType: '',
  31. // 照片
  32. pidPath: '',
  33. bookletPath: '',
  34. personPath: '',
  35. bankPath: '',
  36. insuredPath: '',
  37. jobPath: '',
  38. // 签名
  39. signPath: '',
  40. status: 0
  41. },
  42. showInfo: {
  43. gender: '',
  44. degree: '',
  45. askType: '',
  46. pidFrontPhoto: '',
  47. pidLaterPhoto: '',
  48. bookletPhoto: '',
  49. personPathPhoto: '',
  50. bankPhoto: '',
  51. insuredPhoto: '',
  52. jobPhoto: [],
  53. pidFrontPath: '',
  54. pidLaterPath: '',
  55. retire_age_man: 0,
  56. retire_age_women: 0
  57. },
  58. steps: [{
  59. text: '填写资料一'
  60. },
  61. {
  62. text: '填写资料二'
  63. },
  64. {
  65. text: '补充资料'
  66. },
  67. {
  68. text: '签名'
  69. }
  70. ],
  71. active: 0,
  72. curActive: 0,
  73. },
  74. onLoad(opt) {
  75. if (opt.id) {
  76. this.setData({
  77. id: opt.id
  78. })
  79. }
  80. if (opt.id || wx.getStorageSync('id')) {
  81. this.getDetail()
  82. }
  83. },
  84. /**
  85. * 生命周期函数--监听页面显示
  86. */
  87. onShow() {
  88. let self = this;
  89. // 获取退休年龄
  90. reqInterface.GetBladeSystemDictDictionary({
  91. code: 'retire_age'
  92. }).then(res => {
  93. self.setData({
  94. 'showInfo.retire_age_man': res[0].dictKey,
  95. 'showInfo.retire_age_women': res[1].dictKey
  96. })
  97. })
  98. },
  99. getDetail() {
  100. let self = this;
  101. reqInterface.GetConsumerinfoCheckDetail({
  102. consumerInfoId: self.data.id ? self.data.id : wx.getStorageSync('id')
  103. }).then(res => {
  104. self.data.showInfo.jobPhoto = res.jobPath.split(",")
  105. for (let i = 0; i < self.data.showInfo.jobPhoto.length; i++) {
  106. self.data.showInfo.jobPhoto[i] = self.data.api + self.data.showInfo.jobPhoto[i];
  107. }
  108. self.setData({
  109. info: res,
  110. 'info.status': 0,
  111. 'showInfo.pidFrontPhoto': res.pidPath ? self.data.api + res.pidPath.split(',')[0] : '',
  112. 'showInfo.pidLaterPhoto': res.pidPath ? self.data.api + res.pidPath.split(',')[1] : '',
  113. 'showInfo.bookletPhoto': res.bookletPath ? self.data.api + res.bookletPath : '',
  114. 'showInfo.personPathPhoto': res.personPath ? self.data.api + res.personPath : '',
  115. 'showInfo.bankPhoto': res.bankPath ? self.data.api + res.bankPath : '',
  116. 'showInfo.insuredPhoto': res.insuredPath ? self.data.api + res.insuredPath : '',
  117. 'showInfo.jobPhoto': self.data.showInfo.jobPhoto,
  118. })
  119. })
  120. },
  121. errorCheck() {
  122. return new Promise((resolve, reject) => {
  123. let self = this;
  124. switch (self.data.curActive) {
  125. case 0:
  126. if (!self.data.showInfo.pidFrontPhoto) {
  127. self.errorInfo('请上传身份证人像面');
  128. reject(false)
  129. return false;
  130. }
  131. if (!self.data.showInfo.pidLaterPhoto) {
  132. self.errorInfo('请上传身份证国徽面');
  133. reject(false)
  134. return false;
  135. }
  136. if (!self.data.info.name) {
  137. self.errorInfo('请填写姓名');
  138. reject(false)
  139. return false;
  140. }
  141. if (!self.data.info.gender) {
  142. self.errorInfo('请选择性别');
  143. reject(false)
  144. return false;
  145. }
  146. if (!self.data.info.pid) {
  147. self.errorInfo('请填写身份证号');
  148. reject(false)
  149. return false;
  150. }
  151. if (!self.data.info.phone) {
  152. self.errorInfo('请填写联系电话');
  153. reject(false)
  154. return false;
  155. }
  156. if (!self.data.info.degree) {
  157. self.errorInfo('请选择文化程度');
  158. reject(false)
  159. return false;
  160. }
  161. if (!self.data.info.homeAddress) {
  162. self.errorInfo('请填写家庭住址');
  163. reject(false)
  164. return false;
  165. }
  166. if (!self.data.info.workName) {
  167. self.errorInfo('请填写务工单位');
  168. reject(false)
  169. return false;
  170. }
  171. if (!self.data.info.workAddress) {
  172. self.errorInfo('请填写单位地址');
  173. reject(false)
  174. return false;
  175. }
  176. break;
  177. case 1:
  178. if (!self.data.showInfo.bankPhoto) {
  179. self.errorInfo('请上传银行卡照片');
  180. reject(false)
  181. return false;
  182. }
  183. if (!self.data.info.bankNumber) {
  184. self.errorInfo('请填写银行卡号');
  185. reject(false)
  186. return false;
  187. }
  188. if (!self.data.info.bankName) {
  189. self.errorInfo('请填写开户银行');
  190. reject(false)
  191. return false;
  192. }
  193. if (self.data.info.carAmount === '') {
  194. self.errorInfo('请选择一次性交通补贴');
  195. reject(false)
  196. return false;
  197. }
  198. if (self.data.info.socialAmount === '') {
  199. self.errorInfo('请选择个人社保补贴');
  200. reject(false)
  201. return false;
  202. }
  203. if (self.data.info.workAmount === '') {
  204. self.errorInfo('请选择就业补贴');
  205. reject(false)
  206. return false;
  207. }
  208. if (!self.data.info.askType) {
  209. self.errorInfo('请选择补贴对象');
  210. reject(false)
  211. return false;
  212. }
  213. break;
  214. case 2:
  215. if (!self.data.showInfo.bookletPhoto) {
  216. self.errorInfo('请上传户口本户主页');
  217. reject(false)
  218. return false;
  219. }
  220. if (!self.data.showInfo.personPathPhoto) {
  221. self.errorInfo('请上传户口本本人页');
  222. reject(false)
  223. return false;
  224. }
  225. if (!self.data.showInfo.insuredPhoto) {
  226. self.errorInfo('请上传参保证明');
  227. reject(false)
  228. return false;
  229. }
  230. if (!self.data.showInfo.jobPhoto) {
  231. self.errorInfo('请上传工作证明');
  232. reject(false)
  233. return false;
  234. }
  235. break;
  236. }
  237. resolve(true)
  238. })
  239. },
  240. errorInfo(val) {
  241. wx.showToast({
  242. title: val,
  243. icon: 'none'
  244. })
  245. },
  246. toNext(e) {
  247. let self = this;
  248. self.errorCheck().then(() => {
  249. switch (self.data.curActive) {
  250. case 0:
  251. reqInterface.PostConsumerinfoSubmit(self.data.info).then(res => {
  252. if (!self.data.id) {
  253. wx.setStorageSync('id', res.id)
  254. }
  255. self.setData({
  256. 'info.id': res.id,
  257. id: res.id,
  258. active: 1,
  259. curActive: 1,
  260. })
  261. })
  262. break;
  263. case 1:
  264. reqInterface.PostConsumerinfoSubmit(self.data.info).then(res => {
  265. self.setData({
  266. 'info.id': res.id,
  267. id: res.id,
  268. active: 2,
  269. curActive: 2,
  270. })
  271. })
  272. break;
  273. case 2:
  274. reqInterface.PostConsumerinfoSubmit(self.data.info).then(res => {
  275. self.setData({
  276. 'info.id': res.id,
  277. id: res.id,
  278. active: 3,
  279. curActive: 3,
  280. })
  281. })
  282. break;
  283. }
  284. })
  285. },
  286. toFront() {
  287. let self = this;
  288. // self.getDetail()
  289. if (self.data.active == 1) {
  290. self.setData({
  291. active: 0,
  292. curActive: 0,
  293. })
  294. }
  295. if (self.data.active == 2) {
  296. self.setData({
  297. active: 1,
  298. curActive: 1,
  299. })
  300. }
  301. if (self.data.active == 3) {
  302. self.setData({
  303. active: 2,
  304. curActive: 2,
  305. })
  306. }
  307. },
  308. async ocrCheckIdCardFront(e) {
  309. let self = this;
  310. // 计算年纪
  311. const startdate = new Date(e.detail.birth.text);
  312. const now = new Date();
  313. const year = now.getFullYear();
  314. const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份从0开始,所以加1,并补零
  315. const day = String(now.getDate()).padStart(2, '0'); // 补零
  316. const enddate = new Date(`${year}-${month}-${day}`);
  317. const timeDifference = enddate.getTime() - startdate.getTime();
  318. const age = Math.floor(timeDifference / (1000 * 60 * 60 * 24 * 365));
  319. // 判断是否满足申请年龄
  320. if (e.detail.gender.text == '男' && age > self.data.showInfo.retire_age_man) {
  321. wx.showModal({
  322. title: '无法申请',
  323. content: '已超出申请年龄,无法申请',
  324. confirmText: '退出申请',
  325. showCancel: false,
  326. success(res1) {
  327. if (res1.confirm) {
  328. wx.reLaunch({
  329. url: '/pages/my/index/index',
  330. })
  331. }
  332. }
  333. })
  334. } else if (e.detail.gender.text == '女' && age > self.data.showInfo.retire_age_women) {
  335. wx.showModal({
  336. title: '无法申请',
  337. content: '已超出申请年龄,无法申请',
  338. confirmText: '退出申请',
  339. showCancel: false,
  340. success(res1) {
  341. if (res1.confirm) {
  342. wx.reLaunch({
  343. url: '/pages/my/index/index',
  344. })
  345. }
  346. }
  347. })
  348. } else {
  349. try {
  350. self.setData({
  351. 'info.name': e.detail.name.text,
  352. 'info.gender': e.detail.gender.text == '男' ? 1 : 2,
  353. 'showInfo.gender': e.detail.gender.text,
  354. 'info.pid': e.detail.id.text,
  355. 'info.birthday': e.detail.birth.text,
  356. 'info.homeAddress': e.detail.address.text,
  357. })
  358. let res = await reqInterface.PostImageUpload(e.detail.image_path);
  359. self.setData({
  360. 'showInfo.pidFrontPhoto': res.data.url,
  361. 'showInfo.pidFrontPath': res.data.path
  362. })
  363. if (self.data.showInfo.pidFrontPath) {
  364. self.setData({
  365. 'info.pidPath': self.data.showInfo.pidFrontPath + ',' + self.data.showInfo.pidLaterPath
  366. })
  367. }
  368. } catch {
  369. }
  370. }
  371. },
  372. async ocrCheckIdCardLater(e) {
  373. try {
  374. let self = this;
  375. let res = await reqInterface.PostImageUpload(e.detail.image_path);
  376. self.setData({
  377. 'showInfo.pidLaterPhoto': res.data.url,
  378. 'showInfo.pidLaterPath': res.data.path
  379. })
  380. if (self.data.showInfo.pidLaterPath) {
  381. self.setData({
  382. 'info.pidPath': self.data.showInfo.pidFrontPath + ',' + self.data.showInfo.pidLaterPath
  383. })
  384. }
  385. } catch {
  386. }
  387. },
  388. nameValue(e) {
  389. let self = this;
  390. if (!e.detail.val) {
  391. self.errorInfo('请填写姓名');
  392. return false;
  393. }
  394. self.setData({
  395. 'info.name': e.detail.val
  396. })
  397. },
  398. genderValue(e) {
  399. let self = this;
  400. self.setData({
  401. 'info.gender': e.detail.val
  402. })
  403. },
  404. idNumberValue(e) {
  405. let self = this;
  406. console.log(e.detail.val)
  407. reg.IDCard(e.detail.val).then(res => {
  408. if (res) {
  409. self.setData({
  410. 'info.pid': e.detail.val
  411. })
  412. }
  413. }).catch(() => {
  414. self.setData({
  415. 'info.pid': ''
  416. })
  417. })
  418. },
  419. // 联系电话
  420. phoneValue(e) {
  421. let self = this;
  422. reg.phone(e.detail.val).then(res => {
  423. if (res) {
  424. self.setData({
  425. 'info.phone': e.detail.val
  426. })
  427. }
  428. }).catch(err => {
  429. self.setData({
  430. 'info.phone': ''
  431. })
  432. })
  433. },
  434. // 文化程度
  435. degreeValue(e) {
  436. let self = this;
  437. self.setData({
  438. 'info.degree': e.detail.val
  439. })
  440. },
  441. // 家庭住址
  442. homeAddressValue(e) {
  443. let self = this;
  444. if (!e.detail.val) {
  445. self.errorInfo('请填写家庭住址');
  446. return false;
  447. }
  448. self.setData({
  449. 'info.homeAddress': e.detail.val
  450. })
  451. },
  452. // 务工单位
  453. workNameValue(e) {
  454. let self = this;
  455. if (!e.detail.val) {
  456. self.errorInfo('请填写务工单位');
  457. return false;
  458. }
  459. self.setData({
  460. 'info.workName': e.detail.val
  461. })
  462. },
  463. // 单位地址
  464. workAddressValue(e) {
  465. let self = this;
  466. if (!e.detail.val) {
  467. self.errorInfo('请填写单位地址');
  468. return false;
  469. }
  470. self.setData({
  471. 'info.workAddress': e.detail.val
  472. })
  473. },
  474. // 银行卡识别
  475. async ocrCheckBankCard(e) {
  476. let self = this;
  477. self.setData({
  478. 'info.bankNumber': e.detail.number.text,
  479. })
  480. let res = await reqInterface.PostImageUpload(e.detail.image_path);
  481. self.setData({
  482. 'showInfo.bankPhoto': res.data.url,
  483. 'info.bankPath': res.data.path
  484. })
  485. },
  486. // 银行卡号
  487. bankNumberValue(e) {
  488. let self = this;
  489. if (!e.detail.val) {
  490. self.errorInfo('请填写银行卡号');
  491. return false;
  492. }
  493. self.setData({
  494. 'info.bankNumber': e.detail.val
  495. })
  496. },
  497. // 开户银行
  498. bankNameValue(e) {
  499. let self = this;
  500. if (!e.detail.val) {
  501. self.errorInfo('请填写开户银行');
  502. return false;
  503. }
  504. self.setData({
  505. 'info.bankName': e.detail.val
  506. })
  507. },
  508. // 支行名称
  509. bankBranchValue(e) {
  510. let self = this;
  511. self.setData({
  512. 'info.bankBranch': e.detail.val
  513. })
  514. },
  515. // 一次性交通补贴
  516. carAmountValue(e) {
  517. let self = this;
  518. self.setData({
  519. 'info.carAmount': e.detail.val
  520. })
  521. },
  522. // 个人社保补贴
  523. socialAmountValue(e) {
  524. let self = this;
  525. self.setData({
  526. 'info.socialAmount': e.detail.val
  527. })
  528. },
  529. // 就业补贴
  530. workAmountValue(e) {
  531. let self = this;
  532. self.setData({
  533. 'info.workAmount': e.detail.val
  534. })
  535. },
  536. // 性质
  537. askTypeValue(e) {
  538. let self = this;
  539. self.setData({
  540. 'info.askType': e.detail.val
  541. })
  542. },
  543. // 户口本
  544. bookletPhotoValue(data) {
  545. let self = this;
  546. self.setData({
  547. 'showInfo.bookletPhoto': data.detail.url,
  548. 'info.bookletPath': data.detail.path
  549. })
  550. },
  551. // 户口本本人
  552. personPathValue(data) {
  553. let self = this;
  554. self.setData({
  555. 'showInfo.personPathPhoto': data.detail.url,
  556. 'info.personPath': data.detail.path
  557. })
  558. },
  559. // 参保证明
  560. insuredPhotoValue(data) {
  561. let self = this;
  562. self.setData({
  563. 'showInfo.insuredPhoto': data.detail.url,
  564. 'info.insuredPath': data.detail.path
  565. })
  566. },
  567. // 工作证明
  568. jobPhotoValue(data) {
  569. let self = this;
  570. console.log(data)
  571. self.data.info.jobPath = data.detail.imagesPath.join(",")
  572. self.setData({
  573. 'showInfo.jobPhoto': data.detail.images,
  574. 'info.jobPath': self.data.info.jobPath
  575. })
  576. },
  577. toSign(e) {
  578. console.log(e)
  579. wx.navigateTo({
  580. url: '/pages/info/sign/index?id=' + e.currentTarget.dataset.id,
  581. })
  582. },
  583. imageError(e) {
  584. this.setData({
  585. [e.currentTarget.dataset.imgkey]: e.currentTarget.dataset.errimage,
  586. })
  587. },
  588. })