completeInfo.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. <template>
  2. <view>
  3. <ujp-navbar title="完善信息">
  4. <view slot="right" @click="gotoLink" style=" margin-right: 20rpx;"> 跳过</view>
  5. </ujp-navbar>
  6. <view class="data">
  7. <view class="data-img" v-show="!keyShow">
  8. <view class="data-icon">
  9. <u-icon name="camera-fill" custom-prefix="custom-icon" color="#fff" size="32"></u-icon>
  10. </view>
  11. <u-avatar :src="form.headImg+'?x-oss-process=image/resize,m_fill,w_256,h_256'" size="216"
  12. @click="uploadPhoto" /></u-avatar>
  13. </view>
  14. <view class="data-input">
  15. <u-form :model="form" ref="uForm">
  16. <u-form-item label-position="top" required label="昵称"><u-input v-model="form.nickName"
  17. placeholder="请填写昵称" /></u-form-item>
  18. </u-form>
  19. </view>
  20. <p class="car-num" ><span style="color:rgba(238, 49, 56, 1)">*</span>车牌号码
  21. <span @click="gotoLink"
  22. style="color: rgb(63, 189, 112);float: right;">临时车牌,点击快速充电</span>
  23. </p>
  24. <view class="key-input" @tap="keyShow=true">
  25. <umessageInput :focus="true" @selectIndex="getSelectIndex" :value="form.carNum" :maxlength="maxlength"
  26. :disabled-keyboard="true"></umessageInput>
  27. <!-- <u-message-input :focus="true" :value="form.carNum" :maxlength="maxlength" :disabled-keyboard="true"></u-message-input>
  28. -->
  29. </view>
  30. <p class="car-num" ><span @tap="keyShow=!keyShow"
  31. style="float: right;color: #9e9e9e;">点击输入框{{keyShow?'收起':'唤起'}}键盘</span></p>
  32. <p class="car-num" v-show="!keyShow"><span style="color:rgba(238, 49, 56, 1)">*</span>车辆用途</p>
  33. <view class="car-type" v-show="!keyShow">
  34. <view class="card" v-for="(item,i) in carlist" :key="i"
  35. @click="usage=item.value"
  36. >
  37. <view class="cardin" :class="{
  38. cardselect:usage==item.value,
  39. cardno:usage!=item.value
  40. }" >
  41. <view class="cardgo" >
  42. <view class="cardinfo">
  43. <img
  44. src="@/assets/img/riFill-check-fill.svg" alt="">
  45. </view>
  46. </view>
  47. <view class="title">{{item.name}}</view>
  48. <p class="carimgp">
  49. <img class="carimg"
  50. :src="item.img" alt="">
  51. </p>
  52. </view>
  53. </view>
  54. </view>
  55. <p class="car-num" v-show="!keyShow">
  56. 车辆认证
  57. <view style="font-size: 12px;color:rgba(51, 51, 51, 1);margin: 2px 0;">上传机动车行驶证清晰照片</view>
  58. </p>
  59. <view class="car-type" v-show="!keyShow">
  60. <view class="carAuth">
  61. <view class="mark" v-show="!carAuthImg">
  62. <view class="text">例</view>
  63. </view>
  64. <view class="carAuthIcon" @click="uploadPhoto2">
  65. <u-icon name="camera-fill" custom-prefix="custom-icon" color="#fff" size="48"></u-icon>
  66. </view>
  67. <image class="carAuthImg" @click="uploadPhoto2" v-show="carAuthImg" :src="carAuthImg"></image>
  68. <image class="carAuthImg" @click="uploadPhoto2" v-show="!carAuthImg" src="@/assets/img/carDet/authtest.png"></image>
  69. </view>
  70. <view class="position" v-if="!carLicense">
  71. <view id="talkbubble">首次认证送5元代金卷</view>
  72. </view>
  73. </view>
  74. <view class="default" v-show="!keyShow">
  75. <view style="width: 350px;">
  76. <u-checkbox-group>
  77. <u-checkbox class="tips" active-color="green" v-model="value" shape="circle"
  78. @change="checkboxChange()"></u-checkbox>
  79. </u-checkbox-group>
  80. <span>我已阅读并同意</span>
  81. <span @click="gotoUrl('pages/article/details?code=GRXXCLSQS')"
  82. style="color: #3fbd70;">《个人信息处理授权书》</span>
  83. </view>
  84. <u-button class="login-btn" @click="keepCar" type="success" shape="circle">完成</u-button>
  85. </view>
  86. <ucarkeyboard ref="uKeyboard" style=" z-index: 999;" :style="!keyShow?'display: none':''" mode="car"
  87. :confirmBtn="false" :mask-close-able="false" :tooltip="false" v-show="keyShow" @change="valChange"
  88. @backspace="backspace">
  89. <view style="
  90. text-align: center;
  91. font-size: 18px;
  92. ">
  93. <span style="color: #fff;">车牌号:{{form.carNum}}</span>
  94. <span @tap="keyShow=!keyShow" style="
  95. float: right;
  96. padding-right: 10px;
  97. color: #41a863;
  98. ">确定</span>
  99. </view>
  100. </ucarkeyboard>
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. import * as userApi from '@/apis/user.js'
  106. import ucarkeyboard from '@/components/Ucarkeyboard.vue'
  107. import * as loginApi from '@/apis/login.js'
  108. import umessageInput from '@/components/UmessageInput.vue'
  109. var car1=require("@/assets/img/cartype/car1.png")
  110. var car2=require("@/assets/img/cartype/car2.png")
  111. var car3=require("@/assets/img/cartype/car3.png")
  112. var car4=require("@/assets/img/cartype/car4.png")
  113. export default {
  114. components: {
  115. ucarkeyboard,
  116. umessageInput
  117. },
  118. data() {
  119. return {
  120. carLicense:"",
  121. carAuthImg:"",
  122. value: false,
  123. selectIndex: -1,
  124. maxlength: 8,
  125. keyShow: false,
  126. isLogin: false,
  127. code: "",
  128. codeId: "",
  129. form: {
  130. nickName: '',
  131. headImg: '',
  132. carNum: '',
  133. defaultFlag: true,
  134. },
  135. usage:"",
  136. carlist:[
  137. {
  138. value:1,
  139. name:"出租车",
  140. img:car1
  141. },
  142. {
  143. value:2,
  144. name:"专快车",
  145. img:car2
  146. },
  147. {
  148. value:3,
  149. name:"物流车/商用车",
  150. img:car3
  151. },
  152. {
  153. value:4,
  154. name:"私家车",
  155. img:car4
  156. }
  157. ]
  158. }
  159. },
  160. onLoad(op) {
  161. if (op.jpcode) {
  162. var str1 = op.jpcode.slice(0, 19);
  163. var str2 = op.jpcode.slice(20, 21);
  164. var str3 = op.jpcode.slice(22);
  165. if (str1 == 'jp_team51_charge_id') {
  166. if (str2 == 'A') {
  167. this.code = str2;
  168. this.codeId = str3;
  169. }
  170. }
  171. }
  172. if (op.login) {
  173. this.isLogin = true;
  174. }
  175. },
  176. onReady() {
  177. //this.$refs.uKeyboard.changeCarInputMode();
  178. this.getUserInfo();
  179. },
  180. methods: {
  181. uploadFile(imageSrc){
  182. var action=process.car.BASE_URL+"uploadPicture"
  183. var token=this.carhelp.getToken()
  184. var header={
  185. 'Authorization':token
  186. }
  187. var formData={
  188. subFolder:"/team51/message"
  189. }
  190. var _this=this
  191. uni.showLoading({
  192. title: '上传中'
  193. })
  194. uni.uploadFile({
  195. url: action, //仅为示例,非真实的接口地址
  196. filePath: imageSrc,
  197. name: 'photoFile',
  198. header: header,
  199. formData: formData,
  200. success: (res) => {
  201. uni.hideLoading();
  202. uni.showToast({
  203. title: '上传成功',
  204. icon: 'success',
  205. duration: 1000
  206. })
  207. _this.carAuthImg = JSON.parse(res.data).data
  208. _this.$forceUpdate()
  209. },
  210. fail: (err) => {
  211. console.log('uploadImage fail', err);
  212. uni.hideLoading();
  213. uni.showModal({
  214. content: err.errMsg,
  215. showCancel: false
  216. });
  217. },
  218. });
  219. },
  220. uploadPhoto2() {
  221. if(this.carLicense){
  222. uni.showToast({
  223. title: "车辆认证后不可修改",
  224. mask: true,
  225. })
  226. return
  227. }
  228. uni.chooseImage({
  229. count: 1,
  230. sizeType:['compressed'],
  231. success: async (res) => {
  232. console.log(res)
  233. var imageSrc = res.tempFilePaths[0]
  234. this.uploadFile(imageSrc);
  235. },
  236. fail: (err) => {
  237. console.log('chooseImage fail', err)
  238. }
  239. })
  240. },
  241. getUserInfo() {
  242. uni.showLoading({
  243. title: "加载中",
  244. mask: true,
  245. })
  246. loginApi.findByOpenId({
  247. openId: this.carhelp.getOpenId()
  248. }).then((res) => {
  249. uni.hideLoading();
  250. this.form.nickName = res.data.regUser.nickName;
  251. this.form.headImg = res.data.regUser.headImg;
  252. }).catch(error => {
  253. uni.showToast({
  254. title: error,
  255. icon: "none"
  256. })
  257. })
  258. },
  259. uploadPhoto() {
  260. let _self = this;
  261. const crop = {
  262. quality: 100,
  263. width: 600,
  264. height: 600,
  265. resize: true
  266. };
  267. // 上传图片
  268. uni.chooseImage({
  269. count: 1,
  270. crop,
  271. success: async (res) => {
  272. //(res);
  273. let tempFile = res.tempFiles[0],
  274. avatar_file = {
  275. // #ifdef H5
  276. extname: tempFile.name.split('.')[tempFile.name.split('.').length - 1],
  277. // #endif
  278. // #ifndef H5
  279. extname: tempFile.path.split('.')[tempFile.path.split('.').length - 1]
  280. // #endif
  281. },
  282. filePath = res.tempFilePaths[0]
  283. // #ifndef APP-PLUS
  284. //(`filePath=${filePath}`)
  285. //非app端用前端组件剪裁头像,app端用内置的原生裁剪
  286. let fileData = await new Promise((callback) => {
  287. uni.navigateTo({
  288. url: '/pages/user/cropImage?path=' + filePath +
  289. `&options=${JSON.stringify(crop)}`,
  290. animationType: "fade-in",
  291. events: {
  292. success: url => {
  293. callback(url)
  294. }
  295. }
  296. });
  297. })
  298. // #endif
  299. //返回 base64 图片
  300. //(fileData);
  301. var token = _self.carhelp.getToken()
  302. uni.showLoading({
  303. title: '上传中'
  304. });
  305. uni.request({
  306. url: process.car.BASE_URL + "uploadBase64",
  307. method: 'POST',
  308. data: {
  309. photoBase64Data: fileData,
  310. branchParameter:process.car.branchParameter
  311. },
  312. header: {
  313. 'Authorization': token,
  314. 'content-type': 'application/x-www-form-urlencoded'
  315. },
  316. success: (res) => {
  317. let jsonData = res.data;
  318. _self.form.headImg = jsonData.data;
  319. uni.hideLoading();
  320. }
  321. });
  322. }
  323. });
  324. },
  325. gotoLink() {
  326. if (this.code == 'A') {
  327. uni.redirectTo({
  328. url: '/pages/searchPile/stationAndPile/chargingPileDetails?id=' + this.codeId
  329. })
  330. } else if (this.isLogin) {
  331. uni.redirectTo({
  332. url: '/pages/index/index'
  333. })
  334. }else{
  335. uni.redirectTo({
  336. url: '/pages/index/index'
  337. })
  338. }
  339. },
  340. checkboxChange() {
  341. this.value = !this.value;
  342. },
  343. getSelectIndex(i) {
  344. this.selectIndex = i;
  345. if (i == 0) {
  346. var aaa = this.$refs.uKeyboard.changeCarInputValue();
  347. if (aaa) {
  348. this.$refs.uKeyboard.changeCarInputMode();
  349. }
  350. }
  351. },
  352. // 按键被点击(点击退格键不会触发此事件)
  353. valChange(val) {
  354. if (this.form.carNum.length >= this.maxlength && this.selectIndex == -1) {
  355. return
  356. }
  357. if (this.selectIndex == -1) {
  358. this.form.carNum += val;
  359. } else {
  360. const replaceStr = (str, index, char) => {
  361. const strAry = str.split('');
  362. if (index < strAry.length) {
  363. strAry[index] = char;
  364. }
  365. return strAry.join('');
  366. }
  367. this.form.carNum = replaceStr(this.form.carNum, this.selectIndex, val);
  368. this.selectIndex = -1;
  369. }
  370. // 将每次按键的值拼接到form.carNum变量中,注意+=写法
  371. //(this.form.carNum);
  372. var aaa = this.$refs.uKeyboard.changeCarInputValue();
  373. if ((this.form.carNum.length == 0) && aaa) {
  374. this.$refs.uKeyboard.changeCarInputMode();
  375. } else if (!aaa) {
  376. this.$refs.uKeyboard.changeCarInputMode();
  377. }
  378. },
  379. // 退格键被点击
  380. backspace() {
  381. // 删除form.carNum的最后一个字符
  382. if (this.form.carNum.length) {
  383. if (this.selectIndex == -1) {
  384. this.form.carNum = this.form.carNum.substr(0, this.form.carNum.length - 1);
  385. } else {
  386. const replaceStr = (str, index, char) => {
  387. const strAry = str.split('');
  388. if (index < strAry.length) {
  389. strAry[index] = char;
  390. }
  391. return strAry.join('');
  392. }
  393. this.form.carNum = replaceStr(this.form.carNum, this.selectIndex, '');
  394. //this.selectIndex=-1;
  395. }
  396. }
  397. //(this.form.carNum);
  398. var aaa = this.$refs.uKeyboard.changeCarInputValue();
  399. if (this.form.carNum.length == 0 && aaa) {
  400. this.$refs.uKeyboard.changeCarInputMode();
  401. }
  402. },
  403. keepCar() {
  404. if (this.form.carNum.length != 8) {
  405. uni.showToast({
  406. title: "请填写新能源车牌"
  407. })
  408. return
  409. }
  410. if (!this.usage) {
  411. uni.showToast({
  412. title: "请选择车辆用途"
  413. })
  414. return
  415. }
  416. if (!this.value) {
  417. uni.showToast({
  418. title: "请阅读并同意《个人信息处理授权书》"
  419. })
  420. return
  421. }
  422. //(this.form)
  423. this.form.usage=this.usage;
  424. this.form.photoFile=this.carAuthImg;
  425. uni.showLoading({
  426. title: "加载中",
  427. mask: true,
  428. })
  429. userApi.perfectPersonInformation(this.form).then((res) => {
  430. uni.hideLoading();
  431. if(this.carAuthImg){
  432. var obj=this.carhelp.getPersonInfo()
  433. obj.carLicense=this.carAuthImg
  434. this.carhelp.setPersonInfo(obj)
  435. }
  436. this.gotoLink()
  437. }).catch(error => {
  438. uni.hideLoading();
  439. uni.showModal({
  440. content: error,
  441. showCancel: false
  442. });
  443. })
  444. }
  445. }
  446. }
  447. </script>
  448. <style>
  449. page {
  450. background: #fff;
  451. }
  452. </style>
  453. <style lang="scss" scoped>
  454. .u-char-item {
  455. width: 58rpx !important;
  456. }
  457. .skip {
  458. margin-left: 81.3%;
  459. }
  460. .data-icon {
  461. height: 28px;
  462. width: 28px;
  463. background-color: #00B962;
  464. border-radius: 14px;
  465. border: 2px solid #fff;
  466. text-align: center;
  467. line-height: 24px;
  468. position: absolute;
  469. z-index: 999;
  470. right: 0;
  471. bottom: 0px
  472. }
  473. .data-img {
  474. margin: 10px auto;
  475. height: 216rpx;
  476. width: 216rpx;
  477. position: relative;
  478. }
  479. .data-input {
  480. margin: 0 60rpx;
  481. }
  482. .login-btn {
  483. margin-top: 12px;
  484. background-color: #00B962 !important;
  485. border-color: #00B962 !important;
  486. color: #fff !important;
  487. }
  488. .car-num {
  489. padding: 20rpx 60rpx 0 60rpx;
  490. line-height: 18px;
  491. }
  492. .key-input {
  493. padding-top: 19px;
  494. }
  495. .default {
  496. margin: 30rpx 60rpx;
  497. }
  498. ::v-deep .u-char-item {
  499. width: 60rpx !important;
  500. height: 80rpx !important;
  501. font-size: 36rpx !important;
  502. }
  503. .car-type{
  504. display: flex;
  505. flex-direction: row;
  506. margin: 0 40rpx;
  507. flex-wrap: wrap;
  508. }
  509. .cardone{
  510. // margin-right: 20rpx;
  511. }
  512. .card{
  513. width: 50%;
  514. padding: 0 10rpx;
  515. .cardin {
  516. // margin-left: 5px;
  517. overflow: hidden;
  518. padding: 20rpx;
  519. margin-top: 20rpx;
  520. height: 150rpx;
  521. .title{
  522. font-weight: bold;
  523. }
  524. .carimgp{
  525. float: right;
  526. }
  527. .carimg{
  528. width: 180rpx;
  529. height: 64rpx;
  530. }
  531. }
  532. }
  533. .cardselect {
  534. border-radius: 8px;
  535. border: 2px solid rgba(0, 185, 98, 1);
  536. .title{
  537. color:#00B962;
  538. font-weight: bold;
  539. }
  540. .cardgo{
  541. position: relative;
  542. .cardinfo{
  543. background-color: #57ad55;
  544. width: 36rpx;
  545. height: 36rpx;
  546. position: absolute;
  547. top: -12px;
  548. right: -12px;
  549. border-radius: 0 0 0 4px;
  550. img{
  551. width: 36rpx;
  552. }
  553. }
  554. }
  555. }
  556. .cardno {
  557. border: 2px solid #f6f6f6;
  558. border-radius: 8px;
  559. background-color: #f6f6f6;
  560. .title{
  561. font-weight: bold;
  562. }
  563. .cardgo{
  564. position: relative;
  565. .cardinfo{
  566. background-color: #f6f6f6;
  567. width: 36rpx;
  568. height: 36rpx;
  569. position: absolute;
  570. top: -12px;
  571. right: -12px;
  572. border-radius: 0 0 0 4px;
  573. img{
  574. width: 36rpx;
  575. }
  576. }
  577. }
  578. }
  579. .carAuth{
  580. border-radius: 12px;
  581. background-color: rgba(255, 255, 255, 1);
  582. border: 2px dashed rgba(187, 187, 187, 1);
  583. //height: 400rpx;
  584. width: 100%;
  585. overflow: hidden;
  586. text-align: center;
  587. .carAuthImg{
  588. margin-top: 10px;
  589. margin-bottom: 10px;
  590. width: 510rpx;
  591. height: 360rpx;
  592. }
  593. .carAuthIcon{
  594. position: absolute;
  595. background: #6e7175;
  596. width: 44px;
  597. height: 44px;
  598. border-radius: 50px;
  599. /* left: 200px; */
  600. /* top: 200px; */
  601. margin: 160rpx 280rpx;
  602. z-index: 999;
  603. display: flex;
  604. justify-content: center;
  605. }
  606. }
  607. .mark {
  608. width: 0px;
  609. height: 0px;
  610. border-top: 40px solid rgba(0, 185, 98, 1);
  611. border-right: 40px solid transparent;
  612. position: absolute;
  613. z-index: 999;
  614. .text{
  615. white-space: nowrap;
  616. transform: rotate(-45deg) scale(0.5);
  617. position: absolute;
  618. top: -45px;
  619. background-color: rgba(0, 185, 98, 1);
  620. color: rgba(255, 255, 255, 1);
  621. font-size: 25px;
  622. }
  623. }
  624. .position {
  625. position: relative;
  626. top: -520rpx;
  627. left: 54%;
  628. z-index: 999;
  629. width: 130px;
  630. }
  631. #talkbubble {
  632. top: 0;
  633. left: 0;
  634. padding: 0 10rpx;
  635. line-height: 20px;
  636. font-size: 12px;
  637. color: #fff;
  638. background: red;
  639. position: relative;
  640. border-radius: 4px;
  641. text-align: center;
  642. }
  643. #talkbubble:before {
  644. content: "";
  645. position: absolute;
  646. top: 100%;
  647. right: 25%;
  648. border-top: 5px solid red;
  649. border-right: 5px solid transparent;
  650. border-left: 5px solid transparent;
  651. }
  652. </style>