getin.vue 8.9 KB

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