getin.vue 9.0 KB

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