index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view>
  3. <!-- 轮播 -->
  4. <view v-if="banner_list.length > 0" class="padding-horizontal-main padding-top-main">
  5. <component-banner :propData="banner_list"></component-banner>
  6. </view>
  7. <view v-if="data_list.length > 0">
  8. <view class="padding-horizontal-main">
  9. <!-- 导航 -->
  10. <view class="spacing-nav-title">
  11. <text class="text-wrapper">最新直播</text>
  12. <navigator url="/pages/plugins/weixinliveplayer/search/search" hover-class="none" class="arrow-right padding-right-xxxl cr-gray fr">更多</navigator>
  13. </view>
  14. <!-- 数据列表 -->
  15. <view class="data-list">
  16. <view v-for="(item, index) in data_list" :key="index" class="item padding-main border-radius-main bg-white oh pr spacing-mb">
  17. <navigator :url="'/pages/plugins/weixinliveplayer/detail/detail?id=' + item.id" hover-class="none">
  18. <image class="fl radius" :src="item.share_img" mode="aspectFit"></image>
  19. <view class="base fl">
  20. <view class="single-text text-size">{{item.name}}</view>
  21. <view class="margin-top-xl oh">
  22. <view class="time-title fl cr-white radius tc text-size-sm padding-sm margin-right-sm">开播时间</view>
  23. <view class="fl cr-green">{{item.start_time}}</view>
  24. <view class="fl cr-red">{{item.end_time}}</view>
  25. </view>
  26. <view :class="'status pa status-' + item.status">{{item.status_name}}</view>
  27. </view>
  28. </navigator>
  29. </view>
  30. </view>
  31. </view>
  32. <!-- 结尾 -->
  33. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  34. </view>
  35. <view v-else>
  36. <!-- 提示信息 -->
  37. <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. const app = getApp();
  43. import componentBanner from "../../../../components/slider/slider";
  44. import componentNoData from "../../../../components/no-data/no-data";
  45. import componentBottomLine from "../../../../components/bottom-line/bottom-line";
  46. export default {
  47. data() {
  48. return {
  49. data_list_loding_status: 1,
  50. data_bottom_line_status: false,
  51. data_list_loding_msg: '',
  52. data_list: [],
  53. data_base: null,
  54. banner_list: [],
  55. // 自定义分享信息
  56. share_info: {}
  57. };
  58. },
  59. components: {
  60. componentBanner,
  61. componentNoData,
  62. componentBottomLine
  63. },
  64. props: {},
  65. onShow() {
  66. this.init();
  67. },
  68. // 下拉刷新
  69. onPullDownRefresh() {
  70. this.init();
  71. },
  72. methods: {
  73. init() {
  74. // 获取数据
  75. this.get_data_list();
  76. },
  77. // 获取数据
  78. get_data_list() {
  79. uni.showLoading({
  80. title: '加载中...'
  81. });
  82. this.setData({
  83. data_list_loding_status: 1
  84. });
  85. uni.request({
  86. url: app.globalData.get_request_url("index", "index", "weixinliveplayer"),
  87. method: 'POST',
  88. data: {},
  89. dataType: 'json',
  90. success: res => {
  91. uni.hideLoading();
  92. uni.stopPullDownRefresh();
  93. if (res.data.code == 0) {
  94. var data = res.data.data;
  95. var status = (data.data || null) == null || data.data.length == 0;
  96. this.setData({
  97. data_base: data.base || null,
  98. banner_list: data.banner_list || [],
  99. data_list: data.data,
  100. data_list_loding_status: status ? 0 : 3,
  101. data_bottom_line_status: !status
  102. });
  103. if ((this.data_base || null) != null) {
  104. // 基础自定义分享
  105. this.setData({
  106. share_info: {
  107. title: this.data_base.seo_title || this.data_base.application_name,
  108. desc: this.data_base.seo_desc,
  109. path: '/pages/plugins/weixinliveplayer/index/index',
  110. img: ((this.banner_list || null) != null && this.banner_list.length > 0) ? this.banner_list[0]['images_url'] : ''
  111. }
  112. });
  113. // 导航名称
  114. if((this.data_base.application_name || null) != null) {
  115. uni.setNavigationBarTitle({
  116. title: this.data_base.application_name
  117. });
  118. }
  119. }
  120. } else {
  121. this.setData({
  122. data_bottom_line_status: true,
  123. data_list_loding_status: 2,
  124. data_list_loding_msg: res.data.msg
  125. });
  126. app.globalData.showToast(res.data.msg);
  127. }
  128. // 分享菜单处理
  129. app.globalData.page_share_handle(this.share_info);
  130. },
  131. fail: () => {
  132. uni.hideLoading();
  133. uni.stopPullDownRefresh();
  134. this.setData({
  135. data_bottom_line_status: false,
  136. data_list_loding_status: 2,
  137. data_list_loding_msg: '服务器请求出错'
  138. });
  139. }
  140. });
  141. }
  142. }
  143. };
  144. </script>
  145. <style>
  146. @import './index.css';
  147. </style>