codeing.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <view class="pt-10 pr-60 pl-60">
  3. <view class="lh-0">
  4. <!-- #ifdef MP-WEIXIN -->
  5. <!-- #endif -->
  6. <image
  7. src="/pages-charge/static/charge-input-head.png"
  8. mode="widthFix"
  9. style="width: 100%"
  10. ></image>
  11. </view>
  12. <view class="mt-20">
  13. <style-input
  14. title="充电编码"
  15. :value="value"
  16. :focus="focus"
  17. type="text"
  18. @input="input"
  19. />
  20. </view>
  21. <view style="margin-top: 100rpx">
  22. <style-button type="primary" @click="submit">确认</style-button>
  23. <view class="mt-20"></view>
  24. <style-button type="primary" :border="true" @click="scanCode"
  25. >扫码充电</style-button
  26. >
  27. </view>
  28. </view>
  29. </template>
  30. <script setup lang="ts">
  31. import {fetchStationByConnectorIdOrShortId, fetchStationDetailByConnectorId} from "@/api/charge";
  32. import { ref } from "vue";
  33. import { scanCode } from "../../utils/code";
  34. import { to } from "../../utils/navigate";
  35. const value = ref("");
  36. const focus = ref(true);
  37. const submit = () => {
  38. if (!value.value) {
  39. uni.showToast({
  40. title: "请输入充电编码",
  41. icon: "none",
  42. });
  43. return;
  44. }
  45. uni.showLoading({
  46. title: "加载中",
  47. });
  48. fetchStationDetailByConnectorId(value.value)
  49. .then(() => {
  50. uni.hideLoading();
  51. to(`/pages-charge/appointment/appointment?connectorId=${value.value}`);
  52. })
  53. .catch((err) => {
  54. value.value = ''
  55. console.log(err);
  56. uni.hideLoading();
  57. uni.showModal({
  58. title: "温馨提示",
  59. content: `充电桩编号不存在,请检查后重新输入`,
  60. confirmText: "确定",
  61. confirmColor: "#2d9e95",
  62. showCancel: false,
  63. });
  64. });
  65. };
  66. const input = (e: any) => {
  67. value.value = e.value;
  68. };
  69. </script>