index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <app-layout>
  3. <view class="box">
  4. <view v-if="list.length" class="list-box">
  5. <view class="item"
  6. v-for="(item, index) in list"
  7. :key="index"
  8. @click="liveClick(item)">
  9. <view class="anchor-img-box">
  10. <image mode="aspectFill" class="anchor-img" :src="item.anchor_img"></image>
  11. <image v-if="item.live_status === 103" class="play-icon"
  12. src="/static/image/video-play.png"></image>
  13. <!--<view @click.stop="subscribeClick" class="subscribe-box" v-if="item.live_status === 102">-->
  14. <!--<subscribe :room-id="item.roomid"></subscribe>-->
  15. <!--</view>-->
  16. </view>
  17. <view class="room-info-box">
  18. <view class="name">{{item.name}}</view>
  19. <view class="user-info-box">
  20. <image mode="aspectFill" class="anchor-img" :src="item.anchor_img"></image>
  21. <span class="anchor-name">{{item.anchor_name}}</span>
  22. </view>
  23. </view>
  24. <view v-if="item.live_status === 101" class="tag-box tag-box-3">
  25. <view class="text">
  26. <image class="live-icon" src="/static/image/icon/liveing.png"></image>
  27. <span>{{item.status_text}}</span>
  28. </view>
  29. </view>
  30. <!--预告-->
  31. <view v-else-if="item.live_status === 102" class="tag-box tag-box-1">
  32. <view class="text">
  33. <view class="round"></view>
  34. <span>{{item.status_text}}</span>
  35. </view>
  36. <view class="text-time">{{item.text_time}}</view>
  37. </view>
  38. <view v-else-if="item.live_status === 103" class="tag-box tag-box-2">
  39. <view class="text">
  40. <view class="round"></view>
  41. <span>{{item.status_text}}</span>
  42. </view>
  43. </view>
  44. <view v-else class="tag-box tag-box-3">
  45. <view class="text">
  46. <view class="round"></view>
  47. <span>{{item.status_text}}</span>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view v-else class="empty-box">
  53. <image src="/static/image/order-empty.png"></image>
  54. <span>暂无任何内容</span>
  55. </view>
  56. <app-load-text v-if="is_show_load"></app-load-text>
  57. <view v-if="is_show_hint" class="hint">没有更多内容了哦</view>
  58. </view>
  59. </app-layout>
  60. </template>
  61. <script>
  62. import {mapState} from "vuex";
  63. export default {
  64. data() {
  65. return {
  66. list: [],
  67. page: 1,
  68. is_show_load: false,
  69. is_show_hint: false,
  70. }
  71. },
  72. computed: {
  73. ...mapState({
  74. userInfo: state => state.user.info,
  75. })
  76. },
  77. methods: {
  78. liveClick(live) {
  79. let self = this;
  80. if (live.live_status === 101 || live.live_status === 102) {
  81. let userId = this.userInfo ? this.userInfo.options.user_id : 0;
  82. let customParams = {user_id: userId}; // 开发者在直播间页面路径上携带自定义参数
  83. uni.navigateTo({
  84. url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${live.roomid}&custom_params=${encodeURIComponent(JSON.stringify(customParams))}`
  85. })
  86. } else if (live.live_status === 103) {
  87. uni.setStorage({
  88. key: "live_playback",
  89. data: {
  90. room_info: live
  91. }
  92. });
  93. uni.navigateTo({
  94. url: `/pages/live/playback?room_id=${live.roomid}`
  95. })
  96. }
  97. },
  98. getList() {
  99. let self = this;
  100. if (!self.is_show_load) {
  101. self.$showLoading({
  102. text: '加载中...'
  103. });
  104. }
  105. self.$request({
  106. url: self.$api.live.index,
  107. data: {
  108. page: self.page,
  109. },
  110. }).then(response => {
  111. self.$hideLoading();
  112. self.is_show_load = false;
  113. if (response.code === 0) {
  114. let {list} = response.data;
  115. if (self.page != 1) {
  116. self.list = self.list.concat(list)
  117. } else {
  118. self.list = list;
  119. }
  120. self.page = list.length ? self.page + 1 : self.page;
  121. if (list.length === 0) {
  122. self.is_show_hint = true;
  123. }
  124. } else {
  125. uni.showToast({
  126. title: response.msg,
  127. icon: 'none',
  128. duration: 1000,
  129. });
  130. }
  131. }).catch(() => {
  132. self.is_show_load = false;
  133. self.$hideLoading();
  134. });
  135. },
  136. subscribeClick() {
  137. console.log(1)
  138. }
  139. },
  140. onLoad(options) {
  141. this.getList();
  142. },
  143. /**
  144. * 页面上拉触底事件的处理函数
  145. */
  146. onReachBottom() {
  147. this.is_show_load = true;
  148. this.is_show_hint = false;
  149. this.getList()
  150. },
  151. onShareAppMessage(object) {
  152. return this.$shareAppMessage({
  153. title: '直播列表',
  154. path: '/pages/live/index',
  155. params: {
  156. user_id: this.userInfo ? this.userInfo.options.user_id : 0
  157. }
  158. });
  159. },
  160. }
  161. </script>
  162. <style scoped lang="scss">
  163. .list-box {
  164. padding: 20#{rpx};
  165. display: flex;
  166. flex-wrap: wrap;
  167. justify-content: space-between;
  168. .item {
  169. width: 346#{rpx};
  170. border-radius: 16#{rpx};
  171. box-shadow: 0 0 10#{rpx} 1#{rpx} rgba(0, 0, 0, 0.1);
  172. margin-bottom: 20#{rpx};
  173. position: relative;
  174. background: #ffffff;
  175. .tag-box {
  176. position: absolute;
  177. top: 0;
  178. left: 0;
  179. display: flex;
  180. }
  181. .tag-box-1 {
  182. .text {
  183. background: #22ac38;
  184. }
  185. .text-time {
  186. padding: 12#{rpx} 20#{rpx};
  187. font-size: 24#{rpx};
  188. color: #fff;
  189. background: rgba(0, 0, 0, 0.5);
  190. margin-left: -20rpx;
  191. border-bottom-right-radius: 30#{rpx};
  192. border-top-right-radius: 30#{rpx};
  193. padding-left: 30#{rpx};
  194. }
  195. }
  196. .tag-box-2 {
  197. .text {
  198. background: #777777;
  199. }
  200. }
  201. .tag-box-3 {
  202. .text {
  203. background: #ff4544;
  204. }
  205. .live-icon {
  206. width: 24#{rpx};
  207. height: 24#{rpx};
  208. margin-right: 12#{rpx};
  209. }
  210. }
  211. .round {
  212. width: 15#{rpx};
  213. height: 15#{rpx};
  214. background: #fff;
  215. border-radius: 50%;
  216. margin-right: 12#{rpx};
  217. }
  218. .text {
  219. padding: 12#{rpx} 20#{rpx};
  220. font-size: 26#{rpx};
  221. border-top-left-radius: 16#{rpx};
  222. border-top-right-radius: 30#{rpx};
  223. border-bottom-right-radius: 30#{rpx};
  224. z-index: 10;
  225. color: #fff;
  226. display: flex;
  227. align-items: center;
  228. }
  229. .anchor-img-box {
  230. width: 346#{rpx};
  231. height: 346#{rpx};
  232. border-radius: 16#{rpx};
  233. position: relative;
  234. overflow: hidden;
  235. .anchor-img {
  236. position: absolute;
  237. top: 0;
  238. left: 0;
  239. width: 100%;
  240. height: 100%;
  241. }
  242. .play-icon {
  243. width: 100#{rpx};
  244. height: 100#{rpx};
  245. position: absolute;
  246. top: 123#{rpx};
  247. left: 123#{rpx};
  248. }
  249. .subscribe-box {
  250. position: absolute;
  251. top: 153#{rpx};
  252. left: 53#{rpx};
  253. }
  254. }
  255. .room-info-box {
  256. padding: 15#{rpx} 28#{rpx};
  257. .name {
  258. font-size: 28#{rpx};
  259. color: #353535;
  260. white-space: nowrap;
  261. -ms-text-overflow: ellipsis;
  262. text-overflow: ellipsis;
  263. overflow: hidden;
  264. }
  265. .user-info-box {
  266. display: flex;
  267. align-items: center;
  268. margin-top: 12#{rpx};
  269. .anchor-img {
  270. width: 40#{rpx};
  271. height: 40#{rpx};
  272. -webkit-border-radius: 50%;
  273. -moz-border-radius: 50%;
  274. border-radius: 50%;
  275. }
  276. .anchor-name {
  277. width: 200#{rpx};
  278. font-size: 24#{rpx};
  279. color: #999999;
  280. margin-left: 12#{rpx};
  281. white-space: nowrap;
  282. -ms-text-overflow: ellipsis;
  283. text-overflow: ellipsis;
  284. overflow: hidden;
  285. }
  286. }
  287. }
  288. }
  289. }
  290. .empty-box {
  291. width: 100%;
  292. height: 100vh;
  293. display: flex;
  294. justify-content: center;
  295. align-items: center;
  296. flex-direction: column;
  297. image {
  298. width: 280#{rpx};
  299. height: 280#{rpx};
  300. }
  301. span {
  302. margin-top: 15#{rpx};
  303. color: #999;
  304. font-size: 28#{rpx};
  305. }
  306. }
  307. .hint {
  308. font-size: 24#{rpx};
  309. color: #999999;
  310. text-align: center;
  311. width: 100%;
  312. margin-bottom: 15#{rpx};
  313. }
  314. </style>