getin.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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. </view>
  66. </template>
  67. <script>
  68. import { config } from '@/common/config.js';
  69. import { mydata } from '@/common/data.js';
  70. console.log('mydata',mydata.carColorList)
  71. //#ifdef APP-PLUS
  72. import speak from '@/utils/speaks.js';
  73. let ALog = uni.requireNativePlugin("AndroidLog");
  74. let device = uni.requireNativePlugin("DeviceInfo");
  75. let ocr = uni.requireNativePlugin("OcrPlug");
  76. //#endif
  77. export default {
  78. data() {
  79. return {
  80. carImg:'/static/img/default-car.png',
  81. uploadAction:config.baseUrl+'/file/tencent/upload',
  82. spaceId:'',
  83. spaceName:'',
  84. carTypeShow:false,
  85. carColorShow:false,
  86. carTypeList:mydata.carTypeList,
  87. carColorList:mydata.carColorList,
  88. vehicleType:0,
  89. vehicleColor:0,
  90. currentTime: new Date(), // 获取当前时间
  91. vehicleNo:'',
  92. vehicleImage:null,
  93. memberId:null,
  94. depositAmount:null,
  95. balance:null,
  96. images:[],
  97. keyboardshow:false,
  98. }
  99. },
  100. onLoad(page) {
  101. this.spaceId = page.spaceId;
  102. this.orderInTime = page.orderInTime;
  103. this.spaceName = page.spaceName;
  104. this.roadNo = page.roadNo;
  105. },
  106. onShow() {
  107. },
  108. methods:{
  109. customBack(){
  110. this.$u.route({
  111. // type:'switchTab',
  112. url: 'pages/parking/parking'
  113. });
  114. },
  115. openPage(path) {
  116. console.log('path',path);
  117. this.$u.route({
  118. url: path
  119. })
  120. },
  121. carTypeConfirm(e){
  122. // console.log('carTypeConfirm',e[0].label);
  123. // this.carType = e[0].label;
  124. // this.carType = e[0].value;
  125. this.vehicleType = e[0].value;
  126. },
  127. carColorConfirm(e){
  128. console.log('e',e)
  129. this.vehicleColor = e[0].value;
  130. },
  131. submit(){
  132. let files = [];
  133. let that = this;
  134. // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
  135. files = this.$refs.uUpload.lists.filter(val => {
  136. return val.progress == 100;
  137. });
  138. // 如果不需要进行太多的处理,直接如下即可
  139. // files = this.$refs.uUpload.lists;
  140. files.forEach(function(element) {
  141. that.images.push(element.response.data.url);
  142. });
  143. let param ={
  144. spaceId:this.spaceId,
  145. vehicleNo:this.vehicleNo,
  146. vehicleColor:this.vehicleColor,
  147. vehicleImage:this.vehicleImage,
  148. vehicleType:this.vehicleType,
  149. memberId:this.memberId,
  150. depositAmount:this.depositAmount,
  151. images:this.images
  152. };
  153. this.$u.api.entrance(param)
  154. .then(res=>{
  155. this.$refs.uToast.show({
  156. title: res.msg,
  157. type: 'success',
  158. url:'pages/getout/getout'
  159. });
  160. //#ifdef APP-PLUS
  161. device.print(res.data.print);
  162. speak(res.data.speak);
  163. //#endif
  164. console.log('entrance',res)
  165. }).catch(err=>{
  166. this.$refs.uToast.show({
  167. title: err.msg,
  168. type: 'error',
  169. // url:'pages/parking/parking'
  170. });
  171. console.log('entrance ',err)
  172. });
  173. },
  174. handleParkInInfo(){
  175. let param ={
  176. vehicleNo:this.vehicleNo,
  177. roadNo:this.roadNo
  178. };
  179. this.$u.api.parkInInfo(param)
  180. .then(res=>{
  181. this.$refs.uToast.show({
  182. title: res.msg,
  183. type: 'success',
  184. // url:'pages/getout/getout'
  185. });
  186. //#ifdef APP-PLUS
  187. speak(this.vehicleNo);
  188. //#endif
  189. this.vehicleType = res?.data?.vehicleType??"0";
  190. this.balance = res?.data?.balance;
  191. console.log('parkInInfo',res);
  192. console.log('this.vehicleType',this.vehicleType)
  193. }).catch(err=>{
  194. this.$refs.uToast.show({
  195. title: err.msg,
  196. type: 'error',
  197. // url:'pages/parking/parking'
  198. });
  199. console.log('parkInInfo ',err)
  200. });
  201. },
  202. getPic(){
  203. let that = this;
  204. ocr.ocrVehicleNo((ret) => {
  205. if (ret.success){
  206. that.vehicleNo = ret.vehicleNo;
  207. that.carImg = 'data:image/png;base64,' + ret.imageBase64;
  208. this.$u.api.tencentBase64Upload({
  209. base64: ret.imageBase64,
  210. suffix: 'png'
  211. })
  212. .then(res=>{
  213. that.vehicleImage = res.data.url;
  214. }).catch(err=>{});
  215. }else {
  216. plus.nativeUI.toast('识别失败');
  217. }
  218. });
  219. // uni.chooseImage({
  220. // count: 1, //默认9
  221. // sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  222. // sourceType: ['camera'], //
  223. // success: function (res) {
  224. // console.log('img',res)
  225. // that.carImg = res.tempFilePaths[0];
  226. // uni.showLoading({});
  227. // const tempFilePaths = res.tempFilePaths;
  228. // // 若多选,需循环调用uni.uploadFile ,因微信小程序只支持单文件上传
  229. // uni.uploadFile({
  230. // url: `${that.config.fileUrl}/baidu/ocr`,
  231. // filePath: tempFilePaths[0],
  232. // name: 'file',
  233. // formData: {
  234. // 'isUpload': '1' // 上传附带参数
  235. // },
  236. // success: (res) => {
  237. // // 根据接口具体返回格式 赋值具体对应url
  238. // // alert(uploadFileRes.data);
  239. // let resobj=eval("("+res.data+")");
  240. // uni.hideLoading();
  241. // if(resobj.code==200){
  242. // console.log(resobj);
  243. // //#ifdef APP-PLUS
  244. // speak(resobj.data.vehicleNo);
  245. // //#endif
  246. // that.vehicleNo = resobj.data.vehicleNo;
  247. // that.vehicleClor = resobj.data.vehicleClor;
  248. // that.vehicleImage = resobj.data.url;
  249. // }else{
  250. // that.$refs.uToast.show({
  251. // title: resobj.msg,
  252. // type: 'error'
  253. // });
  254. // };
  255. // console.log('resobj',resobj);
  256. // },
  257. // fail: (err) => {
  258. // that.$refs.uToast.show({
  259. // title:err.msg,
  260. // type: 'error'
  261. // });
  262. // uni.hideLoading();
  263. // }
  264. // });
  265. // }
  266. // });
  267. },
  268. messageInputClick(){
  269. this.keyboardshow = true;
  270. },
  271. // 按键被点击(点击退格键不会触发此事件)
  272. keyboardChange(val) {
  273. // 将每次按键的值拼接到value变量中,注意+=写法
  274. this.vehicleNo += val;
  275. console.log(this.newPlateNumber);
  276. },
  277. // 退格键被点击
  278. backspace() {
  279. // 删除value的最后一个字符
  280. if(this.vehicleNo.length) this.vehicleNo = this.vehicleNo.substr(0, this.vehicleNo.length - 1);
  281. console.log(this.vehicleNo);
  282. },
  283. }
  284. }
  285. </script>
  286. <style lang="scss">
  287. @import "./getin.scss";
  288. </style>