index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. data() {
  58. return {
  59. list: [],
  60. page: 1,
  61. is_show_load: false,
  62. is_show_hint: false,
  63. }
  64. },
  65. computed: {
  66. ...mapState({
  67. userInfo: state => state.user.info,
  68. })
  69. },
  70. methods: {
  71. liveClick(live) {
  72. let self = this;
  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() {
  119. this.getList();
  120. },
  121. /**
  122. * 页面上拉触底事件的处理函数
  123. */
  124. onReachBottom() {
  125. this.is_show_load = true;
  126. this.is_show_hint = false;
  127. this.getList()
  128. },
  129. onShareAppMessage() {
  130. return this.$shareAppMessage({
  131. title: '直播列表',
  132. path: '/pages/live/index',
  133. params: {
  134. user_id: this.userInfo ? this.userInfo.options.user_id : 0
  135. }
  136. });
  137. },
  138. }
  139. </script>
  140. <style scoped lang="scss">
  141. .list-box {
  142. padding: 20#{rpx};
  143. display: flex;
  144. flex-wrap: wrap;
  145. justify-content: space-between;
  146. .item {
  147. width: 346#{rpx};
  148. border-radius: 16#{rpx};
  149. box-shadow: 0 0 10#{rpx} 1#{rpx} rgba(0, 0, 0, 0.1);
  150. margin-bottom: 20#{rpx};
  151. position: relative;
  152. background: #ffffff;
  153. .tag-box {
  154. position: absolute;
  155. top: 0;
  156. left: 0;
  157. display: flex;
  158. }
  159. .tag-box-1 {
  160. .text {
  161. background: #22ac38;
  162. }
  163. .text-time {
  164. padding: 12#{rpx} 20#{rpx};
  165. font-size: 24#{rpx};
  166. color: #fff;
  167. background: rgba(0, 0, 0, 0.5);
  168. margin-left: -20rpx;
  169. border-bottom-right-radius: 30#{rpx};
  170. border-top-right-radius: 30#{rpx};
  171. padding-left: 30#{rpx};
  172. }
  173. }
  174. .tag-box-2 {
  175. .text {
  176. background: #777777;
  177. }
  178. }
  179. .tag-box-3 {
  180. .text {
  181. background: #ff4544;
  182. }
  183. .live-icon {
  184. width: 24#{rpx};
  185. height: 24#{rpx};
  186. margin-right: 12#{rpx};
  187. }
  188. }
  189. .round {
  190. width: 15#{rpx};
  191. height: 15#{rpx};
  192. background: #fff;
  193. border-radius: 50%;
  194. margin-right: 12#{rpx};
  195. }
  196. .text {
  197. padding: 12#{rpx} 20#{rpx};
  198. font-size: 26#{rpx};
  199. border-top-left-radius: 16#{rpx};
  200. border-top-right-radius: 30#{rpx};
  201. border-bottom-right-radius: 30#{rpx};
  202. z-index: 10;
  203. color: #fff;
  204. display: flex;
  205. align-items: center;
  206. }
  207. .anchor-img-box {
  208. width: 346#{rpx};
  209. height: 346#{rpx};
  210. border-radius: 16#{rpx};
  211. position: relative;
  212. overflow: hidden;
  213. .anchor-img {
  214. position: absolute;
  215. top: 0;
  216. left: 0;
  217. width: 100%;
  218. height: 100%;
  219. }
  220. .play-icon {
  221. width: 100#{rpx};
  222. height: 100#{rpx};
  223. position: absolute;
  224. top: 123#{rpx};
  225. left: 123#{rpx};
  226. }
  227. .subscribe-box {
  228. position: absolute;
  229. top: 153#{rpx};
  230. left: 53#{rpx};
  231. }
  232. }
  233. .room-info-box {
  234. padding: 15#{rpx} 28#{rpx};
  235. .name {
  236. font-size: 28#{rpx};
  237. color: #353535;
  238. white-space: nowrap;
  239. -ms-text-overflow: ellipsis;
  240. text-overflow: ellipsis;
  241. overflow: hidden;
  242. }
  243. .user-info-box {
  244. display: flex;
  245. align-items: center;
  246. margin-top: 12#{rpx};
  247. .anchor-img {
  248. width: 40#{rpx};
  249. height: 40#{rpx};
  250. -webkit-border-radius: 50%;
  251. -moz-border-radius: 50%;
  252. border-radius: 50%;
  253. }
  254. .anchor-name {
  255. width: 200#{rpx};
  256. font-size: 24#{rpx};
  257. color: #999999;
  258. margin-left: 12#{rpx};
  259. white-space: nowrap;
  260. -ms-text-overflow: ellipsis;
  261. text-overflow: ellipsis;
  262. overflow: hidden;
  263. }
  264. }
  265. }
  266. }
  267. }
  268. .empty-box {
  269. width: 100%;
  270. height: 100vh;
  271. display: flex;
  272. justify-content: center;
  273. align-items: center;
  274. flex-direction: column;
  275. image {
  276. width: 280#{rpx};
  277. height: 280#{rpx};
  278. }
  279. span {
  280. margin-top: 15#{rpx};
  281. color: #999;
  282. font-size: 28#{rpx};
  283. }
  284. }
  285. .hint {
  286. font-size: 24#{rpx};
  287. color: #999999;
  288. text-align: center;
  289. width: 100%;
  290. margin-bottom: 15#{rpx};
  291. }
  292. </style>