index.vue 3.3 KB

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