getin.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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: '#008CFF' }"></u-navbar>
  10. <view class="car-info u-flex">
  11. <view class="car-info-img" @click="getPic">
  12. <u-image src="/static/img/default-car.png" 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">{{carType|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="deposit" height="80" type="text" placeholder="输入进场押金" />
  36. </view>
  37. </view>
  38. <view class="upload-wrap">
  39. <u-upload :action="upload" :file-list="fileList" upload-text="拍照取证" ></u-upload>
  40. </view>
  41. <view class="bottom-btn-wrap">
  42. <view class="bottom-btn-box u-flex">
  43. <view class="bottom-btn bg-blue" @click="submit">入场</view>
  44. <view class="bottom-btn bg-gray" @click="openPage('pages/getout/getout')">取消</view>
  45. </view>
  46. </view>
  47. <u-select v-model="carTypeShow" :default-value="[carType]" :list="carTypeList" @confirm="carTypeConfirm"></u-select>
  48. <u-toast ref="uToast" />
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data() {
  54. return {
  55. spaceId:'',
  56. spaceName:'',
  57. carTypeShow:false,
  58. carTypeList:[
  59. {label: '小车',value:0}
  60. ,{label: '大车',value:1}
  61. ,{label: '超大型车',value:2}
  62. ,{label: '摩托车',value:3}
  63. ,{label: '非机动车',value:4}
  64. ,{label: '其他',value:5}
  65. ],
  66. carType:0,
  67. vehicleType:null,
  68. currentTime: new Date(), // 获取当前时间
  69. vehicleNo:null,
  70. vehicleColor:null,
  71. vehicleImage:null,
  72. deposit:null,
  73. balance:null,
  74. fileList:[]
  75. }
  76. },
  77. onLoad(page) {
  78. this.spaceId = page.spaceId;
  79. this.orderInTime = page.orderInTime;
  80. this.spaceName = page.spaceName;
  81. this.roadNo = page.roadNo;
  82. },
  83. onShow() {
  84. },
  85. methods:{
  86. customBack(){
  87. this.$u.route({
  88. // type:'switchTab',
  89. url: 'pages/parking/parking'
  90. });
  91. },
  92. openPage(path) {
  93. console.log('path',path);
  94. this.$u.route({
  95. url: path
  96. })
  97. },
  98. carTypeConfirm(e){
  99. // console.log('carTypeConfirm',e[0].label);
  100. // this.carType = e[0].label;
  101. this.carType = e[0].value;
  102. this.vehicleType = e[0].value;
  103. },
  104. submit(){
  105. let param ={
  106. spaceId:this.spaceId,
  107. vehicleNo:this.vehicleNo,
  108. vehicleColor:this.vehicleColor,
  109. vehicleImage:this.vehicleImage,
  110. vehicleType:this.vehicleType,
  111. deposit:this.deposit
  112. };
  113. this.$u.api.parkInConfirm(param)
  114. .then(res=>{
  115. this.$refs.uToast.show({
  116. title: res.msg,
  117. type: 'success',
  118. url:'pages/getout/getout'
  119. });
  120. console.log('parkInConfirm',res)
  121. }).catch(err=>{
  122. this.$refs.uToast.show({
  123. title: err.msg,
  124. type: 'error',
  125. // url:'pages/parking/parking'
  126. });
  127. console.log('parkInConfirm ',err)
  128. });
  129. },
  130. handleParkInInfo(){
  131. let param ={
  132. vehicleNo:this.vehicleNo,
  133. roadNo:this.roadNo
  134. };
  135. this.$u.api.parkInInfo(param)
  136. .then(res=>{
  137. this.$refs.uToast.show({
  138. title: res.msg,
  139. type: 'success',
  140. // url:'pages/getout/getout'
  141. });
  142. this.vehicleType = res.data.vehicleType??"0";
  143. this.balance = res.data.balance;
  144. console.log('parkInInfo',res);
  145. console.log('this.vehicleType',this.vehicleType)
  146. }).catch(err=>{
  147. this.$refs.uToast.show({
  148. title: err.msg,
  149. type: 'error',
  150. // url:'pages/parking/parking'
  151. });
  152. console.log('parkInInfo ',err)
  153. });
  154. },
  155. getPic(){
  156. let that = this;
  157. uni.chooseImage({
  158. count: 1, //默认9
  159. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  160. sourceType: ['camera'], //
  161. success: function (res) {
  162. // console.log('img',res)
  163. uni.showLoading({});
  164. const tempFilePaths = res.tempFilePaths;
  165. // 若多选,需循环调用uni.uploadFile ,因微信小程序只支持单文件上传
  166. uni.uploadFile({
  167. url: `${that.config.fileUrl}/baidu/ocr`,
  168. filePath: tempFilePaths[0],
  169. name: 'file',
  170. formData: {
  171. 'test': 'test' // 上传附带参数
  172. },
  173. success: (res) => {
  174. // 根据接口具体返回格式 赋值具体对应url
  175. // alert(uploadFileRes.data);
  176. let resobj=eval("("+res.data+")");
  177. uni.hideLoading();
  178. if(resobj.code==200){
  179. console.log(resobj);
  180. that.vehicleNo = resobj.data.vehicleNo;
  181. that.vehicleClor = resobj.data.vehicleClor;
  182. }else{
  183. that.$refs.uToast.show({
  184. title: resobj.msg,
  185. type: 'error'
  186. });
  187. }
  188. console.log(res);
  189. },
  190. fail: (err) => {
  191. that.$refs.uToast.show({
  192. title:err.msg,
  193. type: 'error'
  194. });
  195. uni.hideLoading();
  196. }
  197. });
  198. }
  199. });
  200. },
  201. upload(){
  202. }
  203. }
  204. }
  205. </script>
  206. <style lang="scss">
  207. @import "./getin.scss";
  208. </style>