VehicleInquiry.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <!-- 车辆查询 -->
  2. <template>
  3. <view class="container">
  4. <view class="container-title">
  5. <text>输入车牌,查询车费</text>
  6. </view>
  7. <!-- 车牌输入 -->
  8. <view class="container-input" @click="vehicleNoInputClick">
  9. <u-message-input :maxlength="8" width="60" font-size="40" :disabled-keyboard="true" v-model="form.vehicleNo" />
  10. </view>
  11. <!-- 车辆下拉 -->
  12. <view class="container-select">
  13. <u-collapse ref="refValue" :head-style="{ fontSize: '28rpx' }">
  14. <u-collapse-item title="点击选择车牌" align="center">
  15. <scroll-view class="container-select-scroll" scroll-y="true">
  16. <u-cell-group v-if="vehicleList.length">
  17. <u-cell-item :title="item.value" v-for="(item, index) in vehicleList" :key="index" :arrow="false">
  18. <u-radio-group v-model="form.vehicleNo" @change="radioGroupChange">
  19. <u-radio :name="item.value" :key="index" />
  20. </u-radio-group>
  21. </u-cell-item>
  22. </u-cell-group>
  23. <template v-else>
  24. <view class="container-select-empty">暂无绑定车牌</view>
  25. </template>
  26. </scroll-view>
  27. </u-collapse-item>
  28. </u-collapse>
  29. </view>
  30. <view class="container-btn">
  31. <u-button type="primary" :loading="loading" @click="submitVehicleInquiry">确定</u-button>
  32. </view>
  33. <!-- 选择颜色 -->
  34. <u-action-sheet :list="bindVehiclePop.colorList" @click="confirmColor" v-model="bindVehiclePop.colorShow" />
  35. <!-- 车牌号键盘 -->
  36. <u-keyboard ref="uKeyboard" mode="car" @change="keyboardChange" @confirm="keyboardConfirm" @backspace="backspace" v-model="keyboardshow" />
  37. <u-toast ref="uToast" />
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. form: {
  45. vehicleNo: ''
  46. },
  47. vehicleList: [],
  48. keyboardshow: false,
  49. loading: false,
  50. showChangeVehicleNo: false,
  51. bindVehiclePop: {
  52. colorShow: false,
  53. colorList: [
  54. {
  55. text: '蓝色',
  56. colorCode: 0
  57. },
  58. {
  59. text: '黄色',
  60. colorCode: 1
  61. },
  62. {
  63. text: '黑色',
  64. colorCode: 2
  65. },
  66. {
  67. text: '白色',
  68. colorCode: 3
  69. },
  70. {
  71. text: '绿色',
  72. colorCode: 4
  73. },
  74. {
  75. text: '其他',
  76. colorCode: 99
  77. }
  78. ]
  79. }
  80. };
  81. },
  82. onShow() {
  83. this.getCarsList();
  84. },
  85. methods: {
  86. /**
  87. * @description: 获取我的车辆列表
  88. * @return {*}
  89. */
  90. async getCarsList() {
  91. const { data } = await this.$u.api.getMycars({ pageNum: 1, pageSize: 100 });
  92. const vehicleList = [];
  93. data.rows.forEach((item) => {
  94. const { vehicleNo } = item;
  95. vehicleList.push({ label: vehicleNo, value: vehicleNo });
  96. });
  97. this.vehicleList = vehicleList;
  98. await this.$nextTick();
  99. this.$refs.refValue.init();
  100. },
  101. /**
  102. * @description: 车牌输入框点击
  103. * @return {*}
  104. */
  105. vehicleNoInputClick() {
  106. this.keyboardshow = true;
  107. this.form.vehicleNo = '';
  108. },
  109. /**
  110. * @description: 单击车牌
  111. * @param {*} e
  112. * @return {*}
  113. */
  114. radioGroupChange(e) {
  115. this.form.vehicleNo = e;
  116. },
  117. /**
  118. * @description: 颜色下拉确认
  119. * @return {*}
  120. */
  121. confirmColor() {
  122. this.bindVehiclePop.colorShow = false;
  123. },
  124. /**
  125. * @description: 车牌键盘输入变化
  126. * @param {*} val
  127. * @return {*}
  128. */
  129. keyboardChange(val) {
  130. // 将每次按键的值拼接到value变量中,注意+=写法
  131. this.form.vehicleNo += val;
  132. },
  133. /**
  134. * @description: 键盘输入完成确认时
  135. * @return {*}
  136. */
  137. keyboardConfirm() {
  138. this.bindVehiclePop.colorShow = true;
  139. },
  140. /**
  141. * @description: 退格键被点击
  142. * @return {*}
  143. */
  144. backspace() {
  145. // 删除value的最后一个字符
  146. if (this.form.vehicleNo.length) this.form.vehicleNo = this.form.vehicleNo.substr(0, this.form.vehicleNo.length - 1);
  147. },
  148. /**
  149. * @description: 获取当前用户车辆
  150. * @return {*}
  151. */
  152. async getVehicleInquiryList() {
  153. try {
  154. const response = await this.$u.api.getVehicleInquiryListApi();
  155. if (response.code === 200) {
  156. console.log(response);
  157. }
  158. } catch (error) {
  159. }
  160. },
  161. /**
  162. * @description: 确认车费查询
  163. * @return {*}
  164. */
  165. async submitVehicleInquiry() {
  166. const { vehicleNo } = this.form;
  167. if (this.$u.test.carNo(vehicleNo)) {
  168. this.loading = true;
  169. this.$refs.uToast.show({
  170. title: '查询成功!',
  171. type: 'success',
  172. url: '/pages/OnsitePayment/OnsitePayment',
  173. params: {
  174. vehicleNo
  175. },
  176. callback: () => {
  177. this.loading = false;
  178. }
  179. });
  180. } else {
  181. this.$refs.uToast.show({
  182. title: '请输入有效的车牌号!',
  183. type: 'error'
  184. });
  185. }
  186. }
  187. }
  188. };
  189. </script>
  190. <style lang="scss" scoped>
  191. @import './VehicleInquiry.scss';
  192. </style>