enclosures.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view class="center">
  3. <view class="c-list">
  4. <view class="xinxiup">
  5. <view>{{title}}</view>
  6. <view v-for="item in list">
  7. <view class="c-row b-b">
  8. <text class="tit">{{item.appendixName}}</text>
  9. </view>
  10. <view class="c-row b-b">
  11. <text class="tit">{{item.appendixSize}}</text>
  12. </view>
  13. <view class="c-row b-b">
  14. <text class="tit">{{item.appendixPath}}</text>
  15. </view>
  16. <u-button @click="download(item.appendixPath)">下载</u-button>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. name: "trust",
  25. data() {
  26. return {
  27. list:[],
  28. title:""
  29. };
  30. },
  31. onLoad(param) {
  32. var that = this
  33. this.$api.doRequest('get', '/appendix/query/getFileList', {appendixIds:param.addressUrl}).then(res => {
  34. if (res.data.code == 200) {
  35. that.list = res.data.data
  36. that.title = "共"+that.list.length+"个附件"
  37. } else {
  38. uni.showToast({
  39. title: res.data.message,
  40. icon: 'none',
  41. duration: 2000
  42. })
  43. }
  44. })
  45. .catch(res => {
  46. if(res.errmsg){
  47. uni.showToast({
  48. title: res.errmsg,
  49. icon: 'none',
  50. duration: 2000
  51. })
  52. }
  53. else{
  54. uni.showToast({
  55. title: "系统异常,请联系管理员",
  56. icon: 'none',
  57. duration: 2000
  58. })
  59. }
  60. });
  61. },
  62. methods: {
  63. download(path){
  64. uni.downloadFile({
  65. url: path,
  66. success: function (res) {
  67. var filePath = res.tempFilePath;
  68. uni.saveFile({
  69. tempFilePath: filePath,
  70. success: function (res) {
  71. var savedFilePath = res.savedFilePath;
  72. uni.showModal({
  73. title: '提示',
  74. content: '下载成功,是否打开文件?',
  75. showCancel: true,
  76. success: (e) => {
  77. if (e.confirm) {
  78. uni.openDocument({
  79. filePath: savedFilePath,
  80. success: function (res) {
  81. uni.showToast({
  82. title: "打开成功",
  83. icon: 'none',
  84. duration: 2000
  85. })
  86. }
  87. });
  88. }
  89. },
  90. fail: () => {},
  91. complete: () => {}
  92. })
  93. }
  94. });
  95. },
  96. })
  97. }
  98. }
  99. }
  100. </script>
  101. <style>
  102. </style>