<template>
  <view class="pt-10 pr-60 pl-60">
    <view class="lh-0">
      <image
        src="../images/charge-input-head.png"
        mode="widthFix"
        style="width: 100%"
      ></image>
    </view>
    <view class="mt-20">
      <style-input
        title="充电编码"
        :value="value"
        :focus="focus"
        type="text"
        @input="input"
      />
    </view>
    <view style="margin-top: 100rpx">
      <style-button type="primary" @click="submit">确认</style-button>
      <view class="mt-20"></view>
      <style-button type="primary" :border="true" @click="scanCode"
        >扫码充电</style-button
      >
    </view>
  </view>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { scanCode } from "../../utils/code";

const value = ref("");
const focus = ref(true);

const submit = () => {
  if (!value.value) {
    uni.showToast({
      title: "请输入充电编码",
      icon: "none",
    });
    return;
  }
  uni.navigateTo({
    url: `/pages-charge/ordering/ordering?sn=${value.value}`,
  });
};
const input = (e: any) => {
  value.value = e.value;
};
</script>
