getin.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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. },
  174. onShow() {
  175. this.timeList[1].time = this.getTimer();
  176. // this.timeList[1].time=this.currentTime.getFullYear()+ '-' +(this.currentTime.getMonth()+1)+ '-' +this.currentTime.getDate()+ ' ' +this.finialtime+ ':'+"00";
  177. setTimeout( () => {
  178. this.timeList[0].time = this.inTime;
  179. }, 1000);
  180. },
  181. methods:{
  182. // upset(){
  183. // this.visible=true;
  184. // },
  185. bindTimeChange(e) {
  186. this.finialtime = e.target.value;
  187. console.log(this.finialtime)
  188. this.timeList[1].time=this.getYMD()+ ' ' +this.finialtime+ ':'+"00";
  189. console.log(this.timeList[0].time)
  190. this.confirmTime=this.timeList[1].time
  191. },
  192. cancel(){
  193. this.timeshow=false;
  194. },
  195. submit(){
  196. this.time = this.confirmTime;
  197. console.log(this.timeList[1].time)
  198. this.timeshow=true;
  199. // this.timeList[0].time = this.inTime;
  200. },
  201. radioGroupChange(){
  202. },
  203. getYMD(){
  204. var time = new Date();
  205. var y = time.getFullYear();
  206. var mon = time.getMonth() + 1;
  207. mon = mon <10 ? '0' + mon : mon;
  208. var d = time.getDate();
  209. d = d <10 ? '0' + d : d;
  210. return y + '-' + mon + '-' + d ;
  211. },
  212. getTimer(){
  213. var time = new Date();
  214. var y = time.getFullYear();
  215. var mon = time.getMonth() + 1;
  216. mon = mon <10 ? '0' + mon : mon;
  217. var d = time.getDate();
  218. d = d <10 ? '0' + d : d;
  219. var h = time.getHours();
  220. h = h < 10 ? '0' + h : h;
  221. var m = time.getMinutes();
  222. m = m < 10 ? '0' + m : m;
  223. var s = time.getSeconds();
  224. s = s < 10 ? '0' + s : s;
  225. return y + '-' + mon + '-' + d + ' ' + h + ':' + m + ':' + s;
  226. },
  227. radioChange(e) {
  228. this.confirmTime = e;
  229. },
  230. customBack(){
  231. this.$u.route({
  232. // type:'switchTab',
  233. url: 'pages/parking/parking'
  234. });
  235. },
  236. openPage(path) {
  237. console.log('path',path);
  238. this.$u.route({
  239. url: path
  240. })
  241. },
  242. carTypeConfirm(e){
  243. // console.log('carTypeConfirm',e[0].label);
  244. // this.carType = e[0].label;
  245. // this.carType = e[0].value;
  246. this.vehicleType = e[0].value;
  247. },
  248. carColorConfirm(e){
  249. console.log('e',e)
  250. this.vehicleColor = e[0].value;
  251. },
  252. timesubmit(){
  253. this.time = this.confirmTime;
  254. console.log(this.time)
  255. let files = [];
  256. let that = this;
  257. // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
  258. files = this.$refs.uUpload.lists.filter(val => {
  259. return val.progress == 100;
  260. });
  261. // 如果不需要进行太多的处理,直接如下即可
  262. // files = this.$refs.uUpload.lists;
  263. files.forEach(function(element) {
  264. that.images.push(element.response.data.url);
  265. });
  266. let param ={
  267. spaceId:this.spaceId,
  268. vehicleNo:this.vehicleNo,
  269. vehicleColor:this.vehicleColor,
  270. vehicleImage:this.vehicleImage,
  271. vehicleType:this.vehicleType,
  272. memberId:this.memberId,
  273. depositAmount:this.depositAmount,
  274. images:this.images,
  275. inTime:this.time
  276. };
  277. if(this.placeStatus==1&&(this.currentVehicleNo=='')){
  278. this.$u.api.parkInConfirm(param)//有车但是车牌为空
  279. .then(res=>{
  280. this.$refs.uToast.show({
  281. title: res.msg,
  282. type: 'success',
  283. url:'pages/getout/getout'
  284. });
  285. //#ifdef APP-PLUS
  286. device.print(res.data.print);
  287. speak(res.data.speak);
  288. //#endif
  289. console.log('parkInConfirm',res)
  290. }).catch(err=>{
  291. this.$refs.uToast.show({
  292. title: err.msg,
  293. type: 'error',
  294. // url:'pages/parking/parking'
  295. });
  296. console.log('parkInConfirm ',err)
  297. });
  298. }else{
  299. this.$u.api.entrance(param)//车位空闲调
  300. .then(res=>{
  301. this.$refs.uToast.show({
  302. title: res.msg,
  303. type: 'success',
  304. url:'pages/getout/getout'
  305. });
  306. //#ifdef APP-PLUS
  307. device.print(res.data.print);
  308. speak(res.data.speak);
  309. //#endif
  310. console.log('entrance',res)
  311. }).catch(err=>{
  312. this.$refs.uToast.show({
  313. title: err.msg,
  314. type: 'error',
  315. // url:'pages/parking/parking'
  316. });
  317. console.log('entrance ',err)
  318. });
  319. }
  320. },
  321. handleParkInInfo(){
  322. let param ={
  323. vehicleNo:this.vehicleNo,
  324. roadNo:this.roadNo
  325. };
  326. this.$u.api.parkInInfo(param)
  327. .then(res=>{
  328. this.$refs.uToast.show({
  329. title: res.msg,
  330. type: 'success',
  331. // url:'pages/getout/getout'
  332. });
  333. //#ifdef APP-PLUS
  334. speak(this.vehicleNo);
  335. //#endif
  336. this.vehicleType = res?.data?.vehicleType??"0";
  337. this.balance = res?.data?.balance;
  338. console.log('parkInInfo',res);
  339. console.log('this.vehicleType',this.vehicleType)
  340. }).catch(err=>{
  341. this.$refs.uToast.show({
  342. title: err.msg,
  343. type: 'error',
  344. // url:'pages/parking/parking'
  345. });
  346. console.log('parkInInfo ',err)
  347. });
  348. },
  349. getPic(){
  350. let that = this;
  351. ocr.ocrVehicleNo((ret) => {
  352. if (ret.success){
  353. that.vehicleNo = ret.vehicleNo;
  354. that.carImg = 'data:image/png;base64,' + ret.imageBase64;
  355. this.$u.api.tencentBase64Upload({
  356. base64: ret.imageBase64,
  357. suffix: 'png'
  358. })
  359. .then(res=>{
  360. that.vehicleImage = res.data.url;
  361. }).catch(err=>{});
  362. }else {
  363. plus.nativeUI.toast('识别失败');
  364. }
  365. });
  366. // uni.chooseImage({
  367. // count: 1, //默认9
  368. // sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  369. // sourceType: ['camera'], //
  370. // success: function (res) {
  371. // console.log('img',res)
  372. // that.carImg = res.tempFilePaths[0];
  373. // uni.showLoading({});
  374. // const tempFilePaths = res.tempFilePaths;
  375. // // 若多选,需循环调用uni.uploadFile ,因微信小程序只支持单文件上传
  376. // uni.uploadFile({
  377. // url: `${that.config.fileUrl}/baidu/ocr`,
  378. // filePath: tempFilePaths[0],
  379. // name: 'file',
  380. // formData: {
  381. // 'isUpload': '1' // 上传附带参数
  382. // },
  383. // success: (res) => {
  384. // // 根据接口具体返回格式 赋值具体对应url
  385. // // alert(uploadFileRes.data);
  386. // let resobj=eval("("+res.data+")");
  387. // uni.hideLoading();
  388. // if(resobj.code==200){
  389. // console.log(resobj);
  390. // //#ifdef APP-PLUS
  391. // speak(resobj.data.vehicleNo);
  392. // //#endif
  393. // that.vehicleNo = resobj.data.vehicleNo;
  394. // that.vehicleClor = resobj.data.vehicleClor;
  395. // that.vehicleImage = resobj.data.url;
  396. // }else{
  397. // that.$refs.uToast.show({
  398. // title: resobj.msg,
  399. // type: 'error'
  400. // });
  401. // };
  402. // console.log('resobj',resobj);
  403. // },
  404. // fail: (err) => {
  405. // that.$refs.uToast.show({
  406. // title:err.msg,
  407. // type: 'error'
  408. // });
  409. // uni.hideLoading();
  410. // }
  411. // });
  412. // }
  413. // });
  414. },
  415. messageInputClick(){
  416. this.keyboardshow = true;
  417. },
  418. // 按键被点击(点击退格键不会触发此事件)
  419. keyboardChange(val) {
  420. // 将每次按键的值拼接到value变量中,注意+=写法
  421. this.vehicleNo += val;
  422. console.log(this.newPlateNumber);
  423. },
  424. // 退格键被点击
  425. backspace() {
  426. // 删除value的最后一个字符
  427. if(this.vehicleNo.length) this.vehicleNo = this.vehicleNo.substr(0, this.vehicleNo.length - 1);
  428. console.log(this.vehicleNo);
  429. },
  430. }
  431. }
  432. </script>
  433. <style lang="scss">
  434. @import "./getin.scss";
  435. </style>