documentList.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view>
  3. <!-- 顶部 -->
  4. <cu-custom bgColor="bg-blue" :isBack="true">
  5. <block slot="backText">查看文件</block>
  6. <block slot="content"></block>
  7. <block slot="right">
  8. <view class="flex justify-center">
  9. <button @click="code()" class="margin-top-ssm cu-btn round line-blue text-white">生成二维码</button>
  10. </view>
  11. </block>
  12. </cu-custom>
  13. <!-- 标题 -->
  14. <view class="cu-bar bg-white solid-bottom">
  15. <view class="action">
  16. <text class="text-xl text-black text-bold">{{title}} (<text class="text-blue">{{fileList.length}}</text>)</text>
  17. </view>
  18. </view>
  19. <view class="cu-list menu-avatar margin-top">
  20. <view class="cu-item" v-for="(item,index) in fileList" :key="index" @click="navTo(item)">
  21. <view class="cu-avatar round lg">
  22. <image v-if="item.fileType==1" class="menuImageTask " src="/static/task/excel.png"></image>
  23. <image v-if="item.fileType==2" class="menuImageTask " src="/static/task/word.png"></image>
  24. <image v-if="item.fileType==3" class="menuImageTask " src="/static/task/pdf.png"></image>
  25. <image v-if="item.fileType==4" class="menuImageTask " src="/static/task/image.png"></image>
  26. </view>
  27. <view class="content text-cut">
  28. <view class="text-black text-cut text-lg">{{item.fileName}}</view>
  29. <view class="flex justify-start">
  30. <text class="text-gray text-sm">{{item.fileSize}}</text>
  31. </view>
  32. </view>
  33. <view class="action margin-right-sm"style="width: auto;" >
  34. <text class="text-gray cuIcon-right"></text>
  35. </view>
  36. </view>
  37. <view class="flex justify-center text-gray margin-top-lg" >没有更多内容了~</view>
  38. </view>
  39. <!-- 二维码弹窗 -->
  40. <view class="cu-modal" :class="modalShow?'show':''" >
  41. <view class="cu-dialog bg-white" style="padding: 20rpx;position: relative;">
  42. <view class="cu-bar justify-end">
  43. <view class="content text-bold text-black">[{{codeName}}]二维码</view>
  44. </view>
  45. <view class="content padding">
  46. <image class="codeImage" :src="codeImage"></image>
  47. </view>
  48. <view class="flex justify-center" >
  49. <view class="text-black">{{startTime}} 至 {{endTime}}有效</view>
  50. </view>
  51. <view class="margin-top flex justify-center" >
  52. <button style="width: 400rpx;" class="cu-btn bg-blue lg round" @click="download()" >保存到手机</button>
  53. </view>
  54. </view>
  55. <view style="z-index: 3;position: absolute;bottom: 40rpx;right: 0;left: 0;" @click="modalShow=false">
  56. <image class="menuImageTask" src="/static/index/delete-blue.png"></image>
  57. </view>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. export default {
  63. data() {
  64. return {
  65. fileList:[],
  66. modalShow:false,
  67. title:"",
  68. codeName:"",
  69. codeImage:"/static/other/code.png",
  70. dataId:"",
  71. startTime:"",
  72. endTime:""
  73. }
  74. },
  75. methods: {
  76. findFile(){
  77. var that=this;
  78. that.http.request("/app/divideClient/findFile",{nodeId:that.dataId}).then((res)=>{
  79. that.fileList = res.datas;
  80. });
  81. },
  82. code(){
  83. var that=this;
  84. that.http.request("/app/divideClient/createdCode",{name:that.title,id:that.dataId,number:999,type:3}).then((res)=>{
  85. that.startTime = res.result;
  86. that.endTime = res.msg;
  87. that.codeImage =res.data
  88. that.modalShow=true
  89. })
  90. },
  91. download(){
  92. uni.showLoading({
  93. title: '下载中'
  94. });
  95. uni.saveImageToPhotosAlbum({
  96. filePath: this.codeImage,
  97. success: function() {
  98. uni.hideLoading();
  99. uni.showToast({
  100. title: '已保存到相册',
  101. icon: 'none',
  102. duration: 2200
  103. });
  104. }
  105. });
  106. },
  107. navTo(data){
  108. if(data.fileType=="4"){
  109. uni.navigateTo({
  110. url:"/pages/view/view?file="+data.fileUrl+"&title="+data.fileName
  111. })
  112. }else{
  113. uni.showLoading({
  114. title:"跳转中..."
  115. })
  116. uni.downloadFile({
  117. url:data.fileUrl,
  118. success: function (res) {
  119. var filePath = res.tempFilePath;
  120. uni.openDocument({
  121. filePath: filePath,
  122. success: function (res) {
  123. uni.hideLoading()
  124. console.log('打开文档成功');
  125. },
  126. });
  127. }
  128. });
  129. }
  130. }
  131. },
  132. onLoad(e) {
  133. this.title=e.title;
  134. var value =e.title.split("/");
  135. this.codeName = value[value.length-1];
  136. this.dataId = e.id;
  137. this.findFile();
  138. }
  139. }
  140. </script>
  141. <style>
  142. .codeImage{
  143. width: 300px;
  144. height: 300px;
  145. }
  146. .text-black{
  147. color:#101010;
  148. }
  149. .cu-modal.show {
  150. overflow-y: auto;
  151. pointer-events: auto;
  152. }
  153. .cu-list.menu-avatar>.cu-item:after, .cu-list.menu>.cu-item:after {
  154. border-bottom: 1px solid #E3e1e1!important;
  155. }
  156. </style>