index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  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-if="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-if="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-if="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. // 根据需要加载对应标签的数据
  406. this.loadTabData(index);
  407. },
  408. loadTabData(index) {
  409. // 这里添加加载不同标签数据的逻辑
  410. switch (index) {
  411. case 0:
  412. if (!this.followList.length) {
  413. this.loadFollowList();
  414. }
  415. break;
  416. case 1:
  417. if (!this.recommendList.length) {
  418. this.loadRecommendList();
  419. }
  420. break;
  421. case 2:
  422. // 加载热点新闻和新闻列表
  423. if (!this.hotNewsList.length) {
  424. this.loadHotNews();
  425. }
  426. if (!this.newsList.length) {
  427. this.loadNewsList();
  428. }
  429. break;
  430. }
  431. },
  432. loadFollowList() {
  433. if (this.isLoadingFollow) return;
  434. this.isLoadingFollow = true;
  435. uni.request({
  436. url: this.$apiHost + '/Work/getlist',
  437. data: {
  438. uuid: getApp().globalData.uuid,
  439. skey: getApp().globalData.skey,
  440. type: 'attention', // 关注列表
  441. offset: this.followOffset
  442. },
  443. header: {
  444. "content-type": "application/json",
  445. 'sign': getApp().globalData.headerSign
  446. },
  447. success: (res) => {
  448. console.log("关注列表数据:", res.data);
  449. // 确保在任何情况下都完成加载
  450. if (res.data.success == 'yes' && res.data.list && res.data.list.length > 0) {
  451. // 只有当列表有数据时才追加
  452. this.followList = [...this.followList, ...res.data.list];
  453. this.followOffset += res.data.list.length;
  454. if (res.data.list.length < 20) {
  455. this.hasMoreFollow = false;
  456. }
  457. } else {
  458. // 如果列表为空,确保标记没有更多数据
  459. this.hasMoreFollow = false;
  460. }
  461. // 无论是否有数据,都需要通知z-paging组件完成刷新
  462. if (this.$refs.paging) {
  463. this.$refs.paging.complete(this.followList);
  464. }
  465. },
  466. complete: () => {
  467. this.isLoadingFollow = false;
  468. },
  469. fail: (e) => {
  470. console.log("请求关注列表失败:", e);
  471. this.isLoadingFollow = false;
  472. // 加载失败时也要通知组件完成
  473. if (this.$refs.paging) {
  474. this.$refs.paging.complete(false);
  475. }
  476. }
  477. });
  478. },
  479. loadRecommendList() {
  480. if (this.isLoadingRecommend) return;
  481. this.isLoadingRecommend = true;
  482. uni.request({
  483. url: this.$apiHost + '/Work/getlist',
  484. data: {
  485. uuid: getApp().globalData.uuid,
  486. skey: getApp().globalData.skey,
  487. type: 'recommend', // 推荐列表
  488. offset: this.recommendOffset
  489. },
  490. header: {
  491. "content-type": "application/json",
  492. 'sign': getApp().globalData.headerSign
  493. },
  494. success: (res) => {
  495. console.log("推荐列表数据:", res.data);
  496. if (res.data.success == 'yes' && res.data.list && res.data.list.length > 0) {
  497. this.recommendList = [...this.recommendList, ...res.data.list];
  498. this.recommendOffset += res.data.list.length;
  499. if (res.data.list.length < 20) {
  500. this.hasMoreRecommend = false;
  501. }
  502. } else {
  503. this.hasMoreRecommend = false;
  504. }
  505. // 无论是否有数据,都需要通知z-paging组件完成刷新
  506. if (this.$refs.paging) {
  507. this.$refs.paging.complete(this.recommendList);
  508. }
  509. },
  510. complete: () => {
  511. this.isLoadingRecommend = false;
  512. },
  513. fail: (e) => {
  514. console.log("请求推荐列表失败:", e);
  515. this.isLoadingRecommend = false;
  516. // 加载失败时也要通知组件完成
  517. if (this.$refs.paging) {
  518. this.$refs.paging.complete(false);
  519. }
  520. }
  521. });
  522. },
  523. loadHotNews() {
  524. if (this.isLoadingExplore) return;
  525. this.isLoadingExplore = true;
  526. uni.request({
  527. url: this.$apiHost + '/Article/getlist',
  528. data: {
  529. uuid: getApp().globalData.uuid,
  530. skey: getApp().globalData.skey,
  531. type: 'hot' // 热点新闻
  532. },
  533. header: {
  534. "content-type": "application/json",
  535. 'sign': getApp().globalData.headerSign
  536. },
  537. success: (res) => {
  538. console.log("热点新闻数据:", res.data);
  539. if (res.data.success == 'yes' && res.data.list && res.data.list.length > 0) {
  540. this.hotNewsList = res.data.list;
  541. // 如果有热点新闻数据,更新热搜资讯
  542. if (this.hotNewsList.length > 0) {
  543. // 将API返回的热点新闻转换为热搜资讯格式
  544. this.hotTopics = this.hotNewsList.map((item, index) => {
  545. return {
  546. id: item.id,
  547. title: item.title || '热门话题',
  548. num_like: item.num_like || 0,
  549. isHot: index % 2 === 0 // 偶数索引的设为热点
  550. };
  551. });
  552. }
  553. }
  554. },
  555. complete: () => {
  556. this.isLoadingExplore = false;
  557. },
  558. fail: (e) => {
  559. console.log("请求热点新闻失败:", e);
  560. this.isLoadingExplore = false;
  561. }
  562. });
  563. },
  564. loadNewsList() {
  565. if (this.isLoadingNews) return;
  566. this.isLoadingNews = true;
  567. uni.request({
  568. url: this.$apiHost + '/Article/getlist',
  569. data: {
  570. uuid: getApp().globalData.uuid,
  571. skey: getApp().globalData.skey,
  572. type: 'list', // 新闻列表
  573. offset: this.newsOffset
  574. },
  575. header: {
  576. "content-type": "application/json",
  577. 'sign': getApp().globalData.headerSign
  578. },
  579. success: (res) => {
  580. console.log("新闻列表数据:", res.data);
  581. if (res.data.success == 'yes' && res.data.list && res.data.list.length > 0) {
  582. this.newsList = [...this.newsList, ...res.data.list];
  583. this.newsOffset += res.data.list.length;
  584. if (res.data.list.length < 20) {
  585. this.hasMoreNews = false;
  586. }
  587. } else {
  588. this.hasMoreNews = false;
  589. }
  590. // 无论是否有数据,都需要通知z-paging组件完成刷新
  591. if (this.$refs.paging) {
  592. this.$refs.paging.complete(this.newsList);
  593. }
  594. },
  595. complete: () => {
  596. this.isLoadingNews = false;
  597. },
  598. fail: (e) => {
  599. console.log("请求新闻列表失败:", e);
  600. this.isLoadingNews = false;
  601. // 加载失败时也要通知组件完成
  602. if (this.$refs.paging) {
  603. this.$refs.paging.complete(false);
  604. }
  605. }
  606. });
  607. },
  608. loadMoreData() {
  609. // 根据当前标签加载更多数据
  610. switch (this.currentTab) {
  611. case 0:
  612. if (this.hasMoreFollow && !this.isLoadingFollow) {
  613. this.loadFollowList();
  614. }
  615. break;
  616. case 1:
  617. if (this.hasMoreRecommend && !this.isLoadingRecommend) {
  618. this.loadRecommendList();
  619. }
  620. break;
  621. case 2:
  622. if (this.hasMoreNews && !this.isLoadingNews) {
  623. this.loadNewsList();
  624. }
  625. break;
  626. }
  627. },
  628. handleTopicPageChange(e) {
  629. this.currentTopicPage = e.detail.current;
  630. },
  631. formatItem(item) {
  632. // 处理接口返回的数据,使其适配card组件
  633. return {
  634. id: item.id,
  635. allowEdit: false,
  636. author: item.author,
  637. num_like: item.num_like,
  638. num_view: item.num_view,
  639. image: item.images || item.img_url || item.image, // 优先使用images字段
  640. w: item.width,
  641. h: item.height,
  642. title: item.title || '',
  643. desc: item.desc || ''
  644. }
  645. },
  646. goToArticleDetail(id) {
  647. if (!id) {
  648. uni.showToast({
  649. title: '文章ID不存在',
  650. icon: 'none'
  651. });
  652. return;
  653. }
  654. uni.$emit('check_login', () => {
  655. uni.navigateTo({
  656. url: '/pages/index/articleDetail?id=' + id
  657. });
  658. })
  659. },
  660. goWork(item) {
  661. console.log("skeylogin", "xxx");
  662. uni.$emit('check_login', () => {
  663. uni.navigateTo({
  664. url: '/pages/index/workDetail?id=' + item.id
  665. })
  666. })
  667. },
  668. goToMake() {
  669. console.log("skeylogin", "xxx2");
  670. uni.$emit('check_login', () => {
  671. uni.navigateTo({
  672. url: '/pages/make/make'
  673. });
  674. })
  675. },
  676. goPage(page) {
  677. uni.$emit('check_login', () => {
  678. uni.navigateTo({
  679. url: page
  680. })
  681. })
  682. }
  683. }
  684. }
  685. </script>
  686. <style lang="scss">
  687. @import 'index.scss';
  688. </style>