<template>
  <view class="ss-p-b-100">
    <view v-if="bioList.length > 0">
			<uni-card v-for="(item, index) in bioList" :key="index" :is-shadow="true" :border='false' shadow="0px 0px 3px 1px rgba(0,0,0,0.1)">
				<view style="font-weight: bold;">{{ item.fileName ? item.fileName : `简历${index + 1}` }}</view>
				<view>上传时间：{{ item.createTime }}</view>
			</uni-card>
		</view>
		<view v-else class="nodata-img-parent">
			<image src="https://minio.citupro.com/dev/static/nodata.png" mode="widthFix" style="width: 100vw;height: 100vh;"></image>
		</view>
    <view class="bottom-sticky">
      <button class="recomm-button" @click="handleUpload">从微信导入简历</button>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue'
import { getPersonResumeCv } from '@/api/user'

// 获取附件
const bioList = ref([])
const getList = async () => {
  const { data } = await getPersonResumeCv()
  bioList.value = data
}
getList()

const handleUpload = () => {
  wx.chooseMessageFile({
    count: 1,
    type: 'file',
    success (res) {
      console.log(res,'res');
      const tempFilePaths = res.tempFiles.map(item=>{
        return item.path
      })
      let name = res.tempFiles[0].name
      //效验是否为支持的文件格式
      if(/\.(pdf|docx|doc)$/.test(name)){
        console.log(tempFilePaths, name, '============')
      }else{
        uni.showToast({
          icon: 'none',
          title: '请上传pdf、word类型的文件',
          duration: 2000
        })
        return
      }
    }
  })
}
</script>

<style scoped lang="scss">

</style>
