index.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view>
  3. <view class="TUI-fileMessage">
  4. <view class="fileMessage">
  5. <view class="fileMessage-box">
  6. <image class="file-icon" src="/static/static/images/file.png"></image>
  7. <label @tap="download" class="file-title">{{ filePayload.fileName }}</label>
  8. </view>
  9. </view>
  10. </view>
  11. <view class="pop" v-if="Show">
  12. <view class="text-box"><text class="download-confirm" @tap.stop="downloadConfirm">下载</text></view>
  13. <view class="text-box"><text class="abandon" @tap="cancel">取消</text></view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. Show: false,
  22. filePayload: {}
  23. };
  24. },
  25. components: {},
  26. props: {
  27. message: {
  28. type: Object,
  29. default: () => {}
  30. },
  31. isMine: {
  32. type: Boolean,
  33. default: true
  34. }
  35. },
  36. watch: {
  37. message: {
  38. handler: function(newVal) {
  39. this.filePayload= newVal.payload;
  40. // this.setData({
  41. // filePayload: newVal.payload
  42. // });
  43. },
  44. immediate: true,
  45. deep: true
  46. }
  47. },
  48. methods: {
  49. download() {
  50. this.Show=true;
  51. // this.setData({
  52. // Show: true
  53. // });
  54. },
  55. downloadConfirm() {
  56. uni.downloadFile({
  57. url: this.filePayload.fileUrl,
  58. success(res) {
  59. const filePath = res.tempFilePath;
  60. uni.openDocument({
  61. filePath,
  62. success() {
  63. console.log('打开文档成功');
  64. }
  65. });
  66. }
  67. });
  68. },
  69. cancel() {
  70. this.Show=false;
  71. // this.setData({
  72. // Show: false
  73. // });
  74. }
  75. }
  76. };
  77. </script>
  78. <style>
  79. @import './index.css';
  80. </style>