ownerInquiry.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="inquiry">
  3. <view class="inquiry-input" @click="keyboardShow = true">
  4. <u-code-input v-model="cardNum" :maxlength="8" size="25" :disabledKeyboard="true"></u-code-input>
  5. <u-keyboard ref="uKeyboard" mode="car" :show="keyboardShow" @change="keyboardChange"
  6. @confirm="keyboardConfirm" @backspace="keyboardBackspace"></u-keyboard>
  7. <u-picker :show="colorShow" :columns="colorList" keyName="text" @confirm="colorConfirm"></u-picker>
  8. </view>
  9. <view class="inquiry-button">
  10. <u-button type="primary" text="查询" @click="searchRecords"></u-button>
  11. </view>
  12. <view class="inquiry-tips">通过输入车牌号查询车主的停车记录</view>
  13. <u-toast ref="uToast"></u-toast>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. cardNum: '',
  21. colorCode: '',
  22. keyboardShow: false,
  23. colorList: [
  24. [{
  25. text: '蓝色',
  26. colorCode: 0
  27. }, {
  28. text: '黄色',
  29. colorCode: 1
  30. }, {
  31. text: '黑色',
  32. colorCode: 2
  33. }, {
  34. text: '白色',
  35. colorCode: 3
  36. }, {
  37. text: '绿色',
  38. colorCode: 4
  39. }, {
  40. text: '其他',
  41. colorCode: 99
  42. }]
  43. ],
  44. colorShow: false
  45. }
  46. },
  47. methods: {
  48. keyboardChange(val) {
  49. if (this.cardNum.length < 7) {
  50. this.cardNum += val
  51. }
  52. console.log(this.cardNum)
  53. },
  54. keyboardConfirm(val) {
  55. this.keyboardShow = false
  56. this.colorShow = true
  57. },
  58. keyboardBackspace() {
  59. if (this.cardNum.length) this.cardNum = this.cardNum.substr(0, this.cardNum.length - 1);
  60. },
  61. colorConfirm(val) {
  62. this.colorCode = val.value[0].colorCode
  63. this.colorShow = false
  64. },
  65. searchRecords() {
  66. if (this.cardNum.length === 7 && (this.colorCode || this.colorCode == 0)) {
  67. uni.$u.route({
  68. url: 'pages/ownerInquiry/queryResults/queryResults'
  69. })
  70. } else if (this.cardNum.length < 7 && this.colorCode){
  71. this.$refs.uToast.show({
  72. type: 'warning',
  73. title: '提示',
  74. message: "请选择正确的车牌号",
  75. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/warning.png'
  76. })
  77. } else if (this.cardNum.length === 7 && this.colorCode === '') {
  78. this.$refs.uToast.show({
  79. type: 'warning',
  80. title: '提示',
  81. message: "请选择车牌颜色",
  82. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/warning.png'
  83. })
  84. } else {
  85. this.$refs.uToast.show({
  86. type: 'warning',
  87. title: '提示',
  88. message: "请选择车牌号和车牌颜色",
  89. iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/warning.png'
  90. })
  91. }
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. .inquiry {
  98. padding: 0 40rpx;
  99. &-input {
  100. padding-top: 420rpx;
  101. text-align: center;
  102. width: calc(100% - 40rpx);
  103. margin: 0 auto;
  104. }
  105. &-button {
  106. margin-top: 100rpx;
  107. }
  108. &-tips {
  109. color: #bbb;
  110. font-size: 28rpx;
  111. margin-top: 100rpx;
  112. text-align: center;
  113. }
  114. }
  115. </style>