getin.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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">{{vehicleType|filterCarType}}</view>
  21. </view>
  22. <view class="text-item u-flex u-flex u-row-between">
  23. <view class="">余额:<span class="balance">{{balance||'暂无'}}</span></view>
  24. <!-- <view class="recharge" @click="$refs.uToast.show({title: '建设中'})">充值</view> -->
  25. </view>
  26. <view class="text-item">{{$u.timeFormat(currentTime, 'yyyy-mm-dd hh:MM:ss')}}</view>
  27. </view>
  28. </view>
  29. <view class="other-info">
  30. <view class="other-info-item u-flex">
  31. <u-input v-model="vehicleNo" height="80" type="text" placeholder="输入车牌号" />
  32. <u-button type="primary" @click="handleParkInInfo">确认</u-button>
  33. </view>
  34. <!-- <view class="other-info-item">
  35. <u-input style="width: 100%;" v-model="depositAmount" height="80" type="text" placeholder="输入进场押金" />
  36. </view> -->
  37. </view>
  38. <view class="upload-wrap">
  39. <u-upload
  40. ref="uUpload"
  41. :action="uploadAction"
  42. :show-progress="false"
  43. upload-text="拍照取证" ></u-upload>
  44. </view>
  45. <view class="bottom-btn-wrap">
  46. <view class="bottom-btn-box u-flex">
  47. <view class="bottom-btn bg-blue" @click="submit">入场</view>
  48. <view class="bottom-btn bg-gray" @click="openPage('pages/getout/getout')">取消</view>
  49. </view>
  50. </view>
  51. <u-select v-model="carTypeShow" :default-value="[vehicleType]" :list="carTypeList" @confirm="carTypeConfirm"></u-select>
  52. <u-toast ref="uToast" />
  53. </view>
  54. </template>
  55. <script>
  56. import { config } from '@/common/config.js';
  57. export default {
  58. data() {
  59. return {
  60. carImg:'/static/img/default-car.png',
  61. uploadAction:config.baseUrl+'/file/qiniu/upload',
  62. spaceId:'',
  63. spaceName:'',
  64. carTypeShow:false,
  65. carTypeList:[
  66. {label: '小车',value:0}
  67. ,{label: '大车',value:1}
  68. ,{label: '超大型车',value:2}
  69. ,{label: '摩托车',value:3}
  70. ,{label: '非机动车',value:4}
  71. ,{label: '其他',value:5}
  72. ],
  73. vehicleType:0,
  74. currentTime: new Date(), // 获取当前时间
  75. vehicleNo:null,
  76. vehicleColor:null,
  77. vehicleImage:null,
  78. memberId:null,
  79. depositAmount:null,
  80. balance:null,
  81. images:[]
  82. }
  83. },
  84. onLoad(page) {
  85. this.spaceId = page.spaceId;
  86. this.orderInTime = page.orderInTime;
  87. this.spaceName = page.spaceName;
  88. this.roadNo = page.roadNo;
  89. },
  90. onShow() {
  91. },
  92. methods:{
  93. customBack(){
  94. this.$u.route({
  95. // type:'switchTab',
  96. url: 'pages/parking/parking'
  97. });
  98. },
  99. openPage(path) {
  100. console.log('path',path);
  101. this.$u.route({
  102. url: path
  103. })
  104. },
  105. carTypeConfirm(e){
  106. // console.log('carTypeConfirm',e[0].label);
  107. // this.carType = e[0].label;
  108. this.carType = e[0].value;
  109. this.vehicleType = e[0].value;
  110. },
  111. submit(){
  112. let files = [];
  113. let that = this;
  114. // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
  115. files = this.$refs.uUpload.lists.filter(val => {
  116. return val.progress == 100;
  117. });
  118. // 如果不需要进行太多的处理,直接如下即可
  119. // files = this.$refs.uUpload.lists;
  120. files.forEach(function(element) {
  121. that.images.push(element.response.data.url);
  122. });
  123. let param ={
  124. spaceId:this.spaceId,
  125. vehicleNo:this.vehicleNo,
  126. vehicleColor:this.vehicleColor,
  127. vehicleImage:this.vehicleImage,
  128. vehicleType:this.vehicleType,
  129. memberId:this.memberId,
  130. depositAmount:this.depositAmount,
  131. images:this.images
  132. };
  133. this.$u.api.entrance(param)
  134. .then(res=>{
  135. this.$refs.uToast.show({
  136. title: res.msg,
  137. type: 'success',
  138. url:'pages/getout/getout'
  139. });
  140. console.log('entrance',res)
  141. }).catch(err=>{
  142. this.$refs.uToast.show({
  143. title: err.msg,
  144. type: 'error',
  145. // url:'pages/parking/parking'
  146. });
  147. console.log('entrance ',err)
  148. });
  149. },
  150. handleParkInInfo(){
  151. let param ={
  152. vehicleNo:this.vehicleNo,
  153. roadNo:this.roadNo
  154. };
  155. this.$u.api.parkInInfo(param)
  156. .then(res=>{
  157. this.$refs.uToast.show({
  158. title: res.msg,
  159. type: 'success',
  160. // url:'pages/getout/getout'
  161. });
  162. this.vehicleType = res?.data?.vehicleType??"0";
  163. this.balance = res?.data?.balance;
  164. console.log('parkInInfo',res);
  165. console.log('this.vehicleType',this.vehicleType)
  166. }).catch(err=>{
  167. this.$refs.uToast.show({
  168. title: err.msg,
  169. type: 'error',
  170. // url:'pages/parking/parking'
  171. });
  172. console.log('parkInInfo ',err)
  173. });
  174. },
  175. getPic(){
  176. let that = this;
  177. uni.chooseImage({
  178. count: 1, //默认9
  179. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  180. sourceType: ['camera'], //
  181. success: function (res) {
  182. console.log('img',res)
  183. that.carImg = res.tempFilePaths[0];
  184. uni.showLoading({});
  185. const tempFilePaths = res.tempFilePaths;
  186. // 若多选,需循环调用uni.uploadFile ,因微信小程序只支持单文件上传
  187. uni.uploadFile({
  188. url: `${that.config.fileUrl}/baidu/ocr`,
  189. filePath: tempFilePaths[0],
  190. name: 'file',
  191. formData: {
  192. 'test': 'test' // 上传附带参数
  193. },
  194. success: (res) => {
  195. // 根据接口具体返回格式 赋值具体对应url
  196. // alert(uploadFileRes.data);
  197. let resobj=eval("("+res.data+")");
  198. uni.hideLoading();
  199. if(resobj.code==200){
  200. console.log(resobj);
  201. that.vehicleNo = resobj.data.vehicleNo;
  202. that.vehicleClor = resobj.data.vehicleClor;
  203. that.vehicleImage = resobj.data.url;
  204. }else{
  205. that.$refs.uToast.show({
  206. title: resobj.msg,
  207. type: 'error'
  208. });
  209. };
  210. console.log('resobj',resobj);
  211. },
  212. fail: (err) => {
  213. that.$refs.uToast.show({
  214. title:err.msg,
  215. type: 'error'
  216. });
  217. uni.hideLoading();
  218. }
  219. });
  220. }
  221. });
  222. }
  223. }
  224. }
  225. </script>
  226. <style lang="scss">
  227. @import "./getin.scss";
  228. </style>