index.vue 25 KB

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