getin.vue 8.2 KB

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