filling.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <view class="page">
  3. <view class="notice">
  4. <u-icon name="info-circle-fill" color="#AC9146" size="30" top="3" />
  5. <text>准确填写个人信息,可享受每份代驾订单人身意外险</text>
  6. </view>
  7. <view class="credentials-container">
  8. <view class="credentials">
  9. <image :src="cardBackground[0]" class="bg"></image>
  10. <view class="cover">
  11. <image src="../static/filling/card.png" mode="widthFix" class="card"></image>
  12. <text class="desc">身份证正面</text>
  13. <ocr-navigator @onSuccess="scanIdcardFront" certificateType="idCard" :opposite="false"><button class="camera"></button></ocr-navigator>
  14. </view>
  15. </view>
  16. <view class="credentials">
  17. <image :src="cardBackground[1]" class="bg"></image>
  18. <view class="cover">
  19. <image src="../static/filling/card.png" mode="widthFix" class="card"></image>
  20. <text class="desc">身份证背面</text>
  21. <ocr-navigator @onSuccess="scanIdcardBack" certificateType="idCard" :opposite="true"><button class="camera"></button></ocr-navigator>
  22. </view>
  23. </view>
  24. <view class="credentials">
  25. <image :src="cardBackground[2]" class="bg"></image>
  26. <view class="cover">
  27. <image src="../static/filling/card.png" mode="widthFix" class="card"></image>
  28. <text class="desc">手持身份证</text>
  29. <button class="camera" @tap="takePhoto('idcardHolding')"></button>
  30. </view>
  31. </view>
  32. <view class="credentials">
  33. <image :src="cardBackground[3]" class="bg"></image>
  34. <view class="cover">
  35. <image src="../static/filling/card.png" mode="widthFix" class="card"></image>
  36. <text class="desc">驾驶证正面</text>
  37. <ocr-navigator @onSuccess="scanDrcardFront" certificateType="driverslicense"><button class="camera"></button></ocr-navigator>
  38. </view>
  39. </view>
  40. <view class="credentials">
  41. <image :src="cardBackground[4]" class="bg"></image>
  42. <view class="cover">
  43. <image src="../static/filling/card.png" mode="widthFix" class="card"></image>
  44. <text class="desc">驾驶证背面</text>
  45. <button class="camera" @tap="takePhoto('drcardBack')"></button>
  46. </view>
  47. </view>
  48. <view class="credentials">
  49. <image :src="cardBackground[5]" class="bg"></image>
  50. <view class="cover">
  51. <image src="../static/filling/card.png" mode="widthFix" class="card"></image>
  52. <text class="desc">手持驾驶证</text>
  53. <button class="camera" @tap="takePhoto('drcardHolding')"></button>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="title">个人信息</view>
  58. <view class="list">
  59. <u-cell-group border="false">
  60. <u-cell-item title="真实姓名" :value="idcard.name" :value-style="style" :arrow="false" />
  61. <u-cell-item title="性别" :value="idcard.sex" :value-style="style" :arrow="false" />
  62. <u-cell-item title="生日" :value="idcard.birthday" :value-style="style" :arrow="false" />
  63. <u-cell-item title="身份证号" :value="idcard.pid" :value-style="style" :arrow="false" />
  64. <u-cell-item title="身份证地址"
  65. :value="idcard.shortAddress"
  66. :value-style="style"
  67. @click="showAddressContent" />
  68. <u-cell-item title="身份证有效期" :value="idcard.expiration" :value-style="style" :arrow="false" />
  69. </u-cell-group>
  70. </view>
  71. <view class="title">联系方式</view>
  72. <view class="list">
  73. <u-cell-group border="false">
  74. <u-cell-item title="手机号码" :value="contact.tel" :value-style="style" @click="enterContent('手机号码', 'tel')" />
  75. <u-cell-item title="电子信箱" :value="contact.shortEmail" :value-style="style" @click="enterContent('电子信箱', 'email')" />
  76. <u-cell-item title="收信地址" :value="contact.shortMailAddress" :value-style="style" @click="enterContent('收信地址', 'mailAddress')" />
  77. <u-cell-item title="紧急联系人" :value="contact.contactName" :value-style="style" @click="enterContent('紧急联系人', 'contactName')" />
  78. <u-cell-item title="紧急联系人电话" :value="contact.contactTel" :value-style="style" @click="enterContent('紧急联系人电话', 'contactTel')" />
  79. </u-cell-group>
  80. </view>
  81. <view class="title">驾驶证</view>
  82. <view class="list">
  83. <u-cell-group border="false">
  84. <u-cell-item title="驾驶证类型" :value="drcard.carClass" :value-style="style" :arrow="false" />
  85. <u-cell-item title="驾驶证有效期" :value="drcard.validTo" :value-style="style" :arrow="false" />
  86. <u-cell-item title="初次领证日期" :value="drcard.issueDate" :value-style="style" :arrow="false" />
  87. </u-cell-group>
  88. </view>
  89. <button class="btn" @tap="save" :disabled="realAuth == 3">保存信息</button>
  90. <view class="remark">您每次提交实名信息之后,都需要工作人员严格审查,请等候1~3天,这期间您将无法接单,特此声明!</view>
  91. <u-toast ref="uToast" />
  92. </view>
  93. </template>
  94. <script>
  95. let dayjs = require('dayjs');
  96. export default {
  97. data() {
  98. return {
  99. mode: 'fill',
  100. style: {
  101. color: '#FF9900'
  102. },
  103. cardBackground: [
  104. '../static/filling/credentials-bg.jpg',
  105. '../static/filling/credentials-bg.jpg',
  106. '../static/filling/credentials-bg.jpg',
  107. '../static/filling/credentials-bg.jpg',
  108. '../static/filling/credentials-bg.jpg',
  109. '../static/filling/credentials-bg.jpg'
  110. ],
  111. idcard: {
  112. pid: '',
  113. name: '',
  114. sex: '',
  115. address: '',
  116. shortAddress: '',
  117. birthday: '',
  118. expiration: '',
  119. idcardFront: '',
  120. idcardBack: '',
  121. idcardHolding: ''
  122. },
  123. contact: {
  124. tel: '',
  125. email: '',
  126. shortEmail: '',
  127. mailAddress: '',
  128. shortMailAddress: '',
  129. contactName: '',
  130. contactTel: ''
  131. },
  132. drcard: {
  133. issueDate: '',
  134. carClass: '',
  135. validFrom: '',
  136. validTo: '',
  137. drcardFront: '',
  138. drcardBack: '',
  139. drcardHolding: ''
  140. },
  141. cosImg: [],
  142. currentImg: {},
  143. realAuth: uni.getStorageSync('realAuth')
  144. };
  145. },
  146. methods: {
  147. scanIdcardFront: function(resp) {
  148. let that = this;
  149. let detail = resp.detail;
  150. that.idcard.pid = detail.id.text;
  151. that.idcard.name = detail.name.text;
  152. that.idcard.sex = detail.gender.text;
  153. that.idcard.address = detail.address.text;
  154. //需要缩略身份证地址,文字太长页面显示不了
  155. that.idcard.shortAddress = detail.address.text.substr(0, 15) + '...';
  156. that.idcard.birthday = detail.birth.text;
  157. //OCR插件拍摄到的身份证正面照片存储地址
  158. that.idcard.idcardFront = detail.image_path;
  159. //让身份证View标签加载身份证正面照片
  160. that.cardBackground[0] = detail.image_path;
  161. that.uploadCos(that.url.uploadCosPrivateFile, detail.image_path, 'driverAuth', function(resp) {
  162. let data = JSON.parse(resp.data);
  163. let path = data.path;
  164. that.currentImg['idcardFront'] = path;
  165. that.cosImg.push(path);
  166. });
  167. },
  168. scanIdcardBack: function(resp) {
  169. let that = this;
  170. let detail = resp.detail;
  171. //OCR插件拍摄到的身份证背面照片存储地址
  172. that.idcard.idcardBack = detail.image_path;
  173. //View标签加载身份证背面照片
  174. that.cardBackground[1] = detail.image_path;
  175. let validDate = detail.valid_date.text.split('-')[1];
  176. that.idcard.expiration = dayjs(validDate, 'YYYYMMDD').format('YYYY-MM-DD');
  177. that.uploadCos(that.url.uploadCosPrivateFile, detail.image_path, 'driverAuth', function(resp) {
  178. let data = JSON.parse(resp.data);
  179. let path = data.path;
  180. that.currentImg['idcardBack'] = path;
  181. that.cosImg.push(path);
  182. });
  183. },
  184. scanDrcardFront: function(resp) {
  185. let that = this;
  186. let detail = resp.detail;
  187. that.drcard.issueDate = detail.issue_date.text; //初次领证日期
  188. that.drcard.carClass = detail.car_class.text; //准驾车型
  189. that.drcard.validFrom = detail.valid_from.text; //驾驶证起始有效期
  190. that.drcard.validTo = detail.valid_to.text; //驾驶证截止有效期
  191. that.drcard.drcardFront = detail.image_path;
  192. that.cardBackground[3] = detail.image_path;
  193. that.uploadCos(that.url.uploadCosPrivateFile, detail.image_path, 'driverAuth', function(resp) {
  194. let data = JSON.parse(resp.data);
  195. let path = data.path;
  196. that.currentImg['drcardFront'] = path;
  197. that.cosImg.push(path);
  198. });
  199. },
  200. updatePhoto: function(type, path) {
  201. let that = this;
  202. that.uploadCos(that.url.uploadCosPrivateFile, path, 'driverAuth', function(resp) {
  203. let data = JSON.parse(resp.data);
  204. that.cosImg.push(data.path);
  205. if (type == 'idcardHolding') {
  206. that.cardBackground[2] = path;
  207. that.currentImg['idcardHolding'] = data.path;
  208. that.idcard.idcardHolding = data.path;
  209. } else if (type == 'drcardBack') {
  210. that.cardBackground[4] = path;
  211. that.currentImg['drcardBack'] = data.path;
  212. that.idcard.drcardBack = data.path;
  213. } else if (type == 'drcardHolding') {
  214. that.cardBackground[5] = path;
  215. that.currentImg['drcardHolding'] = data.path;
  216. that.idcard.drcardHolding = data.path;
  217. }
  218. });
  219. that.$forceUpdate();
  220. },
  221. takePhoto: function(type) {
  222. uni.navigateTo({
  223. url: '../identity_camera/identity_camera?type=' + type
  224. });
  225. },
  226. enterContent: function(title, key) {
  227. let that = this;
  228. uni.showModal({
  229. title: title,
  230. editable: true,
  231. content: that.contact[key],
  232. success: function(resp) {
  233. if (resp.confirm) {
  234. if (key == 'mailAddress') {
  235. that.contact['shortMailAddress'] = resp.content.substr(0, 15) + (resp.content.length > 15 ? '...' : '');
  236. } else if (key == 'email') {
  237. that.contact['shortEmail'] = resp.content.substr(0, 25) + (resp.content.length > 25 ? '...' : '');
  238. }
  239. that.contact[key] = resp.content;
  240. }
  241. }
  242. });
  243. },
  244. save: function() {
  245. let that = this;
  246. //判断是否设置了6张照片
  247. if (Object.keys(that.currentImg).length != 6) {
  248. that.$refs.uToast.show({
  249. title: '证件上传不完整',
  250. type: 'error'
  251. });
  252. }
  253. //执行前端验证
  254. else if (
  255. that.checkValidTel(that.contact.tel, '手机号码') &&
  256. that.checkValidEmail(that.contact.email, '电子信箱') &&
  257. that.checkValidAddress(that.contact.mailAddress, '收信地址') &&
  258. that.checkValidName(that.contact.contactName, '联系人') &&
  259. that.checkValidTel(that.contact.contactTel, '联系人电话')
  260. ) {
  261. uni.showModal({
  262. title: '提示信息',
  263. content: '确认提交实名资料?',
  264. success: function(resp) {
  265. if (resp.confirm) {
  266. //比较哪些照片需要删除
  267. let temp = [];
  268. let values = [];
  269. //从JSON中获取6张证件照片的云端存储地址
  270. for (let key in that.currentImg) {
  271. let path = that.currentImg[key];
  272. values.push(path);
  273. }
  274. //判断cosImg数组里面哪些图片的云端地址不是6张图片的,这些图片要在云端删除
  275. for (let one of that.cosImg) {
  276. if (!values.includes(one)) {
  277. temp.push(one);
  278. }
  279. }
  280. if (temp.length > 0) {
  281. //删除云端文件
  282. that.ajax(that.url.deleteCosPrivateFile, 'POST', JSON.stringify({ pathes: temp }), function() {
  283. console.log('文件删除成功');
  284. });
  285. }
  286. //需要上传的实名认证数据
  287. let data = {
  288. pid: that.idcard.pid,
  289. name: that.idcard.name,
  290. sex: that.idcard.sex,
  291. birthday: that.idcard.birthday,
  292. tel: that.contact.tel,
  293. email: that.contact.email,
  294. mailAddress: that.contact.mailAddress,
  295. contactName: that.contact.contactName,
  296. contactTel: that.contact.contactTel,
  297. idcardAddress: that.idcard.address,
  298. idcardFront: that.currentImg.idcardFront,
  299. idcardBack: that.currentImg.idcardBack,
  300. idcardHolding: that.currentImg.idcardHolding,
  301. idcardExpiration: that.idcard.expiration,
  302. drcardType: that.drcard.carClass,
  303. drcardExpiration: that.drcard.validTo,
  304. drcardIssueDate: that.drcard.issueDate,
  305. drcardFront: that.currentImg.drcardFront,
  306. drcardBack: that.currentImg.drcardBack,
  307. drcardHolding: that.currentImg.drcardHolding
  308. };
  309. //提交Ajax请求,上传数据
  310. that.ajax(that.url.updateDriverAuth, 'POST', data, function(resp) {
  311. console.log('更新成功');
  312. that.$refs.uToast.show({
  313. title: '资料提交成功',
  314. type: 'success',
  315. callback: function() {
  316. uni.setStorageSync('realAuth', 3); //更新小程序Storage
  317. that.realAuth = 3; //更新模型层
  318. if (that.mode == 'create') {
  319. //提示新注册的司机采集面部数据
  320. uni.navigateTo({
  321. url:"../face_camera/face_camera?mode=create"
  322. })
  323. } else {
  324. //跳转到工作台页面
  325. uni.switchTab({
  326. url: '../../pages/workbench/workbench'
  327. });
  328. }
  329. }
  330. });
  331. });
  332. }
  333. }
  334. });
  335. }
  336. },
  337. showAddressContent: function() {
  338. if (this.idcard.address.length > 0) {
  339. uni.showModal({
  340. title: '身份证地址',
  341. content: this.idcard.address,
  342. showCancel: false
  343. });
  344. }
  345. }
  346. },
  347. onLoad: function(options) {
  348. // console.log(uni.getStorageSync('token'));
  349. let that = this;
  350. that.mode = options.mode;
  351. if(uni.getStorageSync('realAuth')==1){
  352. uni.showModal({
  353. title: '提示信息',
  354. content: '新注册的代驾司机请填写实名认证信息,并且上传相关证件照片',
  355. showCancel: false
  356. });
  357. }else{
  358. that.ajax(that.url.searchDriverAuth,"GET",null,function(resp){
  359. let json=resp.data.result
  360. // console.log(json)
  361. that.idcard.pid=json.pid
  362. that.idcard.name = json.name;
  363. that.idcard.sex = json.sex;
  364. that.idcard.birthday = json.birthday;
  365. that.idcard.address = json.idcardAddress;
  366. that.idcard.shortAddress = json.idcardAddress.substr(0, 15) + (json.idcardAddress.length > 15 ? '...' : '');
  367. that.idcard.expiration = json.idcardExpiration;
  368. that.idcard.idcardFront = json.idcardFront;
  369. if(json.idcardFrontUrl.length>0){
  370. that.cardBackground[0]=json.idcardFrontUrl
  371. }
  372. that.idcard.idcardBack = json.idcardBack;
  373. if (json.idcardBackUrl.length > 0) {
  374. that.cardBackground[1] = json.idcardBackUrl;
  375. }
  376. that.idcard.idcardHolding = json.idcardHolding;
  377. if (json.idcardHoldingUrl.length > 0) {
  378. that.cardBackground[2] = json.idcardHoldingUrl;
  379. }
  380. that.contact.tel = json.tel;
  381. that.contact.email = json.email;
  382. that.contact.shortEmail = json.email.substr(0, 25) + (json.email.length > 25 ? '...' : '');
  383. that.contact.mailAddress = json.mailAddress;
  384. that.contact.shortMailAddress = json.mailAddress.substr(0, 15) + (json.mailAddress.length > 15 ? '...' : '');
  385. that.contact.contactName = json.contactName;
  386. that.contact.contactTel = json.contactTel;
  387. that.drcard.carClass = json.drcardType;
  388. that.drcard.validTo = json.drcardExpiration;
  389. that.drcard.issueDate = json.drcardIssueDate;
  390. that.drcard.drcardFront = json.drcardFront;
  391. if (json.drcardFrontUrl.length > 0) {
  392. that.cardBackground[3] = json.drcardFrontUrl;
  393. }
  394. that.drcard.drcardBack = json.drcardBack;
  395. if (json.drcardBackUrl.length > 0) {
  396. that.cardBackground[4] = json.drcardBackUrl;
  397. }
  398. that.drcard.drcardHolding = json.drcardHolding;
  399. if (json.drcardHoldingUrl.length > 0) {
  400. that.cardBackground[5] = json.drcardHoldingUrl;
  401. }
  402. if(that.idcard.idcardFront.length>0){
  403. that.cosImg.push(that.idcard.idcardFront)
  404. that.currentImg['idcardFront']=that.idcard.idcardFront
  405. }
  406. if (that.idcard.idcardBack.length > 0) {
  407. that.cosImg.push(that.idcard.idcardBack);
  408. that.currentImg['idcardBack'] = that.idcard.idcardBack;
  409. }
  410. if (that.idcard.idcardHolding.length > 0) {
  411. that.cosImg.push(that.idcard.idcardHolding);
  412. that.currentImg['idcardHolding'] = that.idcard.idcardHolding;
  413. }
  414. if (that.drcard.drcardFront.length > 0) {
  415. that.cosImg.push(that.drcard.drcardFront);
  416. that.currentImg['drcardFront'] = that.drcard.drcardFront;
  417. }
  418. if (that.drcard.drcardBack.length > 0) {
  419. that.cosImg.push(that.drcard.drcardBack);
  420. that.currentImg['drcardBack'] = that.drcard.drcardBack;
  421. }
  422. if (that.drcard.drcardHolding.length > 0) {
  423. that.cosImg.push(that.drcard.drcardHolding);
  424. that.currentImg['drcardHolding'] = that.drcard.drcardHolding;
  425. }
  426. })
  427. }
  428. }
  429. };
  430. </script>
  431. <style lang="less">
  432. @import url('filling.less');
  433. </style>