VehicleInquiry.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <!-- 车辆查询 -->
  2. <template>
  3. <view class="container">
  4. <view class="container-vehicle">
  5. <u-image width="100%" height="100%" src="/static/img/vehicle-icon.png" />
  6. </view>
  7. <view class="container-content">
  8. <view class="container-content-search">
  9. <view class="container-content-search-title">输入车牌查询</view>
  10. <view class="container-content-search-input" @click="clickCarKeyboard">
  11. <u-message-input :maxlength="8" width="55" font-size="40" :disabled-keyboard="true" v-model="form.vehicleNo" />
  12. </view>
  13. <!-- 车牌号键盘 -->
  14. <u-keyboard
  15. ref="uKeyboard"
  16. mode="car"
  17. @change="keyboardChange"
  18. @confirm="keyboardConfirm"
  19. @backspace="backspace"
  20. v-model="carKeyboard.show"
  21. />
  22. <!-- 选择颜色 -->
  23. <u-action-sheet :list="colorPop.colorList" @click="confirmColor" v-model="colorPop.show" />
  24. </view>
  25. <view class="container-content-choose">
  26. <view class="container-content-choose-text">点击选择车牌</view>
  27. <view class="container-content-choose-icon">
  28. <u-icon name="arrow-up" v-if="toggle"></u-icon>
  29. <u-icon name="arrow-down" v-else></u-icon>
  30. </view>
  31. </view>
  32. <view class="container-content-list">
  33. <radio-group @change="radioChange">
  34. <view class="container-content-list-item" v-for="(item, index) in vehicleList" :key="index">
  35. <view class="left">{{ item.label }}</view>
  36. <view class="right">
  37. <radio :value="item.value" :checked="item.value === form.vehicleNo" />
  38. </view>
  39. </view>
  40. </radio-group>
  41. </view>
  42. <view class="container-content-confirm">
  43. <u-button type="primary" :loading="loading" :disabled="!form.vehicleNo" @click="submitVehicleConfirm">确认</u-button>
  44. </view>
  45. </view>
  46. <parmas-loss-pop :show="lossPopShow" />
  47. </view>
  48. </template>
  49. <script>
  50. import ParmasLossPop from '@/components/params-loss-pop/params-loss-pop.vue';
  51. export default {
  52. components: {
  53. ParmasLossPop
  54. },
  55. data() {
  56. return {
  57. form: {
  58. vehicleNo: ''
  59. },
  60. carKeyboard: {
  61. show: false
  62. },
  63. colorPop: {
  64. show: false,
  65. colorList: [
  66. {
  67. text: '蓝色',
  68. colorCode: 0
  69. },
  70. {
  71. text: '黄色',
  72. colorCode: 1
  73. },
  74. {
  75. text: '黑色',
  76. colorCode: 2
  77. },
  78. {
  79. text: '白色',
  80. colorCode: 3
  81. },
  82. {
  83. text: '绿色',
  84. colorCode: 4
  85. },
  86. {
  87. text: '其他',
  88. colorCode: 99
  89. }
  90. ]
  91. },
  92. toggle: false,
  93. loading: false,
  94. vehicleList: [],
  95. parkInfo: {},
  96. lossPopShow: false
  97. };
  98. },
  99. onLoad(options) {
  100. const { parkNo } = options;
  101. if (parkNo) {
  102. this.form.parkNo = parkNo;
  103. this.getVehicleInquiryList(parkNo);
  104. } else {
  105. this.lossPopShow = true;
  106. }
  107. },
  108. methods: {
  109. /**
  110. * @description: 点击车牌输入框
  111. * @return {*}
  112. */
  113. clickCarKeyboard() {
  114. this.carKeyboard.show = true;
  115. },
  116. /**
  117. * @description: 车牌键盘变化(将每次按键的值拼接到value变量中,注意+=写法)
  118. * @param {*} val
  119. * @return {*}
  120. */
  121. keyboardChange(val) {
  122. this.form.vehicleNo += val;
  123. },
  124. /**
  125. * @description: 获取当前用户车辆
  126. * @return {*}
  127. */
  128. async getVehicleInquiryList(parkNo) {
  129. try {
  130. const { data, code } = await this.$u.api.getVehicleInquiryListApi({ parkNo });
  131. if (code === 200) {
  132. this.parkInfo = data;
  133. this.vehicleList = data.vehicleList.map((item) => {
  134. return { label: item, value: item };
  135. });
  136. await this.$nextTick();
  137. this.$refs.refValue.init();
  138. }
  139. } catch (error) {}
  140. },
  141. /**
  142. * @description: 车牌键盘确认
  143. * @return {*}
  144. */
  145. keyboardConfirm() {
  146. this.colorPop.show = true;
  147. },
  148. /**
  149. * @description: 车牌键盘删除键(删除value的最后一个字符)
  150. * @return {*}
  151. */
  152. backspace() {
  153. if (this.form.vehicleNo.length) this.form.vehicleNo = this.form.vehicleNo.substr(0, this.form.vehicleNo.length - 1);
  154. },
  155. /**
  156. * @description: 选取颜色弹框确认
  157. * @return {*}
  158. */
  159. confirmColor() {
  160. this.colorPop.show = false;
  161. },
  162. /**
  163. * @description:
  164. * @param {*} e
  165. * @return {*}
  166. */
  167. radioChange(e) {
  168. this.form.vehicleNo = e.detail.value;
  169. },
  170. async submitVehicleConfirm() {
  171. const { vehicleNo } = this.form;
  172. const reg =
  173. /^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[a-zA-Z](([DF]((?![IO])[a-zA-Z0-9](?![IO]))[0-9]{4})|([0-9]{5}[DF]))|[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1})$/;
  174. if (reg.test(vehicleNo)) {
  175. this.loading = true;
  176. try {
  177. const { code } = await this.$u.api.getOrderInfoByParknoApi({ ...this.form });
  178. if (code === 200) {
  179. this.$refs.uToast.show({
  180. title: '查询成功!',
  181. type: 'success',
  182. url: '/pages/OnsitePayment/OnsitePayment',
  183. params: {
  184. ...this.form,
  185. vehicleNo: base64Encrypt(this.form.vehicleNo)
  186. },
  187. callback: () => {
  188. this.loading = false;
  189. }
  190. });
  191. }
  192. } catch (error) {
  193. this.loading = false;
  194. // this.showToast(error?.msg, 'error');
  195. }
  196. } else {
  197. this.loading = false;
  198. this.showToast('请输入有效的车牌号!', 'error');
  199. }
  200. },
  201. /**
  202. * @description: 提示
  203. * @param {*} title
  204. * @param {*} type
  205. * @return {*}
  206. */
  207. showToast(title = '操作失败!', type = 'error') {
  208. this.$refs.uToast.show({
  209. title,
  210. type
  211. });
  212. }
  213. }
  214. };
  215. </script>
  216. <style lang="scss" scoped>
  217. @import './VehicleInquiry.scss';
  218. </style>