index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view class="live">
  3. <view class="navBar">
  4. <div class="top">
  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. </view>
  17. <div
  18. class="list-swiper"
  19. v-if="bannerList.length"
  20. :class="{ fadeInBtm: animationLoaded }"
  21. >
  22. <swiper
  23. class="swiper"
  24. radius="24rpx"
  25. bgColor="#ffffff"
  26. circular
  27. previous-margin="30rpx"
  28. next-margin="30rpx"
  29. :indicator-dots="false"
  30. :autoplay="true"
  31. :interval="2000"
  32. :duration="500"
  33. >
  34. <swiper-item
  35. class="swiper-item"
  36. v-for="(item, index) in bannerList"
  37. :key="index"
  38. @click="swiperClick(item)"
  39. >
  40. <div class="top">
  41. <img class="live-img" v-if="item.islive == 1" src="/static/image/game/live.png" alt="">
  42. <div class="flex">
  43. <img class="icon_view" src="/static/image/game/icon_view.png" alt="">
  44. {{ numberToK(item.viewers) || 0 }}
  45. </div>
  46. </div>
  47. <div class="img-box">
  48. <u--image
  49. mode="aspectFill"
  50. :showLoading="true"
  51. :src="item.thumb"
  52. width="100%"
  53. height="42.05vw"
  54. >
  55. <template v-slot:loading>
  56. <image
  57. class="loading-banner-img"
  58. src="/static/image/common/video-banner-bg.png"
  59. ></image>
  60. </template>
  61. </u--image>
  62. </div>
  63. <div class="bottom">
  64. <u--image
  65. class="avatar"
  66. :src="item.avatar"
  67. shape="circle"
  68. width="78rpx"
  69. height="78rpx"
  70. ></u--image>
  71. <div>
  72. <div class="text-clamp">{{ item.title }}</div>
  73. <div>{{ item.user_nickname }} ・ {{ getTimeAgo(item.addtime) }}</div>
  74. </div>
  75. </div>
  76. </swiper-item>
  77. </swiper>
  78. </div>
  79. <div class="ad-list">
  80. <div
  81. class="item"
  82. v-for="item in adList"
  83. :key="item.id"
  84. @click="adClick(item)"
  85. >
  86. <img class="ad" :src="item.img" alt="" />
  87. </div>
  88. </div>
  89. <tournamentList :list="userList"></tournamentList>
  90. <historyList></historyList>
  91. </view>
  92. </template>
  93. <script>
  94. import tournamentList from "./compontent/tournamentList.vue";
  95. import historyList from "./compontent/historyList.vue";
  96. import animationMixin from "@/pages/mixins/animation";
  97. import { numberToK, formatTime } from "@/utils/util";
  98. export default {
  99. components: {
  100. historyList,
  101. tournamentList,
  102. },
  103. mixins: [animationMixin],
  104. data() {
  105. return {
  106. bannerList: [],
  107. adList: [],
  108. list: [],
  109. userList: [],
  110. current: 0,
  111. tokenIsLogin: "",
  112. homeShow: false,
  113. intervalTimer: null,
  114. };
  115. },
  116. computed: {
  117. info() {
  118. return this.$store.state.info;
  119. },
  120. isLogin() {
  121. return this.$store.state.isLogin;
  122. },
  123. },
  124. onReachBottom() {
  125. },
  126. created() {
  127. this.getBanner();
  128. this.intervalTimer = setInterval(() => {
  129. this.getBanner();
  130. }, 10000);
  131. },
  132. activated() {
  133. this.intervalTimer = setInterval(() => {
  134. this.getBanner();
  135. }, 10000);
  136. },
  137. deactivated() {
  138. clearInterval(this.intervalTimer);
  139. this.intervalTimer = null;
  140. },
  141. methods: {
  142. getBanner() {
  143. uni.$u.http
  144. .get("/api/game/home", {
  145. params: {
  146. },
  147. }).then((res) => {
  148. this.adList = res.banner || [];
  149. this.bannerList = res.list || [];
  150. this.userList = res.users || [];
  151. })
  152. .catch((res) => {})
  153. .finally(() => {
  154. if (this.animationLoaded) {
  155. return;
  156. }
  157. this.animationLoaded = true;
  158. this.$nextTick(() => {
  159. this.scrollFun();
  160. });
  161. });
  162. },
  163. go(url, login) {
  164. if (this.isLogin == 2 && login) {
  165. this.$toUrl("/pages/login/login");
  166. return;
  167. }
  168. this.$toUrl(url);
  169. },
  170. adClick(item) {
  171. if (item.url) {
  172. uni.$u.http
  173. .post("/api/live_streaming/click_adv", {
  174. type: 8,
  175. id: item.id,
  176. url: item.url
  177. })
  178. .then((res) => {
  179. }).finally(() => {
  180. });
  181. window.open(item.url);
  182. }
  183. },
  184. swiperClick(item) {
  185. if (item.url) {
  186. window.open(item.url)
  187. return
  188. }
  189. if (item.uid) {
  190. uni.navigateTo({
  191. url: `/pages/Live/live-detail?type=game&id=${item.uid}&ID=${item.id}`,
  192. });
  193. return;
  194. }
  195. if (item.param_id) {
  196. uni.navigateTo({
  197. url: "/pages/Match/match-detail?id=" + item.param_id,
  198. });
  199. return;
  200. }
  201. },
  202. numberToK(v) {
  203. return numberToK(v);
  204. },
  205. getTimeAgo(time) {
  206. return formatTime(time, this)
  207. }
  208. }
  209. }
  210. </script>
  211. <style lang="scss">
  212. page {
  213. background-color: #f3f3f7;
  214. }
  215. .live {
  216. padding-bottom: var(--window-bottom);
  217. }
  218. .navBar {
  219. position: sticky;
  220. top: 0;
  221. z-index: 10;
  222. background-color: #10044a;
  223. .top {
  224. display: flex;
  225. align-items: center;
  226. justify-content: space-between;
  227. padding: 8rpx 16px 16rpx;
  228. .border {
  229. border: 1px solid #cc2900;
  230. border-radius: 50%;
  231. }
  232. }
  233. .logo {
  234. height: 24px;
  235. }
  236. }
  237. .list-swiper {
  238. padding: 20rpx 0;
  239. .swiper {
  240. height: 42.05vw;
  241. color: #fff;
  242. }
  243. .swiper-item {
  244. padding: 0 12rpx;
  245. box-sizing: border-box;
  246. }
  247. .img-box {
  248. border-radius: 24rpx;
  249. overflow: hidden;
  250. position: relative;
  251. }
  252. .top {
  253. position: absolute;
  254. left: 22rpx;
  255. top: 20rpx;
  256. z-index: 10;
  257. display: flex;
  258. align-items: center;
  259. .flex {
  260. background-color: rgba(0, 0, 0, 0.5);
  261. border-radius: 3px;
  262. height: 44rpx;
  263. padding: 0 18rpx;
  264. font-size: 26rpx;
  265. }
  266. .icon_view {
  267. width: 27rpx;
  268. margin-right: 6rpx;
  269. }
  270. }
  271. .live-img {
  272. width: 92rpx;
  273. margin-right: 10rpx;
  274. }
  275. .bottom {
  276. position: absolute;
  277. bottom: 22rpx;
  278. left: 20rpx;
  279. right: 20rpx;
  280. font-size: 28rpx;
  281. display: flex;
  282. align-items: center;
  283. .avatar {
  284. margin-right: 20rpx;
  285. }
  286. }
  287. }
  288. .ad-list {
  289. padding: 0 14px;
  290. .item {
  291. padding-top: 10px;
  292. .ad {
  293. display: block;
  294. width: 100%;
  295. border-radius: 12rpx;
  296. }
  297. }
  298. }
  299. .news-install {
  300. position: sticky;
  301. bottom: var(--window-bottom);
  302. z-index: 200;
  303. }
  304. </style>