You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 15KB

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