|
|
@@ -11,22 +11,22 @@
|
|
|
<view style="display: flex; justify-content: flex-end">
|
|
|
<view class="view6 step7"></view>
|
|
|
</view> -- </view> -->
|
|
|
- <z-paging :use-custom-refresher="false" ref="paging" v-model="dataList" :auto="false"
|
|
|
- :style="{ height: windowHeight - 80 + 'px' }" :show-scrollbar="false" :refresher-enabled="true"
|
|
|
- @refresherrefresh="onRefresh" @refresherrestore="onRefresherRestore" @query="queryLists" :fixed="true"
|
|
|
- :safe-area-inset-bottom="true" :loading-more-enabled="true" :loading-more-no-more-text="'没有更多了'"
|
|
|
- :loading-more-loading-text="'加载中...'" :loading-more-fail-text="'加载失败,点击重试'" :loading-more-default-text="'上拉加载更多'"
|
|
|
- :loading-more-loading-style="{ color: '#999' }" :loading-more-no-more-style="{ color: '#999' }"
|
|
|
- :loading-more-fail-style="{ color: '#999' }" :loading-more-default-style="{ color: '#999' }"
|
|
|
- @loadingMore="onZPagingLoadMore">
|
|
|
- <template #top>
|
|
|
- <page-navbar>
|
|
|
- <template #navCenter>
|
|
|
- <view class="top" style="display: flex">
|
|
|
- <!-- 手动选择城市功能隐藏 -->
|
|
|
- <!-- <view class="topBox" @click="lhSelectCityFun"> -->
|
|
|
- <view class="topBox" >
|
|
|
- <text style="
|
|
|
+ <z-paging :use-custom-refresher="false" ref="paging" v-model="dataList" :auto="false"
|
|
|
+ :style="{ height: windowHeight - 80 + 'px' }" :show-scrollbar="false" :refresher-enabled="true"
|
|
|
+ @refresherrefresh="onRefresh" @refresherrestore="onRefresherRestore" @query="queryLists" :fixed="true"
|
|
|
+ :safe-area-inset-bottom="true" :loading-more-enabled="true" :loading-more-no-more-text="'没有更多了'"
|
|
|
+ :loading-more-loading-text="'加载中...'" :loading-more-fail-text="'加载失败,点击重试'"
|
|
|
+ :loading-more-default-text="'上拉加载更多'" :loading-more-loading-style="{ color: '#999' }"
|
|
|
+ :loading-more-no-more-style="{ color: '#999' }" :loading-more-fail-style="{ color: '#999' }"
|
|
|
+ :loading-more-default-style="{ color: '#999' }" @loadingMore="onZPagingLoadMore">
|
|
|
+ <template #top>
|
|
|
+ <page-navbar>
|
|
|
+ <template #navCenter>
|
|
|
+ <view class="top" style="display: flex">
|
|
|
+ <!-- 手动选择城市功能隐藏 -->
|
|
|
+ <!-- <view class="topBox" @click="lhSelectCityFun"> -->
|
|
|
+ <view class="topBox">
|
|
|
+ <text style="
|
|
|
margin-left: 10rpx;
|
|
|
margin-right: 20rpx;
|
|
|
font-size: 44rpx;
|
|
|
@@ -40,8 +40,8 @@
|
|
|
<view class="weather">
|
|
|
<p>
|
|
|
{{ weather.weather }}<i :class="'qi-' + weather.icon"></i>️{{
|
|
|
- weather.temp
|
|
|
- }}
|
|
|
+ weather.temp
|
|
|
+ }}
|
|
|
</p>
|
|
|
<p>{{ getDayOfWeek }}</p>
|
|
|
</view>
|
|
|
@@ -162,8 +162,8 @@
|
|
|
src="@/static/icon/icon-third.png"
|
|
|
class="topic-index topic-index-img" mode=""></image>
|
|
|
<text v-else class="topic-index">{{
|
|
|
- pageIndex * 4 + index + 1
|
|
|
- }}</text>
|
|
|
+ pageIndex * 4 + index + 1
|
|
|
+ }}</text>
|
|
|
<view class="topic-content toe">
|
|
|
{{ topic.title }}
|
|
|
</view>
|
|
|
@@ -215,934 +215,917 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import sortble from "@/components/sortble/sortble.vue";
|
|
|
- import tabbarVue from "@/components/tabbar/tabbar.vue";
|
|
|
- import pageNavbar from "@/components/page-navbar/page-navbar.vue";
|
|
|
- import wWaterfall from "@/components/w-waterfall/w-waterfall.vue";
|
|
|
- import tabbar from "@/mixins/tabbar";
|
|
|
- import card from "@/components/card/card.vue";
|
|
|
- import lhSelectCity from "@/components/lh-select-city/index.vue";
|
|
|
- import { mapState } from 'vuex'
|
|
|
- import {
|
|
|
- getStorage,
|
|
|
- setStorage,
|
|
|
- removeStorage
|
|
|
- } from "@/common/util.js";
|
|
|
- // import noviceGuidance from "@/components/novice-guidance/index.vue";
|
|
|
- export default {
|
|
|
- components: {
|
|
|
- sortble,
|
|
|
- tabbarVue,
|
|
|
- pageNavbar,
|
|
|
- wWaterfall,
|
|
|
- lhSelectCity,
|
|
|
- card,
|
|
|
- // noviceGuidance
|
|
|
- },
|
|
|
- mixins: [tabbar],
|
|
|
- data() {
|
|
|
- return {
|
|
|
- isFirstLoad: true, // 添加标记,用于判断是否是第一次加载
|
|
|
- swiperHeight: 300, // 默认swiper高度
|
|
|
- noMoreDataTimer: null, // 用于防抖处理的定时器
|
|
|
- step: {
|
|
|
- name: "workbenchSet5",
|
|
|
- guideList: [{
|
|
|
- el: ".step1",
|
|
|
- tips: "这里是第一步的介绍~",
|
|
|
- next: "下一步",
|
|
|
- },
|
|
|
- {
|
|
|
- el: ".step2",
|
|
|
- tips: "这里是第二步的介绍~",
|
|
|
- next: "下一步",
|
|
|
- },
|
|
|
- {
|
|
|
- el: ".step3",
|
|
|
- tips: "这里是第三步的介绍~",
|
|
|
- next: "下一步",
|
|
|
- },
|
|
|
- {
|
|
|
- el: ".step4",
|
|
|
- tips: "这里是第四步的介绍~",
|
|
|
- next: "下一步",
|
|
|
- },
|
|
|
- {
|
|
|
- el: ".step5",
|
|
|
- tips: "这里是第五步的介绍~",
|
|
|
- next: "下一步",
|
|
|
- },
|
|
|
- {
|
|
|
- el: ".step6",
|
|
|
- tips: "这里是第六步的介绍~",
|
|
|
- next: "下一步",
|
|
|
- },
|
|
|
- {
|
|
|
- el: ".step7",
|
|
|
- tips: "最后一步啦~",
|
|
|
- next: "完成",
|
|
|
- },
|
|
|
- ],
|
|
|
+import sortble from "@/components/sortble/sortble.vue";
|
|
|
+import tabbarVue from "@/components/tabbar/tabbar.vue";
|
|
|
+import pageNavbar from "@/components/page-navbar/page-navbar.vue";
|
|
|
+import wWaterfall from "@/components/w-waterfall/w-waterfall.vue";
|
|
|
+import tabbar from "@/mixins/tabbar";
|
|
|
+import card from "@/components/card/card.vue";
|
|
|
+import lhSelectCity from "@/components/lh-select-city/index.vue";
|
|
|
+import { mapState,mapGetters } from 'vuex'
|
|
|
+import {
|
|
|
+ getStorage,
|
|
|
+ setStorage,
|
|
|
+ removeStorage
|
|
|
+} from "@/common/util.js";
|
|
|
+// import noviceGuidance from "@/components/novice-guidance/index.vue";
|
|
|
+export default {
|
|
|
+ components: {
|
|
|
+ sortble,
|
|
|
+ tabbarVue,
|
|
|
+ pageNavbar,
|
|
|
+ wWaterfall,
|
|
|
+ lhSelectCity,
|
|
|
+ card,
|
|
|
+ // noviceGuidance
|
|
|
+ },
|
|
|
+ mixins: [tabbar],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ isFirstLoad: true, // 添加标记,用于判断是否是第一次加载
|
|
|
+ swiperHeight: 300, // 默认swiper高度
|
|
|
+ noMoreDataTimer: null, // 用于防抖处理的定时器
|
|
|
+ step: {
|
|
|
+ name: "workbenchSet5",
|
|
|
+ guideList: [{
|
|
|
+ el: ".step1",
|
|
|
+ tips: "这里是第一步的介绍~",
|
|
|
+ next: "下一步",
|
|
|
},
|
|
|
- windowHeight: uni.getWindowInfo().windowHeight,
|
|
|
- bannerList: [
|
|
|
- "../../static/dome/home-swper.png",
|
|
|
- "../../static/dome/home-swper.png",
|
|
|
- "../../static/dome/home-swper.png",
|
|
|
- ],
|
|
|
- cardList: [{
|
|
|
- img: "/static/img/img-1.png",
|
|
|
- bgimg: "/static/image/bg-2.png",
|
|
|
- },
|
|
|
- {
|
|
|
- img: "/static/img/img-3.png",
|
|
|
- bgimg: "/static/image/bg-3.png",
|
|
|
- },
|
|
|
- {
|
|
|
- img: "/static/img/img-2.png",
|
|
|
- bgimg: "/static/image/bg-1.png",
|
|
|
- },
|
|
|
- ],
|
|
|
- list: [], // 瀑布流全部数据
|
|
|
- dataList: [],
|
|
|
- tabs: ["关注", "推荐", "探索"],
|
|
|
- currentTab: 1,
|
|
|
- currentTopicPage: 0,
|
|
|
- followList: [], // 关注列表数据
|
|
|
- recommendList: [], // 推荐列表数据
|
|
|
- exploreList: [], // 探索列表数据
|
|
|
- hotNewsList: [], // 热点新闻数据
|
|
|
- newsList: [], // 新闻列表数据
|
|
|
- followOffset: 0, // 关注列表偏移量
|
|
|
- recommendOffset: 0, // 推荐列表偏移量
|
|
|
- exploreOffset: 0, // 探索列表偏移量
|
|
|
- newsOffset: 0, // 新闻列表偏移量
|
|
|
- hasMoreFollow: true, // 是否有更多关注列表数据
|
|
|
- hasMoreRecommend: true, // 是否有更多推荐列表数据
|
|
|
- hasMoreExplore: true, // 是否有更多探索列表数据
|
|
|
- hasMoreNews: true, // 是否有更多新闻列表数据
|
|
|
- isLoadingFollow: false, // 是否正在加载关注列表
|
|
|
- isLoadingRecommend: false, // 是否正在加载推荐列表
|
|
|
- isLoadingExplore: false, // 是否正在加载探索列表
|
|
|
- isLoadingNews: false, // 是否正在加载新闻列表
|
|
|
- hotTopics: [],
|
|
|
- lhSelectCityFalg: false,
|
|
|
- hotCitys: [
|
|
|
- "杭州",
|
|
|
- "天津",
|
|
|
- "北京",
|
|
|
- "上海",
|
|
|
- "深圳",
|
|
|
- "广州",
|
|
|
- "成都",
|
|
|
- "重庆",
|
|
|
- "厦门",
|
|
|
- ],
|
|
|
- currentCity: "北京",
|
|
|
- windowHeight: "",
|
|
|
- weather: {
|
|
|
- city: "",
|
|
|
- weather: "",
|
|
|
- temp: "0℃",
|
|
|
- icon: 101,
|
|
|
+ {
|
|
|
+ el: ".step2",
|
|
|
+ tips: "这里是第二步的介绍~",
|
|
|
+ next: "下一步",
|
|
|
},
|
|
|
- isContentRecommendation: true,
|
|
|
- updateHeightTimer: null,
|
|
|
- };
|
|
|
- },
|
|
|
-
|
|
|
- computed: {
|
|
|
- ...mapState('switchingModule', ['isTheTask']),
|
|
|
- getDayOfWeek() {
|
|
|
- const days = [
|
|
|
- "星期日",
|
|
|
- "星期一",
|
|
|
- "星期二",
|
|
|
- "星期三",
|
|
|
- "星期四",
|
|
|
- "星期五",
|
|
|
- "星期六",
|
|
|
- ];
|
|
|
- const today = new Date();
|
|
|
- const dayOfWeek = days[today.getDay()];
|
|
|
- return dayOfWeek;
|
|
|
+ {
|
|
|
+ el: ".step3",
|
|
|
+ tips: "这里是第三步的介绍~",
|
|
|
+ next: "下一步",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ el: ".step4",
|
|
|
+ tips: "这里是第四步的介绍~",
|
|
|
+ next: "下一步",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ el: ".step5",
|
|
|
+ tips: "这里是第五步的介绍~",
|
|
|
+ next: "下一步",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ el: ".step6",
|
|
|
+ tips: "这里是第六步的介绍~",
|
|
|
+ next: "下一步",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ el: ".step7",
|
|
|
+ tips: "最后一步啦~",
|
|
|
+ next: "完成",
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- currentList() {
|
|
|
- switch (this.currentTab) {
|
|
|
- case 0:
|
|
|
- return this.followList;
|
|
|
- case 1:
|
|
|
- return this.recommendList; // 使用专门的推荐列表
|
|
|
- case 2:
|
|
|
- return this.exploreList;
|
|
|
- default:
|
|
|
- return [];
|
|
|
- }
|
|
|
+ windowHeight: uni.getWindowInfo().windowHeight,
|
|
|
+ bannerList: [
|
|
|
+ "../../static/dome/home-swper.png",
|
|
|
+ "../../static/dome/home-swper.png",
|
|
|
+ "../../static/dome/home-swper.png",
|
|
|
+ ],
|
|
|
+ cardList: [ ],
|
|
|
+ list: [], // 瀑布流全部数据
|
|
|
+ dataList: [],
|
|
|
+ tabs: ["关注", "推荐", "探索"],
|
|
|
+ currentTab: 1,
|
|
|
+ currentTopicPage: 0,
|
|
|
+ followList: [], // 关注列表数据
|
|
|
+ recommendList: [], // 推荐列表数据
|
|
|
+ exploreList: [], // 探索列表数据
|
|
|
+ hotNewsList: [], // 热点新闻数据
|
|
|
+ newsList: [], // 新闻列表数据
|
|
|
+ followOffset: 0, // 关注列表偏移量
|
|
|
+ recommendOffset: 0, // 推荐列表偏移量
|
|
|
+ exploreOffset: 0, // 探索列表偏移量
|
|
|
+ newsOffset: 0, // 新闻列表偏移量
|
|
|
+ hasMoreFollow: true, // 是否有更多关注列表数据
|
|
|
+ hasMoreRecommend: true, // 是否有更多推荐列表数据
|
|
|
+ hasMoreExplore: true, // 是否有更多探索列表数据
|
|
|
+ hasMoreNews: true, // 是否有更多新闻列表数据
|
|
|
+ isLoadingFollow: false, // 是否正在加载关注列表
|
|
|
+ isLoadingRecommend: false, // 是否正在加载推荐列表
|
|
|
+ isLoadingExplore: false, // 是否正在加载探索列表
|
|
|
+ isLoadingNews: false, // 是否正在加载新闻列表
|
|
|
+ hotTopics: [],
|
|
|
+ lhSelectCityFalg: false,
|
|
|
+ hotCitys: [
|
|
|
+ "杭州",
|
|
|
+ "天津",
|
|
|
+ "北京",
|
|
|
+ "上海",
|
|
|
+ "深圳",
|
|
|
+ "广州",
|
|
|
+ "成都",
|
|
|
+ "重庆",
|
|
|
+ "厦门",
|
|
|
+ ],
|
|
|
+ currentCity: "北京",
|
|
|
+ windowHeight: "",
|
|
|
+ weather: {
|
|
|
+ city: "",
|
|
|
+ weather: "",
|
|
|
+ temp: "0℃",
|
|
|
+ icon: 101,
|
|
|
},
|
|
|
- topicPages() {
|
|
|
- const pages = [];
|
|
|
- for (let i = 0; i < this.hotTopics.length; i += 4) {
|
|
|
- pages.push(this.hotTopics.slice(i, i + 4));
|
|
|
- }
|
|
|
- return pages;
|
|
|
- },
|
|
|
- },
|
|
|
- onLoad() {
|
|
|
- let that = this;
|
|
|
- // 计算出可用高度
|
|
|
- this.windowHeight = uni.getSystemInfoSync().windowHeight + "px";
|
|
|
- // 计算swiper默认高度
|
|
|
- const systemInfo = uni.getSystemInfoSync();
|
|
|
- this.swiperHeight = systemInfo.windowHeight * 0.6; // 初始设置为窗口高度的60%
|
|
|
-
|
|
|
- // 获取天气信息
|
|
|
- this.getWeather();
|
|
|
+ updateHeightTimer: null,
|
|
|
+ };
|
|
|
+ },
|
|
|
|
|
|
- // 初始化数据,确保首次加载正确
|
|
|
- this.$nextTick(() => {
|
|
|
- // 根据当前标签加载数据
|
|
|
- this.initialLoad();
|
|
|
- });
|
|
|
+ computed: {
|
|
|
+ ...mapState('switchingModule', ['isTheTask']),
|
|
|
+ ...mapState('rightsManagement', ['teenageMode','iscontentRecommendation']),
|
|
|
+ ...mapGetters( 'rightsManagement', ['isContent']),
|
|
|
+ getDayOfWeek() {
|
|
|
+ const days = [
|
|
|
+ "星期日",
|
|
|
+ "星期一",
|
|
|
+ "星期二",
|
|
|
+ "星期三",
|
|
|
+ "星期四",
|
|
|
+ "星期五",
|
|
|
+ "星期六",
|
|
|
+ ];
|
|
|
+ const today = new Date();
|
|
|
+ const dayOfWeek = days[today.getDay()];
|
|
|
+ return dayOfWeek;
|
|
|
+ },
|
|
|
+ currentList() {
|
|
|
+ switch (this.currentTab) {
|
|
|
+ case 0:
|
|
|
+ return this.followList;
|
|
|
+ case 1:
|
|
|
+ return this.recommendList; // 使用专门的推荐列表
|
|
|
+ case 2:
|
|
|
+ return this.exploreList;
|
|
|
+ default:
|
|
|
+ return [];
|
|
|
+ }
|
|
|
},
|
|
|
- onShow() {
|
|
|
- var isContentRecommendation = getStorage("isContentRecommendation");
|
|
|
- console.log(isContentRecommendation, "isContentRecommendation");
|
|
|
- if (isContentRecommendation != "false") {
|
|
|
- isContentRecommendation = true;
|
|
|
- } else {
|
|
|
- isContentRecommendation = false;
|
|
|
+ topicPages() {
|
|
|
+ const pages = [];
|
|
|
+ for (let i = 0; i < this.hotTopics.length; i += 4) {
|
|
|
+ pages.push(this.hotTopics.slice(i, i + 4));
|
|
|
}
|
|
|
- this.isContentRecommendation = isContentRecommendation;
|
|
|
+ return pages;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ onLoad() {
|
|
|
+ let that = this;
|
|
|
+ // 计算出可用高度
|
|
|
+ this.windowHeight = uni.getSystemInfoSync().windowHeight + "px";
|
|
|
+ // 计算swiper默认高度
|
|
|
+ const systemInfo = uni.getSystemInfoSync();
|
|
|
+ this.swiperHeight = systemInfo.windowHeight * 0.6; // 初始设置为窗口高度的60%
|
|
|
|
|
|
- if (isContentRecommendation == false) {
|
|
|
- this.tabs = ["关注"];
|
|
|
- this.currentTab = 0;
|
|
|
- this.queryList();
|
|
|
- } else {
|
|
|
- this.tabs = ["关注", "推荐", "探索"];
|
|
|
- // this.currentTab = 1;
|
|
|
- // 如果数据为空,加载初始数据
|
|
|
- if (this.recommendList.length === 0) {
|
|
|
- this.initialLoad();
|
|
|
- }
|
|
|
- }
|
|
|
- uni.$emit('check_update');
|
|
|
- },
|
|
|
- // 修改触底加载方法
|
|
|
- onReachBottom() {
|
|
|
- console.log('触底加载更多');
|
|
|
- // 根据当前标签页加载更多数据
|
|
|
- switch (this.currentTab) {
|
|
|
- case 0:
|
|
|
- if (this.hasMoreFollow && !this.isLoadingFollow) {
|
|
|
- this.loadFollowList();
|
|
|
- }
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- if (this.hasMoreRecommend && !this.isLoadingRecommend) {
|
|
|
- this.loadRecommendList();
|
|
|
- }
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- if (this.hasMoreNews && !this.isLoadingNews) {
|
|
|
- this.loadNewsList();
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- },
|
|
|
+ // 获取天气信息
|
|
|
+ this.getWeather();
|
|
|
|
|
|
- // 下拉刷新数据
|
|
|
- methods: {
|
|
|
- swipeRight() {
|
|
|
- let index = this.currentTab
|
|
|
- index--
|
|
|
- if (index < 0) {
|
|
|
- index = this.tabs.length - 1
|
|
|
+ // 初始化数据,确保首次加载正确
|
|
|
+ this.$nextTick(() => {
|
|
|
+ // 根据当前标签加载数据
|
|
|
+ this.initialLoad();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onShow() {
|
|
|
+ console.log('teenageMode',this.teenageMode);
|
|
|
+ console.log('iscontentRecommendation',this.iscontentRecommendation);
|
|
|
+ console.log('isContent',this.isContent);
|
|
|
+ if ( !this.isContent ) {
|
|
|
+ this.tabs = ["关注"];
|
|
|
+ this.currentTab = 0;
|
|
|
+ this.queryList();
|
|
|
+ } else {
|
|
|
+ this.tabs = ["关注", "推荐", "探索"];
|
|
|
+ // this.currentTab = 1;
|
|
|
+ // 如果数据为空,加载初始数据
|
|
|
+ if (this.recommendList.length === 0) {
|
|
|
+ this.initialLoad();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ uni.$emit('check_update');
|
|
|
+ },
|
|
|
+ // 修改触底加载方法
|
|
|
+ onReachBottom() {
|
|
|
+ console.log('触底加载更多');
|
|
|
+ // 根据当前标签页加载更多数据
|
|
|
+ switch (this.currentTab) {
|
|
|
+ case 0:
|
|
|
+ if (this.hasMoreFollow && !this.isLoadingFollow) {
|
|
|
+ this.loadFollowList();
|
|
|
}
|
|
|
- this.switchTab(index)
|
|
|
- console.log('向右滑动')
|
|
|
- },
|
|
|
- swipeLeft() {
|
|
|
- let index = this.currentTab
|
|
|
- index++
|
|
|
- if (index > this.tabs.length - 1) {
|
|
|
- index = 0
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ if (this.hasMoreRecommend && !this.isLoadingRecommend) {
|
|
|
+ this.loadRecommendList();
|
|
|
}
|
|
|
- this.switchTab(index)
|
|
|
- console.log('向左滑动')
|
|
|
- },
|
|
|
- getWeather(city) {
|
|
|
- uni.request({
|
|
|
- url: this.$apiHost + "/Index/getAreaInfo",
|
|
|
- data: {
|
|
|
- uuid: getApp().globalData.uuid,
|
|
|
- skey: getApp().globalData.skey,
|
|
|
- city: city || (this.currentCity == "北京" ? "" : this.currentCity),
|
|
|
- },
|
|
|
- header: {
|
|
|
- "content-type": "application/json",
|
|
|
- sign: getApp().globalData.headerSign,
|
|
|
- },
|
|
|
- success: (res) => {
|
|
|
- console.log(this.weather, "天气数据", res.data);
|
|
|
- if (res.data.city) {
|
|
|
- this.currentCity = res.data.city;
|
|
|
- this.weather = res.data;
|
|
|
- }
|
|
|
- },
|
|
|
- complete: () => {},
|
|
|
- fail: (e) => {},
|
|
|
- });
|
|
|
- },
|
|
|
- lhSelectCityFun() {
|
|
|
- this.lhSelectCityFalg = true;
|
|
|
- },
|
|
|
- // 选中事件
|
|
|
- City(city) {
|
|
|
- this.currentCity = city;
|
|
|
- setTimeout(() => {
|
|
|
- this.lhSelectCityFalg = false;
|
|
|
- }, 300);
|
|
|
- },
|
|
|
- closeLhSelectCityFun() {
|
|
|
- this.lhSelectCityFalg = false;
|
|
|
- },
|
|
|
- queryList() {
|
|
|
- // 根据当前标签刷新数据
|
|
|
- switch (this.currentTab) {
|
|
|
- case 0:
|
|
|
- // 重置关注列表
|
|
|
- this.followList = [];
|
|
|
- this.followOffset = 0;
|
|
|
- this.hasMoreFollow = true;
|
|
|
- this.loadFollowList();
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- // 重置推荐列表
|
|
|
- this.recommendList = [];
|
|
|
- this.recommendOffset = 0;
|
|
|
- this.hasMoreRecommend = true;
|
|
|
- this.loadRecommendList();
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- // 重置热点新闻和新闻列表
|
|
|
- this.hotNewsList = [];
|
|
|
- this.newsList = [];
|
|
|
- this.newsOffset = 0;
|
|
|
- this.hasMoreNews = true;
|
|
|
- // 加载热点新闻和新闻列表
|
|
|
- this.loadHotNews();
|
|
|
- this.loadNewsList();
|
|
|
- break;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ if (this.hasMoreNews && !this.isLoadingNews) {
|
|
|
+ this.loadNewsList();
|
|
|
}
|
|
|
- },
|
|
|
- queryLists() {
|
|
|
- // 根据当前标签刷新数据
|
|
|
- switch (this.currentTab) {
|
|
|
- case 0:
|
|
|
- // 重置关注列表
|
|
|
- this.loadFollowList();
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- // 重置推荐列表
|
|
|
- this.loadRecommendList();
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- // 重置热点新闻和新闻列表
|
|
|
- // 加载热点新闻和新闻列表
|
|
|
- this.loadHotNews();
|
|
|
- this.loadNewsList();
|
|
|
- break;
|
|
|
- }
|
|
|
- // 第一次加载完成后,将标记设置为false
|
|
|
- this.isFirstLoad = false;
|
|
|
- },
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
- switchTab(index) {
|
|
|
- if (this.currentTab === index) return;
|
|
|
- this.currentTab = index;
|
|
|
+ // 下拉刷新数据
|
|
|
+ methods: {
|
|
|
+ swipeRight() {
|
|
|
+ let index = this.currentTab
|
|
|
+ index--
|
|
|
+ if (index < 0) {
|
|
|
+ index = this.tabs.length - 1
|
|
|
+ }
|
|
|
+ this.switchTab(index)
|
|
|
+ console.log('向右滑动')
|
|
|
+ },
|
|
|
+ swipeLeft() {
|
|
|
+ let index = this.currentTab
|
|
|
+ index++
|
|
|
+ if (index > this.tabs.length - 1) {
|
|
|
+ index = 0
|
|
|
+ }
|
|
|
+ this.switchTab(index)
|
|
|
+ console.log('向左滑动')
|
|
|
+ },
|
|
|
+ getWeather(city) {
|
|
|
+ uni.request({
|
|
|
+ url: this.$apiHost + "/Index/getAreaInfo",
|
|
|
+ data: {
|
|
|
+ uuid: getApp().globalData.uuid,
|
|
|
+ skey: getApp().globalData.skey,
|
|
|
+ city: city || (this.currentCity == "北京" ? "" : this.currentCity),
|
|
|
+ },
|
|
|
+ header: {
|
|
|
+ "content-type": "application/json",
|
|
|
+ sign: getApp().globalData.headerSign,
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log(this.weather, "天气数据", res.data);
|
|
|
+ if (res.data.data.city) {
|
|
|
+ this.currentCity = res.data.data.city;
|
|
|
+ this.weather = res.data.data;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ complete: () => { },
|
|
|
+ fail: (e) => { },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ lhSelectCityFun() {
|
|
|
+ this.lhSelectCityFalg = true;
|
|
|
+ },
|
|
|
+ // 选中事件
|
|
|
+ City(city) {
|
|
|
+ this.currentCity = city;
|
|
|
+ setTimeout(() => {
|
|
|
+ this.lhSelectCityFalg = false;
|
|
|
+ }, 300);
|
|
|
+ },
|
|
|
+ closeLhSelectCityFun() {
|
|
|
+ this.lhSelectCityFalg = false;
|
|
|
+ },
|
|
|
+ queryList() {
|
|
|
+ // 根据当前标签刷新数据
|
|
|
+ switch (this.currentTab) {
|
|
|
+ case 0:
|
|
|
+ // 重置关注列表
|
|
|
+ this.followList = [];
|
|
|
+ this.followOffset = 0;
|
|
|
+ this.hasMoreFollow = true;
|
|
|
+ this.loadFollowList();
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ // 重置推荐列表
|
|
|
+ this.recommendList = [];
|
|
|
+ this.recommendOffset = 0;
|
|
|
+ this.hasMoreRecommend = true;
|
|
|
+ this.loadRecommendList();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ // 重置热点新闻和新闻列表
|
|
|
+ this.hotNewsList = [];
|
|
|
+ this.newsList = [];
|
|
|
+ this.newsOffset = 0;
|
|
|
+ this.hasMoreNews = true;
|
|
|
+ // 加载热点新闻和新闻列表
|
|
|
+ this.loadHotNews();
|
|
|
+ this.loadNewsList();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ queryLists() {
|
|
|
+ // 根据当前标签刷新数据
|
|
|
+ switch (this.currentTab) {
|
|
|
+ case 0:
|
|
|
+ // 重置关注列表
|
|
|
+ this.loadFollowList();
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ // 重置推荐列表
|
|
|
+ this.loadRecommendList();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ // 重置热点新闻和新闻列表
|
|
|
+ // 加载热点新闻和新闻列表
|
|
|
+ this.loadHotNews();
|
|
|
+ this.loadNewsList();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ // 第一次加载完成后,将标记设置为false
|
|
|
+ this.isFirstLoad = false;
|
|
|
+ },
|
|
|
|
|
|
- // 重置当前标签页的数据
|
|
|
- switch (index) {
|
|
|
- case 0:
|
|
|
- this.followList = [];
|
|
|
- this.followOffset = 0;
|
|
|
- this.hasMoreFollow = true;
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- this.recommendList = [];
|
|
|
- this.recommendOffset = 0;
|
|
|
- this.hasMoreRecommend = true;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- this.newsList = [];
|
|
|
- this.hotTopics = [];
|
|
|
- this.newsOffset = 0;
|
|
|
- this.hasMoreNews = true;
|
|
|
- break;
|
|
|
- }
|
|
|
+ switchTab(index) {
|
|
|
+ if (this.currentTab === index) return;
|
|
|
+ this.currentTab = index;
|
|
|
|
|
|
- // 加载新标签页的数据
|
|
|
- this.loadTabData(index);
|
|
|
+ // 重置当前标签页的数据
|
|
|
+ switch (index) {
|
|
|
+ case 0:
|
|
|
+ this.followList = [];
|
|
|
+ this.followOffset = 0;
|
|
|
+ this.hasMoreFollow = true;
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ this.recommendList = [];
|
|
|
+ this.recommendOffset = 0;
|
|
|
+ this.hasMoreRecommend = true;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ this.newsList = [];
|
|
|
+ this.hotTopics = [];
|
|
|
+ this.newsOffset = 0;
|
|
|
+ this.hasMoreNews = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- // 切换标签后更新swiper高度
|
|
|
- // 在切换标签时,先将高度设置为一个合适的默认值
|
|
|
- // 然后在数据加载完成后再动态调整
|
|
|
- const systemInfo = uni.getSystemInfoSync();
|
|
|
- this.swiperHeight = systemInfo.windowHeight * 0.6;
|
|
|
- },
|
|
|
- loadTabData(index) {
|
|
|
- switch (index) {
|
|
|
- case 0:
|
|
|
- this.loadFollowList();
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- this.loadRecommendList();
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- this.loadHotNews();
|
|
|
- this.loadNewsList();
|
|
|
- break;
|
|
|
- }
|
|
|
- },
|
|
|
- // 修改关注列表加载方法
|
|
|
- loadFollowList() {
|
|
|
- if (this.isLoadingFollow) return;
|
|
|
- this.isLoadingFollow = true;
|
|
|
+ // 加载新标签页的数据
|
|
|
+ this.loadTabData(index);
|
|
|
|
|
|
- // 保存当前列表数据
|
|
|
- const currentList = [...this.followList];
|
|
|
+ // 切换标签后更新swiper高度
|
|
|
+ // 在切换标签时,先将高度设置为一个合适的默认值
|
|
|
+ // 然后在数据加载完成后再动态调整
|
|
|
+ const systemInfo = uni.getSystemInfoSync();
|
|
|
+ this.swiperHeight = systemInfo.windowHeight * 0.6;
|
|
|
+ },
|
|
|
+ loadTabData(index) {
|
|
|
+ switch (index) {
|
|
|
+ case 0:
|
|
|
+ this.loadFollowList();
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ this.loadRecommendList();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ this.loadHotNews();
|
|
|
+ this.loadNewsList();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 修改关注列表加载方法
|
|
|
+ loadFollowList() {
|
|
|
+ if (this.isLoadingFollow) return;
|
|
|
+ this.isLoadingFollow = true;
|
|
|
|
|
|
- // offset设置为当前列表长度
|
|
|
- this.followOffset = currentList.length;
|
|
|
- console.log('请求关注列表数据,当前offset =', this.followOffset);
|
|
|
+ // 保存当前列表数据
|
|
|
+ const currentList = [...this.followList];
|
|
|
|
|
|
- uni.request({
|
|
|
- url: this.$apiHost + "/Work/getlist",
|
|
|
- data: {
|
|
|
- uuid: getApp().globalData.uuid,
|
|
|
- skey: getApp().globalData.skey,
|
|
|
- type: "attention",
|
|
|
- offset: this.followOffset,
|
|
|
- },
|
|
|
- header: {
|
|
|
- "content-type": "application/json",
|
|
|
- sign: getApp().globalData.headerSign,
|
|
|
- },
|
|
|
- success: (res) => {
|
|
|
- console.log("关注列表数据:", res.data);
|
|
|
- if (res.data.success == "yes" && res.data.list && res.data.list.length > 0) {
|
|
|
- // 追加新数据到列表
|
|
|
- this.followList = [...currentList, ...res.data.list];
|
|
|
- console.log('关注列表加载成功,当前列表长度:', this.followList.length);
|
|
|
- this.hasMoreFollow = res.data.list.length >= 20;
|
|
|
- } else {
|
|
|
- this.hasMoreFollow = false;
|
|
|
- this.showNoMoreDataToast("没有更多关注内容了");
|
|
|
- }
|
|
|
+ // offset设置为当前列表长度
|
|
|
+ this.followOffset = currentList.length;
|
|
|
+ console.log('请求关注列表数据,当前offset =', this.followOffset);
|
|
|
|
|
|
- // 使用 nextTick 确保数据更新后再通知组件
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.$refs.paging) {
|
|
|
- // 第一个参数需要是数组,将当前列表传入
|
|
|
- this.$refs.paging.complete(this.followList);
|
|
|
- }
|
|
|
- // 数据加载完成后更新swiper高度
|
|
|
- if (this.currentTab === 0) {
|
|
|
- // 使用setTimeout确保数据渲染完成后再更新高度
|
|
|
- setTimeout(() => {
|
|
|
- this.updateSwiperHeight();
|
|
|
- }, 300);
|
|
|
- setTimeout(() => {
|
|
|
- this.updateSwiperHeight();
|
|
|
- }, 650);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- complete: () => {
|
|
|
- this.isLoadingFollow = false;
|
|
|
- },
|
|
|
- fail: (e) => {
|
|
|
- console.log("请求关注列表失败:", e);
|
|
|
- this.isLoadingFollow = false;
|
|
|
+ uni.request({
|
|
|
+ url: this.$apiHost + "/Work/getlist",
|
|
|
+ data: {
|
|
|
+ uuid: getApp().globalData.uuid,
|
|
|
+ skey: getApp().globalData.skey,
|
|
|
+ type: "attention",
|
|
|
+ offset: this.followOffset,
|
|
|
+ },
|
|
|
+ header: {
|
|
|
+ "content-type": "application/json",
|
|
|
+ sign: getApp().globalData.headerSign,
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log("关注列表数据:", res.data);
|
|
|
+ if (res.data.success == "yes" && res.data.list && res.data.list.length > 0) {
|
|
|
+ // 追加新数据到列表
|
|
|
+ this.followList = [...currentList, ...res.data.list];
|
|
|
+ console.log('关注列表加载成功,当前列表长度:', this.followList.length);
|
|
|
+ this.hasMoreFollow = res.data.list.length >= 20;
|
|
|
+ } else {
|
|
|
+ this.hasMoreFollow = false;
|
|
|
+ this.showNoMoreDataToast("没有更多关注内容了");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用 nextTick 确保数据更新后再通知组件
|
|
|
+ this.$nextTick(() => {
|
|
|
if (this.$refs.paging) {
|
|
|
- // 加载失败时提供空数组
|
|
|
- this.$refs.paging.complete([]);
|
|
|
+ // 第一个参数需要是数组,将当前列表传入
|
|
|
+ this.$refs.paging.complete(this.followList);
|
|
|
}
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
- // 修改推荐列表加载方法
|
|
|
- loadRecommendList() {
|
|
|
- if (this.isLoadingRecommend) return;
|
|
|
- this.isLoadingRecommend = true;
|
|
|
+ // 数据加载完成后更新swiper高度
|
|
|
+ if (this.currentTab === 0) {
|
|
|
+ // 使用setTimeout确保数据渲染完成后再更新高度
|
|
|
+ setTimeout(() => {
|
|
|
+ this.updateSwiperHeight();
|
|
|
+ }, 300);
|
|
|
+ setTimeout(() => {
|
|
|
+ this.updateSwiperHeight();
|
|
|
+ }, 650);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ this.isLoadingFollow = false;
|
|
|
+ },
|
|
|
+ fail: (e) => {
|
|
|
+ console.log("请求关注列表失败:", e);
|
|
|
+ this.isLoadingFollow = false;
|
|
|
+ if (this.$refs.paging) {
|
|
|
+ // 加载失败时提供空数组
|
|
|
+ this.$refs.paging.complete([]);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 修改推荐列表加载方法
|
|
|
+ loadRecommendList() {
|
|
|
+ if (this.isLoadingRecommend) return;
|
|
|
+ this.isLoadingRecommend = true;
|
|
|
|
|
|
- // 保存当前列表数据
|
|
|
- const currentList = [...this.recommendList];
|
|
|
+ // 保存当前列表数据
|
|
|
+ const currentList = [...this.recommendList];
|
|
|
|
|
|
- // offset设置为当前列表长度
|
|
|
- this.recommendOffset = currentList.length;
|
|
|
- console.log('请求推荐列表数据,当前offset =', this.recommendOffset);
|
|
|
+ // offset设置为当前列表长度
|
|
|
+ this.recommendOffset = currentList.length;
|
|
|
+ console.log('请求推荐列表数据,当前offset =', this.recommendOffset);
|
|
|
|
|
|
- uni.request({
|
|
|
- url: this.$apiHost + "/Work/getlist",
|
|
|
- data: {
|
|
|
- uuid: getApp().globalData.uuid,
|
|
|
- skey: getApp().globalData.skey,
|
|
|
- type: "recommend",
|
|
|
- offset: this.recommendOffset,
|
|
|
- },
|
|
|
- header: {
|
|
|
- "content-type": "application/json",
|
|
|
- sign: getApp().globalData.headerSign,
|
|
|
- },
|
|
|
- success: (res) => {
|
|
|
- console.log("推荐列表数据:", res.data);
|
|
|
- if (res.data.success == "yes" && res.data.list && res.data.list.length > 0) {
|
|
|
- // 追加新数据到列表
|
|
|
- this.recommendList = [...currentList, ...res.data.list];
|
|
|
- console.log('推荐列表加载成功,当前列表长度:', this.recommendList.length);
|
|
|
- this.hasMoreRecommend = res.data.list.length >= 20;
|
|
|
- } else {
|
|
|
- this.hasMoreRecommend = false;
|
|
|
- this.showNoMoreDataToast("没有更多推荐内容了");
|
|
|
- }
|
|
|
+ uni.request({
|
|
|
+ url: this.$apiHost + "/Work/getlist",
|
|
|
+ data: {
|
|
|
+ uuid: getApp().globalData.uuid,
|
|
|
+ skey: getApp().globalData.skey,
|
|
|
+ type: "recommend",
|
|
|
+ offset: this.recommendOffset,
|
|
|
+ },
|
|
|
+ header: {
|
|
|
+ "content-type": "application/json",
|
|
|
+ sign: getApp().globalData.headerSign,
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log("推荐列表数据:", res.data);
|
|
|
+ if (res.data.success == "yes" && res.data.list && res.data.list.length > 0) {
|
|
|
+ // 追加新数据到列表
|
|
|
+ this.recommendList = [...currentList, ...res.data.list];
|
|
|
+ console.log('推荐列表加载成功,当前列表长度:', this.recommendList.length);
|
|
|
+ this.hasMoreRecommend = res.data.list.length >= 20;
|
|
|
+ } else {
|
|
|
+ this.hasMoreRecommend = false;
|
|
|
+ this.showNoMoreDataToast("没有更多推荐内容了");
|
|
|
+ }
|
|
|
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.$refs.paging) {
|
|
|
- // 第一个参数需要是数组,将当前列表传入
|
|
|
- this.$refs.paging.complete(this.recommendList);
|
|
|
- }
|
|
|
- // 数据加载完成后更新swiper高度
|
|
|
- if (this.currentTab === 1) {
|
|
|
- setTimeout(() => {
|
|
|
- this.updateSwiperHeight();
|
|
|
- }, 300);
|
|
|
- setTimeout(() => {
|
|
|
- this.updateSwiperHeight();
|
|
|
- }, 650);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- complete: () => {
|
|
|
- this.isLoadingRecommend = false;
|
|
|
- },
|
|
|
- fail: (e) => {
|
|
|
- console.log("请求推荐列表失败:", e);
|
|
|
- this.isLoadingRecommend = false;
|
|
|
+ this.$nextTick(() => {
|
|
|
if (this.$refs.paging) {
|
|
|
- // 加载失败时提供空数组
|
|
|
- this.$refs.paging.complete([]);
|
|
|
+ // 第一个参数需要是数组,将当前列表传入
|
|
|
+ this.$refs.paging.complete(this.recommendList);
|
|
|
}
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
- loadHotNews() {
|
|
|
- if (this.isLoadingExplore) return;
|
|
|
- this.isLoadingExplore = true;
|
|
|
-
|
|
|
- uni.request({
|
|
|
- url: this.$apiHost + "/Article/getlist",
|
|
|
- data: {
|
|
|
- uuid: getApp().globalData.uuid,
|
|
|
- skey: getApp().globalData.skey,
|
|
|
- type: "hot",
|
|
|
- },
|
|
|
- header: {
|
|
|
- "content-type": "application/json",
|
|
|
- sign: getApp().globalData.headerSign,
|
|
|
- },
|
|
|
- success: (res) => {
|
|
|
- console.log("热点新闻数据:", res.data);
|
|
|
- if (res.data.success == "yes" && res.data.list && res.data.list.length > 0) {
|
|
|
- this.hotNewsList = res.data.list;
|
|
|
- this.hotTopics = this.hotNewsList.map((item, index) => ({
|
|
|
- id: item.id,
|
|
|
- title: item.title || "热门话题",
|
|
|
- num_like: item.num_like || 0,
|
|
|
- isHot: index % 2 === 0,
|
|
|
- }));
|
|
|
+ // 数据加载完成后更新swiper高度
|
|
|
+ if (this.currentTab === 1) {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.updateSwiperHeight();
|
|
|
+ }, 300);
|
|
|
+ setTimeout(() => {
|
|
|
+ this.updateSwiperHeight();
|
|
|
+ }, 650);
|
|
|
}
|
|
|
- },
|
|
|
- complete: () => {
|
|
|
- this.isLoadingExplore = false;
|
|
|
- },
|
|
|
- fail: (e) => {
|
|
|
- console.log("请求热点新闻失败:", e);
|
|
|
- this.isLoadingExplore = false;
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
- // 修改新闻列表加载方法
|
|
|
- loadNewsList() {
|
|
|
- if (this.isLoadingNews) return;
|
|
|
- this.isLoadingNews = true;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ this.isLoadingRecommend = false;
|
|
|
+ },
|
|
|
+ fail: (e) => {
|
|
|
+ console.log("请求推荐列表失败:", e);
|
|
|
+ this.isLoadingRecommend = false;
|
|
|
+ if (this.$refs.paging) {
|
|
|
+ // 加载失败时提供空数组
|
|
|
+ this.$refs.paging.complete([]);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ loadHotNews() {
|
|
|
+ if (this.isLoadingExplore) return;
|
|
|
+ this.isLoadingExplore = true;
|
|
|
|
|
|
- // 保存当前列表数据
|
|
|
- const currentList = [...this.newsList];
|
|
|
+ uni.request({
|
|
|
+ url: this.$apiHost + "/Article/getlist",
|
|
|
+ data: {
|
|
|
+ uuid: getApp().globalData.uuid,
|
|
|
+ skey: getApp().globalData.skey,
|
|
|
+ type: "hot",
|
|
|
+ },
|
|
|
+ header: {
|
|
|
+ "content-type": "application/json",
|
|
|
+ sign: getApp().globalData.headerSign,
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log("热点新闻数据:", res.data);
|
|
|
+ if (res.data.success == "yes" && res.data.list && res.data.list.length > 0) {
|
|
|
+ this.hotNewsList = res.data.list;
|
|
|
+ this.hotTopics = this.hotNewsList.map((item, index) => ({
|
|
|
+ id: item.id,
|
|
|
+ title: item.title || "热门话题",
|
|
|
+ num_like: item.num_like || 0,
|
|
|
+ isHot: index % 2 === 0,
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ this.isLoadingExplore = false;
|
|
|
+ },
|
|
|
+ fail: (e) => {
|
|
|
+ console.log("请求热点新闻失败:", e);
|
|
|
+ this.isLoadingExplore = false;
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 修改新闻列表加载方法
|
|
|
+ loadNewsList() {
|
|
|
+ if (this.isLoadingNews) return;
|
|
|
+ this.isLoadingNews = true;
|
|
|
|
|
|
- // offset设置为当前列表长度
|
|
|
- this.newsOffset = currentList.length;
|
|
|
- console.log('请求新闻列表数据,当前offset =', this.newsOffset);
|
|
|
+ // 保存当前列表数据
|
|
|
+ const currentList = [...this.newsList];
|
|
|
|
|
|
- uni.request({
|
|
|
- url: this.$apiHost + "/Article/getlist",
|
|
|
- data: {
|
|
|
- uuid: getApp().globalData.uuid,
|
|
|
- skey: getApp().globalData.skey,
|
|
|
- type: "list",
|
|
|
- offset: this.newsOffset,
|
|
|
- },
|
|
|
- header: {
|
|
|
- "content-type": "application/json",
|
|
|
- sign: getApp().globalData.headerSign,
|
|
|
- },
|
|
|
- success: (res) => {
|
|
|
- console.log("新闻列表数据:", res.data);
|
|
|
- if (res.data.success == "yes" && res.data.list && res.data.list.length > 0) {
|
|
|
- // 追加新数据到列表
|
|
|
- this.newsList = [...currentList, ...res.data.list];
|
|
|
- console.log('新闻列表加载成功,当前列表长度:', this.newsList.length);
|
|
|
+ // offset设置为当前列表长度
|
|
|
+ this.newsOffset = currentList.length;
|
|
|
+ console.log('请求新闻列表数据,当前offset =', this.newsOffset);
|
|
|
|
|
|
- this.hasMoreNews = res.data.list.length >= 20;
|
|
|
- } else {
|
|
|
- this.hasMoreNews = false;
|
|
|
- this.showNoMoreDataToast("没有更多新闻内容了");
|
|
|
- }
|
|
|
+ uni.request({
|
|
|
+ url: this.$apiHost + "/Article/getlist",
|
|
|
+ data: {
|
|
|
+ uuid: getApp().globalData.uuid,
|
|
|
+ skey: getApp().globalData.skey,
|
|
|
+ type: "list",
|
|
|
+ offset: this.newsOffset,
|
|
|
+ },
|
|
|
+ header: {
|
|
|
+ "content-type": "application/json",
|
|
|
+ sign: getApp().globalData.headerSign,
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ console.log("新闻列表数据:", res.data);
|
|
|
+ if (res.data.success == "yes" && res.data.list && res.data.list.length > 0) {
|
|
|
+ // 追加新数据到列表
|
|
|
+ this.newsList = [...currentList, ...res.data.list];
|
|
|
+ console.log('新闻列表加载成功,当前列表长度:', this.newsList.length);
|
|
|
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.$refs.paging) {
|
|
|
- // 第一个参数需要是数组,将当前列表传入
|
|
|
- this.$refs.paging.complete(this.newsList);
|
|
|
- }
|
|
|
- // 数据加载完成后更新swiper高度
|
|
|
- if (this.currentTab === 2) {
|
|
|
- setTimeout(() => {
|
|
|
- this.updateSwiperHeight();
|
|
|
- }, 300);
|
|
|
- setTimeout(() => {
|
|
|
- this.updateSwiperHeight();
|
|
|
- }, 650);
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- complete: () => {
|
|
|
- this.isLoadingNews = false;
|
|
|
- },
|
|
|
- fail: (e) => {
|
|
|
- console.log("请求新闻列表失败:", e);
|
|
|
- this.isLoadingNews = false;
|
|
|
+ this.hasMoreNews = res.data.list.length >= 20;
|
|
|
+ } else {
|
|
|
+ this.hasMoreNews = false;
|
|
|
+ this.showNoMoreDataToast("没有更多新闻内容了");
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$nextTick(() => {
|
|
|
if (this.$refs.paging) {
|
|
|
- // 加载失败时提供空数组
|
|
|
- this.$refs.paging.complete([]);
|
|
|
+ // 第一个参数需要是数组,将当前列表传入
|
|
|
+ this.$refs.paging.complete(this.newsList);
|
|
|
}
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
- handleTopicPageChange(e) {
|
|
|
- this.currentTopicPage = e.detail.current;
|
|
|
- },
|
|
|
+ // 数据加载完成后更新swiper高度
|
|
|
+ if (this.currentTab === 2) {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.updateSwiperHeight();
|
|
|
+ }, 300);
|
|
|
+ setTimeout(() => {
|
|
|
+ this.updateSwiperHeight();
|
|
|
+ }, 650);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ this.isLoadingNews = false;
|
|
|
+ },
|
|
|
+ fail: (e) => {
|
|
|
+ console.log("请求新闻列表失败:", e);
|
|
|
+ this.isLoadingNews = false;
|
|
|
+ if (this.$refs.paging) {
|
|
|
+ // 加载失败时提供空数组
|
|
|
+ this.$refs.paging.complete([]);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleTopicPageChange(e) {
|
|
|
+ this.currentTopicPage = e.detail.current;
|
|
|
+ },
|
|
|
|
|
|
- formatItem(item) {
|
|
|
- console.log("item:", item);
|
|
|
+ formatItem(item) {
|
|
|
+ console.log("item:", item);
|
|
|
|
|
|
|
|
|
- let img = "";
|
|
|
- if (item.images) {
|
|
|
- img = item.images.split("|")[0];
|
|
|
- }
|
|
|
+ let img = "";
|
|
|
+ if (item.images) {
|
|
|
+ img = item.images.split("|")[0];
|
|
|
+ }
|
|
|
|
|
|
- // 处理接口返回的数据,使其适配card组件
|
|
|
- return {
|
|
|
- id: item.id,
|
|
|
- allowEdit: false,
|
|
|
- nickname: item.nickname,
|
|
|
- avator: item.avator,
|
|
|
- num_like: item.num_like,
|
|
|
- num_view: item.num_view,
|
|
|
- image: img || item.img_url || item.image, // 优先使用images字段
|
|
|
- w: item.width,
|
|
|
- h: item.height,
|
|
|
- title: item.title || "",
|
|
|
- desc: item.desc || "",
|
|
|
- userID: item.userID || 0,
|
|
|
- backgroundColor: "#f6f6f6",
|
|
|
- };
|
|
|
- },
|
|
|
+ // 处理接口返回的数据,使其适配card组件
|
|
|
+ return {
|
|
|
+ id: item.id,
|
|
|
+ allowEdit: false,
|
|
|
+ nickname: item.nickname,
|
|
|
+ avator: item.avator,
|
|
|
+ num_like: item.num_like,
|
|
|
+ num_view: item.num_view,
|
|
|
+ image: img || item.img_url || item.image, // 优先使用images字段
|
|
|
+ w: item.width,
|
|
|
+ h: item.height,
|
|
|
+ title: item.title || "",
|
|
|
+ desc: item.desc || "",
|
|
|
+ userID: item.userID || 0,
|
|
|
+ backgroundColor: "#f6f6f6",
|
|
|
+ };
|
|
|
+ },
|
|
|
|
|
|
- goToArticleDetail(id) {
|
|
|
- if (!id) {
|
|
|
- uni.showToast({
|
|
|
- title: "文章ID不存在",
|
|
|
- icon: "none",
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- // uni.$emit("check_login", () => {
|
|
|
- uni.navigateTo({
|
|
|
- url: "/pages/index/articleDetail?id=" + id,
|
|
|
+ goToArticleDetail(id) {
|
|
|
+ if (!id) {
|
|
|
+ uni.showToast({
|
|
|
+ title: "文章ID不存在",
|
|
|
+ icon: "none",
|
|
|
});
|
|
|
- // });
|
|
|
- },
|
|
|
- goWork(item) {
|
|
|
- console.log("skeylogin", "xxx");
|
|
|
- uni.$emit("check_login", () => {
|
|
|
- uni.navigateTo({
|
|
|
- url: "/pages/index/workDetail?id=" + item.id,
|
|
|
- });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // uni.$emit("check_login", () => {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: "/pages/index/articleDetail?id=" + id,
|
|
|
+ });
|
|
|
+ // });
|
|
|
+ },
|
|
|
+ goWork(item) {
|
|
|
+ console.log("skeylogin", "xxx");
|
|
|
+ uni.$emit("check_login", () => {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: "/pages/index/workDetail?id=" + item.id,
|
|
|
});
|
|
|
- },
|
|
|
- goToMake() {
|
|
|
- console.log("skeylogin", "xxx2");
|
|
|
- uni.$emit("check_login", () => {
|
|
|
- uni.navigateTo({
|
|
|
- // 生成个人形象
|
|
|
- // url: "/pages/make/make",
|
|
|
- url: "/pages/make/fabuArticle?id=-1",
|
|
|
- });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ goToMake() {
|
|
|
+ console.log("skeylogin", "xxx2");
|
|
|
+ uni.$emit("check_login", () => {
|
|
|
+ uni.navigateTo({
|
|
|
+ // 生成个人形象
|
|
|
+ // url: "/pages/make/make",
|
|
|
+ url: "/pages/make/fabuArticle?id=-1",
|
|
|
});
|
|
|
- },
|
|
|
- goPage(page) {
|
|
|
- uni.$emit("check_login", () => {
|
|
|
- uni.navigateTo({
|
|
|
- url: page,
|
|
|
- });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ goPage(page) {
|
|
|
+ uni.$emit("check_login", () => {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: page,
|
|
|
});
|
|
|
- },
|
|
|
- // 修改下拉刷新方法
|
|
|
- onRefresh() {
|
|
|
- console.log('下拉刷新开始');
|
|
|
- // 重置所有数据
|
|
|
- this.followList = [];
|
|
|
- this.recommendList = [];
|
|
|
- this.newsList = [];
|
|
|
- this.hotTopics = [];
|
|
|
-
|
|
|
- // 重置偏移量
|
|
|
- this.followOffset = 0;
|
|
|
- this.recommendOffset = 0;
|
|
|
- this.newsOffset = 0;
|
|
|
-
|
|
|
- // 重置加载状态
|
|
|
- this.hasMoreFollow = true;
|
|
|
- this.hasMoreRecommend = true;
|
|
|
- this.hasMoreNews = true;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 修改下拉刷新方法
|
|
|
+ onRefresh() {
|
|
|
+ console.log('下拉刷新开始');
|
|
|
+ // 重置所有数据
|
|
|
+ this.followList = [];
|
|
|
+ this.recommendList = [];
|
|
|
+ this.newsList = [];
|
|
|
+ this.hotTopics = [];
|
|
|
|
|
|
- // 根据当前标签页加载数据
|
|
|
- this.loadTabData(this.currentTab);
|
|
|
- },
|
|
|
+ // 重置偏移量
|
|
|
+ this.followOffset = 0;
|
|
|
+ this.recommendOffset = 0;
|
|
|
+ this.newsOffset = 0;
|
|
|
|
|
|
- // 下拉刷新恢复
|
|
|
- onRefresherRestore() {
|
|
|
- console.log('下拉刷新恢复');
|
|
|
- },
|
|
|
- // 处理z-paging的触底加载更多事件
|
|
|
- onZPagingLoadMore(pageNo, pageSize) {
|
|
|
- console.log('触底加载更多, 页码:', pageNo, '页大小:', pageSize);
|
|
|
- // 根据当前标签页加载更多数据
|
|
|
- switch (this.currentTab) {
|
|
|
- case 0:
|
|
|
- if (this.hasMoreFollow && !this.isLoadingFollow) {
|
|
|
- this.loadFollowList();
|
|
|
- } else if (!this.hasMoreFollow && !this.isLoadingFollow && this.followList.length > 0) {
|
|
|
- this.showNoMoreDataToast("没有更多关注内容了");
|
|
|
- // 通知组件加载完毕且没有更多数据
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.$refs.paging) {
|
|
|
- this.$refs.paging.complete(this.followList);
|
|
|
- }
|
|
|
- });
|
|
|
- } else if (this.followList.length === 0 && !this.isLoadingFollow) {
|
|
|
- this.showNoMoreDataToast("暂无关注内容");
|
|
|
- // 通知组件加载完毕且没有数据
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.$refs.paging) {
|
|
|
- this.$refs.paging.complete([]);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- if (this.hasMoreRecommend && !this.isLoadingRecommend) {
|
|
|
- this.loadRecommendList();
|
|
|
- } else if (!this.hasMoreRecommend && !this.isLoadingRecommend && this.recommendList.length > 0) {
|
|
|
- this.showNoMoreDataToast("没有更多推荐内容了");
|
|
|
- // 通知组件加载完毕且没有更多数据
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.$refs.paging) {
|
|
|
- this.$refs.paging.complete(this.recommendList);
|
|
|
- }
|
|
|
- });
|
|
|
- } else if (this.recommendList.length === 0 && !this.isLoadingRecommend) {
|
|
|
- this.showNoMoreDataToast("暂无推荐内容");
|
|
|
- // 通知组件加载完毕且没有数据
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.$refs.paging) {
|
|
|
- this.$refs.paging.complete([]);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- if (this.hasMoreNews && !this.isLoadingNews) {
|
|
|
- this.loadNewsList();
|
|
|
- } else if (!this.hasMoreNews && !this.isLoadingNews && this.newsList.length > 0) {
|
|
|
- this.showNoMoreDataToast("没有更多新闻内容了");
|
|
|
- // 通知组件加载完毕且没有更多数据
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.$refs.paging) {
|
|
|
- this.$refs.paging.complete(this.newsList);
|
|
|
- }
|
|
|
- });
|
|
|
- } else if (this.newsList.length === 0 && !this.isLoadingNews) {
|
|
|
- this.showNoMoreDataToast("暂无新闻内容");
|
|
|
- // 通知组件加载完毕且没有数据
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.$refs.paging) {
|
|
|
- this.$refs.paging.complete([]);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- },
|
|
|
- // 处理swiper的change事件
|
|
|
- handleTabChange(e) {
|
|
|
- const current = e.detail.current;
|
|
|
- this.switchTab(current);
|
|
|
- // 在tab切换后,延迟更新swiper高度
|
|
|
- // 切换标签页后,需要给一些时间让内容渲染,然后再更新高度
|
|
|
- setTimeout(() => {
|
|
|
- this.updateSwiperHeight();
|
|
|
- }, 300);
|
|
|
- },
|
|
|
- // 更新swiper高度方法
|
|
|
- updateSwiperHeight() {
|
|
|
- const query = uni.createSelectorQuery().in(this);
|
|
|
+ // 重置加载状态
|
|
|
+ this.hasMoreFollow = true;
|
|
|
+ this.hasMoreRecommend = true;
|
|
|
+ this.hasMoreNews = true;
|
|
|
|
|
|
- // 根据当前选中的标签页查询内容高度
|
|
|
- let selector = '.follow-list';
|
|
|
- if (this.currentTab === 1) {
|
|
|
- selector = '.recommend-list';
|
|
|
- } else if (this.currentTab === 2) {
|
|
|
- selector = '.explore-list';
|
|
|
- }
|
|
|
+ // 根据当前标签页加载数据
|
|
|
+ this.loadTabData(this.currentTab);
|
|
|
+ },
|
|
|
|
|
|
- query.select(selector).boundingClientRect(data => {
|
|
|
- if (data) {
|
|
|
- // 设置最小高度,防止内容过少时swiper太小
|
|
|
- let minHeight = uni.getSystemInfoSync().windowHeight * 0.2; // 最小高度为窗口高度的40%
|
|
|
- this.swiperHeight = Math.max(data.height, minHeight);
|
|
|
- console.log('更新swiper高度:', this.swiperHeight, 'selector:', selector);
|
|
|
- }
|
|
|
- }).exec();
|
|
|
- },
|
|
|
- // 首次进入页面初始化数据
|
|
|
- initialLoad() {
|
|
|
- console.log('初始化数据加载...');
|
|
|
- // 根据当前标签页加载初始数据
|
|
|
- switch (this.currentTab) {
|
|
|
- case 0:
|
|
|
- // 重置关注列表
|
|
|
- this.followList = [];
|
|
|
- this.followOffset = 0;
|
|
|
- this.hasMoreFollow = true;
|
|
|
+ // 下拉刷新恢复
|
|
|
+ onRefresherRestore() {
|
|
|
+ console.log('下拉刷新恢复');
|
|
|
+ },
|
|
|
+ // 处理z-paging的触底加载更多事件
|
|
|
+ onZPagingLoadMore(pageNo, pageSize) {
|
|
|
+ console.log('触底加载更多, 页码:', pageNo, '页大小:', pageSize);
|
|
|
+ // 根据当前标签页加载更多数据
|
|
|
+ switch (this.currentTab) {
|
|
|
+ case 0:
|
|
|
+ if (this.hasMoreFollow && !this.isLoadingFollow) {
|
|
|
this.loadFollowList();
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- // 重置推荐列表
|
|
|
- this.recommendList = [];
|
|
|
- this.recommendOffset = 0;
|
|
|
- this.hasMoreRecommend = true;
|
|
|
+ } else if (!this.hasMoreFollow && !this.isLoadingFollow && this.followList.length > 0) {
|
|
|
+ this.showNoMoreDataToast("没有更多关注内容了");
|
|
|
+ // 通知组件加载完毕且没有更多数据
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.$refs.paging) {
|
|
|
+ this.$refs.paging.complete(this.followList);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (this.followList.length === 0 && !this.isLoadingFollow) {
|
|
|
+ this.showNoMoreDataToast("暂无关注内容");
|
|
|
+ // 通知组件加载完毕且没有数据
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.$refs.paging) {
|
|
|
+ this.$refs.paging.complete([]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ if (this.hasMoreRecommend && !this.isLoadingRecommend) {
|
|
|
this.loadRecommendList();
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- // 重置热点新闻和新闻列表
|
|
|
- this.hotNewsList = [];
|
|
|
- this.newsList = [];
|
|
|
- this.newsOffset = 0;
|
|
|
- this.hasMoreNews = true;
|
|
|
- // 加载热点新闻和新闻列表
|
|
|
- this.loadHotNews();
|
|
|
+ } else if (!this.hasMoreRecommend && !this.isLoadingRecommend && this.recommendList.length > 0) {
|
|
|
+ this.showNoMoreDataToast("没有更多推荐内容了");
|
|
|
+ // 通知组件加载完毕且没有更多数据
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.$refs.paging) {
|
|
|
+ this.$refs.paging.complete(this.recommendList);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (this.recommendList.length === 0 && !this.isLoadingRecommend) {
|
|
|
+ this.showNoMoreDataToast("暂无推荐内容");
|
|
|
+ // 通知组件加载完毕且没有数据
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.$refs.paging) {
|
|
|
+ this.$refs.paging.complete([]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ if (this.hasMoreNews && !this.isLoadingNews) {
|
|
|
this.loadNewsList();
|
|
|
- break;
|
|
|
- }
|
|
|
- },
|
|
|
- // 显示没有更多数据的提示,带防抖处理
|
|
|
- showNoMoreDataToast(message) {
|
|
|
- return
|
|
|
- // 如果已经有一个定时器在运行,先清除它
|
|
|
- if (this.noMoreDataTimer) {
|
|
|
- clearTimeout(this.noMoreDataTimer);
|
|
|
- this.noMoreDataTimer = null;
|
|
|
- }
|
|
|
+ } else if (!this.hasMoreNews && !this.isLoadingNews && this.newsList.length > 0) {
|
|
|
+ this.showNoMoreDataToast("没有更多新闻内容了");
|
|
|
+ // 通知组件加载完毕且没有更多数据
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.$refs.paging) {
|
|
|
+ this.$refs.paging.complete(this.newsList);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (this.newsList.length === 0 && !this.isLoadingNews) {
|
|
|
+ this.showNoMoreDataToast("暂无新闻内容");
|
|
|
+ // 通知组件加载完毕且没有数据
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.$refs.paging) {
|
|
|
+ this.$refs.paging.complete([]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 处理swiper的change事件
|
|
|
+ handleTabChange(e) {
|
|
|
+ const current = e.detail.current;
|
|
|
+ this.switchTab(current);
|
|
|
+ // 在tab切换后,延迟更新swiper高度
|
|
|
+ // 切换标签页后,需要给一些时间让内容渲染,然后再更新高度
|
|
|
+ setTimeout(() => {
|
|
|
+ this.updateSwiperHeight();
|
|
|
+ }, 300);
|
|
|
+ },
|
|
|
+ // 更新swiper高度方法
|
|
|
+ updateSwiperHeight() {
|
|
|
+ const query = uni.createSelectorQuery().in(this);
|
|
|
|
|
|
- // 设置新的定时器,防抖处理,1秒内不会重复显示提示
|
|
|
- this.noMoreDataTimer = setTimeout(() => {
|
|
|
- console.log(message);
|
|
|
- uni.showToast({
|
|
|
- title: message,
|
|
|
- icon: 'none',
|
|
|
- duration: 2000
|
|
|
- });
|
|
|
- this.noMoreDataTimer = null;
|
|
|
- }, 1000);
|
|
|
- },
|
|
|
- onImageLoaded() {
|
|
|
- // 图片加载完成后重新计算高度
|
|
|
- // 使用延迟执行,确保所有图片都有时间加载完成
|
|
|
- if (this.updateHeightTimer) {
|
|
|
- clearTimeout(this.updateHeightTimer);
|
|
|
+ // 根据当前选中的标签页查询内容高度
|
|
|
+ let selector = '.follow-list';
|
|
|
+ if (this.currentTab === 1) {
|
|
|
+ selector = '.recommend-list';
|
|
|
+ } else if (this.currentTab === 2) {
|
|
|
+ selector = '.explore-list';
|
|
|
+ }
|
|
|
+
|
|
|
+ query.select(selector).boundingClientRect(data => {
|
|
|
+ if (data) {
|
|
|
+ // 设置最小高度,防止内容过少时swiper太小
|
|
|
+ let minHeight = uni.getSystemInfoSync().windowHeight * 0.2; // 最小高度为窗口高度的40%
|
|
|
+ this.swiperHeight = Math.max(data.height, minHeight);
|
|
|
+ console.log('更新swiper高度:', this.swiperHeight, 'selector:', selector);
|
|
|
}
|
|
|
- this.updateHeightTimer = setTimeout(() => {
|
|
|
- this.updateSwiperHeight();
|
|
|
- }, 300);
|
|
|
- },
|
|
|
+ }).exec();
|
|
|
+ },
|
|
|
+ // 首次进入页面初始化数据
|
|
|
+ initialLoad() {
|
|
|
+ console.log('初始化数据加载...');
|
|
|
+ // 根据当前标签页加载初始数据
|
|
|
+ switch (this.currentTab) {
|
|
|
+ case 0:
|
|
|
+ // 重置关注列表
|
|
|
+ this.followList = [];
|
|
|
+ this.followOffset = 0;
|
|
|
+ this.hasMoreFollow = true;
|
|
|
+ this.loadFollowList();
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ // 重置推荐列表
|
|
|
+ this.recommendList = [];
|
|
|
+ this.recommendOffset = 0;
|
|
|
+ this.hasMoreRecommend = true;
|
|
|
+ this.loadRecommendList();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ // 重置热点新闻和新闻列表
|
|
|
+ this.hotNewsList = [];
|
|
|
+ this.newsList = [];
|
|
|
+ this.newsOffset = 0;
|
|
|
+ this.hasMoreNews = true;
|
|
|
+ // 加载热点新闻和新闻列表
|
|
|
+ this.loadHotNews();
|
|
|
+ this.loadNewsList();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 显示没有更多数据的提示,带防抖处理
|
|
|
+ showNoMoreDataToast(message) {
|
|
|
+ return
|
|
|
+ // 如果已经有一个定时器在运行,先清除它
|
|
|
+ if (this.noMoreDataTimer) {
|
|
|
+ clearTimeout(this.noMoreDataTimer);
|
|
|
+ this.noMoreDataTimer = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置新的定时器,防抖处理,1秒内不会重复显示提示
|
|
|
+ this.noMoreDataTimer = setTimeout(() => {
|
|
|
+ console.log(message);
|
|
|
+ uni.showToast({
|
|
|
+ title: message,
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ this.noMoreDataTimer = null;
|
|
|
+ }, 1000);
|
|
|
+ },
|
|
|
+ onImageLoaded() {
|
|
|
+ // 图片加载完成后重新计算高度
|
|
|
+ // 使用延迟执行,确保所有图片都有时间加载完成
|
|
|
+ if (this.updateHeightTimer) {
|
|
|
+ clearTimeout(this.updateHeightTimer);
|
|
|
+ }
|
|
|
+ this.updateHeightTimer = setTimeout(() => {
|
|
|
+ this.updateSwiperHeight();
|
|
|
+ }, 300);
|
|
|
},
|
|
|
- };
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
- @import "index.scss";
|
|
|
+@import "index.scss";
|
|
|
|
|
|
- // 添加过渡效果样式
|
|
|
- .fade-enter-active,
|
|
|
- .fade-leave-active {
|
|
|
- transition: opacity 0.3s;
|
|
|
- }
|
|
|
+// 添加过渡效果样式
|
|
|
+.fade-enter-active,
|
|
|
+.fade-leave-active {
|
|
|
+ transition: opacity 0.3s;
|
|
|
+}
|
|
|
|
|
|
- .fade-enter,
|
|
|
- .fade-leave-to {
|
|
|
- opacity: 0;
|
|
|
- }
|
|
|
+.fade-enter,
|
|
|
+.fade-leave-to {
|
|
|
+ opacity: 0;
|
|
|
+}
|
|
|
|
|
|
- // 确保列表项有最小高度,避免闪烁
|
|
|
- .list-item {
|
|
|
- min-height: 200rpx;
|
|
|
- background: #fff;
|
|
|
- margin-bottom: 20rpx;
|
|
|
- border-radius: 12rpx;
|
|
|
- overflow: hidden;
|
|
|
- }
|
|
|
+// 确保列表项有最小高度,避免闪烁
|
|
|
+.list-item {
|
|
|
+ min-height: 200rpx;
|
|
|
+ background: #fff;
|
|
|
+ margin-bottom: 20rpx;
|
|
|
+ border-radius: 12rpx;
|
|
|
+ overflow: hidden;
|
|
|
+}
|
|
|
|
|
|
- // swiper样式
|
|
|
- .tab-content-swiper {
|
|
|
- width: 100%;
|
|
|
- transition: height 0.3s;
|
|
|
- }
|
|
|
+// swiper样式
|
|
|
+.tab-content-swiper {
|
|
|
+ width: 100%;
|
|
|
+ transition: height 0.3s;
|
|
|
+}
|
|
|
|
|
|
- /* 确保内容可以正常显示 */
|
|
|
- .swiper-item {
|
|
|
- height: auto;
|
|
|
- overflow: visible;
|
|
|
- }
|
|
|
+/* 确保内容可以正常显示 */
|
|
|
+.swiper-item {
|
|
|
+ height: auto;
|
|
|
+ overflow: visible;
|
|
|
+}
|
|
|
|
|
|
- .follow-list,
|
|
|
- .recommend-list,
|
|
|
- .explore-list {
|
|
|
- min-height: 300px;
|
|
|
- }
|
|
|
+.follow-list,
|
|
|
+.recommend-list,
|
|
|
+.explore-list {
|
|
|
+ min-height: 300px;
|
|
|
+}
|
|
|
</style>
|
|
|
<style>
|
|
|
- @import "@/style/qweather-icons.css";
|
|
|
+@import "@/style/qweather-icons.css";
|
|
|
</style>
|