index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981
  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. <image class="classModel-img" src="@/static/zhHans-text-icon/text-2.png" mode="">
  58. </image>
  59. </view>
  60. <view class="classModel-bg classModel-bg2" ref="classModel2">
  61. <image class="classModel-img" src="@/static/zhHans-text-icon/text-3.png" mode="">
  62. </image>
  63. </view>
  64. <view class="classModel-bg" ref="classModel3">
  65. <image class="classModel-img" src="@/static/zhHans-text-icon/text-4.png" mode="">
  66. </image>
  67. </view>
  68. </view>
  69. </template>
  70. <!-- <template #uvSwiperCard>
  71. <view style="background: #fff;padding: 30rpx 0;">
  72. <image src="/static/zhHans-text-icon/text-1.png" ref="classModel4"
  73. style="width: 432rpx;height: 34rpx;margin-left: 28rpx;margin-bottom: 43rpx"></image>
  74. <swiper-card :width="257" :height="290">
  75. <template v-for="(item,index) in cardList" :slot="`card-${index}`">
  76. <view style="position: relative;align-items: center;"
  77. :style="{width:`${257}rpx`,height:`${290}rpx`}">
  78. <image style="position: absolute;top:15px;" :src="item.img"
  79. :style="{width:`${257}rpx`,height:`${290}rpx`}">
  80. </image>
  81. <image style="position: absolute;" :src="item.bgimg"
  82. :style="{width:`${257}rpx`,height:`${290}rpx`}"></image>
  83. </view>
  84. </template>
  85. </swiper-card>
  86. </view>
  87. </template> -->
  88. </sortble>
  89. </z-paging-cell>
  90. <z-paging-cell>
  91. <view class="tab-nav">
  92. <view v-for="(tab, index) in tabs" :key="index"
  93. :class="['tab-item', currentTab === index ? 'active' : '']" @click="switchTab(index)">
  94. {{ tab }}
  95. </view>
  96. </view>
  97. <view v-if="currentTab === 2" class="hot-topics">
  98. <view class="hot-topics-header">
  99. <text class="hot-topics-title">热搜资讯!</text>
  100. </view>
  101. <swiper class="hot-topics-swiper" :current="currentTopicPage" @change="handleTopicPageChange">
  102. <swiper-item v-for="(page, pageIndex) in topicPages" :key="pageIndex">
  103. <view class="hot-topics-list">
  104. <view v-for="(topic, index) in page" :key="index" class="topic-item"
  105. @click="goToArticleDetail(topic.id)">
  106. <text class="topic-index">{{ pageIndex * 5 + index + 1 }}</text>
  107. <view class="topic-content">
  108. <view class="topic-title-row">
  109. <text class="topic-title">{{ topic.title }}</text>
  110. <text v-if="topic.isHot" class="hot-tag">HOT</text>
  111. </view>
  112. <text class="topic-participants">{{ topic.num_like }}人正在热议</text>
  113. </view>
  114. </view>
  115. </view>
  116. </swiper-item>
  117. </swiper>
  118. <view class="indicator-dots">
  119. <view v-for="i in 2" :key="i" :class="['dot', currentTopicPage === i-1 ? 'active' : '']"></view>
  120. </view>
  121. </view>
  122. <!-- 根据当前标签显示不同样式的列表 -->
  123. <!-- 关注列表 - 类似my.vue -->
  124. <view v-if="currentTab === 0" class="follow-list">
  125. <block v-if="followList.length > 0">
  126. <view class="works-list">
  127. <view class="work-item" v-for="(item, index) in followList" :key="index"
  128. @click="goWork(item)">
  129. <image class="work-image" :src="item.images || item.img_url" mode="aspectFill"></image>
  130. <view class="work-title">{{item.title || '作品'+index}}</view>
  131. </view>
  132. </view>
  133. </block>
  134. <view class="no-data" v-else-if="!isLoadingFollow">
  135. <text>暂无关注数据</text>
  136. </view>
  137. </view>
  138. <!-- 推荐列表 - 瀑布流样式 -->
  139. <w-waterfall v-if="currentTab === 1 && recommendList.length > 0" :data="recommendList">
  140. <template v-slot:content="{item,width}">
  141. <card :item="formatItem(item)" :width="width" :custom-style="{background:'#fff'}"
  142. textColor="#000"></card>
  143. </template>
  144. </w-waterfall>
  145. <!-- 探索列表 - 热点新闻已经有现成的热搜资讯组件,只需添加新闻列表 -->
  146. <view v-if="currentTab === 2 && newsList.length > 0" class="news-list">
  147. <view class="news-grid">
  148. <view class="news-item" v-for="(item, index) in newsList" :key="index"
  149. @click="goToArticleDetail(item.id)">
  150. <image class="news-image" :src="item.img_url || item.images" mode="aspectFill"></image>
  151. <view class="news-title">{{item.title || '新闻标题'}}</view>
  152. <view class="news-footer">
  153. <view class="news-author">{{item.author || '作者'}}</view>
  154. <view class="news-views">
  155. <image src="/static/icon/icon-4.png" class="view-icon"></image>
  156. <text>{{item.num_view || '0'}}</text>
  157. </view>
  158. </view>
  159. </view>
  160. </view>
  161. </view>
  162. <view class="no-data" v-if="currentTab === 1 && recommendList.length === 0 && !isLoadingRecommend">
  163. <text>暂无推荐数据</text>
  164. </view>
  165. <view class="no-data" v-if="currentTab === 2 && newsList.length === 0 && !isLoadingNews">
  166. <text>暂无新闻数据</text>
  167. </view>
  168. </z-paging-cell>
  169. <view class="blankHeight"></view>
  170. </z-paging>
  171. <tabbar-vue :tabbars="tabbars" :currentIndex="0" ref="tabbar"></tabbar-vue>
  172. <!-- 添加浮动按钮 -->
  173. <view v-if="currentTab === 2" class="float-btn" @click="goToMake">
  174. <image src="/static/icon/icon_add_black.png" class="float-btn-icon"></image>
  175. </view>
  176. <novice-guidance :step="step"></novice-guidance>
  177. </view>
  178. </template>
  179. <script>
  180. import sortble from "@/components/sortble/sortble.vue";
  181. import tabbarVue from "@/components/tabbar/tabbar.vue";
  182. import pageNavbar from "@/components/page-navbar/page-navbar.vue";
  183. import wWaterfall from "@/components/w-waterfall/w-waterfall.vue";
  184. import tabbar from "@/mixins/tabbar";
  185. import card from "@/components/card/card.vue";
  186. // import noviceGuidance from "@/components/novice-guidance/index.vue";
  187. export default {
  188. components: {
  189. sortble,
  190. tabbarVue,
  191. pageNavbar,
  192. wWaterfall,
  193. // noviceGuidance
  194. },
  195. mixins: [tabbar],
  196. data() {
  197. return {
  198. step: {
  199. name: 'workbenchSet5',
  200. guideList: [{
  201. el: '.step1',
  202. tips: '这里是第一步的介绍~',
  203. next: '下一步',
  204. }, {
  205. el: '.step2',
  206. tips: '这里是第二步的介绍~',
  207. next: '下一步',
  208. }, {
  209. el: '.step3',
  210. tips: '这里是第三步的介绍~',
  211. next: '下一步',
  212. }, {
  213. el: '.step4',
  214. tips: '这里是第四步的介绍~',
  215. next: '下一步',
  216. }, {
  217. el: '.step5',
  218. tips: '这里是第五步的介绍~',
  219. next: '下一步',
  220. }, {
  221. el: '.step6',
  222. tips: '这里是第六步的介绍~',
  223. next: '下一步',
  224. }, {
  225. el: '.step7',
  226. tips: '最后一步啦~',
  227. next: '完成',
  228. }]
  229. },
  230. windowHeight: uni.getWindowInfo().windowHeight,
  231. bannerList: [
  232. 'https://e.zhichao.art/AI_images/a_1112_10.png',
  233. 'https://e.zhichao.art/AI_images/a_1112_108.png',
  234. 'https://e.zhichao.art/AI_images/a_1112_113.png',
  235. ],
  236. cardList: [{
  237. img: '/static/img/img-1.png',
  238. bgimg: '/static/image/bg-2.png'
  239. }, {
  240. img: '/static/img/img-3.png',
  241. bgimg: '/static/image/bg-3.png'
  242. }, {
  243. img: '/static/img/img-2.png',
  244. bgimg: '/static/image/bg-1.png'
  245. }, ],
  246. list: [], // 瀑布流全部数据
  247. dataList: [],
  248. tabs: ['关注', '推荐', '探索'],
  249. currentTab: 1,
  250. currentTopicPage: 0,
  251. followList: [], // 关注列表数据
  252. recommendList: [], // 推荐列表数据
  253. exploreList: [], // 探索列表数据
  254. hotNewsList: [], // 热点新闻数据
  255. newsList: [], // 新闻列表数据
  256. followOffset: 0, // 关注列表偏移量
  257. recommendOffset: 0, // 推荐列表偏移量
  258. exploreOffset: 0, // 探索列表偏移量
  259. newsOffset: 0, // 新闻列表偏移量
  260. hasMoreFollow: true, // 是否有更多关注列表数据
  261. hasMoreRecommend: true, // 是否有更多推荐列表数据
  262. hasMoreExplore: true, // 是否有更多探索列表数据
  263. hasMoreNews: true, // 是否有更多新闻列表数据
  264. isLoadingFollow: false, // 是否正在加载关注列表
  265. isLoadingRecommend: false, // 是否正在加载推荐列表
  266. isLoadingExplore: false, // 是否正在加载探索列表
  267. isLoadingNews: false, // 是否正在加载新闻列表
  268. hotTopics: [],
  269. }
  270. },
  271. computed: {
  272. currentList() {
  273. switch (this.currentTab) {
  274. case 0:
  275. return this.followList;
  276. case 1:
  277. return this.recommendList; // 使用专门的推荐列表
  278. case 2:
  279. return this.exploreList;
  280. default:
  281. return [];
  282. }
  283. },
  284. topicPages() {
  285. const pages = [];
  286. for (let i = 0; i < this.hotTopics.length; i += 5) {
  287. pages.push(this.hotTopics.slice(i, i + 5));
  288. }
  289. return pages;
  290. }
  291. },
  292. onLoad() {
  293. let that = this;
  294. // 不在onLoad中直接加载数据,避免与z-paging组件重复请求
  295. // 让z-paging组件通过queryList方法控制数据加载
  296. },
  297. // 上拉加载更多
  298. onReachBottom() {
  299. this.loadMoreData();
  300. },
  301. // 下拉刷新数据
  302. methods: {
  303. queryList() {
  304. // 根据当前标签刷新数据
  305. switch (this.currentTab) {
  306. case 0:
  307. // 重置关注列表
  308. this.followList = [];
  309. this.followOffset = 0;
  310. this.hasMoreFollow = true;
  311. this.loadFollowList();
  312. break;
  313. case 1:
  314. // 重置推荐列表
  315. this.recommendList = [];
  316. this.recommendOffset = 0;
  317. this.hasMoreRecommend = true;
  318. this.loadRecommendList();
  319. break;
  320. case 2:
  321. // 重置热点新闻和新闻列表
  322. this.hotNewsList = [];
  323. this.newsList = [];
  324. this.newsOffset = 0;
  325. this.hasMoreNews = true;
  326. // 加载热点新闻和新闻列表
  327. this.loadHotNews();
  328. this.loadNewsList();
  329. break;
  330. }
  331. },
  332. async init() {
  333. const {
  334. data
  335. } = await this.getData();
  336. this.list.push.apply(this.list, data);
  337. },
  338. // 模拟的后端数据
  339. getData() {
  340. return new Promise((resolve) => {
  341. const imgs = [{
  342. url: 'https://e.zhichao.art/AI_images/a_1112_10.png',
  343. },
  344. {
  345. url: 'https://e.zhichao.art/AI_images/a_1112_108.png',
  346. },
  347. {
  348. url: 'https://e.zhichao.art/AI_images/a_1112_113.png',
  349. },
  350. {
  351. url: 'https://e.zhichao.art/AI_images/a_1112_13.png',
  352. },
  353. {
  354. url: 'https://e.zhichao.art/AI_images/a_1112_137.png',
  355. },
  356. {
  357. url: 'https://e.zhichao.art/AI_images/a_1112_141.png',
  358. },
  359. {
  360. url: 'https://e.zhichao.art/AI_images/a_1114__562.png',
  361. },
  362. {
  363. url: 'https://e.zhichao.art/AI_images/a_1114__568.png',
  364. },
  365. {
  366. url: 'https://e.zhichao.art/AI_images/a_1114__569.png',
  367. },
  368. {
  369. url: 'https://e.zhichao.art/AI_images/a_1114__570.png',
  370. },
  371. {
  372. url: 'https://e.zhichao.art/AI_images/a_1114__571.png',
  373. },
  374. {
  375. url: 'https://e.zhichao.art/AI_images/a_1114__575.png',
  376. },
  377. ];
  378. let list = [];
  379. const doFn = (i) => {
  380. const randomIndex = Math.floor(Math.random() * 10);
  381. return {
  382. allowEdit: i == 0,
  383. image: imgs[randomIndex].url,
  384. w: imgs[randomIndex].width,
  385. h: imgs[randomIndex].height,
  386. title: i % 2 == 0 ? `玛丽` : `凌音`,
  387. desc: i % 2 == 0 ?
  388. `欢迎使用uv-ui,uni-app生态专用的UI框架` : `开发者编写一套代码, 可发布到iOS、Android、H5、以及各种小程序`
  389. }
  390. };
  391. // 模拟异步
  392. setTimeout(() => {
  393. for (let i = 0; i < 20; i++) {
  394. list.push(doFn(i));
  395. }
  396. resolve({
  397. data: list
  398. });
  399. }, 200)
  400. })
  401. },
  402. switchTab(index) {
  403. this.currentTab = index;
  404. // 根据需要加载对应标签的数据
  405. this.loadTabData(index);
  406. },
  407. loadTabData(index) {
  408. // 这里添加加载不同标签数据的逻辑
  409. switch (index) {
  410. case 0:
  411. if (!this.followList.length) {
  412. this.loadFollowList();
  413. }
  414. break;
  415. case 1:
  416. if (!this.recommendList.length) {
  417. this.loadRecommendList();
  418. }
  419. break;
  420. case 2:
  421. // 加载热点新闻和新闻列表
  422. if (!this.hotNewsList.length) {
  423. this.loadHotNews();
  424. }
  425. if (!this.newsList.length) {
  426. this.loadNewsList();
  427. }
  428. break;
  429. }
  430. },
  431. loadFollowList() {
  432. if (this.isLoadingFollow) return;
  433. this.isLoadingFollow = true;
  434. uni.request({
  435. url: this.$apiHost + '/Work/getlist',
  436. data: {
  437. uuid: getApp().globalData.uuid,
  438. skey: getApp().globalData.skey,
  439. type: 'attention', // 关注列表
  440. offset: this.followOffset
  441. },
  442. header: {
  443. "content-type": "application/json",
  444. 'sign': getApp().globalData.headerSign
  445. },
  446. success: (res) => {
  447. console.log("关注列表数据:", res.data);
  448. // 确保在任何情况下都完成加载
  449. if (res.data.success == 'yes' && res.data.list && res.data.list.length > 0) {
  450. // 只有当列表有数据时才追加
  451. this.followList = [...this.followList, ...res.data.list];
  452. this.followOffset += res.data.list.length;
  453. if (res.data.list.length < 20) {
  454. this.hasMoreFollow = false;
  455. }
  456. } else {
  457. // 如果列表为空,确保标记没有更多数据
  458. this.hasMoreFollow = false;
  459. }
  460. // 无论是否有数据,都需要通知z-paging组件完成刷新
  461. if (this.$refs.paging) {
  462. this.$refs.paging.complete(this.followList);
  463. }
  464. },
  465. complete: () => {
  466. this.isLoadingFollow = false;
  467. },
  468. fail: (e) => {
  469. console.log("请求关注列表失败:", e);
  470. this.isLoadingFollow = false;
  471. // 加载失败时也要通知组件完成
  472. if (this.$refs.paging) {
  473. this.$refs.paging.complete(false);
  474. }
  475. }
  476. });
  477. },
  478. loadRecommendList() {
  479. if (this.isLoadingRecommend) return;
  480. this.isLoadingRecommend = true;
  481. uni.request({
  482. url: this.$apiHost + '/Work/getlist',
  483. data: {
  484. uuid: getApp().globalData.uuid,
  485. skey: getApp().globalData.skey,
  486. type: 'recommend', // 推荐列表
  487. offset: this.recommendOffset
  488. },
  489. header: {
  490. "content-type": "application/json",
  491. 'sign': getApp().globalData.headerSign
  492. },
  493. success: (res) => {
  494. console.log("推荐列表数据:", res.data);
  495. if (res.data.success == 'yes' && res.data.list && res.data.list.length > 0) {
  496. this.recommendList = [...this.recommendList, ...res.data.list];
  497. this.recommendOffset += res.data.list.length;
  498. if (res.data.list.length < 20) {
  499. this.hasMoreRecommend = false;
  500. }
  501. } else {
  502. this.hasMoreRecommend = false;
  503. }
  504. // 无论是否有数据,都需要通知z-paging组件完成刷新
  505. if (this.$refs.paging) {
  506. this.$refs.paging.complete(this.recommendList);
  507. }
  508. },
  509. complete: () => {
  510. this.isLoadingRecommend = false;
  511. },
  512. fail: (e) => {
  513. console.log("请求推荐列表失败:", e);
  514. this.isLoadingRecommend = false;
  515. // 加载失败时也要通知组件完成
  516. if (this.$refs.paging) {
  517. this.$refs.paging.complete(false);
  518. }
  519. }
  520. });
  521. },
  522. loadHotNews() {
  523. if (this.isLoadingExplore) return;
  524. this.isLoadingExplore = true;
  525. uni.request({
  526. url: this.$apiHost + '/Article/getlist',
  527. data: {
  528. uuid: getApp().globalData.uuid,
  529. skey: getApp().globalData.skey,
  530. type: 'hot' // 热点新闻
  531. },
  532. header: {
  533. "content-type": "application/json",
  534. 'sign': getApp().globalData.headerSign
  535. },
  536. success: (res) => {
  537. console.log("热点新闻数据:", res.data);
  538. if (res.data.success == 'yes' && res.data.list && res.data.list.length > 0) {
  539. this.hotNewsList = res.data.list;
  540. // 如果有热点新闻数据,更新热搜资讯
  541. if (this.hotNewsList.length > 0) {
  542. // 将API返回的热点新闻转换为热搜资讯格式
  543. this.hotTopics = this.hotNewsList.map((item, index) => {
  544. return {
  545. id: item.id,
  546. title: item.title || '热门话题',
  547. num_like: item.num_like || 0,
  548. isHot: index % 2 === 0 // 偶数索引的设为热点
  549. };
  550. });
  551. }
  552. }
  553. },
  554. complete: () => {
  555. this.isLoadingExplore = false;
  556. },
  557. fail: (e) => {
  558. console.log("请求热点新闻失败:", e);
  559. this.isLoadingExplore = false;
  560. }
  561. });
  562. },
  563. loadNewsList() {
  564. if (this.isLoadingNews) return;
  565. this.isLoadingNews = true;
  566. uni.request({
  567. url: this.$apiHost + '/Article/getlist',
  568. data: {
  569. uuid: getApp().globalData.uuid,
  570. skey: getApp().globalData.skey,
  571. type: 'list', // 新闻列表
  572. offset: this.newsOffset
  573. },
  574. header: {
  575. "content-type": "application/json",
  576. 'sign': getApp().globalData.headerSign
  577. },
  578. success: (res) => {
  579. console.log("新闻列表数据:", res.data);
  580. if (res.data.success == 'yes' && res.data.list && res.data.list.length > 0) {
  581. this.newsList = [...this.newsList, ...res.data.list];
  582. this.newsOffset += res.data.list.length;
  583. if (res.data.list.length < 20) {
  584. this.hasMoreNews = false;
  585. }
  586. } else {
  587. this.hasMoreNews = false;
  588. }
  589. // 无论是否有数据,都需要通知z-paging组件完成刷新
  590. if (this.$refs.paging) {
  591. this.$refs.paging.complete(this.newsList);
  592. }
  593. },
  594. complete: () => {
  595. this.isLoadingNews = false;
  596. },
  597. fail: (e) => {
  598. console.log("请求新闻列表失败:", e);
  599. this.isLoadingNews = false;
  600. // 加载失败时也要通知组件完成
  601. if (this.$refs.paging) {
  602. this.$refs.paging.complete(false);
  603. }
  604. }
  605. });
  606. },
  607. loadMoreData() {
  608. // 根据当前标签加载更多数据
  609. switch (this.currentTab) {
  610. case 0:
  611. if (this.hasMoreFollow && !this.isLoadingFollow) {
  612. this.loadFollowList();
  613. }
  614. break;
  615. case 1:
  616. if (this.hasMoreRecommend && !this.isLoadingRecommend) {
  617. this.loadRecommendList();
  618. }
  619. break;
  620. case 2:
  621. if (this.hasMoreNews && !this.isLoadingNews) {
  622. this.loadNewsList();
  623. }
  624. break;
  625. }
  626. },
  627. handleTopicPageChange(e) {
  628. this.currentTopicPage = e.detail.current;
  629. },
  630. formatItem(item) {
  631. // 处理接口返回的数据,使其适配card组件
  632. return {
  633. id: item.id,
  634. allowEdit: false,
  635. author: item.author,
  636. num_like: item.num_like,
  637. num_view: item.num_view,
  638. image: item.images || item.img_url || item.image, // 优先使用images字段
  639. w: item.width,
  640. h: item.height,
  641. title: item.title || '',
  642. desc: item.desc || ''
  643. }
  644. },
  645. goToArticleDetail(id) {
  646. if (!id) {
  647. uni.showToast({
  648. title: '文章ID不存在',
  649. icon: 'none'
  650. });
  651. return;
  652. }
  653. uni.navigateTo({
  654. url: '/pages/index/articleDetail?id=' + id
  655. });
  656. },
  657. goWork(item) {
  658. uni.navigateTo({
  659. url: '/pages/index/workDetail?id=' + item.id
  660. })
  661. },
  662. goToMake() {
  663. uni.navigateTo({
  664. url: '/pages/make/make'
  665. });
  666. },
  667. }
  668. }
  669. </script>
  670. <style lang="scss">
  671. .classModel {
  672. width: 750rpx;
  673. height: 110rpx;
  674. // #ifndef APP-NVUE
  675. display: flex;
  676. // #endif
  677. // #ifdef APP-NVUE
  678. flex-direction: row;
  679. // #endif
  680. justify-content: space-around;
  681. margin-bottom: 20rpx;
  682. .classModel-bg {
  683. width: 210rpx;
  684. height: 90rpx;
  685. background-color: #3F4141;
  686. border-radius: 60rpx;
  687. box-shadow: 3px 3px 2px rgba(174, 230, 93, 1);
  688. .classModel-img {
  689. width: 175rpx;
  690. height: 75rpx;
  691. }
  692. }
  693. }
  694. .tab-nav {
  695. display: flex;
  696. justify-content: center;
  697. padding: 20rpx 0;
  698. background: #161616;
  699. .tab-item {
  700. padding: 0 30rpx;
  701. color: #808080;
  702. font-size: 28rpx;
  703. &.active {
  704. color: #ffffff;
  705. font-weight: bold;
  706. }
  707. }
  708. }
  709. .hot-topics {
  710. padding: 20rpx;
  711. background: #28292D;
  712. margin: 20rpx;
  713. border-radius: 16rpx;
  714. .hot-topics-header {
  715. margin-bottom: 20rpx;
  716. .hot-topics-title {
  717. font-size: 32rpx;
  718. font-weight: bold;
  719. color: #ffffff;
  720. }
  721. }
  722. .hot-topics-swiper {
  723. height: 400rpx; // Adjust this value based on your content
  724. }
  725. .hot-topics-list {
  726. padding: 10rpx 0;
  727. }
  728. .topic-item {
  729. display: flex;
  730. align-items: center;
  731. padding: 15rpx 0;
  732. .topic-index {
  733. width: 40rpx;
  734. color: #808080;
  735. text-align: center;
  736. flex-shrink: 0;
  737. }
  738. .topic-content {
  739. flex: 1;
  740. width: 0;
  741. /* 重要:确保flex子项不会超过容器宽度 */
  742. overflow: hidden;
  743. .topic-title-row {
  744. display: flex;
  745. align-items: center;
  746. width: 100%;
  747. .topic-title {
  748. color: #ffffff;
  749. font-size: 28rpx;
  750. white-space: nowrap;
  751. overflow: hidden;
  752. text-overflow: ellipsis;
  753. flex: 1;
  754. width: 0;
  755. /* 重要:确保flex子项不会超过容器宽度 */
  756. }
  757. .hot-tag {
  758. margin-left: 10rpx;
  759. padding: 4rpx 10rpx;
  760. background: #FF4B4B;
  761. color: #ffffff;
  762. font-size: 20rpx;
  763. border-radius: 8rpx;
  764. flex-shrink: 0;
  765. }
  766. }
  767. .topic-participants {
  768. font-size: 24rpx;
  769. color: #808080;
  770. margin-top: 6rpx;
  771. }
  772. }
  773. }
  774. .indicator-dots {
  775. display: flex;
  776. justify-content: center;
  777. margin-top: 20rpx;
  778. .dot {
  779. width: 12rpx;
  780. height: 12rpx;
  781. border-radius: 50%;
  782. background: #808080;
  783. margin: 0 6rpx;
  784. &.active {
  785. background: #ffffff;
  786. }
  787. }
  788. }
  789. }
  790. .follow-list {
  791. padding: 20rpx;
  792. background: #161616;
  793. margin: 0rpx;
  794. border-radius: 0rpx;
  795. .works-list {
  796. display: flex;
  797. flex-wrap: wrap;
  798. padding: 10rpx;
  799. .work-item {
  800. width: 48%;
  801. margin: 1%;
  802. margin-bottom: 20rpx;
  803. .work-image {
  804. width: 100%;
  805. aspect-ratio: 1;
  806. border-radius: 12rpx;
  807. }
  808. .work-title {
  809. font-size: 28rpx;
  810. color: #ffffff;
  811. margin-top: 10rpx;
  812. padding: 0 10rpx;
  813. white-space: nowrap;
  814. overflow: hidden;
  815. text-overflow: ellipsis;
  816. }
  817. }
  818. }
  819. .no-data {
  820. display: flex;
  821. flex-direction: column;
  822. align-items: center;
  823. justify-content: center;
  824. padding: 60rpx 0;
  825. text {
  826. color: #808080;
  827. font-size: 28rpx;
  828. }
  829. }
  830. }
  831. .no-data {
  832. text-align: center;
  833. padding: 40rpx 0;
  834. color: #808080;
  835. font-size: 28rpx;
  836. }
  837. .news-list {
  838. padding: 20rpx;
  839. background: #161616;
  840. .news-grid {
  841. display: flex;
  842. flex-wrap: wrap;
  843. justify-content: space-between;
  844. .news-item {
  845. width: 48%;
  846. margin-bottom: 30rpx;
  847. background: #28292D;
  848. border-radius: 12rpx;
  849. overflow: hidden;
  850. .news-image {
  851. width: 100%;
  852. aspect-ratio: 1;
  853. height: auto;
  854. border-radius: 12rpx 12rpx 0 0;
  855. }
  856. .news-title {
  857. font-size: 28rpx;
  858. color: #ffffff;
  859. padding: 15rpx;
  860. white-space: nowrap;
  861. overflow: hidden;
  862. text-overflow: ellipsis;
  863. height: 60rpx;
  864. line-height: 60rpx;
  865. }
  866. .news-footer {
  867. display: flex;
  868. justify-content: space-between;
  869. align-items: center;
  870. padding: 0 15rpx 15rpx;
  871. .news-author {
  872. font-size: 24rpx;
  873. color: #808080;
  874. max-width: 60%;
  875. white-space: nowrap;
  876. overflow: hidden;
  877. text-overflow: ellipsis;
  878. }
  879. .news-views {
  880. display: flex;
  881. align-items: center;
  882. font-size: 24rpx;
  883. color: #808080;
  884. .view-icon {
  885. width: 26rpx;
  886. height: 18rpx;
  887. margin-right: 6rpx;
  888. }
  889. }
  890. }
  891. }
  892. }
  893. }
  894. .float-btn {
  895. position: fixed;
  896. right: 30rpx;
  897. bottom: 120rpx;
  898. width: 100rpx;
  899. height: 100rpx;
  900. background-color: #FFFFFF;
  901. border-radius: 50%;
  902. display: flex;
  903. justify-content: center;
  904. align-items: center;
  905. box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1);
  906. z-index: 999;
  907. .float-btn-icon {
  908. width: 40rpx;
  909. height: 40rpx;
  910. }
  911. }
  912. .blankHeight {
  913. width: 500rpx;
  914. height: 500rpx;
  915. }
  916. </style>