index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. <template>
  2. <view :style="{ height: windowHeight + 'px'}">
  3. <view style="display: flex;justify-content: flex-end;">
  4. <view class="view0 step1"></view>
  5. </view>
  6. <view class="view1 step2"></view>
  7. <view class="view2 step3"></view>
  8. <view class="view3 step4"></view>
  9. <view class="view4 step5"></view>
  10. <view class="view5 step6"></view>
  11. <view style="display: flex;justify-content: flex-end;">
  12. <view class="view6 step7"></view>
  13. </view>
  14. <image src="@/static/image/white-bg.png" :style="{ height: windowHeight + 'px',width:'750rpx'}"></image>
  15. <z-paging ref="paging" v-model="dataList" @query="queryList" :style="{ height: windowHeight - 80 + 'px'}"
  16. :show-scrollbar="false">
  17. <template #top>
  18. <page-navbar>
  19. <template #navLeft>
  20. <view style="display:flex;flex-direction: row;justify-content: center; align-items: center;">
  21. <image src="@/static/icon/loacltion.png" style="width: 30rpx; height: 38rpx;"></image>
  22. <text style="margin-left:10rpx;font-size: 28rpx;">
  23. 杭州
  24. </text>
  25. <image src="@/static/icon/down.png" style="width: 30rpx; height: 16rpx;"></image>
  26. </view>
  27. </template>
  28. <template #navCenter>
  29. <view style="width: 520rpx;height: 50rpx;margin-left:126rpx;">
  30. <uv-input placeholder="“潮玩大作战” 派对季重磅开启!" border="none"
  31. :custom-style="{background:'#8BDB67',paddingLeft:'20rpx'}" shape="circle">
  32. <template #prefix>
  33. <image src="@/static/icon/fiery.png" style="width: 14px;height: 18px;"></image>
  34. </template>
  35. <template #suffix>
  36. <view style="width: 77rpx;height: 42rpx;
  37. background-color: #57A335;border-radius: 20rpx;
  38. margin-right: 5rpx;display: flex;align-items: center;justify-content: center;">
  39. <image src="@/static/icon/search.png" style="width: 32rpx;height: 32rpx;">
  40. </image>
  41. </view>
  42. </template>
  43. </uv-input>
  44. </view>
  45. </template>
  46. </page-navbar>
  47. </template>
  48. <z-paging-cell>
  49. <sortble :default-sorts="['uvSwiper','classModel','uvSwiperCard']">
  50. <template #uvSwiper>
  51. <uv-swiper :list="bannerList" :autoplay="true" circular :interval="5000" indicator
  52. indicator-mode="dot" height='380' radius='0'></uv-swiper>
  53. </template>
  54. <template #classModel>
  55. <view class="classModel">
  56. <view class="classModel-bg classModel-bg1" ref="classModel1"
  57. @click="goPage('/pages/my/job')">
  58. <image class="classModel-img" src="@/static/zhHans-text-icon/text-2.png" mode="">
  59. </image>
  60. </view>
  61. <view class="classModel-bg classModel-bg2" ref="classModel2">
  62. <image class="classModel-img" src="@/static/zhHans-text-icon/text-3.png" mode="">
  63. </image>
  64. </view>
  65. <view class="classModel-bg" ref="classModel3">
  66. <image class="classModel-img" src="@/static/zhHans-text-icon/text-4.png" mode="">
  67. </image>
  68. </view>
  69. </view>
  70. </template>
  71. <!-- <template #uvSwiperCard>
  72. <view style="background: #fff;padding: 30rpx 0;">
  73. <image src="/static/zhHans-text-icon/text-1.png" ref="classModel4"
  74. style="width: 432rpx;height: 34rpx;margin-left: 28rpx;margin-bottom: 43rpx"></image>
  75. <swiper-card :width="257" :height="290">
  76. <template v-for="(item,index) in cardList" :slot="`card-${index}`">
  77. <view style="position: relative;align-items: center;"
  78. :style="{width:`${257}rpx`,height:`${290}rpx`}">
  79. <image style="position: absolute;top:15px;" :src="item.img"
  80. :style="{width:`${257}rpx`,height:`${290}rpx`}">
  81. </image>
  82. <image style="position: absolute;" :src="item.bgimg"
  83. :style="{width:`${257}rpx`,height:`${290}rpx`}"></image>
  84. </view>
  85. </template>
  86. </swiper-card>
  87. </view>
  88. </template> -->
  89. </sortble>
  90. </z-paging-cell>
  91. <z-paging-cell>
  92. <view class="tab-nav">
  93. <view v-for="(tab, index) in tabs" :key="index"
  94. :class="['tab-item', currentTab === index ? 'active' : '']" @click="switchTab(index)">
  95. {{ tab }}
  96. </view>
  97. </view>
  98. <view v-if="currentTab === 2" class="hot-topics">
  99. <view class="hot-topics-header">
  100. <text class="hot-topics-title">热搜资讯!</text>
  101. </view>
  102. <swiper class="hot-topics-swiper" :current="currentTopicPage" @change="handleTopicPageChange">
  103. <swiper-item v-for="(page, pageIndex) in topicPages" :key="pageIndex">
  104. <view class="hot-topics-list">
  105. <view v-for="(topic, index) in page" :key="index" class="topic-item"
  106. @click="goToArticleDetail(topic.id)">
  107. <text class="topic-index">{{ pageIndex * 5 + index + 1 }}</text>
  108. <view class="topic-content">
  109. <view class="topic-title-row">
  110. <text class="topic-title">{{ topic.title }}</text>
  111. <text v-if="topic.isHot" class="hot-tag">HOT</text>
  112. </view>
  113. <text class="topic-participants">{{ topic.num_like }}人正在热议</text>
  114. </view>
  115. </view>
  116. </view>
  117. </swiper-item>
  118. </swiper>
  119. <view class="indicator-dots">
  120. <view v-for="i in 2" :key="i" :class="['dot', currentTopicPage === i-1 ? 'active' : '']"></view>
  121. </view>
  122. </view>
  123. <!-- 根据当前标签显示不同样式的列表 -->
  124. <!-- 关注列表 - 类似my.vue -->
  125. <view v-show="currentTab === 0" class="follow-list">
  126. <block v-if="followList.length > 0">
  127. <view class="works-list">
  128. <view class="work-item" v-for="(item, index) in followList" :key="index"
  129. @click="goWork(item)">
  130. <image class="work-image" :src="item.images || item.img_url" mode="aspectFill"></image>
  131. <view class="work-title">{{item.title || '作品'+index}}</view>
  132. </view>
  133. </view>
  134. </block>
  135. <view class="no-data" v-else-if="!isLoadingFollow">
  136. <text>暂无关注数据</text>
  137. </view>
  138. </view>
  139. <!-- 推荐列表 - 瀑布流样式 -->
  140. <w-waterfall v-show="currentTab === 1 && recommendList.length > 0" :data="recommendList">
  141. <template v-slot:content="{item,width}">
  142. <card :item="formatItem(item)" :width="width" :custom-style="{background:'#fff'}"
  143. textColor="#000"></card>
  144. </template>
  145. </w-waterfall>
  146. <!-- 探索列表 - 热点新闻已经有现成的热搜资讯组件,只需添加新闻列表 -->
  147. <view v-show="currentTab === 2 && newsList.length > 0" class="news-list">
  148. <view class="news-grid">
  149. <view class="news-item" v-for="(item, index) in newsList" :key="index"
  150. @click="goToArticleDetail(item.id)">
  151. <image class="news-image" :src="item.img_url || item.images" mode="aspectFill"></image>
  152. <view class="news-title">{{item.title || '新闻标题'}}</view>
  153. <view class="news-footer">
  154. <view class="news-author">{{item.author || '作者'}}</view>
  155. <view class="news-views">
  156. <image src="/static/icon/icon-4.png" class="view-icon"></image>
  157. <text>{{item.num_view || '0'}}</text>
  158. </view>
  159. </view>
  160. </view>
  161. </view>
  162. </view>
  163. <view class="no-data" v-if="currentTab === 1 && recommendList.length === 0 && !isLoadingRecommend">
  164. <text>暂无推荐数据</text>
  165. </view>
  166. <view class="no-data" v-if="currentTab === 2 && newsList.length === 0 && !isLoadingNews">
  167. <text>暂无新闻数据</text>
  168. </view>
  169. </z-paging-cell>
  170. <view class="blankHeight"></view>
  171. </z-paging>
  172. <tabbar-vue :tabbars="tabbars" :currentIndex="0" ref="tabbar"></tabbar-vue>
  173. <!-- 添加浮动按钮 -->
  174. <view v-if="currentTab === 2" class="float-btn" @click="goToMake">
  175. <image src="/static/icon/icon_add_black.png" class="float-btn-icon"></image>
  176. </view>
  177. <novice-guidance :step="step"></novice-guidance>
  178. </view>
  179. </template>
  180. <script>
  181. import sortble from "@/components/sortble/sortble.vue";
  182. import tabbarVue from "@/components/tabbar/tabbar.vue";
  183. import pageNavbar from "@/components/page-navbar/page-navbar.vue";
  184. import wWaterfall from "@/components/w-waterfall/w-waterfall.vue";
  185. import tabbar from "@/mixins/tabbar";
  186. import card from "@/components/card/card.vue";
  187. // import noviceGuidance from "@/components/novice-guidance/index.vue";
  188. export default {
  189. components: {
  190. sortble,
  191. tabbarVue,
  192. pageNavbar,
  193. wWaterfall,
  194. // noviceGuidance
  195. },
  196. mixins: [tabbar],
  197. data() {
  198. return {
  199. step: {
  200. name: 'workbenchSet5',
  201. guideList: [{
  202. el: '.step1',
  203. tips: '这里是第一步的介绍~',
  204. next: '下一步',
  205. }, {
  206. el: '.step2',
  207. tips: '这里是第二步的介绍~',
  208. next: '下一步',
  209. }, {
  210. el: '.step3',
  211. tips: '这里是第三步的介绍~',
  212. next: '下一步',
  213. }, {
  214. el: '.step4',
  215. tips: '这里是第四步的介绍~',
  216. next: '下一步',
  217. }, {
  218. el: '.step5',
  219. tips: '这里是第五步的介绍~',
  220. next: '下一步',
  221. }, {
  222. el: '.step6',
  223. tips: '这里是第六步的介绍~',
  224. next: '下一步',
  225. }, {
  226. el: '.step7',
  227. tips: '最后一步啦~',
  228. next: '完成',
  229. }]
  230. },
  231. windowHeight: uni.getWindowInfo().windowHeight,
  232. bannerList: [
  233. 'https://e.zhichao.art/AI_images/a_1112_10.png',
  234. 'https://e.zhichao.art/AI_images/a_1112_108.png',
  235. 'https://e.zhichao.art/AI_images/a_1112_113.png',
  236. ],
  237. cardList: [{
  238. img: '/static/img/img-1.png',
  239. bgimg: '/static/image/bg-2.png'
  240. }, {
  241. img: '/static/img/img-3.png',
  242. bgimg: '/static/image/bg-3.png'
  243. }, {
  244. img: '/static/img/img-2.png',
  245. bgimg: '/static/image/bg-1.png'
  246. }, ],
  247. list: [], // 瀑布流全部数据
  248. dataList: [],
  249. tabs: ['关注', '推荐', '探索'],
  250. currentTab: 1,
  251. currentTopicPage: 0,
  252. followList: [], // 关注列表数据
  253. recommendList: [], // 推荐列表数据
  254. exploreList: [], // 探索列表数据
  255. hotNewsList: [], // 热点新闻数据
  256. newsList: [], // 新闻列表数据
  257. followOffset: 0, // 关注列表偏移量
  258. recommendOffset: 0, // 推荐列表偏移量
  259. exploreOffset: 0, // 探索列表偏移量
  260. newsOffset: 0, // 新闻列表偏移量
  261. hasMoreFollow: true, // 是否有更多关注列表数据
  262. hasMoreRecommend: true, // 是否有更多推荐列表数据
  263. hasMoreExplore: true, // 是否有更多探索列表数据
  264. hasMoreNews: true, // 是否有更多新闻列表数据
  265. isLoadingFollow: false, // 是否正在加载关注列表
  266. isLoadingRecommend: false, // 是否正在加载推荐列表
  267. isLoadingExplore: false, // 是否正在加载探索列表
  268. isLoadingNews: false, // 是否正在加载新闻列表
  269. hotTopics: [],
  270. }
  271. },
  272. computed: {
  273. currentList() {
  274. switch (this.currentTab) {
  275. case 0:
  276. return this.followList;
  277. case 1:
  278. return this.recommendList; // 使用专门的推荐列表
  279. case 2:
  280. return this.exploreList;
  281. default:
  282. return [];
  283. }
  284. },
  285. topicPages() {
  286. const pages = [];
  287. for (let i = 0; i < this.hotTopics.length; i += 5) {
  288. pages.push(this.hotTopics.slice(i, i + 5));
  289. }
  290. return pages;
  291. }
  292. },
  293. onLoad() {
  294. let that = this;
  295. // 不在onLoad中直接加载数据,避免与z-paging组件重复请求
  296. // 让z-paging组件通过queryList方法控制数据加载
  297. },
  298. // 上拉加载更多
  299. onReachBottom() {
  300. this.loadMoreData();
  301. },
  302. // 下拉刷新数据
  303. methods: {
  304. queryList() {
  305. // 根据当前标签刷新数据
  306. switch (this.currentTab) {
  307. case 0:
  308. // 重置关注列表
  309. this.followList = [];
  310. this.followOffset = 0;
  311. this.hasMoreFollow = true;
  312. this.loadFollowList();
  313. break;
  314. case 1:
  315. // 重置推荐列表
  316. this.recommendList = [];
  317. this.recommendOffset = 0;
  318. this.hasMoreRecommend = true;
  319. this.loadRecommendList();
  320. break;
  321. case 2:
  322. // 重置热点新闻和新闻列表
  323. this.hotNewsList = [];
  324. this.newsList = [];
  325. this.newsOffset = 0;
  326. this.hasMoreNews = true;
  327. // 加载热点新闻和新闻列表
  328. this.loadHotNews();
  329. this.loadNewsList();
  330. break;
  331. }
  332. },
  333. async init() {
  334. const {
  335. data
  336. } = await this.getData();
  337. this.list.push.apply(this.list, data);
  338. },
  339. // 模拟的后端数据
  340. getData() {
  341. return new Promise((resolve) => {
  342. const imgs = [{
  343. url: 'https://e.zhichao.art/AI_images/a_1112_10.png',
  344. },
  345. {
  346. url: 'https://e.zhichao.art/AI_images/a_1112_108.png',
  347. },
  348. {
  349. url: 'https://e.zhichao.art/AI_images/a_1112_113.png',
  350. },
  351. {
  352. url: 'https://e.zhichao.art/AI_images/a_1112_13.png',
  353. },
  354. {
  355. url: 'https://e.zhichao.art/AI_images/a_1112_137.png',
  356. },
  357. {
  358. url: 'https://e.zhichao.art/AI_images/a_1112_141.png',
  359. },
  360. {
  361. url: 'https://e.zhichao.art/AI_images/a_1114__562.png',
  362. },
  363. {
  364. url: 'https://e.zhichao.art/AI_images/a_1114__568.png',
  365. },
  366. {
  367. url: 'https://e.zhichao.art/AI_images/a_1114__569.png',
  368. },
  369. {
  370. url: 'https://e.zhichao.art/AI_images/a_1114__570.png',
  371. },
  372. {
  373. url: 'https://e.zhichao.art/AI_images/a_1114__571.png',
  374. },
  375. {
  376. url: 'https://e.zhichao.art/AI_images/a_1114__575.png',
  377. },
  378. ];
  379. let list = [];
  380. const doFn = (i) => {
  381. const randomIndex = Math.floor(Math.random() * 10);
  382. return {
  383. allowEdit: i == 0,
  384. image: imgs[randomIndex].url,
  385. w: imgs[randomIndex].width,
  386. h: imgs[randomIndex].height,
  387. title: i % 2 == 0 ? `玛丽` : `凌音`,
  388. desc: i % 2 == 0 ?
  389. `欢迎使用uv-ui,uni-app生态专用的UI框架` : `开发者编写一套代码, 可发布到iOS、Android、H5、以及各种小程序`
  390. }
  391. };
  392. // 模拟异步
  393. setTimeout(() => {
  394. for (let i = 0; i < 20; i++) {
  395. list.push(doFn(i));
  396. }
  397. resolve({
  398. data: list
  399. });
  400. }, 200)
  401. })
  402. },
  403. switchTab(index) {
  404. this.currentTab = index;
  405. // Check if the target tab's list is already populated
  406. if (this.currentList.length > 0) {
  407. // If the list is already populated, do not fetch data again
  408. return;
  409. }
  410. // If the list is not populated, load the corresponding data
  411. this.loadTabData(index);
  412. },
  413. loadTabData(index) {
  414. switch (index) {
  415. case 0:
  416. if (!this.followList.length) {
  417. this.loadFollowList();
  418. }
  419. break;
  420. case 1:
  421. if (!this.recommendList.length) {
  422. this.loadRecommendList();
  423. }
  424. break;
  425. case 2:
  426. if (!this.hotNewsList.length) {
  427. this.loadHotNews();
  428. }
  429. if (!this.newsList.length) {
  430. this.loadNewsList();
  431. }
  432. break;
  433. }
  434. },
  435. loadFollowList() {
  436. if (this.isLoadingFollow) return;
  437. this.isLoadingFollow = true;
  438. uni.request({
  439. url: this.$apiHost + '/Work/getlist',
  440. data: {
  441. uuid: getApp().globalData.uuid,
  442. skey: getApp().globalData.skey,
  443. type: 'attention', // 关注列表
  444. offset: this.followOffset
  445. },
  446. header: {
  447. "content-type": "application/json",
  448. 'sign': getApp().globalData.headerSign
  449. },
  450. success: (res) => {
  451. console.log("关注列表数据:", res.data);
  452. // 确保在任何情况下都完成加载
  453. if (res.data.success == 'yes' && res.data.list && res.data.list.length > 0) {
  454. // 只有当列表有数据时才追加
  455. this.followList = [...this.followList, ...res.data.list];
  456. this.followOffset += res.data.list.length;
  457. if (res.data.list.length < 20) {
  458. this.hasMoreFollow = false;
  459. }
  460. } else {
  461. // 如果列表为空,确保标记没有更多数据
  462. this.hasMoreFollow = false;
  463. }
  464. // 无论是否有数据,都需要通知z-paging组件完成刷新
  465. if (this.$refs.paging) {
  466. this.$refs.paging.complete(this.followList);
  467. }
  468. },
  469. complete: () => {
  470. this.isLoadingFollow = false;
  471. },
  472. fail: (e) => {
  473. console.log("请求关注列表失败:", e);
  474. this.isLoadingFollow = false;
  475. // 加载失败时也要通知组件完成
  476. if (this.$refs.paging) {
  477. this.$refs.paging.complete(false);
  478. }
  479. }
  480. });
  481. },
  482. loadRecommendList() {
  483. if (this.isLoadingRecommend) return;
  484. this.isLoadingRecommend = true;
  485. uni.request({
  486. url: this.$apiHost + '/Work/getlist',
  487. data: {
  488. uuid: getApp().globalData.uuid,
  489. skey: getApp().globalData.skey,
  490. type: 'recommend', // 推荐列表
  491. offset: this.recommendOffset
  492. },
  493. header: {
  494. "content-type": "application/json",
  495. 'sign': getApp().globalData.headerSign
  496. },
  497. success: (res) => {
  498. console.log("推荐列表数据:", res.data);
  499. if (res.data.success == 'yes' && res.data.list && res.data.list.length > 0) {
  500. this.recommendList = [...this.recommendList, ...res.data.list];
  501. this.recommendOffset += res.data.list.length;
  502. if (res.data.list.length < 20) {
  503. this.hasMoreRecommend = false;
  504. }
  505. } else {
  506. this.hasMoreRecommend = false;
  507. }
  508. // 无论是否有数据,都需要通知z-paging组件完成刷新
  509. if (this.$refs.paging) {
  510. this.$refs.paging.complete(this.recommendList);
  511. }
  512. },
  513. complete: () => {
  514. this.isLoadingRecommend = false;
  515. },
  516. fail: (e) => {
  517. console.log("请求推荐列表失败:", e);
  518. this.isLoadingRecommend = false;
  519. // 加载失败时也要通知组件完成
  520. if (this.$refs.paging) {
  521. this.$refs.paging.complete(false);
  522. }
  523. }
  524. });
  525. },
  526. loadHotNews() {
  527. if (this.isLoadingExplore) return;
  528. this.isLoadingExplore = true;
  529. uni.request({
  530. url: this.$apiHost + '/Article/getlist',
  531. data: {
  532. uuid: getApp().globalData.uuid,
  533. skey: getApp().globalData.skey,
  534. type: 'hot' // 热点新闻
  535. },
  536. header: {
  537. "content-type": "application/json",
  538. 'sign': getApp().globalData.headerSign
  539. },
  540. success: (res) => {
  541. console.log("热点新闻数据:", res.data);
  542. if (res.data.success == 'yes' && res.data.list && res.data.list.length > 0) {
  543. this.hotNewsList = res.data.list;
  544. // 如果有热点新闻数据,更新热搜资讯
  545. if (this.hotNewsList.length > 0) {
  546. // 将API返回的热点新闻转换为热搜资讯格式
  547. this.hotTopics = this.hotNewsList.map((item, index) => {
  548. return {
  549. id: item.id,
  550. title: item.title || '热门话题',
  551. num_like: item.num_like || 0,
  552. isHot: index % 2 === 0 // 偶数索引的设为热点
  553. };
  554. });
  555. }
  556. }
  557. },
  558. complete: () => {
  559. this.isLoadingExplore = false;
  560. },
  561. fail: (e) => {
  562. console.log("请求热点新闻失败:", e);
  563. this.isLoadingExplore = false;
  564. }
  565. });
  566. },
  567. loadNewsList() {
  568. if (this.isLoadingNews) return;
  569. this.isLoadingNews = true;
  570. uni.request({
  571. url: this.$apiHost + '/Article/getlist',
  572. data: {
  573. uuid: getApp().globalData.uuid,
  574. skey: getApp().globalData.skey,
  575. type: 'list', // 新闻列表
  576. offset: this.newsOffset
  577. },
  578. header: {
  579. "content-type": "application/json",
  580. 'sign': getApp().globalData.headerSign
  581. },
  582. success: (res) => {
  583. console.log("新闻列表数据:", res.data);
  584. if (res.data.success == 'yes' && res.data.list && res.data.list.length > 0) {
  585. this.newsList = [...this.newsList, ...res.data.list];
  586. this.newsOffset += res.data.list.length;
  587. if (res.data.list.length < 20) {
  588. this.hasMoreNews = false;
  589. }
  590. } else {
  591. this.hasMoreNews = false;
  592. }
  593. // 无论是否有数据,都需要通知z-paging组件完成刷新
  594. if (this.$refs.paging) {
  595. this.$refs.paging.complete(this.newsList);
  596. }
  597. },
  598. complete: () => {
  599. this.isLoadingNews = false;
  600. },
  601. fail: (e) => {
  602. console.log("请求新闻列表失败:", e);
  603. this.isLoadingNews = false;
  604. // 加载失败时也要通知组件完成
  605. if (this.$refs.paging) {
  606. this.$refs.paging.complete(false);
  607. }
  608. }
  609. });
  610. },
  611. loadMoreData() {
  612. // 根据当前标签加载更多数据
  613. switch (this.currentTab) {
  614. case 0:
  615. if (this.hasMoreFollow && !this.isLoadingFollow) {
  616. this.loadFollowList();
  617. }
  618. break;
  619. case 1:
  620. if (this.hasMoreRecommend && !this.isLoadingRecommend) {
  621. this.loadRecommendList();
  622. }
  623. break;
  624. case 2:
  625. if (this.hasMoreNews && !this.isLoadingNews) {
  626. this.loadNewsList();
  627. }
  628. break;
  629. }
  630. },
  631. handleTopicPageChange(e) {
  632. this.currentTopicPage = e.detail.current;
  633. },
  634. formatItem(item) {
  635. // 处理接口返回的数据,使其适配card组件
  636. return {
  637. id: item.id,
  638. allowEdit: false,
  639. author: item.author,
  640. num_like: item.num_like,
  641. num_view: item.num_view,
  642. image: item.images || item.img_url || item.image, // 优先使用images字段
  643. w: item.width,
  644. h: item.height,
  645. title: item.title || '',
  646. desc: item.desc || ''
  647. }
  648. },
  649. goToArticleDetail(id) {
  650. if (!id) {
  651. uni.showToast({
  652. title: '文章ID不存在',
  653. icon: 'none'
  654. });
  655. return;
  656. }
  657. uni.$emit('check_login', () => {
  658. uni.navigateTo({
  659. url: '/pages/index/articleDetail?id=' + id
  660. });
  661. })
  662. },
  663. goWork(item) {
  664. console.log("skeylogin", "xxx");
  665. uni.$emit('check_login', () => {
  666. uni.navigateTo({
  667. url: '/pages/index/workDetail?id=' + item.id
  668. })
  669. })
  670. },
  671. goToMake() {
  672. console.log("skeylogin", "xxx2");
  673. uni.$emit('check_login', () => {
  674. uni.navigateTo({
  675. url: '/pages/make/make'
  676. });
  677. })
  678. },
  679. goPage(page) {
  680. uni.$emit('check_login', () => {
  681. uni.navigateTo({
  682. url: page
  683. })
  684. })
  685. }
  686. }
  687. }
  688. </script>
  689. <style lang="scss">
  690. @import 'index.scss';
  691. </style>