lin-upload.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view>
  3. <view>
  4. <button type="primary" :size="size" @click="chooseClick">上传文档</button>
  5. </view>
  6. <view class="file">
  7. <view class="fileSin" v-for="(item,index) in fileList" :key="index">
  8. <view class="left centerBox">
  9. <image src="./image/PDF.png" v-if="item.ext == 'pdf'"></image>
  10. <image src="./image/text.png" v-else-if="item.ext == 'text'"></image>
  11. <image src="./image/DOC.png" v-else-if="item.ext == 'doc' || item.ext == 'docx'"></image>
  12. <image src="./image/PDF.png" v-else-if="item.ext == 'png'"></image>
  13. <image src="./image/document_fill.png" v-else></image>
  14. </view>
  15. <view class="center">
  16. <text>55555555555555555555555555555555555555555555555555555555555555</text>
  17. </view>
  18. <view class="right centerBox">
  19. <image src="./image/dolc.png"></image>
  20. <image src="./image/del.png"></image>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import http from '@/common/service/http.js'
  28. import {
  29. ACCESS_TOKEN,
  30. USER_NAME,
  31. USER_INFO
  32. } from "@/common/util/constants" // 拉取登录token,userName,userInfo
  33. export default {
  34. props: {
  35. size: {
  36. type: String,
  37. default: "mini"
  38. },
  39. fileList: {
  40. type: Array,
  41. default: () => []
  42. }
  43. },
  44. methods: {
  45. chooseClick() {
  46. let token = uni.getStorageSync(ACCESS_TOKEN)
  47. uni.chooseImage({
  48. success: (chooseImageRes) => {
  49. const tempFilePaths = chooseImageRes.tempFilePaths[0]
  50. // this.$emit('chooseClick')
  51. uni.uploadFile({
  52. // url: http.apiHosp + 'ibps/platform/v3/file/upload/mobile', //仅为示例,非真实的接口地址
  53. url: http.apiHosp + '/ibps/platform/v3/file/upload', //仅为示例,非真实的接口地址
  54. filePath: tempFilePaths,
  55. name: 'file',
  56. formData: {
  57. 'ext': '.jpg'
  58. },
  59. header: {
  60. 'X-Authorization-access_token': token,
  61. 'X-Authorization-systemid': ''
  62. },
  63. success: (uploadFileRes) => {
  64. }
  65. });
  66. }
  67. })
  68. }
  69. }
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. .uploadBox {
  74. margin: 10rpx;
  75. }
  76. .file {
  77. .fileSin {
  78. display: flex;
  79. justify-content: space-between;
  80. align-items: center;
  81. border-bottom: 1rpx #e6e6e6 solid;
  82. margin: 10rpx;
  83. .left {
  84. width: 60rpx;
  85. height: 60rpx;
  86. margin-right: 10rpx;
  87. image {
  88. width: 50rpx;
  89. height: 50rpx;
  90. }
  91. }
  92. .center {
  93. width: calc(100% - 250);
  94. line-height: 60rpx;
  95. display: inline-block;
  96. white-space: nowrap;
  97. overflow: hidden;
  98. text-overflow: ellipsis;
  99. text {
  100. font-size: 30rpx;
  101. color: #666666;
  102. }
  103. }
  104. .right {
  105. width: 120rpx;
  106. height: 60rpx;
  107. margin-left: 10rpx;
  108. image {
  109. margin-right: 10rpx;
  110. width: 30rpx;
  111. height: 30rpx;
  112. }
  113. }
  114. }
  115. }
  116. .centerBox {
  117. display: flex;
  118. justify-content: center;
  119. align-items: center;
  120. }
  121. </style>