perfectWorkerInfo.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../api/api.js');
  3. var check = require('../../../utils/check.js');
  4. var app = getApp();
  5. Page({
  6. data: {
  7. hasLogin:true,
  8. workerNo:'',
  9. isExist:false,//服务者是否存在
  10. showOcr:false,
  11. workerTel:'',
  12. certificateFileUrl:[],
  13. headPic:'',
  14. worker: {
  15. healthCertificate:'',//0未上传 1已上传 2健康证即将到期 3健康证到期
  16. // workerTel: '',
  17. // workerIdcard: '',
  18. // workerName: '',
  19. // famousRace: '',
  20. // idcardAddr: '',
  21. // birthday: '',
  22. // workType: '',
  23. // contactAddr: "",
  24. // validStartDate: "",
  25. // validEndDate: "",
  26. // healthCert: '',
  27. // healthStart: '',
  28. // healthEnd: '',
  29. // experience: '',
  30. // education: '',
  31. // emergencyContact: "",
  32. // emergencyPhone: '',
  33. // city: ''
  34. },
  35. applyType: '请选择',
  36. showExperience: false,
  37. showEducation: false, //显示学历
  38. showServiceItem: false, //显示技能项目
  39. showHealthStart: false, //健康证起始日期
  40. showIssuanceDate:false,//健康证发证日期
  41. showHealthEnd: false, //健康证起始日期
  42. showHukou:false,//户口选择
  43. showShebao:false,//社保
  44. showCity: false,
  45. experience: ['无', '1-3年', '3-5年', '5年以上'],
  46. education: ['小学', '初中', '高中', '专科', '本科'],
  47. serviceItem: ['日常保洁', '做饭家厨', '精细擦窗', '空调除尘', '浴室清洁', '厨房清洁', '除尘除螨', '油烟燃气', '洗衣冰箱', '洗衣空调'],
  48. citys: ['上海', '北京', '深圳', '南京', '苏州', '杭州', '武汉'],
  49. minDate: new Date().setTime((new Date()).getTime() - 3600 * 1000 * 24 * 365),
  50. residenceTypeList:[{key:'1',value:'农村'},{key:'2',value:'城镇'}],
  51. socialSecurityList:[{key:'1',value:'社保'},{key:'2',value:'新农保'},{key:'3',value:'已退休'},{key:'4',value:'无'}],
  52. idFront: '', //身份证正反面
  53. idBack: '',
  54. showSubmit: true //是否显示提交按钮
  55. },
  56. goValid() {
  57. if (this.data.workerTel == '' || !check.isValidPhone(this.data.workerTel)) {
  58. wx.showToast({
  59. title: '请输入个人手机号',
  60. icon:none
  61. });
  62. return false;
  63. }
  64. this.getWorkerInfo({
  65. phone: this.data.workerTel
  66. });
  67. },
  68. getWorkerInfo(params){
  69. util.request(api.ServantValid, params, 'GET').then(res=> {
  70. wx.hideLoading();
  71. console.log(res);
  72. if (res.errno === 0) {
  73. // wx.showToast({
  74. // title: '已存在,待完善',
  75. // icon: 'success',
  76. // duration: 2000
  77. // });
  78. this.setData({
  79. isExist:true,
  80. worker:res.data,
  81. showOcr:res.data.orcFlag,//是否需要做ocr,
  82. certificateFileUrl:res.data.certificateFileUrl==''?[]:res.data.certificateFileUrl.split(','),
  83. headPic:res.data.headPic,
  84. idFront:res.data.idcardFront,
  85. idBack:res.data.idcardBack
  86. });
  87. this.setData({
  88. 'worker.certificateFileUrl':res.data.certificateFileUrl==''?[]:res.data.certificateFileUrl.split(',')
  89. });
  90. this.setData({
  91. workerNo:res.data.workerNo
  92. });
  93. let hukou='';
  94. this.data.residenceTypeList.forEach(e=>{
  95. if(res.data.residenceType!=''&&res.data.residenceType==e.key){
  96. hukou=e.value;
  97. }
  98. })
  99. let shebao='';
  100. this.data.socialSecurityList.forEach(e=>{
  101. if(res.data.socialSecurity!=''&&res.data.socialSecurity==e.key){
  102. shebao=e.value;
  103. }
  104. })
  105. this.setData({
  106. 'worker.residenceTypeName': hukou,
  107. 'worker.socialSecurityName': shebao
  108. });
  109. if(this.data.worker.idcardStartdate){
  110. this.setData({
  111. 'worker.break': '至',
  112. });
  113. }
  114. if(!this.data.showOcr){
  115. this.setData({
  116. idFront:res.data.idcardFront,
  117. idBack:res.data.idcardBack
  118. });
  119. }
  120. } else {
  121. this.setData({
  122. isExist:false
  123. });
  124. wx.showModal({
  125. title: '提示',
  126. content: res.errmsg,
  127. showCancel:false,
  128. success (res) {
  129. if (res.confirm) {
  130. }
  131. }
  132. });
  133. }
  134. });
  135. },
  136. submitFeedback: function (e) {
  137. let that = this;
  138. let worker = that.data.worker;
  139. console.info(worker)
  140. if (worker.workerIdcard == '' || worker.workerIdcard.length != 18) {
  141. // util.showErrorToast('请上传身份证并识别');
  142. wx.showToast({
  143. title: '请上传身份证并识别',
  144. icon:'none',
  145. duration: 3000
  146. });
  147. return false;
  148. }
  149. // if (worker.workerTel == '' || !check.isValidPhone(worker.workerTel)) {
  150. // util.showErrorToast('请输入个人手机号');
  151. // return false;
  152. // }
  153. // if (worker.workerType == '') {
  154. // util.showErrorToast('请选择工作类型');
  155. // return false;
  156. // }
  157. // if (worker.experience == '') {
  158. // util.showErrorToast('请选择工作经验');
  159. // return false;
  160. // }
  161. // if (worker.city == '') {
  162. // util.showErrorToast('请选择工作城市');
  163. // return false;
  164. // }
  165. // if (worker.education == '') {
  166. // util.showErrorToast('请选择学历');
  167. // return false;
  168. // }
  169. // if (worker.contactAddr == '') {
  170. // util.showErrorToast('请输入联系地址');
  171. // return false;
  172. // }
  173. // if (worker.emergencyContact == '' || worker.emergencyPhone == '' || !check.isValidPhone(worker.emergencyPhone)) {
  174. // util.showErrorToast('请填写紧急联系人');
  175. // return false;
  176. // }
  177. if (worker.certificateFileUrl == [] || worker.certificateNo == '' || worker.issuanceDate == ''||worker.expirationDateStart == ''|| worker.expirationDateEnd == '') {
  178. // util.showErrorToast('请填写健康证信息');
  179. wx.showToast({
  180. title: '请填写健康证信息',
  181. icon:'none',
  182. duration: 3000
  183. });
  184. return false;
  185. }
  186. if (worker.expirationDateEnd <= worker.expirationDateStart) {
  187. // util.showErrorToast('请选择正确健康证有效期');
  188. wx.showToast({
  189. title: '请选择正确健康证有效期',
  190. icon:'none',
  191. duration: 3000
  192. });
  193. return false;
  194. }
  195. wx.showModal({
  196. title: '提醒',
  197. content: '请核对填写信息,提交后无法更改,确定提交?',
  198. success: function (res) {
  199. wx.showLoading({
  200. title: '提交中...',
  201. mask: true,
  202. });
  203. let params=JSON.parse(JSON.stringify(worker));
  204. params.certificateFileUrl=params.certificateFileUrl.join(',')
  205. util.request(api.ServantPerfect,
  206. params, 'POST').then(function (res) {
  207. wx.hideLoading();
  208. if (res.errno === 0) {
  209. that.setData({
  210. showSubmit: false
  211. })
  212. wx.showToast({
  213. title: '信息完善成功',
  214. icon: 'success',
  215. duration: 2000
  216. });
  217. } else {
  218. util.showErrorToast(res.errmsg);
  219. }
  220. });
  221. }
  222. })
  223. },
  224. bindWorkerTel(e) {
  225. this.setData({
  226. workerTel: e.detail.value
  227. });
  228. },
  229. bindContactAddr(e) {
  230. this.setData({
  231. 'worker.contactAddr': e.detail.value
  232. });
  233. },
  234. bindEmergencyContact(e) {
  235. this.setData({
  236. 'worker.emergencyContact': e.detail.value
  237. });
  238. },
  239. bindHeight: function (e) {
  240. this.setData({
  241. 'worker.height': e.detail.value
  242. });
  243. },
  244. bindWeight: function (e) {
  245. this.setData({
  246. 'worker.weight': e.detail.value
  247. });
  248. },
  249. bindBankNo:function(e){
  250. this.setData({
  251. 'worker.bankNo': e.detail.value
  252. });
  253. },
  254. bindBankOfDeposit:function(e){
  255. this.setData({
  256. 'worker.bankOfDeposit': e.detail.value
  257. });
  258. },
  259. bindWorkerTel1: function (e) {
  260. this.setData({
  261. 'worker.workerTel1': e.detail.value
  262. });
  263. },
  264. bindHealthCert(e) {
  265. this.setData({
  266. 'worker.certificateNo': e.detail.value
  267. });
  268. },
  269. showHealthStart() {
  270. this.setData({
  271. showHealthStart: true
  272. });
  273. },
  274. showIssuanceDate() {
  275. this.setData({
  276. showIssuanceDate: true
  277. });
  278. },
  279. showHealthEnd() {
  280. this.setData({
  281. showHealthEnd: true
  282. });
  283. },
  284. showEducation() {
  285. this.setData({
  286. showEducation: true
  287. });
  288. },
  289. showExperience() {
  290. this.setData({
  291. showExperience: true
  292. });
  293. },
  294. showServiceItem() {
  295. this.setData({
  296. showServiceItem: true
  297. });
  298. },
  299. showCity() {
  300. this.setData({
  301. showCity: true
  302. });
  303. },
  304. showShebao:function(){
  305. this.setData({
  306. showShebao: true,
  307. });
  308. },
  309. onShebaoCancel:function(){
  310. this.setData({
  311. showShebao: false,
  312. });
  313. },
  314. onShebaoConfirm:function(event){
  315. console.log(event);
  316. let k=event.detail.value.key;
  317. if(this.data.worker.residenceType==undefined||this.data.worker.residenceType==''){
  318. wx.showToast({
  319. title: '请先选择户口,再选社保',
  320. icon:'none',
  321. duration: 2000
  322. });
  323. return ;
  324. }
  325. if(this.data.worker.residenceType==1&&(k==1||k==3)){
  326. wx.showToast({
  327. title: '农村户口请选:新农保、无',
  328. icon:'none',
  329. duration: 2000
  330. });
  331. return ;
  332. }
  333. if(this.data.worker.residenceType==2&&(k==2)){
  334. wx.showToast({
  335. title: '城镇户口不能选新农保',
  336. icon:'none',
  337. duration: 2000
  338. });
  339. return ;
  340. }
  341. this.setData({
  342. 'worker.socialSecurity': event.detail.value.key,
  343. 'worker.socialSecurityName': event.detail.value.value,
  344. showShebao: false,
  345. });
  346. },
  347. showHukou:function(){
  348. this.setData({
  349. showHukou: true,
  350. });
  351. },
  352. onHukouCancel:function(){
  353. this.setData({
  354. showHukou: false,
  355. });
  356. },
  357. onHukouConfirm:function(event){
  358. console.log(event.detail);
  359. this.setData({
  360. 'worker.residenceType': event.detail.value.key,
  361. 'worker.residenceTypeName': event.detail.value.value,
  362. showHukou: false,
  363. });
  364. },
  365. onHealthEndCancel: function () {
  366. this.setData({
  367. showHealthEnd: false,
  368. });
  369. },
  370. onHealthEndConfirm: function (event) {
  371. let date = util.toDate(event.detail / 1000, true, '');
  372. this.setData({
  373. 'worker.expirationDateEnd': date,
  374. showHealthEnd: false,
  375. });
  376. },
  377. onHealthStartCancel: function () {
  378. this.setData({
  379. showHealthStart: false,
  380. });
  381. },
  382. onHealthStartConfirm: function (event) {
  383. let date = util.toDate(event.detail / 1000, true, '');
  384. console.info(date)
  385. this.setData({
  386. 'worker.expirationDateStart': date,
  387. showHealthStart: false,
  388. });
  389. },
  390. onIssuanceDateCancel: function () {
  391. this.setData({
  392. showIssuanceDate: false,
  393. });
  394. },
  395. onIssuanceDateConfirm: function (event) {
  396. let date = util.toDate(event.detail / 1000, true, '');
  397. console.info(date)
  398. this.setData({
  399. 'worker.issuanceDate': date,
  400. showIssuanceDate: false,
  401. });
  402. },
  403. onServiceItemCancel: function () {
  404. this.setData({
  405. showServiceItem: false,
  406. });
  407. },
  408. onServiceItemConfirm: function (event) {
  409. this.setData({
  410. 'worker.workType': event.detail.value,
  411. showServiceItem: false,
  412. });
  413. },
  414. onExperienceCancel: function () {
  415. this.setData({
  416. showExperience: false,
  417. });
  418. },
  419. onExperienceConfirm: function (event) {
  420. this.setData({
  421. 'worker.experience': event.detail.value,
  422. showExperience: false,
  423. });
  424. },
  425. onEducationCancel: function () {
  426. this.setData({
  427. showEducation: false,
  428. });
  429. },
  430. onEducationConfirm: function (event) {
  431. this.setData({
  432. 'worker.education': event.detail.value,
  433. showEducation: false,
  434. });
  435. },
  436. onCityCancel: function () {
  437. this.setData({
  438. showCity: false,
  439. });
  440. },
  441. onCityConfirm: function (event) {
  442. this.setData({
  443. 'worker.city': event.detail.value,
  444. showCity: false,
  445. });
  446. },
  447. uploadHeadPic(){
  448. var that = this;
  449. wx.chooseImage({
  450. count: 1,
  451. sizeType: ['original', 'compressed'],
  452. sourceType: ['album', 'camera'],
  453. success: function (res) {
  454. let file=res.tempFilePaths[0];
  455. that.upload(file,'head');
  456. }
  457. })
  458. },
  459. uploadHealth(){
  460. var that = this;
  461. wx.chooseImage({
  462. count: 1,
  463. sizeType: ['original', 'compressed'],
  464. sourceType: ['album', 'camera'],
  465. success: function (res) {
  466. let file=res.tempFilePaths[0];
  467. that.upload(file,'health');
  468. }
  469. })
  470. },
  471. upload: function (path,type) {
  472. var that = this;
  473. const uploadTask = wx.uploadFile({
  474. url: api.StorageUpload(),
  475. filePath: path, //res.tempFilePaths[0],
  476. name: 'file',
  477. success: function (res) {
  478. var _res = JSON.parse(res.data);
  479. if (_res.errno === 0) {
  480. var url = _res.data.fileUrl
  481. if(type=='head'){
  482. that.setData({
  483. headPic:url,
  484. 'worker.headPic':url
  485. });
  486. }else{
  487. that.setData({
  488. certificateFileUrl:[url],
  489. 'worker.certificateFileUrl':[url]
  490. });
  491. }
  492. }
  493. },
  494. fail: function (e) {
  495. wx.showModal({
  496. title: '错误',
  497. content: '上传失败',
  498. showCancel: false
  499. })
  500. },
  501. })
  502. },
  503. chooseImage: function (e) {
  504. var that = this;
  505. let type = e.currentTarget.dataset.type;
  506. console.info(type)
  507. wx.chooseImage({
  508. count: 1,
  509. sizeType: ['original', 'compressed'],
  510. sourceType: ['album', 'camera'],
  511. success: function (res) {
  512. if (type == "back")
  513. that.setData({
  514. idBack: res.tempFilePaths[0]
  515. });
  516. else
  517. that.setData({
  518. idFront: res.tempFilePaths[0]
  519. });
  520. }
  521. })
  522. },
  523. uploadIdFrontImage: function () {
  524. if (this.data.idBack == '' || this.data.idFront == '') {
  525. util.showErrorToast('请选择身份证照片');
  526. return;
  527. }
  528. wx.showLoading({
  529. title: '识别正面',
  530. })
  531. var that = this;
  532. wx.uploadFile({
  533. url: api.ServantPerfectOCR(),
  534. filePath: that.data.idFront,
  535. name: 'file',
  536. formData: {
  537. type: 'front'
  538. },
  539. header: {
  540. 'Content-Type': 'multipart/form-data',
  541. 'X-JZ-Token': wx.getStorageSync('token')
  542. },
  543. success: function (res) {
  544. wx.hideLoading();
  545. var _res = JSON.parse(res.data);
  546. console.info(_res)
  547. if (_res.errno === 0) {
  548. //赋值
  549. var data=_res.data;
  550. console.log(data);
  551. that.setData({
  552. 'worker.workerIdcard': data.workerIdcard,
  553. 'worker.workerName': data.workerName,
  554. 'worker.idcardAddress': data.idcardAddress,
  555. 'worker.gender': data.gender,
  556. 'worker.nation': data.nation,
  557. 'worker.nativePlace': data.nativePlace
  558. })
  559. that.uploadIdBackImage();
  560. } else {
  561. wx.showModal({
  562. title: '错误',
  563. content: _res.errmsg,
  564. showCancel: false
  565. })
  566. }
  567. },
  568. fail: function (e) {
  569. console.info(e)
  570. wx.hideLoading();
  571. wx.showModal({
  572. title: '错误',
  573. content: '请重新选择正反面后上传',
  574. showCancel: false
  575. })
  576. },
  577. })
  578. },
  579. uploadIdBackImage: function () {
  580. wx.showLoading({
  581. title: '识别反面',
  582. })
  583. var that = this;
  584. const uploadTask = wx.uploadFile({
  585. url: api.ServantPerfectOCR(),
  586. filePath: that.data.idBack,
  587. name: 'file',
  588. formData: {
  589. type: 'back'
  590. },
  591. header: {
  592. 'Content-Type': 'multipart/form-data',
  593. 'X-JZ-Token': wx.getStorageSync('token')
  594. },
  595. success: function (res) {
  596. wx.hideLoading();
  597. that.getWorkerInfo({
  598. workerNo: that.data.workerNo
  599. });
  600. var _res = JSON.parse(res.data);
  601. console.log(_res);
  602. if (_res.errno === 0) {
  603. var data=_res.data;
  604. console.log(data);
  605. that.setData({
  606. 'worker.idcardStartdate': _res.data.idcardStartdate,
  607. 'worker.break': '到',
  608. 'worker.idcardEnddate': _res.data.idcardEnddate,
  609. })
  610. wx.showToast({
  611. title: '识别成功',
  612. duration: 2000
  613. });
  614. } else {
  615. wx.showModal({
  616. title: '错误',
  617. content: _res.errmsg,
  618. showCancel: false
  619. })
  620. }
  621. },
  622. fail: function (e) {
  623. console.info(e)
  624. wx.hideLoading();
  625. wx.showModal({
  626. title: '错误',
  627. content: '上传失败',
  628. showCancel: false
  629. })
  630. },
  631. })
  632. },
  633. previewImage: function (e) {
  634. wx.previewImage({
  635. current: e.currentTarget.id, // 当前显示图片的http链接
  636. urls: [e.currentTarget.id] // 需要预览的图片http链接列表
  637. })
  638. },
  639. onLoad: function (options) {
  640. let hasLogin=app.globalData.hasLogin;
  641. this.setData({
  642. hasLogin:hasLogin
  643. });
  644. if(hasLogin){
  645. // 通过workerno获取信息
  646. let userInfo = wx.getStorageSync('userInfo');
  647. if(userInfo && userInfo.workerNo){
  648. let workerNo=userInfo.workerNo;
  649. this.setData({
  650. workerNo:workerNo
  651. });
  652. this.getWorkerInfo({
  653. workerNo:workerNo
  654. });
  655. }
  656. }else{
  657. // 通过手机号获取信息
  658. }
  659. },
  660. onReady: function () {
  661. },
  662. onShow: function () {
  663. // wx.hideHomeButton();
  664. },
  665. onHide: function () {
  666. // 页面隐藏
  667. },
  668. onUnload: function () {
  669. // 页面关闭
  670. }
  671. })