list-2.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <!-- 推荐 -->
  2. <template>
  3. <view class="list">
  4. <view class="list-swiper">
  5. <!-- <image src="" mode="scaleToFill"></image> -->
  6. <view class=""
  7. style="background: rgb(221, 221, 221);width: 100%;height: 60vw;border-radius: 20rpx;"
  8. v-if="list.length == 0">
  9. </view>
  10. <swiper v-else class="swiper" circular :indicator-dots="false" @change="swiperChange" :autoplay="true" :interval="2000"
  11. :duration="500">
  12. <swiper-item v-for="(item, index) in list" :key="index" @click="swiperClick(item)">
  13. <u--image
  14. mode="scaleToFill"
  15. :showLoading="true"
  16. :src="item.img"
  17. width="100%"
  18. height="60vw"
  19. >
  20. <template v-slot:loading>
  21. <image class="loading-banner-img" src="/static/image/common/video-banner-bg.png"></image>
  22. </template>
  23. </u--image>
  24. </swiper-item>
  25. </swiper>
  26. <div v-if="list.length > 1" class="swiper__indicator">
  27. <div class="line__bar" :style="{'width': lineWidth, 'transform': lineTransform}"></div>
  28. </div>
  29. </view>
  30. <todayList v-if="todayList.length > 0" :todayList="todayList"></todayList>
  31. <comingList v-if="comingList.length > 0" :comingList="comingList" :todayListLength="todayList.length"></comingList>
  32. <view class="detail-title flex-start" v-if="live_commentary.length>0">
  33. <image src="/static/image/live/detail01.png" mode=""></image>
  34. <text>{{$t('live.title2')}}</text>
  35. <!-- <view class="" v-if="item1.length != 0" @click="$toUrl('./list?type=' + i)">
  36. {{$t('live.more')}}>
  37. </view> -->
  38. </view>
  39. <view class="detail-video-list flex">
  40. <view class="detail-video-li" style="position: relative;" v-for="(item,index) in live_commentary" :key="index"
  41. @click="toUrlLive(item)">
  42. <div v-if="item.islive==0" class="zhezao">{{formatDate(item.starttime)}}</div>
  43. <div class="img_box">
  44. <u--image :showLoading="true" :src="(item.home_logo && item.away_logo) ? item.bottom : item.thumb" width="100%" height="176rpx">
  45. <template v-slot:loading>
  46. <image class="loading-list-img" src="/static/image/common/live-list-bg.png"></image>
  47. </template>
  48. </u--image>
  49. <image v-if="item.home_logo && item.away_logo" class="home_logo" :src="item.home_logo" mode="aspectFill" alt=""></image>
  50. <image v-if="item.home_logo && item.away_logo" class="away_logo" :src="item.away_logo" mode="aspectFill" alt=""></image>
  51. </div>
  52. <image v-if="item.islive==1" src="/static/image/live/live-icon.png" mode="" class="live-icon"></image>
  53. <view class="detail-video-content ">
  54. <view class="detail-video-title text-clamp2">
  55. {{item.title}}
  56. </view>
  57. <view class="detail-video-right flex">
  58. <image class="detail-video-content-logo" :src="item.avatar" mode="aspectFill"></image>
  59. <view class="detail-video-info flex">
  60. <text class="text-clamp">{{item.user_nickname}}</text>
  61. <u-icon color="#999" name="eye" size="30" v-if="item.viewers && item.islive==1"></u-icon>
  62. <view v-if="item.islive==1">{{numberToK(item.viewers)}}</view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. <view class="detail-title flex-start">
  69. <image src="/static/image/live/detail01.png" mode=""></image>
  70. <text>{{$t('live.title3')}}</text>
  71. <view class="more" v-if="robotLength > 6" @click="$toUrl('./list?type=2')">
  72. {{$t('live.more')}}<u-icon name="arrow-right" color="#DC3C23" size="28rpx"></u-icon>
  73. </view>
  74. </view>
  75. <u-empty v-if="robot.length == 0" mode="data" width="474" height="312" textSize="28" marginTop="100"
  76. :text="$t('common.nodata')" icon="/static/image/common/nodata.png">
  77. </u-empty>
  78. <!-- History -->
  79. <view class="detail-video-list flex">
  80. <view class="detail-video-li" style="position: relative;" v-for="(item,index) in robot" :key="index"
  81. @click="historyLive(item)">
  82. <div class="img_box">
  83. <u--image :showLoading="true" :src="item.bottom" width="100%" height="176rpx">
  84. <template v-slot:loading>
  85. <image class="loading-list-img" src="/static/image/common/live-list-bg.png"></image>
  86. </template>
  87. </u--image>
  88. <image class="home_logo" :src="item.home_logo" mode="aspectFill" alt=""></image>
  89. <image class="away_logo" :src="item.away_logo" mode="aspectFill" alt=""></image>
  90. </div>
  91. <image src="/static/image/live/live-history-icon.png" mode="" class="history-icon"></image>
  92. <view class="detail-video-content ">
  93. <view class="detail-video-title1 text-clamp">
  94. {{item.Name}}
  95. </view>
  96. <div class="start_time">{{ parseTime1(item.start_time) }}</div>
  97. <view class="detail-video-right flex">
  98. <image class="detail-video-content-logo" :src="item.UserHead" mode="aspectFill"></image>
  99. <view class="detail-video-info flex">
  100. <text class="text-clamp">{{item.UserName}}</text>
  101. <u-icon color="#999" name="eye" size="30" v-if="item.viewers"></u-icon>
  102. <view>{{numberToK(item.viewers)}}</view>
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. <u-toast ref="uToast"></u-toast>
  109. </view>
  110. </template>
  111. <script>
  112. import todayList from "./todayList.vue";
  113. import comingList from "./comingList.vue";
  114. import { numberToK, parseTime } from '@/utils/util'
  115. export default {
  116. components: {
  117. todayList,
  118. comingList,
  119. },
  120. data() {
  121. return {
  122. // list: [{
  123. // image: 'https://cdn.uviewui.com/uview/swiper/1.jpg',
  124. // title: '昨夜星辰昨夜风,画楼西畔桂堂东'
  125. // },
  126. // {
  127. // image: 'https://cdn.uviewui.com/uview/swiper/2.jpg',
  128. // title: '身无彩凤双飞翼,心有灵犀一点通'
  129. // },
  130. // {
  131. // image: 'https://cdn.uviewui.com/uview/swiper/3.jpg',
  132. // title: '谁念西风独自凉,萧萧黄叶闭疏窗,沉思往事立残阳'
  133. // }
  134. // ],
  135. liveList: {
  136. live_commentary: {},
  137. nolive_broadcast: {},
  138. robot: {}
  139. },
  140. todayList: [],
  141. comingList: [],
  142. live_commentary: [],
  143. nolive_broadcast: [],
  144. robot: [],
  145. bannerList: [],
  146. robotLength: 0,
  147. swiperCurrent: 0
  148. }
  149. },
  150. props: {
  151. list: {
  152. type: Array,
  153. default: []
  154. }
  155. },
  156. computed: {
  157. lineWidth() {
  158. return (1/this.list.length) * 100 + '%'
  159. },
  160. lineTransform() {
  161. return `translateX(${100 * this.swiperCurrent}%)`
  162. }
  163. },
  164. mounted() {
  165. this.getList()
  166. },
  167. methods: {
  168. swiperClick(item) {
  169. if (item.anchor_id) {
  170. uni.navigateTo({
  171. url: `./live-detail?id=${item.anchor_id}&ID=${item.id}`
  172. })
  173. return
  174. }
  175. if (item.param_id) {
  176. uni.navigateTo({
  177. url: '/pages/Match/match-detail?id=' + item.param_id
  178. })
  179. return
  180. }
  181. },
  182. // 点击history
  183. historyLive(item) {
  184. // console.error(item)
  185. // return
  186. uni.navigateTo({
  187. url:`/pages/Live/history-detail?id=${item.Uid}&ID=${item.live_id}&MediaUrl=${item.MediaUrl}`
  188. })
  189. },
  190. /* 跳转 */
  191. toUrl(item) {
  192. console.log(item);
  193. /* item.type == 1?'basketball':'football */
  194. if (item.type == 1) {
  195. uni.navigateTo({
  196. url: '../competition/basketballDetail?id=' + item.id
  197. })
  198. } else {
  199. uni.navigateTo({
  200. url: '../competition/detail?id=' + item.sourceid
  201. })
  202. }
  203. },
  204. toUrlLive(item) {
  205. gtag('event', 'live_H5', {
  206. 'live_H5': '0'
  207. });
  208. uni.navigateTo({
  209. url: `./live-detail?id=${item.live_id}&ID=${item.id}`
  210. })
  211. },
  212. getList() {
  213. uni.$u.http.get('/api/live_streaming/getLiveList', {
  214. params: 2
  215. }).then(res => {
  216. this.live_commentary = res.data || []
  217. })
  218. uni.$u.http.get('/api/live_streaming/getLiveListNew', {
  219. params: {
  220. timeZone: this.$store.state.timeZone
  221. }
  222. }).then(res => {
  223. this.todayList = res.toay || [];
  224. this.comingList = res.upcoming || [];
  225. })
  226. uni.$u.http.get('/api/LivePlayBack/list', {}).then(res => {
  227. if (res.list) {
  228. this.robotLength = res.list.length
  229. this.robot = res.list.slice(0, 6)
  230. } else {
  231. this.robot = []
  232. }
  233. })
  234. },
  235. swiperChange(e) {
  236. this.swiperCurrent = e.detail.current
  237. },
  238. numberToK(v) {
  239. return numberToK(v)
  240. },
  241. formatDate(value) {
  242. var date1 = this.$common.parseTime(value * 1000, '{y}/{m}/{d} {h}:{i}:{s}')
  243. var date = new Date(date1 + ' UTC+5:30');
  244. var weekNum = new Date().getDay()
  245. let week = ""
  246. switch (weekNum) {
  247. case 0:
  248. week = "Sun";
  249. break;
  250. case 1:
  251. week = "Mon";
  252. break;
  253. case 2:
  254. week = "Tue";
  255. break;
  256. case 3:
  257. week = "Wed";
  258. break;
  259. case 4:
  260. week = "Thu";
  261. break;
  262. case 5:
  263. week = "Fri";
  264. break;
  265. case 6:
  266. week = "Sat";
  267. break;
  268. }
  269. var MonthNum = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1)
  270. let Month = ''
  271. switch (MonthNum) {
  272. case 1:
  273. Month = "Jan";
  274. break;
  275. case 2:
  276. Month = "Feb";
  277. break;
  278. case 3:
  279. Month = "Mar";
  280. break;
  281. case 4:
  282. Month = "Apr";
  283. break;
  284. case 5:
  285. Month = "May";
  286. break;
  287. case 6:
  288. Month = "Jun";
  289. break;
  290. case 7:
  291. Month = "Jul";
  292. break;
  293. case 8:
  294. Month = "Aug";
  295. break;
  296. case 9:
  297. Month = "Sept";
  298. break;
  299. case 10:
  300. Month = "Oct";
  301. break;
  302. case 11:
  303. Month = "Nov";
  304. break;
  305. case 12:
  306. Month = "Dec";
  307. break;
  308. }
  309. let day = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate())
  310. // this.week = week
  311. // this.month = Month
  312. // this.day = day
  313. var hours = date.getHours();
  314. var minutes = date.getMinutes();
  315. var ampm = hours >= 12 ? 'PM' : 'AM';
  316. if (hours != 12) {
  317. hours = hours % 12;
  318. }
  319. if (hours == 12 && minutes) {
  320. hours = hours % 12;
  321. ampm = 'PM'
  322. }
  323. hours = hours < 10 ? "0" + hours : hours;
  324. minutes = minutes < 10 ? '0' + minutes : minutes;
  325. // var strTime = week + ',' + day + Month + '.' + 'Watch live in' + hours + ':' + minutes + ' ' + ampm;
  326. var strTime = this.$t('match.lab92') + ' ' + hours + ':' + minutes + ' ' + ampm;
  327. return strTime;
  328. },
  329. parseTime(t) {
  330. return parseTime(t, '{m}-{d} {h}:{i}')
  331. },
  332. parseTime1(t) {
  333. return parseTime(t, '{y}-{m}-{d} {h}:{i}')
  334. }
  335. }
  336. }
  337. </script>
  338. <style lang="scss">
  339. .zhezao {
  340. background: rgba(0, 0, 0, 0.5);
  341. position: absolute;
  342. top: 0;
  343. left: 0;
  344. z-index: 2;
  345. color: #fff;
  346. text-align: center;
  347. line-height: 1;
  348. padding: 10rpx 6rpx;
  349. border-radius: 6rpx;
  350. font-size: 16rpx;
  351. white-space: nowrap;
  352. }
  353. .live-icon {
  354. position: absolute;
  355. right: 10rpx;
  356. bottom: 160rpx;
  357. width: 60rpx;
  358. height: 32rpx;
  359. }
  360. .history-icon {
  361. position: absolute;
  362. right: 10rpx;
  363. bottom: 160rpx;
  364. width: 120rpx;
  365. height: 34rpx;
  366. }
  367. .list {
  368. padding-bottom: 140rpx;
  369. }
  370. .detail-video-list {
  371. padding: 4rpx 18rpx;
  372. flex-wrap: wrap;
  373. .loading-list-img {
  374. width: 100%;
  375. height: 176rpx;
  376. }
  377. }
  378. .img_box {
  379. position: relative;
  380. }
  381. .home_logo, .away_logo {
  382. position: absolute;
  383. top: 50%;
  384. transform: translateY(-50%);
  385. width: 90rpx;
  386. height: 90rpx;
  387. border-radius: 50%;
  388. }
  389. .home_logo {
  390. left: 30rpx;
  391. }
  392. .away_logo {
  393. right: 30rpx;
  394. }
  395. .list-swiper {
  396. padding: 0;
  397. position: relative;
  398. .swiper {
  399. height: 60vw;
  400. }
  401. .loading-banner-img {
  402. width: 100%;
  403. height: 60vw;
  404. }
  405. .swiper__indicator {
  406. position: absolute;
  407. left: 50%;
  408. transform: translateX(-50%);
  409. bottom: 10rpx;
  410. border-radius: 3rpx;
  411. width: 110rpx;
  412. background-color: rgba(255, 255, 255, 0.35);
  413. }
  414. .line__bar {
  415. background-color: #fff;
  416. height: 4rpx;
  417. border-radius: 3rpx;
  418. transition: transform 0.3s, -webkit-transform 0.3s;
  419. }
  420. }
  421. .list-roll {
  422. margin-top: 20rpx;
  423. }
  424. .list-roll-li {
  425. padding: 16rpx;
  426. min-width: 332rpx;
  427. margin-right: 20rpx;
  428. border-radius: 12rpx;
  429. background-color: white;
  430. box-shadow: 0px 4px 12px rgba(51, 51, 51, 0.06);
  431. .list-roll-li-top {
  432. margin-bottom: 26rpx;
  433. font-size: 24rpx;
  434. text {
  435. color: #999;
  436. }
  437. view {
  438. color: #87390E;
  439. padding: 8rpx 26rpx;
  440. background: linear-gradient(90deg, #FFDFAB 0%, #E3AC72 100%);
  441. }
  442. }
  443. .list-roll-li-nav {
  444. view {
  445. font-size: 28rpx;
  446. image {
  447. width: 44rpx;
  448. height: 44rpx;
  449. margin-right: 6rpx;
  450. }
  451. view {
  452. flex: 1;
  453. }
  454. }
  455. }
  456. }
  457. .detail-title {
  458. margin-top: 20rpx;
  459. font-weight: bold;
  460. padding: 0 18rpx;
  461. image {
  462. width: 40rpx;
  463. height: 40rpx;
  464. margin-right: 16rpx;
  465. }
  466. .more {
  467. color: #DC3C23;
  468. font-size: 28rpx;
  469. flex: 1;
  470. display: flex;
  471. align-items: center;
  472. justify-content: flex-end;
  473. }
  474. text {
  475. color: #333;
  476. font-size: 30rpx;
  477. }
  478. }
  479. .detail-video-li {
  480. overflow: hidden;
  481. margin-top: 20rpx;
  482. width: calc(100% / 2 - 9rpx);
  483. border-radius: 12rpx;
  484. background-color: white;
  485. .detail-video-li-logo {
  486. width: 100%;
  487. height: 176rpx;
  488. display: block;
  489. }
  490. .detail-video-content {
  491. padding: 16rpx;
  492. .detail-video-content-logo {
  493. width: 40rpx;
  494. height: 40rpx;
  495. border-radius: 50%;
  496. margin-right: 24rpx;
  497. }
  498. .detail-video-title {
  499. width: 99%;
  500. height: 80rpx;
  501. color: #333;
  502. font-size: 28rpx;
  503. }
  504. .detail-video-title1 {
  505. width: 99%;
  506. color: #333;
  507. font-size: 28rpx;
  508. }
  509. .start_time {
  510. color: #333;
  511. font-size: 28rpx;
  512. }
  513. }
  514. .detail-video-info {
  515. font-size: 24rpx;
  516. flex: 1;
  517. .u-icon {
  518. margin-right: 6rpx;
  519. }
  520. image {
  521. width: 24rpx;
  522. height: 24rpx;
  523. margin-right: 6rpx;
  524. }
  525. text {
  526. flex: 1;
  527. width: 100rpx;
  528. color: #9193B4;
  529. }
  530. view {
  531. color: #999;
  532. }
  533. }
  534. }
  535. .detail-video-right {
  536. flex: 1;
  537. min-width: 100px;
  538. }
  539. </style>