getcarno.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view>
  3. <view class="taking-pictures">
  4. </view>
  5. <view class="wrap">
  6. <view class="title">手输车牌号</view>
  7. <view class="new-plate-number">
  8. <view class="message-input-wrap" @click="messageInputClick">
  9. <u-message-input :maxlength="8" width="70" font-size="50" :disabled-keyboard="true" v-model="newPlateNumber"></u-message-input>
  10. </view>
  11. <u-keyboard ref="uKeyboard" mode="car" @change="keyboardChange" @backspace="backspace" v-model="keyboardshow"></u-keyboard>
  12. </view>
  13. <view class="bottom-btn" @click="submit">确认</view>
  14. </view>
  15. <u-toast ref="uToast" />
  16. </view>
  17. </template>
  18. <script>
  19. import getUrlParams from "../../utils/getUrlParams.js";
  20. export default{
  21. data(){
  22. return{
  23. keyboardshow:false,
  24. newPlateNumber:'',
  25. spaceId:'',
  26. }
  27. },
  28. onLoad(){
  29. let locationLocaturl = window.location.hash;
  30. // console.log('locationLocaturl',locationLocaturl)
  31. this.spaceId = getUrlParams(locationLocaturl,"spaceId");
  32. },
  33. methods:{
  34. messageInputClick(){
  35. this.keyboardshow = true;
  36. },
  37. // 按键被点击(点击退格键不会触发此事件)
  38. keyboardChange(val) {
  39. // 将每次按键的值拼接到value变量中,注意+=写法
  40. this.newPlateNumber += val;
  41. console.log(this.newPlateNumber);
  42. },
  43. // 退格键被点击
  44. backspace() {
  45. // 删除value的最后一个字符
  46. if(this.newPlateNumber.length) this.newPlateNumber = this.newPlateNumber.substr(0, this.newPlateNumber.length - 1);
  47. console.log(this.newPlateNumber);
  48. },
  49. submit(){
  50. let param ={
  51. spaceId:this.spaceId,
  52. vehicleNo:this.newPlateNumber,
  53. };
  54. this.$u.api.entrance(param)
  55. .then(res=>{
  56. this.$refs.uToast.show({
  57. title: res.msg,
  58. type: 'success',
  59. url:'pages/getout/getout'
  60. });
  61. console.log('entrance',res)
  62. }).catch(err=>{
  63. this.$refs.uToast.show({
  64. title: err.msg,
  65. type: 'error',
  66. url:'pages/parking/parking'
  67. });
  68. console.log('entrance ',err)
  69. });
  70. }
  71. }
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. @import "./getcarno.scss";
  76. </style>