editpersonalinformation.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. <template>
  2. <view class="content">
  3. <view class='content1'>
  4. <view class="title">上传身份证人像面</view>
  5. <view @click.stop="uploadImg(1,index)" class="picture picture1" v-if="!dataDetails.cardAddressUrl">
  6. <image class="xj-image" src="@/static/mine/ic_shanchuan@2x.png"></image>
  7. <view class="text">上传身份证人像面</view>
  8. </view>
  9. <view v-if="dataDetails.cardAddressUrl" @click.stop="uploadImg(1,index)" class="preview-card-img picture">
  10. <view @click.stop="delCard(1)">
  11. <image class='del-card' src="@/static/images/common/quxiao@2x.png">
  12. </image>
  13. </view>
  14. <image class="" :src="dataDetails.cardAddressUrl" mode="aspectFit" style=""></image>
  15. </view>
  16. <view class="title">上传身份证国徽面</view>
  17. <view @click="uploadImg(2,index)" class="picture picture2" v-if="!dataDetails.cardBackAddressUrl">
  18. <image class="xj-image" src="@/static/mine/ic_shanchuan@2x.png"></image>
  19. <view class="text">上传身份证国徽面</view>
  20. </view>
  21. <view v-if="dataDetails.cardBackAddressUrl" @click.stop="uploadImg(2,index)"
  22. class="preview-card-img picture">
  23. <!-- <image class="card-img" :src="dataDetails.cardAddressUrl"></image> -->
  24. <view @click.stop="delCard(2)">
  25. <image class='del-card' src="@/static/images/common/quxiao@2x.png">
  26. </image>
  27. </view>
  28. <image class="" :src="dataDetails.cardBackAddressUrl" mode="aspectFit"></image>
  29. </view>
  30. </view>
  31. <view class="content2 content-other">
  32. <view style='padding:5px 0 10px;border-bottom:1px solid #eee;' class="flex width100">
  33. <view style='width:100px;font-size:14px;'>姓名</view>
  34. <view class="flex">
  35. <u--input @input='nameinput' placeholder="输入姓名" inputAlign='left' border="none" v-model="dataDetails.name">
  36. </u--input>
  37. </view>
  38. </view>
  39. <view style='padding:10px 0 5px;border-bottom:1px solid #eee;' class="flex width100">
  40. <view style='width:100px;font-size:14px;'>联系电话</view>
  41. <view class="flex">
  42. <u--input disabledColor='#fff' disabled placeholder="输入联系电话" inputAlign='left' border="none"
  43. v-model="dataDetails.phone">
  44. </u--input>
  45. </view>
  46. </view>
  47. <view class="flex row" style='padding:10px 0 5px;border-bottom:1px solid #eee;'>
  48. <view style='width:100px;font-size:14px;'>性别</view>
  49. <u-radio-group v-model="dataDetails.sex" placement="row">
  50. <u-radio :customStyle="radioCustomStyle" v-for="(item, index) in radiolist1" :key="index"
  51. :label="item.name" :name="item.name" @change="radioChange">
  52. </u-radio>
  53. </u-radio-group>
  54. </view>
  55. <view class="flex row row-ch" style='padding:10px 0 5px;'>
  56. <view style='width:100px;font-size:14px;'>称呼</view>
  57. <u--input placeholder="输入姓氏" class="ch-style" inputAlign='left' border="none"
  58. v-model="dataDetails.call">
  59. </u--input>
  60. <view class="flex align-center" >{{sexText}}</view>
  61. </view>
  62. <view class="flex row">
  63. <view class="left-text">身份证号</view>
  64. <u--input :disabled='dataDetails.id' placeholder="请输入身份证号" inputAlign='left' border="none" v-model="dataDetails.cardNumber">
  65. </u--input>
  66. </view>
  67. <view class="flex row noborder">
  68. <view class="left-text">身份证截止日期</view>
  69. <view style='font-size:16px;width:50%;' class='flex flex-space-between' @click="selectValidityPeriod">
  70. <view :style="{'color':dataDetails.cardValidityDate ? '#000':'#C6CBD5'}">
  71. {{dataDetails.cardValidityDate?dataDetails.cardValidityDate:'选择身份证截止日期'}}
  72. </view>
  73. <view>
  74. <u-icon name="arrow-right" color="#7E7E7E" size="10"></u-icon>
  75. </view>
  76. </view>
  77. </view>
  78. <view class="bz">注:个人信息审核通过后自动认证成为个人货主。</view>
  79. <u-picker :show="isShowcardValidity" ref="uPicker" :columns="validityPeriod"
  80. @confirm="confirmValidityPeriod" @change="changeHandler" @cancel="isShowcardValidity=false">
  81. </u-picker>
  82. </view>
  83. <view class="content4">
  84. <view style='margin:0 0 18px;font-size:12px;color:#999;' class='flex items-center'>
  85. <u--image style='margin-right:5px;' @click='consent'
  86. :src="checked?'../../../static/mine/duihao@2x.png':'../../../static/mine/wxz.png'" width="12px"
  87. height="12px"></u--image>
  88. 我已阅读并同意全部细则
  89. </view>
  90. <view class='line'></view>
  91. <view class="next-btn" @click="submit()">
  92. 提交
  93. </view>
  94. </view>
  95. <!-- <view class="flex flex-space-between width100">
  96. <view>收款人</view>
  97. <view class="flex">
  98. <u--input placeholder="输入收款人姓名" inputAlign='right' border="none" v-model="dataDetails.name">
  99. </u--input>
  100. </view>
  101. </view> -->
  102. <u-action-sheet :actions="$helper.imgTypeList" :title="$helper.imgType" :show="isShowimgType"
  103. @select="imgTypeSelect" @cancel='isShowimgType=false' :closeOnClickOverlay="true" :closeOnClickAction="true"
  104. @close="isShowimgType=false">
  105. </u-action-sheet>
  106. <u-toast ref="uToast"></u-toast>
  107. </view>
  108. </template>
  109. <script>
  110. import {
  111. mapState
  112. } from 'vuex';
  113. import upload from '@/components/upload.vue';
  114. import uploadImage from '@/components/ossutil/uploadFile.js';
  115. var _this;
  116. export default {
  117. components: {},
  118. data() {
  119. return {
  120. radioCustomStyle: {
  121. margin: '0 0 0 20rpx'
  122. },
  123. radiolist1: [{
  124. name: '男',
  125. disabled: false
  126. },
  127. {
  128. name: '女',
  129. disabled: false
  130. },
  131. ],
  132. sexText:"先生",
  133. uploadType: '',
  134. isShowimgType: false,
  135. dataDetails: {
  136. name: '',
  137. phone: '',
  138. commonId: '',
  139. cardNumber: '',
  140. cardAddressUrl: '',
  141. cardBackAddressUrl: '',
  142. cardValidityDate: '',
  143. driverSex: '男',
  144. sex:''
  145. },
  146. checked: false,
  147. isShowcardValidity: false,
  148. imagesrc: '',
  149. validityPeriod: [],
  150. isShowimgType: false,
  151. index: '',
  152. };
  153. },
  154. onLoad(options) {
  155. var _this = this;
  156. this.dataDetails = options
  157. this.validityPeriod = this.$helper.makeValidityPeriod(0, '长期')
  158. this.dataDetails.phone = this.userInfo.phone
  159. this.dataDetails.commonId = this.userInfo.id
  160. },
  161. computed: {
  162. ...mapState(['hasLogin', 'userInfo']),
  163. },
  164. methods: {
  165. nameinput(){
  166. this.dataDetails.call=this.dataDetails.name[0]
  167. },
  168. // 性别切换
  169. radioChange(n) {
  170. this.dataDetails.sex = n
  171. console.log('radioChange', this.dataDetails.sex);
  172. if(n == "男"){
  173. this.sexText = "先生"
  174. }
  175. else{
  176. this.sexText = "女士"
  177. }
  178. },
  179. consent() {
  180. this.checked = !this.checked
  181. },
  182. selectValidityPeriod() {
  183. this.isShowcardValidity = true
  184. },
  185. //设置图片
  186. setImage(e) {
  187. //
  188. console.log(e);
  189. //显示在页面
  190. //this.imagesrc = e.path;
  191. if (e.dotype == 'idphoto') {
  192. _this.zjzClipper(e.path);
  193. } else if (e.dotype == 'watermark') {
  194. _this.watermark(e.path);
  195. } else {
  196. _this.savePhoto(e.path);
  197. }
  198. },
  199. //保存图片到相册,方便核查
  200. savePhoto(path) {
  201. //
  202. this.imagesrc = path;
  203. uploadImage('image',path, 'appData/',
  204. result => {
  205. // 上传成功
  206. console.log('图片地址', result)
  207. }
  208. )
  209. //保存到相册
  210. // uni.saveImageToPhotosAlbum({
  211. // filePath: path,
  212. // success: () => {
  213. // uni.showToast({
  214. // title: '已保存至相册',
  215. // duration: 2000
  216. // });
  217. // }
  218. // });
  219. },
  220. changeHandler(e) {
  221. const {
  222. columnIndex,
  223. value,
  224. values,
  225. index,
  226. picker = this.$refs.uPicker
  227. } = e
  228. // if (columnIndex === 0) {
  229. //
  230. // if (e.index != 0) {
  231. // picker.setColumnValues(1, this.validityPeriod[1].shift())
  232. // }
  233. // } else if (columnIndex === 1) {
  234. // if (e.index != 0) {
  235. // picker.setColumnValues(2, this.validityPeriod[2].shift())
  236. // }
  237. // }
  238. },
  239. confirmValidityPeriod(e) {
  240. console.log('confirm', e)
  241. if (e.value[0] == '长期') {
  242. this.dataDetails.cardValidityDate = e.value[0]
  243. } else {
  244. this.dataDetails.cardValidityDate = e.value[0] + '-' + e.value[1] + '-' + e.value[2]
  245. }
  246. this.isShowcardValidity = false
  247. },
  248. uploadImg(type, index) {
  249. this.uploadType = type
  250. this.isShowimgType = true
  251. this.index = index
  252. },
  253. validate() {
  254. if (uni.$u.test.isEmpty(this.dataDetails.name)) {
  255. this.$refs.uToast.show({
  256. type: 'error',
  257. message: "姓名不能为空!",
  258. })
  259. return true
  260. }
  261. if (this.dataDetails.name.length<2||this.dataDetails.name.length>10) {
  262. this.$refs.uToast.show({
  263. type: 'error',
  264. message: "姓名输入错误!",
  265. })
  266. return true
  267. }
  268. if (this.dataDetails.call.length>4) {
  269. this.$refs.uToast.show({
  270. type: 'error',
  271. message: "称呼输入错误!",
  272. })
  273. return true
  274. }
  275. if (uni.$u.test.isEmpty(this.dataDetails.cardNumber)) {
  276. this.$refs.uToast.show({
  277. type: 'error',
  278. message: "身份证号不能为空!",
  279. })
  280. return true
  281. }
  282. if (this.dataDetails.cardNumber.length<18) {
  283. this.$refs.uToast.show({
  284. type: 'error',
  285. message: "身份证号输入错误!",
  286. })
  287. return true
  288. }
  289. },
  290. submit() {
  291. if (this.validate()) return
  292. uni.showLoading({
  293. title: '加载中',
  294. mask: true
  295. })
  296. var _this = this
  297. this.$request.baseRequest('post', '/cargoOwnerInfo/api/editCargoOwner', _this.dataDetails).then(res => {
  298. uni.hideLoading()
  299. uni.$u.toast('提交成功')
  300. // uni.$u.route('/pages/mine/cargoowner/cargoowner')
  301. uni.navigateBack({
  302. delta:1
  303. })
  304. })
  305. .catch(res => {
  306. uni.hideLoading()
  307. uni.showToast({
  308. title: res.message,
  309. icon: 'none',
  310. duration: 2000
  311. })
  312. });
  313. },
  314. photograph() {
  315. console.log('拍照')
  316. let that = this;
  317. uni.chooseImage({
  318. count: 1,
  319. success: function(res) {
  320. console.log(JSON.stringify(res.tempFilePaths));
  321. uploadImage('image',res.tempFilePaths[0], 'appData/',
  322. result => {
  323. // 上传成功
  324. console.log('图片地址', result)
  325. }
  326. )
  327. }
  328. });
  329. },
  330. imgTypeSelect(val) {
  331. let that = this
  332. console.log(val)
  333. console.log(this.uploadType)
  334. if (val.name == '相册') {
  335. uni.chooseImage({
  336. count: 1,
  337. sourceType: this.$helper.chooseImage.sourceType,
  338. success: function(res) {
  339. console.log(JSON.stringify(res.tempFilePaths));
  340. uploadImage('image',res.tempFilePaths[0], 'appData/',
  341. result => {
  342. // 上传成功回调函数
  343. console.log('图片地址', result)
  344. switch (that.uploadType) {
  345. // 身份正面
  346. case 1:
  347. that.dataDetails.cardAddressUrl = result
  348. // 识别
  349. that.$request.baseRequest('get',
  350. '/driverInfo/personShibie', {
  351. personImg: result,
  352. }).then(res => {
  353. that.dataDetails.cardNumber = res.data.recPersonNo
  354. //性别设置默认
  355. let i = res.data.recPersonNo.substr(16,1)
  356. if(i%2 == 0){
  357. that.dataDetails.sex = "女"
  358. that.sexText = "女士"
  359. }else{
  360. that.dataDetails.sex = "男"
  361. that.sexText = "先生"
  362. }
  363. if (!that.dataDetails.name) {
  364. that.dataDetails.name = res.data.recPerson
  365. }
  366. that.$forceUpdate()
  367. })
  368. .catch(res => {
  369. uni.$u.toast(res.message);
  370. });
  371. break
  372. // 身份反面
  373. case 2:
  374. that.dataDetails.cardBackAddressUrl = result
  375. that.$forceUpdate()
  376. break
  377. }
  378. }
  379. )
  380. }
  381. });
  382. } else {
  383. switch (this.uploadType) {
  384. case 1:
  385. uni.$u.route('/pages/mine/camera/idcard/idcard?dotype=idcardface');
  386. console.log('身份正面')
  387. break
  388. case 2:
  389. uni.$u.route('/pages/mine/camera/idcard/idcard?dotype=badge');
  390. console.log('身份反面')
  391. break
  392. }
  393. }
  394. },
  395. //身份证正面
  396. getImgUrl1(src) {
  397. // console.log(src)
  398. // console.log('------------res-----------')
  399. // let that = this;
  400. // that.id[0] = src
  401. // that.id1 = src
  402. // that.certificates = false
  403. // that.personImgs.personImg = that.id[0]
  404. // that.$api.doRequest('get', '/driverViewInfo/personShibie', that
  405. // .personImgs).then(res => {
  406. // if (res.data.data.recPerson != null) {
  407. // if (res.data.data.recPerson != "") {
  408. // that.$set(that.DriverViewInfo, 'driverName', res
  409. // .data.data.recPerson)
  410. // }
  411. // }
  412. // if (res.data.data.recPersonNo != null) {
  413. // if (res.data.data.recPersonNo != "") {
  414. // that.$set(that.DriverViewInfo, 'numberCard', res
  415. // .data.data.recPersonNo)
  416. // }
  417. // }
  418. // }).catch(res => {
  419. // uni.showToast({
  420. // title: res.data.message,
  421. // icon: 'none',
  422. // duration: 2000
  423. // })
  424. // })
  425. },
  426. },
  427. };
  428. </script>
  429. <style lang="scss" scoped>
  430. /deep/.content{
  431. margin-bottom:160px;
  432. }
  433. // .preview-card-img {
  434. // /deep/uni-image>div, uni-image>img {
  435. // transform: scale(1.5) rotate(-90deg);
  436. // }
  437. // }
  438. /deep/.uni-input-input:disabled{
  439. background:#fff;
  440. }
  441. .picture {
  442. margin-top: 20rpx;
  443. background: #F5F6FA;
  444. width: 212rpx;
  445. height: 212rpx;
  446. border-radius: 20rpx;
  447. display: flex;
  448. flex-direction: column;
  449. justify-content: center;
  450. align-items: center;
  451. color: #6A7282;
  452. }
  453. .content1 {
  454. background: white;
  455. margin: 20rpx;
  456. padding: 20rpx;
  457. border-radius: 20rpx;
  458. .row-ch {
  459. padding-right: 180rpx;
  460. box-sizing: border-box;
  461. // background-color: red;
  462. }
  463. }
  464. .content2 {
  465. margin: 10px 0 95px 0;
  466. .left-text {
  467. // background: red;
  468. width: 290rpx;
  469. color: #333333;
  470. display: flex;
  471. align-items: center;
  472. font-size: 14px;
  473. }
  474. .row {
  475. border-bottom: 1px solid #EEEEEE;
  476. padding-bottom: 28rpx;
  477. margin-top: 26rpx;
  478. .ch-style {
  479. text-align: left;
  480. }
  481. }
  482. .row-ch {
  483. padding-right: 180rpx;
  484. box-sizing: border-box;
  485. // background-color: red;
  486. }
  487. }
  488. .content2,
  489. .content3 {
  490. .del-bank {
  491. position: absolute;
  492. top: 0;
  493. right: 0;
  494. width: 80rpx;
  495. height: 80rpx;
  496. }
  497. }
  498. .picture {
  499. width: 100%;
  500. height: 440rpx;
  501. position: relative;
  502. .text {
  503. margin-top: 20rpx;
  504. }
  505. }
  506. .xj-image {
  507. width: 100rpx;
  508. height: 100rpx;
  509. }
  510. .title {
  511. color: #999999;
  512. margin: 20rpx 0;
  513. font-size: 14px;
  514. }
  515. .u-input {
  516. font-size: 16px;
  517. }
  518. .content4 {
  519. position: fixed;
  520. bottom: 0;
  521. background: white;
  522. width: 100%;
  523. text-align: center;
  524. left: 0;
  525. box-sizing: border-box;
  526. ;
  527. padding: 10px 15px;
  528. .line {
  529. position: absolute;
  530. left: 0;
  531. margin-top: -9px;
  532. border-top: 1px solid #eee;
  533. width: 100%;
  534. }
  535. .next-btn {
  536. background: #2772FB;
  537. width: 85%;
  538. padding: 20rpx 20rpx;
  539. text-align: center;
  540. color: white;
  541. border-radius: 50rpx;
  542. margin: 0 auto;
  543. margin-top: 10px;
  544. }
  545. }
  546. .del-card {
  547. position: absolute;
  548. top: -10rpx;
  549. right: -6rpx;
  550. width: 80rpx;
  551. height: 80rpx;
  552. z-index: 9;
  553. }
  554. .bz{
  555. font-size: 28rpx;
  556. }
  557. .picture1 {
  558. background: url(../../../static/mine/zm.png);
  559. background-size: 100% 100%;
  560. }
  561. .picture2 {
  562. background: url(../../../static/mine/gh.png);
  563. background-size: 100% 100%;
  564. }
  565. .picture3 {
  566. background: url(../../../static/mine/yhkzm.png);
  567. background-size: 100% 100%;
  568. }
  569. </style>