getin.vue 13 KB

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