index.vue 9.3 KB

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