VehicleInquiry.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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" :disabled="!form.vehicleNo" @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. parkNo: ''
  47. },
  48. vehicleList: [],
  49. keyboardshow: false,
  50. loading: false,
  51. showChangeVehicleNo: false,
  52. bindVehiclePop: {
  53. colorShow: false,
  54. colorList: [
  55. {
  56. text: '蓝色',
  57. colorCode: 0
  58. },
  59. {
  60. text: '黄色',
  61. colorCode: 1
  62. },
  63. {
  64. text: '黑色',
  65. colorCode: 2
  66. },
  67. {
  68. text: '白色',
  69. colorCode: 3
  70. },
  71. {
  72. text: '绿色',
  73. colorCode: 4
  74. },
  75. {
  76. text: '其他',
  77. colorCode: 99
  78. }
  79. ]
  80. },
  81. parkNo: null,
  82. parkInfo: {}
  83. };
  84. },
  85. onLoad(options) {
  86. const { parkNo } = options;
  87. if (parkNo) {
  88. this.form.parkNo = parkNo;
  89. this.getVehicleInquiryList(parkNo);
  90. } else {
  91. this.$nextTick(() => {
  92. this.showToast('参数丢失!', 'error');
  93. });
  94. }
  95. },
  96. methods: {
  97. /**
  98. * @description: 车牌输入框点击
  99. * @return {*}
  100. */
  101. vehicleNoInputClick() {
  102. this.keyboardshow = true;
  103. this.form.vehicleNo = '';
  104. },
  105. /**
  106. * @description: 单击车牌
  107. * @param {*} e
  108. * @return {*}
  109. */
  110. radioGroupChange(e) {
  111. this.form.vehicleNo = e;
  112. },
  113. /**
  114. * @description: 颜色下拉确认
  115. * @return {*}
  116. */
  117. confirmColor() {
  118. this.bindVehiclePop.colorShow = false;
  119. },
  120. /**
  121. * @description: 车牌键盘输入变化
  122. * @param {*} val
  123. * @return {*}
  124. */
  125. keyboardChange(val) {
  126. // 将每次按键的值拼接到value变量中,注意+=写法
  127. this.form.vehicleNo += val;
  128. },
  129. /**
  130. * @description: 键盘输入完成确认时
  131. * @return {*}
  132. */
  133. keyboardConfirm() {
  134. this.bindVehiclePop.colorShow = true;
  135. },
  136. /**
  137. * @description: 退格键被点击
  138. * @return {*}
  139. */
  140. backspace() {
  141. // 删除value的最后一个字符
  142. if (this.form.vehicleNo.length) this.form.vehicleNo = this.form.vehicleNo.substr(0, this.form.vehicleNo.length - 1);
  143. },
  144. /**
  145. * @description: 获取当前用户车辆
  146. * @return {*}
  147. */
  148. async getVehicleInquiryList(parkNo) {
  149. try {
  150. const { data, code } = await this.$u.api.getVehicleInquiryListApi({ parkNo });
  151. if (code === 200) {
  152. this.parkInfo = data;
  153. this.vehicleList = data.vehicleList.map((item) => {
  154. return { label: item, value: item };
  155. });
  156. await this.$nextTick();
  157. this.$refs.refValue.init();
  158. }
  159. } catch (error) {}
  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. try {
  170. const { code } = await this.$u.api.getOrderInfoByParknoApi({ ...this.form });
  171. if (code === 200) {
  172. this.$refs.uToast.show({
  173. title: '查询成功!',
  174. type: 'success',
  175. url: '/pages/OnsitePayment/OnsitePayment',
  176. params: {
  177. ...this.form
  178. },
  179. callback: () => {
  180. this.loading = false;
  181. }
  182. });
  183. }
  184. } catch (error) {
  185. this.loading = false;
  186. // this.showToast(error?.msg, 'error');
  187. }
  188. } else {
  189. this.loading = false;
  190. this.showToast('请输入有效的车牌号!', 'error');
  191. }
  192. },
  193. /**
  194. * @description: 提示
  195. * @param {*} title
  196. * @param {*} type
  197. * @return {*}
  198. */
  199. showToast(title = '操作失败!', type = 'error') {
  200. this.$refs.uToast.show({
  201. title,
  202. type
  203. });
  204. }
  205. }
  206. };
  207. </script>
  208. <style lang="scss" scoped>
  209. @import './VehicleInquiry.scss';
  210. </style>