getin.vue 13 KB

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