getin.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. <template>
  2. <view class="">
  3. <u-navbar
  4. title="车辆入场"
  5. title-color="#fff"
  6. :custom-back="customBack"
  7. :border-bottom="false"
  8. back-icon-color="#CCE8FF"
  9. :background="{background: 'linear-gradient(145deg, #41AFF9 0%, #2D8CFB 100%)' }"></u-navbar>
  10. <view class="car-info u-flex">
  11. <view class="car-info-img" @click="getPic">
  12. <u-image :src="carImg" mode="aspectFit" width="100%" height="100%"></u-image>
  13. </view>
  14. <view class="car-info-text u-flex-1">
  15. <view class="text-item position-wrap">
  16. <view class="position">车位:{{spaceName}}</view>
  17. </view>
  18. <view class="text-item u-flex u-flex u-row-between">
  19. <view class="">车辆类型</view>
  20. <view class="" @click="carTypeShow = true">
  21. {{vehicleType|filterCarType}}
  22. <u-icon class="u-m-l-10" name="arrow-down-fill" color="#C2C2C2" size="15"></u-icon>
  23. </view>
  24. </view>
  25. <view class="text-item u-flex u-flex u-row-between">
  26. <view>车辆颜色</view>
  27. <view @click="carColorShow = true">
  28. {{vehicleColor|filterCarColor}}
  29. <u-icon class="u-m-l-10" name="arrow-down-fill" color="#C2C2C2" size="15"></u-icon>
  30. </view>
  31. </view>
  32. <view class="text-item u-flex u-flex u-row-between">
  33. <view class="">余额:<span class="balance">{{balance||'暂无'}}</span></view>
  34. <!-- <view class="recharge" @click="$refs.uToast.show({title: '建设中'})">充值</view> -->
  35. </view>
  36. <view class="text-item">{{$u.timeFormat(currentTime, 'yyyy-mm-dd hh:MM:ss')}}</view>
  37. </view>
  38. </view>
  39. <view class="other-info">
  40. <view class="other-info-item u-flex">
  41. <u-input v-model="vehicleNo" height="80" type="text" @focus="messageInputClick" placeholder="输入车牌号" />
  42. <u-button type="primary" @click="handleParkInInfo">确认</u-button>
  43. </view>
  44. <!-- <view class="other-info-item">
  45. <u-input style="width: 100%;" v-model="depositAmount" height="80" type="text" placeholder="输入进场押金" />
  46. </view> -->
  47. </view>
  48. <view class="note">备注:请按顺序依次拍摄车牌,车头,车尾,发动机号,以作为取证照片!</view>
  49. <view class="upload-wrap">
  50. <u-upload
  51. ref="uUpload"
  52. :action="uploadAction"
  53. :show-progress="false"
  54. max-count="1"
  55. @on-oversize
  56. :source-type="sourceType"
  57. upload-text="拍照取证" ></u-upload>
  58. <u-upload
  59. ref="uUpload1"
  60. :action="uploadAction"
  61. :show-progress="false"
  62. max-count="1"
  63. @on-oversize
  64. :source-type="sourceType"
  65. upload-text="拍照取证" ></u-upload>
  66. <u-upload
  67. ref="uUpload2"
  68. :action="uploadAction"
  69. :show-progress="false"
  70. max-count="1"
  71. @on-oversize
  72. :source-type="sourceType"
  73. upload-text="拍照取证" ></u-upload>
  74. <u-upload
  75. ref="uUpload3"
  76. :action="uploadAction"
  77. :show-progress="false"
  78. max-count="1"
  79. @on-oversize
  80. :source-type="sourceType"
  81. upload-text="拍照取证" ></u-upload>
  82. </view>
  83. <view class="bottom-btn-wrap">
  84. <view class="bottom-btn-box u-flex">
  85. <view class="bottom-btn bg-blue" @click="submit">入场</view>
  86. <view class="bottom-btn bg-gray" @click="onCancel">取消</view>
  87. </view>
  88. </view>
  89. <u-select v-model="carTypeShow" :default-value="[2]" :list="carTypeList" @confirm="carTypeConfirm"></u-select>
  90. <u-select v-model="carColorShow" :default-value="[2]" :list="carColorList" @confirm="carColorConfirm"></u-select>
  91. <u-toast ref="uToast" />
  92. <u-keyboard ref="uKeyboard" mode="car" @change="keyboardChange" @backspace="backspace" v-model="keyboardshow"></u-keyboard>
  93. <u-popup class="popup-confirmTime" v-model="timeshow" :mask-close-able="false" mode="center" border-radius="20" width="90%" style="z-index: 99;">
  94. <view class="popup-title">入场时间确认:</view>
  95. <view class="popup-content">请在地磁时间和当前时间里选择一个来做为入场时间:</view>
  96. <view class="popup-confirm u-flex">
  97. <u-radio-group v-model="timevalue" @change="radioGroupChange" :wrap="true">
  98. <u-radio
  99. @change="radioChange"
  100. v-for="(item, index) in timeList" :key="index"
  101. :name="item.time"
  102. :disabled="item.disabled"
  103. >
  104. <view class="popup-intime">
  105. <view class="popup-intime-top" > {{item.name}}</view>
  106. <!-- <view class="popup-intime-bottom" v-if="item.time !=0">{{item.time}}</view> -->
  107. <picker v-if="index === 1" class="openTime" mode="time" :value="time" start="09:01" end="21:01" @change="bindTimeChange">
  108. <view class="popup-intime-bottom" >{{item.time}}</view>
  109. </picker>
  110. <view v-else class="popup-intime-bottom" >{{item.time}}</view>
  111. </view>
  112. <!-- <view class="pop-right"><u-button class="upset" size="mini" @click="upset()" v-if="index==0">修正</u-button></view> -->
  113. </u-radio>
  114. </u-radio-group>
  115. </view>
  116. <view class="button-wrap">
  117. <u-button class="btn1" @click="timesubmit">确认</u-button>
  118. <u-button class="btn2" @click="cancel">取消</u-button>
  119. </view>
  120. </u-popup>
  121. <!-- <u-popup class="timeopen" v-model="visible" mode="center" border-radius="20" width="90%"height="50%">
  122. <picker class="openTime" mode="time" :value="time" start="09:01" end="21:01" @change="bindTimeChange">
  123. <view class="uni-input">{{time}}</view>
  124. </picker>
  125. </u-popup> -->
  126. <!-- <select-timer :visible="visible"></select-timer> -->
  127. </view>
  128. </template>
  129. <script>
  130. import { config } from '@/common/config.js';
  131. import { mydata } from '@/common/data.js';
  132. import selectTimer from '../../components/select-timer/select-timer.vue';
  133. console.log('mydata',mydata.carColorList)
  134. //#ifdef APP-PLUS
  135. import speak from '@/utils/speaks.js';
  136. let ALog = uni.requireNativePlugin("AndroidLog");
  137. let device = uni.requireNativePlugin("DeviceInfo");
  138. let ocr = uni.requireNativePlugin("OcrPlug");
  139. //#endif
  140. export default {
  141. components: {
  142. selectTimer
  143. },
  144. data() {
  145. return {
  146. speakParkIn:'',
  147. sourceType:['camera'],
  148. time: '12:01',
  149. visible:false,
  150. carImg:'',
  151. uploadAction:config.baseUrl+'/file/tencent/upload',
  152. spaceId:'',
  153. spaceName:'',
  154. carTypeShow:false,
  155. carColorShow:false,
  156. carTypeList:mydata.carTypeList,
  157. carColorList:mydata.carColorList,
  158. vehicleType:0,
  159. vehicleColor:0,
  160. currentTime: new Date(), // 获取当前时间
  161. vehicleNo:'',
  162. vehicleImage:null,
  163. memberId:null,
  164. depositAmount:null,
  165. balance:null,
  166. images:[],
  167. keyboardshow:false,
  168. timeshow:false,
  169. timevalue:'',
  170. timechangeList:[],
  171. timeList:[
  172. {
  173. name:'地磁时间',
  174. disabled: false,
  175. time:''
  176. },
  177. {
  178. name:'当前时间',
  179. disabled: false,
  180. time:''
  181. }
  182. ],
  183. inTime:'',
  184. confirmTime:'',
  185. time:'',
  186. placeStatus:'',
  187. finialtime:'',
  188. currentVehicleNo:''
  189. }
  190. },
  191. onLoad(page) {
  192. uni.getStorage({
  193. key:'speakData',
  194. success: (res) => {
  195. this.speakParkIn = res.data.switchVal3;
  196. },
  197. fail: (err) => {
  198. }
  199. })
  200. console.log('page', page)
  201. this.spaceId = page.spaceId;
  202. this.orderInTime = page.orderInTime;
  203. this.spaceName = page.spaceName;
  204. this.roadNo = page.roadNo;
  205. this.carImg = page.carImg;
  206. this.vehicleImage= page.vehicleImage
  207. this.vehicleNo = page.vehicleNo;
  208. this.inTime = page.inTime;
  209. this.placeStatus=page.placeStatus;
  210. this.currentVehicleNo=page.currentVehicleNo
  211. // if(this.inTime == null || this.inTime == ''){
  212. // this.timeList[0].disabled = true;
  213. // }
  214. },
  215. onShow() {
  216. this.timeList[1].time = this.getTimer();
  217. // this.timeList[1].time=this.currentTime.getFullYear()+ '-' +(this.currentTime.getMonth()+1)+ '-' +this.currentTime.getDate()+ ' ' +this.finialtime+ ':'+"00";
  218. setTimeout( () => {
  219. this.timeList[0].time = this.inTime;
  220. if(this.timeList[0].time==null||this.timeList[0].time==''){
  221. console.log(33)
  222. this.timevalue=this.timeList[1].time
  223. this.timeList[0].disabled=true
  224. }else{
  225. console.log(11)
  226. this.timevalue=this.timeList[0].time
  227. this.timeList[0].disabled=false
  228. }
  229. }, 1000);
  230. },
  231. methods:{
  232. // upset(){
  233. // this.visible=true;
  234. // },
  235. bindTimeChange(e) {
  236. this.finialtime = e.target.value;
  237. console.log(this.finialtime)
  238. this.timeList[1].time=this.getYMD()+ ' ' +this.finialtime+ ':'+"00";
  239. console.log(this.timeList[0].time)
  240. this.confirmTime=this.timeList[1].time
  241. },
  242. cancel(){
  243. this.timeshow=false;
  244. },
  245. submit(){
  246. let files = [];
  247. let that = this;
  248. // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
  249. files[0] = this.$refs.uUpload.lists.filter(val => {
  250. return val.progress == 100;
  251. });
  252. files[1] = this.$refs.uUpload1.lists.filter(val => {
  253. return val.progress == 100;
  254. });
  255. files[2] = this.$refs.uUpload2.lists.filter(val => {
  256. return val.progress == 100;
  257. });
  258. files[3] = this.$refs.uUpload3.lists.filter(val => {
  259. return val.progress == 100;
  260. });
  261. // 如果不需要进行太多的处理,直接如下即可
  262. // files = this.$refs.uUpload.lists;
  263. files.forEach(function(element) {
  264. console.log('files',element)
  265. that.images.push(element[0].response.data.url);
  266. });
  267. if((that.images=='' || that.images==null)&&that.images.length < 2){
  268. this.$refs.uToast.show({
  269. title: '请至少上传两张取证图片',
  270. type: 'error',
  271. })
  272. }else{
  273. this.time = this.confirmTime;
  274. console.log(this.timeList[1].time)
  275. this.timeshow=true;
  276. }
  277. // this.timeList[0].time = this.inTime;
  278. },
  279. radioGroupChange(){
  280. },
  281. getYMD(){
  282. var time = new Date();
  283. var y = time.getFullYear();
  284. var mon = time.getMonth() + 1;
  285. mon = mon <10 ? '0' + mon : mon;
  286. var d = time.getDate();
  287. d = d <10 ? '0' + d : d;
  288. return y + '-' + mon + '-' + d ;
  289. },
  290. getTimer(){
  291. var time = new Date();
  292. var y = time.getFullYear();
  293. var mon = time.getMonth() + 1;
  294. mon = mon <10 ? '0' + mon : mon;
  295. var d = time.getDate();
  296. d = d <10 ? '0' + d : d;
  297. var h = time.getHours();
  298. h = h < 10 ? '0' + h : h;
  299. var m = time.getMinutes();
  300. m = m < 10 ? '0' + m : m;
  301. var s = time.getSeconds();
  302. s = s < 10 ? '0' + s : s;
  303. return y + '-' + mon + '-' + d + ' ' + h + ':' + m + ':' + s;
  304. },
  305. radioChange(e) {
  306. this.confirmTime = e;
  307. },
  308. customBack(){
  309. uni.navigateBack({
  310. delta: 1
  311. });
  312. },
  313. onCancel(){
  314. uni.navigateBack({
  315. delta: 1
  316. });
  317. },
  318. openPage(path) {
  319. console.log('path',path);
  320. this.$u.route({
  321. url: path
  322. })
  323. },
  324. carTypeConfirm(e){
  325. // console.log('carTypeConfirm',e[0].label);
  326. // this.carType = e[0].label;
  327. // this.carType = e[0].value;
  328. this.vehicleType = e[0].value;
  329. },
  330. carColorConfirm(e){
  331. console.log('e',e)
  332. this.vehicleColor = e[0].value;
  333. },
  334. timesubmit(){
  335. this.time = this.confirmTime;
  336. console.log(this.time)
  337. // let files = [];
  338. // let that = this;
  339. // // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
  340. // files = this.$refs.uUpload.lists.filter(val => {
  341. // return val.progress == 100;
  342. // });
  343. // // 如果不需要进行太多的处理,直接如下即可
  344. // // files = this.$refs.uUpload.lists;
  345. // files.forEach(function(element) {
  346. // that.images.push(element.response.data.url);
  347. // });
  348. let param ={
  349. spaceId:this.spaceId,
  350. vehicleNo:this.vehicleNo,
  351. vehicleColor:this.vehicleColor,
  352. vehicleImage:this.vehicleImage,
  353. vehicleType:this.vehicleType,
  354. memberId:this.memberId,
  355. depositAmount:this.depositAmount,
  356. images:this.images,
  357. inTime:this.time
  358. };
  359. if(this.placeStatus==1&&(this.currentVehicleNo == null || this.currentVehicleNo=='')){
  360. this.$u.api.parkInConfirm(param)//有车但是车牌为空
  361. .then(res=>{
  362. // this.$refs.uToast.show({
  363. // title: res.msg,
  364. // type: 'success',
  365. // });
  366. plus.nativeUI.toast(res.msg);
  367. setTimeout(() =>{
  368. uni.redirectTo({
  369. url: '/pages/getout/getout'
  370. });
  371. },1000)
  372. //#ifdef APP-PLUS
  373. device.print(res.data.print);
  374. if(this.speakParkIn==true||this.speakParkIn==''){
  375. speak(res.data.speak);
  376. }
  377. //#endif
  378. // console.log('parkInConfirm',res)
  379. }).catch(err=>{
  380. this.$refs.uToast.show({
  381. title: err.msg,
  382. type: 'error',
  383. // url:'pages/parking/parking'
  384. });
  385. console.log('parkInConfirm ',err)
  386. });
  387. }else{
  388. this.$u.api.entrance(param)//车位空闲调
  389. .then(res=>{
  390. // this.$refs.uToast.show({
  391. // title: res.msg,
  392. // type: 'success'
  393. // });
  394. plus.nativeUI.toast(res.msg);
  395. setTimeout(() =>{
  396. uni.redirectTo({
  397. url: '/pages/getout/getout'
  398. });
  399. },1000)
  400. //#ifdef APP-PLUS
  401. device.print(res.data.print);
  402. if(this.speakParkIn==true||this.speakParkIn==''){
  403. speak(res.data.speak);
  404. }
  405. //#endif
  406. console.log('entrance',res)
  407. }).catch(err=>{
  408. this.$refs.uToast.show({
  409. title: err.msg,
  410. type: 'error',
  411. // url:'pages/parking/parking'
  412. });
  413. console.log('entrance ',err)
  414. });
  415. }
  416. },
  417. handleParkInInfo(){
  418. let param ={
  419. vehicleNo:this.vehicleNo,
  420. roadNo:this.roadNo
  421. };
  422. this.$u.api.parkInInfo(param)
  423. .then(res=>{
  424. this.$refs.uToast.show({
  425. title: res.msg,
  426. type: 'success',
  427. // url:'pages/getout/getout'
  428. });
  429. //#ifdef APP-PLUS
  430. speak(this.vehicleNo);
  431. //#endif
  432. this.vehicleType = res?.data?.vehicleType??"0";
  433. this.balance = res?.data?.balance;
  434. console.log('parkInInfo',res);
  435. console.log('this.vehicleType',this.vehicleType)
  436. }).catch(err=>{
  437. this.$refs.uToast.show({
  438. title: err.msg,
  439. type: 'error',
  440. // url:'pages/parking/parking'
  441. });
  442. console.log('parkInInfo ',err)
  443. });
  444. },
  445. getPic(){
  446. // let that = this;
  447. // ocr.ocrVehicleNo((ret) => {
  448. // if (ret.success){
  449. // that.vehicleNo = ret.vehicleNo;
  450. // that.carImg = 'data:image/png;base64,' + ret.imageBase64;
  451. // this.$u.api.tencentBase64Upload({
  452. // base64: ret.imageBase64,
  453. // suffix: 'png'
  454. // })
  455. // .then(res=>{
  456. // that.vehicleImage = res.data.url;
  457. // }).catch(err=>{});
  458. // }else {
  459. // plus.nativeUI.toast('识别失败');
  460. // }
  461. // });
  462. let that = this;
  463. uni.chooseImage({
  464. count: 1, //默认9
  465. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  466. sourceType: ['camera'], //
  467. success: function (res) {
  468. console.log('img',res)
  469. that.carImg = res.tempFilePaths[0];
  470. uni.showLoading({});
  471. const tempFilePaths = res.tempFilePaths;
  472. // 若多选,需循环调用uni.uploadFile ,因微信小程序只支持单文件上传
  473. uni.uploadFile({
  474. url: `${that.config.fileUrl}/tencent/ocr`,
  475. filePath: tempFilePaths[0],
  476. name: 'file',
  477. formData: {
  478. 'isUpload': 1 // 上传附带参数
  479. },
  480. success: (res) => {
  481. // 根据接口具体返回格式 赋值具体对应url
  482. // alert(uploadFileRes.data);
  483. let resobj=eval("("+res.data+")");
  484. uni.hideLoading();
  485. if(resobj.code==200){
  486. console.log(resobj);
  487. //#ifdef APP-PLUS
  488. speak(resobj.data.vehicleNo);
  489. //#endif
  490. that.vehicleNo = resobj.data.vehicleNo;
  491. that.vehicleClor = resobj.data.vehicleClor;
  492. that.vehicleImage = resobj.data.url;
  493. // that.carImg = 'data:image/png;base64,' + resobj.data.imageBase64;
  494. that.$u.api.tencentBase64Upload({
  495. base64: resobj.data.url,
  496. suffix: 'png'
  497. })
  498. }else{
  499. that.$refs.uToast.show({
  500. title: resobj.msg,
  501. type: 'error'
  502. });
  503. };
  504. console.log('resobj',resobj);
  505. },
  506. fail: (err) => {
  507. that.$refs.uToast.show({
  508. title:err.msg,
  509. type: 'error'
  510. });
  511. uni.hideLoading();
  512. }
  513. });
  514. }
  515. });
  516. },
  517. messageInputClick(){
  518. this.keyboardshow = true;
  519. },
  520. // 按键被点击(点击退格键不会触发此事件)
  521. keyboardChange(val) {
  522. // 将每次按键的值拼接到value变量中,注意+=写法
  523. console.log('val',val);
  524. console.log('11',this.vehicleNo);
  525. if(this.vehicleNo){
  526. this.vehicleNo += val;
  527. }else{
  528. this.vehicleNo = val
  529. }
  530. console.log('22',this.vehicleNo);
  531. },
  532. // 退格键被点击
  533. backspace() {
  534. // 删除value的最后一个字符
  535. if(this.vehicleNo.length) this.vehicleNo = this.vehicleNo.substr(0, this.vehicleNo.length - 1);
  536. console.log(this.vehicleNo);
  537. },
  538. }
  539. }
  540. </script>
  541. <style lang="scss">
  542. @import "./getin.scss";
  543. </style>