getin.vue 9.0 KB

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