browse.wpy 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <style lang="less">
  2. .log {
  3. width: 100%;
  4. height: 100%;
  5. }
  6. .file-box {
  7. width: 100%;
  8. background: #fff;
  9. padding: 0 59rpx 0 35rpx;
  10. box-sizing: border-box;
  11. }
  12. .file-title {
  13. height: 80rpx;
  14. width: 100%;
  15. font-size: 32rpx;
  16. line-height: 80rpx;
  17. color: #848993;
  18. margin-left: 33rpx;
  19. }
  20. .file-item {
  21. width: 100%;
  22. height: 140rpx;
  23. display: flex;
  24. justify-content: space-between;
  25. align-items: center;
  26. .file {
  27. display: flex;
  28. image {
  29. width:74rpx;
  30. height: 76rpx;
  31. margin-right: 26rpx;
  32. }
  33. .file-explain {
  34. display: flex;
  35. flex-direction: column;
  36. justify-content: center;
  37. .title {
  38. font-size:28rpx;
  39. font-weight: bolder;
  40. }
  41. .time {
  42. font-size: 24rpx;
  43. color: #909090;
  44. }
  45. }
  46. }
  47. }
  48. .back {
  49. position: fixed;
  50. left: 40rpx;
  51. bottom: 32rpx;
  52. width:77rpx;
  53. height: 76rpx;
  54. image {
  55. width: 100%;
  56. height: 100%;
  57. }
  58. }
  59. </style>
  60. <template>
  61. <view class="log">
  62. <view class="file-title">文档资料</view>
  63. <view class="file-box">
  64. <repeat for="{{localFile}}" key="index" index="index" item="item">
  65. <view class="file-item" @tap="preview({{item.path}}, {{index}})">
  66. <view class="file">
  67. <image src="../static/img/{{listType[index]}}.png"></image>
  68. <view class="file-explain">
  69. <text class="title">{{item.fileName}}</text>
  70. <text class="time">{{localFileTime[index]}}</text>
  71. </view>
  72. </view>
  73. </view>
  74. </repeat>
  75. </view>
  76. <view class="file-title">白板截图</view>
  77. <view class="file-box">
  78. <repeat for="{{screenshot}}" key="index" index="index" item="item">
  79. <view class="file-item" @tap="previewImg({{item.path}}, {{index}})">
  80. <view class="file">
  81. <image src="{{item.path}}" style="width: 104rpx;height: 76rpx;"></image>
  82. <view class="file-explain">
  83. <text class="title">{{item.fileName}}</text>
  84. <text class="time">{{screenshotTime[index]}}</text>
  85. </view>
  86. </view>
  87. </view>
  88. </repeat>
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. import wepy from 'wepy'
  94. import { httpRequestApi } from '../util/httpRequestApi'
  95. export default class Detail extends wepy.page {
  96. components = {
  97. }
  98. data = {
  99. localFile: [],
  100. screenshot: [],
  101. localFileTime: [],
  102. screenshotTime: [],
  103. listType: []
  104. }
  105. computed = {
  106. }
  107. methods = {
  108. preview (url, index) {
  109. wx.showLoading({
  110. title: '加载中'
  111. })
  112. wx.downloadFile({
  113. url: url,
  114. success: (res) => {
  115. console.log(res.tempFilePath)
  116. wx.openDocument({
  117. filePath: res.tempFilePath,
  118. success: (res) => {
  119. wx.hideLoading()
  120. console.log('打开文档成功')
  121. const fileId = this.localFile[index].id
  122. const taskId = this.localFile[index].taskId
  123. httpRequestApi.addViewLog(fileId, taskId).success(res => {
  124. console.log('添加文档')
  125. })
  126. }
  127. })
  128. }
  129. })
  130. },
  131. previewImg (url, index) {
  132. wx.previewImage({
  133. current: 'url', // 当前显示图片的http链接
  134. urls: [url], // 需要预览的图片http链接列表
  135. success: res => {
  136. const fileId = this.screenshot[index].id
  137. const taskId = this.screenshot[index].taskId
  138. httpRequestApi.addViewLog(fileId, taskId).success(res => {
  139. console.log('添加文档')
  140. })
  141. }
  142. })
  143. }
  144. }
  145. events = {
  146. }
  147. CompileTime (list, type) {
  148. let arr = []
  149. list.forEach(item => {
  150. if (type) {
  151. arr.push(item.path.substr(item.path.lastIndexOf('.') + 1))
  152. } else {
  153. arr.push(new Date(item.gmtCreated).toLocaleString())
  154. }
  155. })
  156. return arr
  157. }
  158. onLoad(params) {
  159. httpRequestApi.getLogList().success(res => {
  160. console.log('记录', res)
  161. // this.screenshot = res.data.data.screenshot
  162. // this.localFile = res.data.data.localFile
  163. // this.localFileTime = this.CompileTime(res.data.data.localFile)
  164. // this.screenshotTime = this.CompileTime(res.data.data.screenshot)
  165. // this.listType = this.CompileTime(res.data.data.localFile, true)
  166. // this.$apply()
  167. })
  168. }
  169. }
  170. </script>