<!--  -->
<template>
  <view style="padding: 20rpx 30rpx;">
    <textarea
      placeholder-style="color:#F76260"
      placeholder="请填写您的个人优势..."
      auto-focus
      maxlength="300"
      v-model="advantage"
      style="border: 1rpx solid gray; width: 100%; min-height: 300px;"
    ></textarea>
    <view class="f-horizon-center">
      <button type="primary" size="default" class="send-button MiSans-Medium" :disabled="disabled" @click="submit">提 交</button>
    </view>
  </view>
</template>

<script setup>
import { saveResumeAdvantage } from '@/api/user'
import { ref } from 'vue'
import { userStore } from '@/store/user'; const useUserStore = userStore()

const advantage = ref('')
// 获取基础信息-
function getBaseInfo () {
  const baseInfo = useUserStore.baseInfo
  advantage.value = baseInfo?.advantage || ''
}

// 获取基础信息
getBaseInfo()
// 提交
const disabled = ref(false)
const submit = async () => {
  if (!advantage.value) {
    uni.showToast({ title: '请填写您的个人优势', icon: 'none' })
    return
  }

  disabled.value = true
  try {
    await saveResumeAdvantage({ content: advantage.value })
    uni.showToast({ title: '编辑成功', icon: 'success' })
    await useUserStore.getInfo(false)
    setTimeout(() => {
      uni.navigateBack({
        delta: 1
      })
      disabled.value = false
    }, 1000)
  } catch {
    disabled.value = false
  }
}
</script>
<style lang="scss" scoped>
</style>
