getin.vue 7.6 KB

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