<route lang="json5">
{
  style: {
    navigationBarTitleText: '填写sn号',
  },
}
</route>

<template>
  <!-- 选网点，选择机器型号，输入SN号，下订单 -->
  <view class="bg-white min-h-screen px-4 py-4">
    <view class="space-y-4">
      <!-- 输入SN号 -->
      <view class="form-item">
        <text class="form-label">SN号</text>
        <wd-input v-model="formData.sn" placeholder="请输入SN号" />
      </view>

      <!-- 提交按钮 -->
      <view class="mt-8 pb-8">
        <wd-button type="success" block @tap="handleSubmit">提交申请</wd-button>
      </view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { useUserStore } from '@/store/user'
import { useMessage } from 'wot-design-uni'

const message = useMessage()
const userStore = useUserStore()
const formData = ref({
  sn: '',
})

// 提交表单
function handleSubmit() {
  // ...
}

onShow(() => {
  if (!userStore.isAuthComplete) {
    message
      .confirm({
        msg: '您还未完善个人信息, 无法享受优惠劵活动, 点击按钮完善信息',
        title: '提示',
        confirmButtonText: '去完善',
        cancelButtonText: '我还在考虑',
      })
      .then(() => {
        uni.navigateTo({
          url: '/pages-sub/user/index',
        })
      })
      .catch(() => {
        uni.navigateBack()
      })
  }
})
</script>

<style lang="scss" scoped>
.form-item {
  @apply mb-6;
  .form-label {
    @apply block text-gray-700 mb-2 text-base;
  }
}
</style>
