codeing.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 {
  32. fetchStationByConnectorIdOrShortId,
  33. fetchStationDetailByConnectorId,
  34. fetchStationDetailByShortId
  35. } from "@/api/charge";
  36. import { ref } from "vue";
  37. import { scanCode } from "../../utils/code";
  38. import { to } from "../../utils/navigate";
  39. const value = ref("");
  40. const focus = ref(true);
  41. const submit = () => {
  42. if (!value.value) {
  43. uni.showToast({
  44. title: "请输入充电编码",
  45. icon: "none",
  46. });
  47. return;
  48. }
  49. uni.showLoading({
  50. title: "加载中",
  51. });
  52. fetchStationDetailByShortId(value.value)
  53. .then(() => {
  54. uni.hideLoading();
  55. to(`/pages-charge/appointment/appointment?sn=${value.value}`);
  56. })
  57. .catch((err) => {
  58. value.value = ''
  59. console.log(err);
  60. uni.hideLoading();
  61. uni.showModal({
  62. title: "温馨提示",
  63. content: `充电桩编号不存在,请检查后重新输入`,
  64. confirmText: "确定",
  65. confirmColor: "#2d9e95",
  66. showCancel: false,
  67. });
  68. });
  69. };
  70. const input = (e: any) => {
  71. value.value = e.value;
  72. };
  73. </script>