carDet.vue 18 KB

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