historyList.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <div class="tournament">
  3. <div class="box" v-if="list.length">
  4. <div class="title">
  5. <!-- History -->
  6. <div :class="{'fadeInRight': animationLoaded}">{{$t('live.title3')}}</div>
  7. <div class="all" :class="{'fadeInLeft': animationLoaded}" @click="$toUrl('./list?type=2')">
  8. <!-- See More -->
  9. {{ $t('live.more1') }}
  10. </div>
  11. </div>
  12. <div class="list-box" :class="{'fadeInTop': animationLoaded}">
  13. <div class="item" v-for="item in list" :key="item.id">
  14. <div class="top flex">
  15. <div class="left flex">
  16. <u--image
  17. class="avatar"
  18. :src="item.avatar"
  19. shape="circle"
  20. width="86rpx"
  21. height="86rpx"
  22. ></u--image>
  23. <div>
  24. <div class="name">{{ item.user_nickname }}</div>
  25. <div class="time">{{ getTimeAgo(item.created_at) }}</div>
  26. </div>
  27. </div>
  28. <div class="right">
  29. <u-icon @click="attention(item)" v-if="item.is_attention != 1" color="#747474" name="plus-people-fill" size="50rpx"></u-icon>
  30. <u-icon @click="attention(item)" v-if="item.is_attention == 1" color="#747474" name="minus-people-fill" size="50rpx"></u-icon>
  31. </div>
  32. </div>
  33. <div class="title">{{ item.title }}</div>
  34. <div class="body" @click="toMatchLive(item)">
  35. <img class="img" :src="item.thumb" alt="">
  36. <div class="flex">
  37. <!-- <img class="live1" src="/static/image/game/live1.png" alt=""> -->
  38. <div class="view-box">
  39. <img class="icon_view1" src="/static/image/game/icon_view.png" alt="">
  40. {{ numberToK(item.viewers) || 0 }}
  41. </div>
  42. </div>
  43. </div>
  44. <div class="root">
  45. <div class="flex">
  46. <u-icon @click="isLike(item)" v-if="item.like != 1" color="#888888" name="heart" size="40rpx"></u-icon>
  47. <u-icon @click="isLike(item)" v-if="item.like == 1" color="#e46d45" name="heart-fill" size="40rpx"></u-icon>
  48. {{ numberToK(item.is_likes) || 0}}
  49. </div>
  50. <div class="flex">
  51. <img class="icon" src="/static/image/game/icon_comment.png" alt="">
  52. {{ numberToK(item.comment) || 0}}
  53. </div>
  54. <div class="flex">
  55. <img class="icon" @click="copyText(item)" src="/static/image/game/icon_share.png" alt="">
  56. <!-- Share -->
  57. {{ $t('news.share') }}
  58. </div>
  59. </div>
  60. </div>
  61. <div class="no-data" v-if="list.length == 0">
  62. <img class="load1" src="/static/image/live/load2.png" alt="">
  63. </div>
  64. </div>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import { numberToK, formatTime } from "@/utils/util";
  70. import animationMixin from '@/pages/mixins/animation'
  71. import NativeShare from 'nativeshare'
  72. export default {
  73. mixins: [animationMixin],
  74. data() {
  75. return {
  76. list: [],
  77. activeInfo: {},
  78. timer: null,
  79. pageNumber: 1,
  80. };
  81. },
  82. deactivated() {
  83. },
  84. created() {
  85. this.getHistory()
  86. },
  87. activated() {
  88. this.getHistory()
  89. },
  90. methods: {
  91. getHistory() {
  92. uni.$u.http.get('/api/game/history', {
  93. params: {
  94. page: this.pageNumber
  95. }
  96. }).then(res => {
  97. if (this.pageNumber == 1) {
  98. this.list = res.data || []
  99. } else {
  100. this.list = this.list.concat(res.data || [])
  101. }
  102. // this.status = this.liveList.length == res.total ? 'nomore' : 'loadmore'
  103. }).finally(() => {
  104. if (this.animationLoaded) {
  105. return;
  106. }
  107. this.animationLoaded = true;
  108. this.$nextTick(() => {
  109. this.scrollFun();
  110. });
  111. })
  112. },
  113. toMatchLive(item) {
  114. uni.navigateTo({
  115. url:`/pages/Live/history-detail?type=game&ID=${item.live_id}&MediaUrl=${item.video}`
  116. })
  117. },
  118. toUrlLive(item) {
  119. gtag("event", "live_H5", {
  120. live_H5: "0",
  121. });
  122. uni.navigateTo({
  123. url: `/pages/Live/live-detail?id=${item.live_id}&ID=${item.live_id}`,
  124. });
  125. },
  126. /* 喜欢 */
  127. isLike(item) {
  128. if (this.$store.state.isLogin != 1) {
  129. this.$toUrl('/pages/login/login')
  130. return
  131. }
  132. uni.showLoading({
  133. title: this.$t('common.lab'),
  134. });
  135. uni.$u.http
  136. .post("/api/Member/live_like", {
  137. id: item.live_id,
  138. type: item.like == 1 ? 0 : 1
  139. })
  140. .then((res) => {
  141. this.getHistory()
  142. }).finally(() => {
  143. uni.hideLoading();
  144. });
  145. },
  146. /* 关注 */
  147. attention(item) {
  148. if (this.$store.state.isLogin != 1) {
  149. this.$toUrl('/pages/login/login')
  150. return
  151. }
  152. uni.showLoading({
  153. title: this.$t('common.lab'),
  154. });
  155. uni.$u.http
  156. .post("/api/Member/attention", {
  157. id: item.uid,
  158. })
  159. .then((res) => {
  160. this.getHistory()
  161. }).finally(() => {
  162. uni.hideLoading();
  163. });
  164. },
  165. copyText(item) {
  166. if (this.$store.state.isLogin != 1) {
  167. this.$toUrl('/pages/login/login')
  168. return
  169. }
  170. this.nativeShare = new NativeShare()
  171. var shareData = {
  172. title: `${item.title}`,
  173. desc: 'OneCric: Live',
  174. // 如果是微信该link的域名必须要在微信后台配置的安全域名之内的。
  175. link: window.location.origin + `/pages/Live/history-detail?type=game&ID=${item.live_id}&MediaUrl=${item.video}`,
  176. icon: 'https://m.onecric.tv/static/logo.png',
  177. // 不要过于依赖以下两个回调,很多浏览器是不支持的
  178. // success: function() {
  179. // alert('success')
  180. // },
  181. // fail: function() {
  182. // alert('fail')
  183. // }
  184. }
  185. this.nativeShare.setShareData(shareData)
  186. try {
  187. this.nativeShare.call()
  188. } catch (err) {
  189. let oInput = document.querySelector('#copy-input')
  190. oInput.value = window.location.origin + `/pages/Live/history-detail?type=game&ID=${item.live_id}&MediaUrl=${item.video}`
  191. oInput.select() // 选择对象;
  192. document.execCommand('Copy') // 执行浏览器复制命令
  193. uni.$u.toast('Copy succeeded');
  194. }
  195. uni.$u.http
  196. .post("/api/Member/live_share", {
  197. id: item.live_id
  198. })
  199. .then((res) => {
  200. this.$emit('success')
  201. this.getHistory()
  202. }).finally(() => {
  203. });
  204. },
  205. numberToK(v) {
  206. return numberToK(v);
  207. },
  208. countdownFun(value) {
  209. if (!value) {
  210. return "";
  211. }
  212. var h = parseInt(value / 3600);
  213. var m = parseInt((value % 3600) / 60);
  214. var str = "";
  215. if (h > 0) {
  216. str += h + "hrs";
  217. if (m < 10) {
  218. m = "0" + m;
  219. }
  220. str += " " + m + "min";
  221. return str;
  222. } else {
  223. if (m > 0) {
  224. if (m < 10) {
  225. m = "0" + m;
  226. }
  227. str += m + "min";
  228. }
  229. }
  230. var s = parseInt((value % 3600) % 60);
  231. if (s < 10) {
  232. s = "0" + s;
  233. }
  234. str += " " + s + "s";
  235. return str;
  236. },
  237. getTimeAgo(time) {
  238. if (!time) {
  239. return ''
  240. }
  241. let t = new Date(time).getTime()
  242. return formatTime(t,this)
  243. }
  244. },
  245. };
  246. </script>
  247. <style lang="scss">
  248. .box {
  249. padding-top: 30px;
  250. padding-bottom: 6rpx;
  251. .title {
  252. font-size: 15px;
  253. padding-right: 14px;
  254. font-weight: bold;
  255. color: #242424;
  256. line-height: 1;
  257. display: flex;
  258. align-items: center;
  259. justify-content: space-between;
  260. padding-bottom: 20rpx;
  261. padding-left: 29rpx;
  262. .icon {
  263. height: 4.08vw;
  264. margin-right: 14rpx;
  265. }
  266. .all {
  267. color: #FF3300;
  268. }
  269. }
  270. }
  271. .list-box {
  272. .item {
  273. padding-top: 20rpx;
  274. padding-bottom: 30rpx;
  275. border-bottom: 1px solid #e7e7e7;
  276. }
  277. .top {
  278. justify-content: space-between;
  279. padding: 0 14px 22rpx 16rpx;
  280. .avatar {
  281. margin-right: 28rpx;
  282. }
  283. .name {
  284. font-size: 31rpx;
  285. font-weight: bold;
  286. }
  287. .time {
  288. font-size: 28rpx;
  289. color: #888;
  290. }
  291. }
  292. .title {
  293. padding: 0 14px 30rpx 16rpx;
  294. font-size: 31rpx;
  295. font-weight: 400;
  296. }
  297. .icon_view {
  298. width: 40rpx;
  299. }
  300. .body {
  301. position: relative;
  302. .flex {
  303. position: absolute;
  304. left: 40rpx;
  305. bottom: 24rpx;
  306. border-radius: 2rpx;
  307. }
  308. .live1 {
  309. height: 44rpx;
  310. margin-right: 34rpx;
  311. }
  312. .view-box {
  313. display: flex;
  314. align-items: center;
  315. height: 44rpx;
  316. padding: 0 12rpx;
  317. color: #fff;
  318. background-color: #000;
  319. border-radius: 2rpx;
  320. font-size: 25rpx;
  321. }
  322. .icon_view1 {
  323. width: 27rpx;
  324. margin-right: 6rpx;
  325. }
  326. }
  327. .img {
  328. display: block;
  329. width: 100%;
  330. margin-bottom: 27rpx;
  331. }
  332. .root {
  333. display: flex;
  334. align-items: center;
  335. justify-content: space-around;
  336. font-size: 28rpx;
  337. color: #888888;
  338. .u-icon {
  339. margin-right: 20rpx;
  340. }
  341. .icon {
  342. margin-right: 20rpx;
  343. width: 40rpx;
  344. }
  345. }
  346. }
  347. .no-data {
  348. padding: 5rpx;
  349. .load1 {
  350. width: 35.74vw;
  351. display: block;
  352. }
  353. }
  354. </style>