1.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <view class="container">
  3. <div class="top">
  4. <div class="header">
  5. <img class="logo" src="/static/logo_big.png" alt="">
  6. <u--image
  7. class="border"
  8. :showLoading="true"
  9. :src="info.avatar || '/static/image/match/teams_avatar_ico@2x.png'"
  10. @click="go('/pages/Match/member/usermanger', true)"
  11. width="24px"
  12. height="24px"
  13. shape="circle"
  14. ></u--image>
  15. </div>
  16. <div class="title-box">
  17. <!-- Videos -->
  18. {{ $t('video.lab') }}
  19. </div>
  20. </div>
  21. <view class="" style="padding: 20rpx 18rpx;">
  22. <view class="left">
  23. <view class="waterfall-item" @click="onTap(params,index)" v-for="(params,index) in leftList" :key="index">
  24. <view class="waterfall-item-img">
  25. <u--image
  26. :showLoading="true"
  27. radius="12"
  28. :src="params.flie[0].img"
  29. width="100%"
  30. mode="aspectFill"
  31. height="404rpx"
  32. >
  33. <template v-slot:loading>
  34. <image class="loading-banner-img" src="/static/image/common/video-list-bg.png" mode="aspectFill"></image>
  35. </template>
  36. </u--image>
  37. <view class="content">
  38. <view class="flex-end">
  39. <!-- <view class="flex-start">
  40. <image src="/static/image/videos/video6.png" mode=""></image>
  41. <u--text color="#fff" margin="0 12rpx" :text="numberToK(params.click)"></u--text>
  42. </view> -->
  43. <view class="flex-start">
  44. <image src="/static/image/videos/video5.png" mode=""></image>
  45. <u--text color="#fff" margin="0 12rpx" :text="numberToK(params.likes)"></u--text>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="c3 waterfall-title"><text class="text-clamp2">{{params.title}}</text></view>
  51. </view>
  52. </view>
  53. <view class="right">
  54. <view class="waterfall-item" @click="onTap(params,index)" v-for="(params,index) in rightList" :key="index">
  55. <view class="waterfall-item-img">
  56. <image class="cover" :src="params.flie[0].img" mode="widthFix"></image>
  57. <view class="content">
  58. <view class="flex-end">
  59. <!-- <view class="flex-start">
  60. <image src="/static/image/videos/video6.png" mode=""></image>
  61. <u--text color="#fff" margin="0 12rpx" :text="numberToK(params.click)"></u--text>
  62. </view> -->
  63. <view class="flex-start">
  64. <image src="/static/image/videos/video5.png" mode=""></image>
  65. <u--text color="#fff" margin="0 12rpx" :text="numberToK(params.likes)"></u--text>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="c3 waterfall-title"><text class="text-clamp2">{{params.title}}</text></view>
  71. </view>
  72. <image src="/static/image/videos/add.png" @click="toUrl()" class="publishicon"></image>
  73. </view>
  74. </view>
  75. <view class="load-txt" v-if="obj.total != 0">{{status}}</view>
  76. <u-empty v-if="obj.total == 0" mode="data" width="474" height="312" textSize="28" marginTop="100"
  77. :text="$t('common.nodata')" icon="/static/image/common/nodata.png">
  78. </u-empty>
  79. <div class="news-install">
  80. <install></install>
  81. </div>
  82. </view>
  83. </template>
  84. <script>
  85. import { numberToK } from '@/utils/util'
  86. import install from '@/components/install/install.vue'
  87. export default {
  88. components: {
  89. install
  90. },
  91. data() {
  92. return {
  93. // 初始化左右盒子
  94. leftList: [],
  95. rightList: [],
  96. // 初始化左右盒子高度
  97. leftH: 0,
  98. rightH: 0,
  99. obj: {
  100. total: 1
  101. },
  102. page: 1,
  103. status: 'loadmore'
  104. }
  105. },
  106. computed: {
  107. info() {
  108. return this.$store.state.info;
  109. },
  110. isLogin() {
  111. return this.$store.state.isLogin;
  112. },
  113. },
  114. onReady() {
  115. this.getList();
  116. },
  117. // 触底触发
  118. onReachBottom() {
  119. if (this.status == 'loadmore') {
  120. this.page++;
  121. this.getList();
  122. }
  123. },
  124. // 下拉刷新
  125. onPullDownRefresh() {
  126. // 正常情况下接口返回应该很会很快。故意延迟调用,让用户有在刷新的体验感
  127. this.page = 1;
  128. this.rightList = [];
  129. this.leftList = [];
  130. this.getList();
  131. },
  132. methods: {
  133. onTap(data,index) {
  134. let videoList_index =Number(index)
  135. this.$toUrl('./live?id=' + data.id+'&index='+videoList_index)
  136. },
  137. toUrl() {
  138. this.$toUrl('./publish')
  139. },
  140. // 获取数据
  141. getList() {
  142. // 设置状态为加载中
  143. this.status = 'loading';
  144. uni.$u.http.get('/api/Video/getList', {
  145. params: {
  146. page: this.page,
  147. type: 1
  148. }
  149. }).then(res => {
  150. // 获取到的数据,请注意数据结构
  151. // 第一页数据执行以下代码
  152. if (this.page == 1) {
  153. // 关闭下拉
  154. this.leftList=res.data
  155. // uni.stopPullDownRefresh();
  156. // 设置组件状态为 重置,可供下拉刷新这类需要重置列表功能时使用
  157. } else {
  158. this.leftList = this.leftList.concat(res.data || [])
  159. }
  160. this.obj = res;
  161. this.setList(res)
  162. }).catch(res => {})
  163. },
  164. numberToK(v) {
  165. return numberToK(v)
  166. },
  167. setList(obj) {
  168. let that = this;
  169. // obj.data.forEach(res => {
  170. // // 获取图片宽高
  171. // // console.log(res.flie[0].img);
  172. // uni.getImageInfo({
  173. // src: res.flie[0].img,
  174. // success: (image) => {
  175. // // console.log(res.src)
  176. // // 计算图片渲染高度
  177. // let showH = (50 * image.height) / image.width
  178. // // 判断左右盒子高度
  179. // if (that.leftH <= that.rightH) {
  180. // that.leftList.push(res)
  181. // that.leftH += showH
  182. // } else {
  183. // that.rightList.push(res)
  184. // that.rightH += showH
  185. // }
  186. // }
  187. // })
  188. // })
  189. let total = this.leftList.length + this.rightList.length;
  190. if (obj.total > total) {
  191. this.status = 'loadmore'
  192. } else {
  193. this.status = 'No more data'
  194. }
  195. },
  196. go(url, login) {
  197. if (this.isLogin == 2 && login) {
  198. this.$toUrl('/pages/login/login')
  199. return
  200. }
  201. this.$toUrl(url)
  202. },
  203. }
  204. }
  205. </script>
  206. <style lang="scss">
  207. page {
  208. background-color: #f3f3f3;
  209. }
  210. .container {
  211. padding-bottom: 140rpx;
  212. }
  213. .top {
  214. position: sticky;
  215. top: 0;
  216. z-index: 999;
  217. .header {
  218. display: flex;
  219. align-items: center;
  220. justify-content: space-between;
  221. padding: 8rpx 16px 16rpx;
  222. background-color: #10044A;
  223. }
  224. .logo {
  225. height: 24px;
  226. }
  227. .border {
  228. border: 1px solid #CC2900;
  229. border-radius: 50%;
  230. }
  231. .title-box {
  232. height: 40px;
  233. background-color: #262E4A;
  234. padding: 0 16px;
  235. display: flex;
  236. align-items: center;
  237. color: #fff;
  238. font-weight: 500;
  239. font-size: 16px;
  240. }
  241. }
  242. .waterfall-item {
  243. background-color: #fff;
  244. border-radius: 12rpx;
  245. overflow: hidden;
  246. font-size: 28rpx;
  247. color: #666;
  248. margin-bottom: 20rpx;
  249. .waterfall-title {
  250. padding: 20rpx 10rpx;
  251. font-weight: 700;
  252. }
  253. .waterfall-item-img {
  254. position: relative;
  255. .loading-banner-img {
  256. width: 100%;
  257. height: 404rpx;
  258. }
  259. .content {
  260. color: #fff;
  261. font-size: 24rpx;
  262. position: absolute;
  263. bottom: 16rpx;
  264. right: 16rpx;
  265. left: 16rpx;
  266. image {
  267. width: 24rpx;
  268. height: 24rpx;
  269. }
  270. }
  271. }
  272. .cover {
  273. display: block;
  274. width: 100%;
  275. border-radius: 12rpx 12rpx 0 0;
  276. // 默认设置一个图片的大约值
  277. // height: 450rpx;
  278. // min-height: 600rpx;
  279. }
  280. }
  281. .load-txt {
  282. padding: 0 0 20rpx 0;
  283. text-align: center;
  284. color: #999;
  285. font-size: 24rpx;
  286. }
  287. .publishicon {
  288. position: fixed;
  289. right: 32rpx;
  290. bottom: 220rpx;
  291. width: 94rpx;
  292. height: 94rpx;
  293. z-index: 99;
  294. }
  295. .news-install {
  296. position: fixed;
  297. left: 0;
  298. right: 0;
  299. bottom: var(--window-bottom);
  300. z-index: 200;
  301. }
  302. </style>