index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <view class="container">
  3. <page-title>现场影像</page-title>
  4. <view class="tabs">
  5. <u-tabs :list="list1" @click="changeTabs" activeStyle='color:#1763E7' :scrollable='false'
  6. lineWidth='174rpx'></u-tabs>
  7. </view>
  8. <view class="cards-list marginTop" v-if="tabFlag == 0">
  9. <view class="card" v-for="(item,index) in iamgetList" :key="index">
  10. <view class="card-box1">
  11. <image :src="item.fileAddre" alt="" class="iamgeSize" @click='viewImg(item.fileAddre)'></image>
  12. <view class="text-box">
  13. <text class="name">{{item.kind}}</text>
  14. <text class="time">时间:</text>
  15. <text class="timeValue">{{item.time}}</text>
  16. </view>
  17. </view>
  18. </view>
  19. <empty-show v-if="iamgetList.length===0" showText='暂无图片'></empty-show>
  20. </view>
  21. <view class="cards-list marginTop" v-if="tabFlag == 1">
  22. <view class="cards" v-for="(item,index) in videoList" :key="index">
  23. <video :src="item.fileAddre" class="videoSize" :show-fullscreen-btn='false'></video>
  24. <view class="text-box">
  25. <text>{{item.kind}}</text>
  26. <text>{{item.time}}</text>
  27. </view>
  28. <div class="videoClick" @click="videoClick(item)"></div>
  29. </view>
  30. <empty-show v-if="videoList.length===0" showText='暂无视频'></empty-show>
  31. </view>
  32. <u-loading-page :loading="loading"></u-loading-page>
  33. </view>
  34. </template>
  35. <script setup>
  36. import {
  37. ref
  38. } from 'vue';
  39. import {
  40. onLoad,
  41. onUnload,
  42. onPullDownRefresh,
  43. onReachBottom,
  44. onPageScroll
  45. } from "@dcloudio/uni-app";
  46. import {
  47. getPageMediaOfSub,
  48. } from "@/api/work/projectInfo.js";
  49. import {
  50. addFocus,
  51. cancelFocus
  52. } from "@/api/work/focus.js";
  53. function backToBefore() {
  54. uni.reLaunch({
  55. url: "/pages/index"
  56. });
  57. };
  58. let scrollTop = ref(0)
  59. let loading = ref(true)
  60. // 参数
  61. let searchInfo = ref({
  62. pageNo: 1,
  63. pageSize: 10,
  64. subId: '',
  65. type: ""
  66. })
  67. let list1 = [{
  68. name: '图片',
  69. }, {
  70. name: '视频',
  71. }]
  72. //图片预览
  73. function viewImg(e) {
  74. let imglist = [e]
  75. uni.previewImage({
  76. longPressActions: true,
  77. urls: imglist
  78. })
  79. }
  80. // 播放文件--视频
  81. function videoClick(event) {
  82. showFile(event.fileType, event.fileAddre)
  83. }
  84. // 文件预览
  85. function showFile(type, filePath) {
  86. uni.navigateTo({
  87. url: `/pages/projectInfo/media/index?type=${type}&filePath=${filePath}`
  88. })
  89. }
  90. //切换tab
  91. let tabFlag = 0
  92. function changeTabs(e) {
  93. tabFlag = e.index
  94. searchInfo.value.pageNo = 1;
  95. iamgetList.value = [];
  96. videoList.value = [];
  97. getList()
  98. }
  99. // 触底加载flag
  100. let moreListFlag = true
  101. // 获取列表
  102. let iamgetList = ref([]);
  103. let videoList = ref([]);
  104. let listTotal = ref(0);
  105. function getList() {
  106. if (searchInfo.value.pageNo == 1) {
  107. loading.value = true
  108. }
  109. if (tabFlag === 0) {
  110. searchInfo.value.type = 'IMAGE'
  111. getPageMediaOfSub(searchInfo.value).then(res => {
  112. loading.value = false
  113. iamgetList.value = iamgetList.value.concat(res.data.list);
  114. listTotal.value = res.data.total;
  115. if (res.data.total == searchInfo.value.pageNo * searchInfo.value.pageSize - (10 - res.data.list
  116. .length)) moreListFlag = false;
  117. }).catch(() => {
  118. loading.value = false
  119. })
  120. } else if (tabFlag === 1) {
  121. searchInfo.value.type = 'VEDIO'
  122. getPageMediaOfSub(searchInfo.value).then(res => {
  123. loading.value = false
  124. videoList.value = videoList.value.concat(res.data.list);
  125. listTotal.value = res.data.total;
  126. if (res.data.total == searchInfo.value.pageNo * searchInfo.value.pageSize - (10 - res.data.list
  127. .length)) moreListFlag = false;
  128. }).catch(() => {
  129. loading.value = false
  130. })
  131. }
  132. }
  133. // function goToDetail(id, subName) {
  134. // uni.navigateTo({
  135. // url: `/pages/projectInfo/detail/index?id=${id}&subName=${subName}`
  136. // })
  137. // }
  138. // function goToPage(url) {
  139. // uni.navigateTo({
  140. // url
  141. // })
  142. // }
  143. // function goToReport(type, subId, subName) {
  144. // uni.navigateTo({
  145. // url: `/pages/projectInfo/report/index?type=${type}&subId=${subId}&subName=${subName}`
  146. // })
  147. // }
  148. onLoad((options) => {
  149. // uni.$on('projectInfoSearch', resolve => {
  150. // searchInfo.value = Object.assign(searchInfo.value, resolve);
  151. // searchInfo.value.pageNo = 1;
  152. // projectList.value = [];
  153. // listTotal.value = 0;
  154. // moreListFlag = true;
  155. // getList();
  156. // });
  157. console.log(options);
  158. searchInfo.value.subId = options.subId
  159. getList();
  160. });
  161. onUnload(() => {
  162. // uni.$off('projectInfoSearch');
  163. })
  164. onPageScroll((e) => {
  165. scrollTop.value = e.scrollTop
  166. })
  167. onPullDownRefresh(() => {
  168. searchInfo.value.pageNo = 1;
  169. iamgetList.value = [];
  170. videoList.value = [];
  171. moreListFlag = true;
  172. try {
  173. getList();
  174. } finally {
  175. uni.stopPullDownRefresh()
  176. }
  177. })
  178. onReachBottom(() => {
  179. if (!moreListFlag) {
  180. return uni.showToast({
  181. title: "已经到底了。",
  182. icon: "none",
  183. duration: 2000
  184. })
  185. }
  186. searchInfo.value.pageNo++;
  187. getList();
  188. })
  189. </script>
  190. <style lang="scss" scoped>
  191. .tabs {
  192. position: absolute;
  193. top: 240rpx;
  194. left: 50%;
  195. transform: translate(-50%);
  196. z-index: 100;
  197. width: 92%;
  198. border-radius: 20rpx 20rpx 20rpx 20rpx;
  199. height: 90rpx;
  200. background: #FFFFFF;
  201. }
  202. .marginTop {
  203. margin-top: 190rpx;
  204. }
  205. .videoSize {
  206. position: absolute;
  207. z-index: 0;
  208. width: 100%;
  209. height: 364rpx;
  210. border-radius: 20rpx 20rpx 0 0;
  211. }
  212. .card-box1 {
  213. padding-top: 40rpx;
  214. display: flex;
  215. justify-content: flex-start;
  216. align-items: center;
  217. .text-box {
  218. margin-left: 40rpx;
  219. display: flex;
  220. flex-direction: column;
  221. align-items: flex-start;
  222. justify-content: center;
  223. .name {
  224. font-size: 32rpx;
  225. font-weight: 400;
  226. font-family: OPPOSans-R;
  227. }
  228. .time {
  229. padding-top: 20rpx;
  230. font-size: 28rpx;
  231. color: #797F89;
  232. font-weight: 400;
  233. }
  234. .timeValue {
  235. padding-top: 10rpx;
  236. font-family: OPPOSans-R;
  237. font-size: 32rpx;
  238. font-weight: 400;
  239. }
  240. }
  241. }
  242. .iamgeSize {
  243. width: 272rpx;
  244. height: 222rpx;
  245. box-shadow: 0rpx 8rpx 12rpx 0rpx rgba(0, 0, 0, 0.21);
  246. border-radius: 10rpx 10rpx 10rpx 10rpx;
  247. }
  248. .cards {
  249. position: relative;
  250. margin: auto;
  251. border-radius: 20rpx;
  252. margin-top: 25rpx;
  253. background: #FFFFFF;
  254. height: 470rpx;
  255. overflow: hidden;
  256. .text-box {
  257. position: absolute;
  258. bottom: 0;
  259. display: flex;
  260. justify-content: space-between;
  261. align-items: center;
  262. width: 100%;
  263. height: 106rpx;
  264. padding: 0 40rpx 0 40rpx;
  265. font-family: OPPOSans-R;
  266. font-size: 32rpx;
  267. }
  268. .videoClick {
  269. position: absolute;
  270. top: -20rpx;
  271. z-index: 100;
  272. width: 100%;
  273. height: 100%;
  274. overflow: hidden;
  275. }
  276. }
  277. </style>