<template>
  <view
    :class="`mx-5 rounded-lg bg-white px-[32rpx] ${userStore.userInfo.openid ? 'py-[56rpx]' : 'py-[26rpx]'}`"
  >
    <view
      class="flex items-center justify-between mx-[34rpx] py-[26rpx]"
      style="border-bottom: 2rpx solid #ededed"
      @click="handleChange"
      v-if="userStore.userInfo.openid"
    >
      <text class="text-[44rpx] text-[#333]">
        {{
          userStore.userInfo.estimatedAchievement.expectedScore
            ? userStore.userInfo.estimatedAchievement.expectedScore
            : '输入模考/高考成绩'
        }}
      </text>
      <image
        class="w-[42rpx] h-[39rpx]"
        src="https://api.static.ycymedu.com/src/images/home/pen.svg"
      ></image>
    </view>
    <view class="flex items-center justify-center" v-else>
      <image
        class="w-[74%] h-[50rpx]"
        mode="widthFix"
        src="https://api.static.ycymedu.com/pagefirstloginbg.png"
      />
    </view>
    <view class="mt-[56rpx] flex items-center justify-between" v-if="userStore.userInfo.openid">
      <button
        class="w-[240rpx]! h-[88rpx]! border-[#1580FF]! text-[#1580FF]! text-[30rpx]! font-normal! mr-[32rpx] flex! items-center! justify-center! rounded-[8rpx]!"
        plain
        @click="navigatorTo"
      >
        一键填报
      </button>
      <button
        class="w-[350rpx]! h-[88rpx]! text-[#fff]! text-[30rpx]! bg-[#1580FF]! font-normal flex! items-center! justify-center! rounded-[8rpx]!"
        @click="navigatorToAi"
      >
        智能填报
      </button>
    </view>
    <view class="flex items-center justify-between mt-[26rpx]" v-else>
      <button
        class="h-[78rpx]! w-full! text-[#fff]! text-[30rpx]! bg-[#1580FF]! font-normal flex! items-center! justify-center! rounded-[8rpx]!"
        @click="navigatorToLogin"
      >
        登录/注册
      </button>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { useUserStore } from '@/store/user'

const userStore = useUserStore()

const handleChange = () => {
  uni.navigateTo({
    url: '/pages-sub/home/inputScore/index',
  })
}

const navigatorTo = () => {
  if (
    Object.prototype.toString.call(userStore.userInfo.estimatedAchievement.expectedScore) ===
      '[object Null]' ||
    userStore.userInfo.estimatedAchievement.expectedScore === ''
  ) {
    handleChange()
  } else {
    uni.navigateTo({
      url: '/pages-sub/home/autoFill/index',
    })
  }
}

const navigatorToAi = () => {
  if (
    Object.prototype.toString.call(userStore.userInfo.estimatedAchievement.expectedScore) ===
      '[object Null]' ||
    userStore.userInfo.estimatedAchievement.expectedScore === ''
  ) {
    handleChange()
  } else {
    uni.navigateTo({
      url: '/pages-evaluation-sub/aiAutoFill/index',
    })
  }
}

const navigatorToLogin = () => {
  uni.navigateTo({
    url: '/login-sub/index',
  })
}
</script>
