index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view class="ss-p-b-100">
  3. <view v-if="bioList.length > 0">
  4. <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)">
  5. <view class="d-flex align-center">
  6. <view @click="preview(item.url)" style="flex: 1;">
  7. <view style="font-weight: bold;">{{ item.title }}</view>
  8. <view>上传时间:{{ timesTampChange(item.createTime, 'Y-M-D') }}</view>
  9. </view>
  10. <view class="ss-m-l-30" style="width: 60rpx;">
  11. <uni-icons @click="handleOpenPopup(item)" type="more-filled" size="20"></uni-icons>
  12. </view>
  13. </view>
  14. </uni-card>
  15. </view>
  16. <view v-else class="nodata-img-parent">
  17. <image src="https://minio.citupro.com/dev/static/nodata.png" mode="widthFix" style="width: 100vw;height: 100vh;"></image>
  18. </view>
  19. <view class="bottom-sticky">
  20. <button class="recomm-button" @click="handleUpload">从微信聊天中导入简历</button>
  21. </view>
  22. <uni-popup ref="popup" type="bottom">
  23. <button class="big-cancel-button" style="color: #333 !important;" @click="handleDelete">删除附件</button>
  24. <button class="big-cancel-button" @click="popup.close(); currentId = ''">取消</button>
  25. </uni-popup>
  26. </view>
  27. </template>
  28. <script setup>
  29. import { ref } from 'vue'
  30. import { getPersonResumeCv, saveResume, deleteResume } from '@/api/user'
  31. import { uploadFileTest } from '@/api/file'
  32. import { timesTampChange } from '@/utils/date'
  33. import { preview } from '@/utils/preview'
  34. // 获取附件
  35. const bioList = ref([])
  36. const getList = async () => {
  37. const { data } = await getPersonResumeCv()
  38. bioList.value = data
  39. }
  40. getList()
  41. // 更多
  42. const currentId = ref('')
  43. const popup = ref()
  44. const handleOpenPopup = (item) => {
  45. currentId.value = item.id
  46. popup.value.open()
  47. }
  48. // 删除附件
  49. const handleDelete = async () => {
  50. if (!currentId.value) return
  51. await deleteResume(currentId.value)
  52. uni.showToast({
  53. title: '删除成功',
  54. icon: 'success',
  55. duration: 2000
  56. })
  57. currentId.value = ''
  58. popup.value.close()
  59. getList()
  60. }
  61. // 上传附件
  62. const handleUpload = () => {
  63. wx.chooseMessageFile({
  64. count: 1,
  65. type: 'file',
  66. success (res) {
  67. const title = res.tempFiles[0].name
  68. const path = res.tempFiles[0].path
  69. //效验是否为支持的文件格式
  70. if(/\.(pdf|docx|doc)$/.test(title)){
  71. uploadFileTest(path).then(async (res) => {
  72. if (!res.data) {
  73. uni.showToast({
  74. title: '上传失败',
  75. icon: 'none'
  76. })
  77. return
  78. }
  79. await saveResume({ title, url: res.data })
  80. uni.showToast({
  81. title: '上传成功',
  82. icon: 'success'
  83. })
  84. getList()
  85. })
  86. }else{
  87. uni.showToast({
  88. icon: 'none',
  89. title: '请上传pdf、word类型的文件',
  90. duration: 2000
  91. })
  92. return
  93. }
  94. }
  95. })
  96. }
  97. </script>
  98. <style scoped lang="scss">
  99. </style>