getin.vue 14 KB

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