getin.vue 15 KB

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