index.vue 11 KB

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