index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view>
  3. <view v-if="(data_base || null) != null">
  4. <!-- 轮播 -->
  5. <view v-if="slider_list.length > 0" class="padding-horizontal-main padding-top-main">
  6. <component-banner :propData="slider_list" propSize="mini"></component-banner>
  7. </view>
  8. <!-- 分类 -->
  9. <scroll-view v-if="(activity_category || null) != null && activity_category.length > 0" class="nav-base scroll-view-horizontal bg-white oh" scroll-x="true">
  10. <view :class="'item cr-gray dis-inline-block padding-horizontal-main ' + (nav_active_value == 0 ? 'cr-main' : '')" @tap="nav_event" data-value="0">全部</view>
  11. <block v-for="(item, index) in activity_category" :key="index">
  12. <view :class="'item cr-gray dis-inline-block padding-horizontal-main ' + (nav_active_value == item.id ? 'cr-main' : '')" @tap="nav_event" :data-value="item.id">{{item.name}}</view>
  13. </block>
  14. </scroll-view>
  15. <!-- 列表 -->
  16. <scroll-view :scroll-y="true" class="scroll-box scroll-box-ece-nav" @scrolltolower="scroll_lower" lower-threshold="30" :style="slider_list.length > 0 ? 'height:calc(100vh - 320rpx);' : ''">
  17. <view v-if="(data_list || null) != null && data_list.length > 0" class="data-list padding-horizontal-main padding-top-main oh">
  18. <block v-for="(item, index) in data_list" :key="index">
  19. <view class="item border-radius-main bg-white oh spacing-mb">
  20. <navigator :url="'/pages/plugins/activity/detail/detail?id=' + item.id" hover-class="none">
  21. <image :src="item.cover" mode="aspectFit"></image>
  22. <view class="padding-main tc">
  23. <view class="single-text fw-b cr-base">{{item.title}}</view>
  24. <view class="multi-text cr-grey margin-top-sm">{{item.describe}}</view>
  25. </view>
  26. </navigator>
  27. </view>
  28. </block>
  29. </view>
  30. <view v-else>
  31. <!-- 提示信息 -->
  32. <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
  33. </view>
  34. <!-- 结尾 -->
  35. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  36. </scroll-view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. const app = getApp();
  42. import componentBanner from "../../../../components/slider/slider";
  43. import componentNoData from "../../../../components/no-data/no-data";
  44. import componentBottomLine from "../../../../components/bottom-line/bottom-line";
  45. export default {
  46. data() {
  47. return {
  48. data_list_loding_status: 1,
  49. data_list_loding_msg: '',
  50. data_bottom_line_status: false,
  51. data_list: [],
  52. data_total: 0,
  53. data_page_total: 0,
  54. data_page: 1,
  55. params: null,
  56. data_base: null,
  57. slider_list: [],
  58. activity_category: [],
  59. nav_active_value: 0,
  60. // 自定义分享信息
  61. share_info: {}
  62. };
  63. },
  64. components: {
  65. componentBanner,
  66. componentNoData,
  67. componentBottomLine
  68. },
  69. props: {},
  70. onLoad(params) {
  71. this.setData({
  72. params: params
  73. });
  74. // 数据加载
  75. this.get_data();
  76. },
  77. // 下拉刷新
  78. onPullDownRefresh() {
  79. this.setData({
  80. data_page: 1
  81. });
  82. this.get_data_list(1);
  83. },
  84. methods: {
  85. // 初始化
  86. get_data() {
  87. uni.showLoading({
  88. title: '加载中...'
  89. });
  90. uni.request({
  91. url: app.globalData.get_request_url("index", "index", "activity"),
  92. method: 'POST',
  93. data: {},
  94. dataType: 'json',
  95. success: res => {
  96. uni.hideLoading();
  97. uni.stopPullDownRefresh();
  98. if (res.data.code == 0) {
  99. var data = res.data.data;
  100. this.setData({
  101. data_base: data.base || null,
  102. slider_list: data.slider_list || [],
  103. activity_category: data.activity_category || []
  104. });
  105. if ((this.data_base || null) != null) {
  106. // 基础自定义分享
  107. this.setData({
  108. share_info: {
  109. title: this.data_base.seo_title || this.data_base.application_name,
  110. desc: this.data_base.seo_desc,
  111. path: '/pages/plugins/activity/index/index'
  112. }
  113. });
  114. // 标题
  115. if((this.data_base.application_name || null) != null) {
  116. uni.setNavigationBarTitle({
  117. title: this.data_base.application_name
  118. });
  119. }
  120. }
  121. // 获取列表数据
  122. this.get_data_list(1);
  123. } else {
  124. this.setData({
  125. data_list_loding_status: 0,
  126. data_list_loding_msg: res.data.msg
  127. });
  128. app.globalData.showToast(res.data.msg);
  129. }
  130. // 分享菜单处理
  131. app.globalData.page_share_handle(this.share_info);
  132. },
  133. fail: () => {
  134. uni.hideLoading();
  135. uni.stopPullDownRefresh();
  136. this.setData({
  137. data_list_loding_status: 2
  138. });
  139. app.globalData.showToast('服务器请求出错');
  140. }
  141. });
  142. },
  143. // 获取数据列表
  144. get_data_list(is_mandatory) {
  145. // 分页是否还有数据
  146. if ((is_mandatory || 0) == 0) {
  147. if (this.data_bottom_line_status == true) {
  148. uni.stopPullDownRefresh();
  149. return false;
  150. }
  151. }
  152. // 加载loding
  153. uni.showLoading({
  154. title: '加载中...'
  155. });
  156. // 获取数据
  157. uni.request({
  158. url: app.globalData.get_request_url("datalist", "index", "activity"),
  159. method: 'POST',
  160. data: {
  161. page: this.data_page,
  162. category_id: this.nav_active_value || 0
  163. },
  164. dataType: 'json',
  165. success: res => {
  166. uni.hideLoading();
  167. uni.stopPullDownRefresh();
  168. if (res.data.code == 0) {
  169. var data = res.data.data;
  170. if (data.data.length > 0) {
  171. if (this.data_page <= 1) {
  172. var temp_data_list = data.data;
  173. } else {
  174. var temp_data_list = this.data_list || [];
  175. var temp_data = data.data || [];
  176. for (var i in temp_data) {
  177. temp_data_list.push(temp_data[i]);
  178. }
  179. }
  180. this.setData({
  181. data_list: temp_data_list,
  182. data_total: data.total,
  183. data_page_total: data.page_total,
  184. data_list_loding_status: 3,
  185. data_page: this.data_page + 1
  186. });
  187. // 是否还有数据
  188. this.setData({
  189. data_bottom_line_status: (this.data_page > 1 && this.data_page > this.data_page_total)
  190. });
  191. } else {
  192. this.setData({
  193. data_list_loding_status: 0
  194. });
  195. if (this.data_page <= 1) {
  196. this.setData({
  197. data_list: [],
  198. data_bottom_line_status: false
  199. });
  200. }
  201. }
  202. } else {
  203. this.setData({
  204. data_list_loding_status: 0,
  205. data_list_loding_msg: res.data.msg
  206. });
  207. app.globalData.showToast(res.data.msg);
  208. }
  209. },
  210. fail: () => {
  211. uni.hideLoading();
  212. uni.stopPullDownRefresh();
  213. this.setData({
  214. data_list_loding_status: 2
  215. });
  216. app.globalData.showToast('服务器请求出错');
  217. }
  218. });
  219. },
  220. // 滚动加载
  221. scroll_lower(e) {
  222. this.get_data_list();
  223. },
  224. // 导航事件
  225. nav_event(e) {
  226. this.setData({
  227. nav_active_value: e.currentTarget.dataset.value || 0,
  228. data_page: 1
  229. });
  230. this.get_data_list(1);
  231. }
  232. }
  233. };
  234. </script>
  235. <style>
  236. @import './index.css';
  237. </style>