getin.vue 15 KB

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