index.vue 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339
  1. <template>
  2. <view :data-theme="theme" class="discover_index">
  3. <view class="page_con" :style="{height: windowHeight + 'px'}">
  4. <view class="discover-header relative z-999">
  5. <!-- #ifdef APP || MP -->
  6. <view class="mp-header" :style="{ height: navH + 'rpx'}">
  7. <view class="sys-head mp-header" :style="{ height: sysHeight+'px' }"></view>
  8. <view class="select_nav flex justify-center align-center" id="home" :style="{top: sysHeight+'px'}">
  9. <text class="iconfont icon-fanhui2 px-20" @tap="returns"></text>
  10. <image @click="goUser" class="avatar" :src="userInfo.avatar ? userInfo.avatar : urlDomain+'crmebimage/presets/morenT.png'">
  11. </image>
  12. <!-- <text class="iconfont icon-gengduo5 px-20" @tap.stop="showNav"></text> -->
  13. <text class="nav_line"></text>
  14. </view>
  15. <view class="nav_title mp-header" :style="{ height: '80rpx',lineHeight: '80rpx', color: '#fff', top: sysHeight+'px' }">
  16. 二手交易
  17. </view>
  18. </view>
  19. <!-- #endif -->
  20. <view class="discover-navTab acea-row row-middle bg--w111-fff mt-4">
  21. <view class="acea-row row-center-wrapper" :style="[textBoxStyle]">
  22. <view style="margin-right: 52rpx;" :class="tabActive == 0 ? 'on' : ''" class="nav-item pb-10" @click="onTabActiveClick(0, 'school')">本校</view>
  23. <view style="margin-right: 52rpx;" :class="tabActive == 1 ? 'on' : ''" class="nav-item pb-10" @click="onTabActiveClick(1, 'city')">同城</view>
  24. <view :class="tabActive == 2 ? 'on' : ''" class="nav-item pb-10" @click="onTabActiveClick(2, 'all')">全国</view>
  25. </view>
  26. <!-- #ifndef MP -->
  27. <view style="width: 32rpx;"></view>
  28. <!-- #endif -->
  29. </view>
  30. <view class='search acea-row '>
  31. <view class='input acea-row row-middle'>
  32. <text class='iconfont icon-sousuo2'></text>
  33. <input class="placeholder" type='text' v-model='searchValue' :focus="focus" placeholder='搜索好物' placeholder-class='placeholder'
  34. confirm-type="search" @confirm="searchBut()"></input>
  35. </view>
  36. <view class='bnt' @tap='searchBut'>搜索</view>
  37. </view>
  38. <!-- banner轮播图 -->
  39. <view class="mb-10" v-if="bannerList.length">
  40. <swiper :indicator-dots="true" :autoplay="true" :interval="2500" :duration="500" circular="true">
  41. <block v-for="(item,index) in bannerList" :key='item.id'>
  42. <swiper-item>
  43. <view class="swiper-item">
  44. <image class="banner-img" :src="item.imageUrl" mode="scaleToFill" />
  45. </view>
  46. </swiper-item>
  47. </block>
  48. </swiper>
  49. </view>
  50. <!-- 话题分类 -->
  51. <view class="mb-10 longTab" v-if="categoryList.length">
  52. <swiper :indicator-dots="true" :interval="interval" indicator-active-color="rgba(255, 103, 2, 1)" :current="swperId"
  53. @change="swiperIdChange">
  54. <block v-for="item in swperIndex" :key="item">
  55. <swiper-item :item-id="`${item}`">
  56. <scroll-view scroll-x="true" style="white-space: nowrap; display: flex" show-scrollbar="false">
  57. <block>
  58. <view class="flex-wrap flex-y-center pt-30">
  59. <view class="flex-col flex-center longTab-item mb-20" style="width: 20%;" v-for="(val, valIndex) in categoryList"
  60. :key="valIndex" v-if="val.swperIndex == item" @tap="onCategoryClick(val)">
  61. <image class="w-44 h-44 mb-10" :src="val.imageUrl" mode=""></image>
  62. <view class="wall-font f-s-24 f-w-500">{{val.name}}</view>
  63. </view>
  64. </view>
  65. </block>
  66. </scroll-view>
  67. </swiper-item>
  68. </block>
  69. </swiper>
  70. </view>
  71. </view>
  72. <view class="discover-boxsss">
  73. <view class='noCommodity h-full'>
  74. <!-- <scroll-view scroll-y="true" :show-scrollbar="false" class="scroll-view h-full" refresher-enabled="true"
  75. :refresher-threshold="100" @scrolltolower="onScrollBottom"> -->
  76. <view v-if="recommendIndexL == 0">
  77. <view class='pictrue'>
  78. <image :src="urlDomain+'crmebimage/presets/noSearch.png'"></image>
  79. </view>
  80. <text class="text-ccc">{{'暂无商品~'}}</text>
  81. </view>
  82. <recommend v-show="recommendIndexL" ref="recommendIndex" :tabActive="tabActive" :dynamics="true" class="mt-40" @getRecommendLength="getRecommendLength"></recommend>
  83. <!-- </scroll-view> -->
  84. </view>
  85. </view>
  86. <view class="publish" @click="publish" :class="bottomNavigationIsCustom?'bottom':''">
  87. <view><text class='iconfont icon-paizhao w-116 h-116'></text></view>
  88. <!-- <image class="w-116 h-116" src="/static/img/ic-fatie.png" mode=""></image> -->
  89. </view>
  90. </view>
  91. <!-- <pageFooter v-if="isShowFooter"></pageFooter> -->
  92. <!-- 评论 -->
  93. <uni-popup type="bottom" ref="comment">
  94. <view :style="'width: '+ windowWidth +'px; background-color: #fff; border-top-left-radius: 10px; border-top-right-radius: 10px;'">
  95. <discoverComment v-if="showComment" @getReplyNum="getReplyNum" :noteId="noteDetails.id" :noteDetails="noteDetails"
  96. @close="close">
  97. </discoverComment>
  98. </view>
  99. </uni-popup>
  100. <!-- 商品列表 -->
  101. <uni-popup type="bottom" ref="goods">
  102. <mentioned v-if="popupShow" :list="proList" @close="popup" class=""></mentioned>
  103. </uni-popup>
  104. <!-- 学校 -->
  105. <uni-popup ref="schoolRef" :is-mask-click="false">
  106. <view class="w-full flex-center" :style="{height: windowHeight + 'px'}">
  107. <navigator hover-class='none' url='/pages/trade_fair/trade_fair_user/index'>
  108. <image src="http://39.105.58.247:20800/crmebimage/public/store/2025/05/20/ac4f4703de5d4a8c9490e7e27c9f25b8pzzy4l1ywq.png" mode="heightFix" style="height: 694rpx;width: 616rpx;"></image>
  109. </navigator>
  110. </view>
  111. </uni-popup>
  112. </view>
  113. </template>
  114. <script>
  115. import {
  116. mapGetters
  117. } from "vuex";
  118. import {
  119. toLogin
  120. } from '@/libs/login.js';
  121. import {
  122. BACK_URL
  123. } from '@/config/cache';
  124. import {
  125. communityCategoryListApi,
  126. recommendAuthorListApi,
  127. discoverListApi,
  128. followListApi,
  129. getSecondHandInfo
  130. } from '@/api/discover.js';
  131. import {
  132. discoverFollowAuthor,
  133. } from '@/libs/follow.js';
  134. import {
  135. tokenIsExistApi
  136. } from '@/api/api.js';
  137. import {
  138. silenceBindingSpread,
  139. getUserSpread
  140. } from '@/utils/index.js';
  141. import recommend from "@/components/base/recommend.vue";
  142. import onShare from "@/mixins/onShare";
  143. import discoverComment from '@/components/discoverComment/index.vue';
  144. import animationType from '@/utils/animationType.js'
  145. import pageFooter from "@/components/pageFooter/index.vue";
  146. import navBar from '@/components/navBar';
  147. import emptyPage from '@/components/emptyPage.vue';
  148. import easyLoadimage from '@/components/base/easy-loadimage.vue';
  149. import WaterfallsFlow from '@/components/WaterfallsFlow/WaterfallsFlow.vue'
  150. import WaterfallsFlowItem from '@/components/discoverFlowItem/discoverFlowItem.vue'
  151. import discoverDetails from '@/components/discoverDetails/index.vue'
  152. import mentioned from '@/components/mentioned.vue';
  153. import TitleBox from '@/components/titleBox/index.vue';
  154. let app = getApp();
  155. let sysHeight = uni.getSystemInfoSync().statusBarHeight;
  156. export default {
  157. mixins: [onShare],
  158. components: {
  159. pageFooter,
  160. navBar,
  161. emptyPage,
  162. easyLoadimage,
  163. WaterfallsFlowItem,
  164. WaterfallsFlow,
  165. discoverDetails,
  166. discoverComment,
  167. mentioned,
  168. TitleBox,
  169. recommend
  170. },
  171. computed: {
  172. ...mapGetters(['globalData', 'isLogin', 'userInfo', 'bottomNavigationIsCustom']),
  173. headerBoxStyle() {
  174. return {
  175. // #ifndef MP
  176. paddingTop: '4rpx',
  177. // #endif
  178. // #ifdef MP
  179. paddingTop: this.marTop + "px",
  180. marginRight: this.statusWidth + this.searchRight + 'px',
  181. // #endif
  182. }
  183. },
  184. textBoxStyle() {
  185. return {
  186. // #ifdef MP
  187. width: '100%',
  188. height: this.searchHeight + 'rpx',
  189. // lineHeight: this.searchHeight + 'rpx',
  190. // #endif
  191. }
  192. }
  193. },
  194. onLoad(options) {
  195. //分销码
  196. getUserSpread(options);
  197. this.windowWidth = uni.getSystemInfoSync().screenWidth; //获取屏幕宽度
  198. tokenIsExistApi().then(res => {
  199. this.tokenIsExist = res.data;
  200. if (this.tokenIsExist && this.isLogin) {
  201. this.getFollowList();
  202. setTimeout(() => {
  203. if (this.noteRecommendList.length === 0 || this.loadendfollow) this
  204. .getRecommendAuthorList();
  205. }, 500)
  206. }
  207. if (!this.tokenIsExist) {
  208. this.$store.commit('UPDATE_LOGIN', '');
  209. this.$store.commit('UPDATE_USERINFO', {});
  210. }
  211. })
  212. // this.getDiscoverList();
  213. // this.getCommunityCategoryList();
  214. this._freshing = false;
  215. },
  216. data() {
  217. return {
  218. returnShow: false,
  219. urlDomain: this.$Cache.get("imgHost"),
  220. sysHeight: sysHeight,
  221. navH: '',
  222. windowWidth: 0, //获取屏幕宽度🌟💗
  223. interval: 3000,
  224. swiperHeight: 0,
  225. listMarTop: 0,
  226. tabClick: 0, //设置导航点击了哪一个
  227. tabLeft: 0, //设置下划线位置
  228. isLeft: 0, //导航栏下划线位置
  229. isWidth: 0, //每个导航栏占位
  230. tabActive: 0, // 顶部关注、发现切换
  231. rangeStr: 'school',
  232. windowHeight: 0,
  233. theme: app.globalData.theme,
  234. marTop: 0,
  235. categoryList: [], //分类列表
  236. swperIndex: [],
  237. swperId: 0,
  238. categoryId: '-1', //分类id
  239. swiperCurrent: 0, //分类索引
  240. isScroll: false, //是否是滑动
  241. params: { //推荐作者
  242. page: 1,
  243. limit: 10
  244. },
  245. followParams: { //关注内容
  246. page: 1,
  247. limit: 10
  248. },
  249. noteRecommendList: [], //关注内容
  250. loadendfollow: false, //关注内容
  251. loadingfollow: false, //关注内容
  252. where: {
  253. categoryId: 0,
  254. page: 1,
  255. limit: 10
  256. },
  257. loadend: false,
  258. loading: false,
  259. loadTitle: '加载更多',
  260. loadTitleFollow: '加载更多',
  261. onnnn: {
  262. good: [{
  263. authorId: 1
  264. }]
  265. },
  266. discoverList: {}, //内容信息
  267. authorList: [], //推荐作者列表
  268. isOpenRefresh: true, // 是否开启下拉
  269. triggered: false,
  270. triggeredDiscover: false,
  271. isShow: false, //加载完成
  272. tokenIsExist: false, //校验token是否有效,true为有效,false为无效
  273. isRefresher: false, //下拉刷新状态
  274. noteDetails: {}, //内容详情
  275. popupShow: false, //商品弹窗
  276. showComment: false, //评论弹窗
  277. proList: [], //提到的商品
  278. isShowFooter: true,
  279. loadingAuthor: false, //推荐作者
  280. showCateDrawer: false, //分类下拉展示
  281. searchRight: 0,
  282. statusWidth: 0,
  283. searchHeight: 0,
  284. bannerList: [],
  285. wallHeadline: [],
  286. navList: [{
  287. id: 0,
  288. name: '默认'
  289. }, {
  290. id: 1,
  291. name: '评论'
  292. }, {
  293. id: 2,
  294. name: '点赞'
  295. }, {
  296. id: 3,
  297. name: '有图'
  298. }],
  299. active: 0,
  300. recommendIndexL: 0,
  301. searchValue: ''
  302. }
  303. },
  304. // 滚动监听
  305. onPageScroll(e) {
  306. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  307. uni.$emit('scroll');
  308. },
  309. onShow() {
  310. this.getHandInfo()
  311. this.showCateDrawer = false;
  312. this.getTokenIsExist();
  313. //分销绑定
  314. silenceBindingSpread(this.isLogin, this.globalData.spread);
  315. },
  316. mounted() {
  317. this.$nextTick(function() {
  318. const query = uni.createSelectorQuery().in(this);
  319. query.select('.discover-header').boundingClientRect(data => {
  320. // #ifndef H5
  321. this.listMarTop = data.height
  322. // #endif
  323. // #ifdef H5
  324. this.listMarTop = data.height
  325. // #endif
  326. }).exec();
  327. });
  328. },
  329. created() {
  330. var pages = getCurrentPages();
  331. this.returnShow = pages.length === 1 ? false : true;
  332. var that = this;
  333. // 获取设备宽度
  334. uni.getSystemInfo({
  335. success(e) {
  336. that.isWidth = e.windowWidth / 6;
  337. that.windowHeight = e.windowHeight;
  338. that.swiperHeight = that.windowHeight - 205
  339. that.$set(that, 'swiperHeight', that.windowHeight - 55);
  340. }
  341. });
  342. // #ifdef MP || APP-PLUS
  343. // 获取导航高度;
  344. this.navH = this.globalData.navHeight;
  345. // #endif
  346. // #ifdef H5
  347. this.navH = 80;
  348. // #endif
  349. that.getNavH()
  350. // #ifdef MP
  351. const res = uni.getMenuButtonBoundingClientRect()
  352. const jnHeight = res.height //胶囊高度
  353. const statusHeight = res.top //胶囊距离顶部
  354. const statusRight = res.right //胶囊右边界坐标
  355. this.statusWidth = res.width
  356. this.searchHeight = 96
  357. console.log('999', statusHeight, this.sysHeight);
  358. this.marTop = statusHeight - this.sysHeight
  359. //搜索框宽度计算
  360. uni.getSystemInfo({
  361. success: res => {
  362. this.searchRight = res.windowWidth - statusRight
  363. }
  364. })
  365. // #endif
  366. },
  367. //uniapp小程序用deep重写组件样式不生效
  368. options: {
  369. styleIsolation: 'shared'
  370. },
  371. methods: {
  372. searchBut () {
  373. this.$nextTick(() => {
  374. this.$refs.recommendIndex.initParams(this.searchValue);
  375. })
  376. },
  377. returns: function() {
  378. if (this.returnShow) {
  379. uni.navigateBack(-1);
  380. } else {
  381. uni.switchTab({
  382. url: '/pages/index/index'
  383. })
  384. }
  385. },
  386. getHandInfo() {
  387. getSecondHandInfo().then(res => {
  388. this.bannerList = res.data.banner
  389. this.wallHeadline = res.data.headline
  390. let arr = res.data.navigatList
  391. let arrs = []
  392. let swperIndex = 1;
  393. let swperArr = [0];
  394. arr.forEach((item, index) => {
  395. if ((index + 1) > (swperIndex * 10)) {
  396. swperIndex++
  397. swperArr.push(swperIndex - 1)
  398. item.swperIndex = (swperIndex - 1)
  399. } else {
  400. item.swperIndex = (swperIndex - 1)
  401. }
  402. arrs.push({...item})
  403. })
  404. this.swperIndex = swperArr
  405. this.categoryList = arrs
  406. console.log(res.data, 111111111111111)
  407. if (!res.data.school) {
  408. this.$refs.schoolRef.open('top')
  409. } else {
  410. this.$refs.schoolRef.close()
  411. }
  412. }).catch(err => {
  413. console.log(err)
  414. })
  415. },
  416. getNavH(marTop) {
  417. // #ifdef H5
  418. this.marTop = 30;
  419. // #endif
  420. // #ifdef APP
  421. this.marTop = marTop - 60;
  422. // #endif
  423. },
  424. getPro(item) {
  425. this.noteDetails = item;
  426. this.proList = item.productList;
  427. this.$refs.goods.open('bottom');
  428. this.popupShow = true;
  429. setTimeout(() => {
  430. if (!this.bottomNavigationIsCustom) {
  431. uni.hideTabBar();
  432. } else {
  433. this.isShowFooter = false;
  434. }
  435. }, 50)
  436. },
  437. popup() {
  438. if (!this.bottomNavigationIsCustom) {
  439. uni.showTabBar();
  440. } else {
  441. this.isShowFooter = true;
  442. }
  443. setTimeout(() => {
  444. this.$refs.goods.close();
  445. this.popupShow = false;
  446. }, 100)
  447. },
  448. close() {
  449. if (!this.bottomNavigationIsCustom) {
  450. uni.showTabBar();
  451. } else {
  452. this.isShowFooter = true;
  453. }
  454. setTimeout(() => {
  455. this.$refs.comment.close();
  456. this.showComment = false;
  457. }, 100);
  458. },
  459. getReplyNum(n) {
  460. this.noteDetails.replyNum = n;
  461. },
  462. getComment(item) {
  463. this.noteDetails = item;
  464. this.$refs.comment.open('bottom');
  465. this.showComment = true;
  466. setTimeout(() => {
  467. if (!this.bottomNavigationIsCustom) {
  468. uni.hideTabBar();
  469. } else {
  470. this.isShowFooter = false;
  471. }
  472. }, 50)
  473. },
  474. //校验token是否有效,true为有效,false为无效
  475. getTokenIsExist() {
  476. tokenIsExistApi().then(res => {
  477. this.tokenIsExist = res.data;
  478. if (!this.tokenIsExist) {
  479. this.$store.commit('UPDATE_LOGIN', '');
  480. this.$store.commit('UPDATE_USERINFO', {});
  481. }
  482. })
  483. },
  484. // 去推荐作者个人主人
  485. goAuthor(item) {
  486. // #ifdef MP || H5
  487. uni.navigateTo({
  488. url: `/pages/discover/discover_user/index?id=${item.authorId}`
  489. })
  490. // #endif
  491. // #ifdef APP-PLUS
  492. uni.navigateTo({
  493. animationType: animationType.type,
  494. animationDuration: animationType.duration,
  495. url: `/pages/discover/discover_user/index?id=${item.authorId}`
  496. })
  497. // #endif
  498. },
  499. // 自定义下拉刷新被中止
  500. onAbort() {
  501. console.error("onAbort");
  502. },
  503. onPulling(e) {
  504. if (e.detail.deltaY < 0) return // 防止上滑页面也触发下拉
  505. if (this.tabActive == 1) {
  506. this.triggeredDiscover = true;
  507. } else {
  508. this.triggered = true;
  509. }
  510. },
  511. // 下拉刷新触发
  512. refresherpullingFun() {
  513. this.isRefresher = true
  514. },
  515. onRefreshDiscover() {
  516. if (this._freshing) return;
  517. this._freshing = true;
  518. setTimeout(() => {
  519. this._freshing = false;
  520. this.discoverList = {}
  521. this.getDiscoverList();
  522. this.triggeredDiscover = false;
  523. uni.stopPullDownRefresh();
  524. this._freshing = false;
  525. }, 1000)
  526. },
  527. onRefresh() {
  528. if (this._freshing) return;
  529. this._freshing = true;
  530. setTimeout(() => {
  531. this.loadendfollow = false;
  532. this.loadend = false;
  533. this.noteRecommendList = [];
  534. this.followParams.page = 1;
  535. this.authorList = [];
  536. this.params.page = 1;
  537. this.getFollowList();
  538. setTimeout(() => {
  539. if (this.noteRecommendList.length === 0 || this.loadendfollow) this
  540. .getRecommendAuthorList();
  541. }, 400)
  542. this.triggered = false
  543. uni.stopPullDownRefresh();
  544. this._freshing = false;
  545. }, 1000)
  546. },
  547. onRestore() {
  548. this.triggeredDiscover = false;
  549. },
  550. //关注内容
  551. getFollowList() {
  552. if (this.loadendfollow) {
  553. this.triggered = false;
  554. return;
  555. }
  556. this.loadingfollow = true;
  557. followListApi(this.followParams).then(res => {
  558. this.$set(this.followParams, 'page', this.followParams.page + 1);
  559. this.loadendfollow = this.followParams.page > res.data.totalPage;
  560. this.loadTitleFollow = this.loadendfollow ? '' : '加载更多';
  561. this.noteRecommendList = this.noteRecommendList.concat(res.data.list || []);
  562. this.loadingfollow = false
  563. this.triggered = false;
  564. }).catch(err => {
  565. this.loadingfollow = false;
  566. this.triggered = false;
  567. uni.showToast({
  568. title: err,
  569. icon: 'none'
  570. })
  571. });
  572. },
  573. // 关注作者
  574. followAuthor(item) {
  575. if (this.isLogin) {
  576. discoverFollowAuthor(item.authorId).then(() => {
  577. this.$set(item, 'isConcerned', !item.isConcerned);
  578. });
  579. } else {
  580. toLogin();
  581. }
  582. },
  583. //回退页面之后重新加载页面
  584. reFresh() {
  585. this.loading = true
  586. this.discoverList = {};
  587. this.getDiscoverList();
  588. },
  589. //发布内容
  590. publish() {
  591. if (this.isLogin) {
  592. // #ifdef MP || H5
  593. uni.navigateTo({
  594. url: `/pages/discover/discover_release/index?fair=${true}`
  595. })
  596. // #endif
  597. // #ifdef APP-PLUS
  598. uni.navigateTo({
  599. animationType: animationType.type,
  600. animationDuration: animationType.duration,
  601. url: `/pages/discover/discover_release/index?fair=${true}`
  602. })
  603. // #endif
  604. } else {
  605. toLogin();
  606. }
  607. },
  608. /**
  609. * 发现列表滑动中用到的方法
  610. */
  611. followScroll() {
  612. uni.$emit('scroll');
  613. },
  614. onTouchmoveRecommend(e) {
  615. if (!this.loadendfollow) this.getFollowList();
  616. if (this.loadendfollow && !this.loadend) this.getRecommendAuthorList();
  617. },
  618. onTouchmove(e) {
  619. this.getDiscoverList();
  620. },
  621. scrollLeft: function(e) {
  622. uni.$emit('scroll');
  623. if (e.detail.scrollTop > e.detail.scrollHeight - 1500) {
  624. this.getDiscoverList();
  625. }
  626. this.swiperHeight = this.windowHeight - 55
  627. },
  628. swiperChange(e) {
  629. let {
  630. current,
  631. source,
  632. currentItemId
  633. } = e.detail;
  634. if (source === 'autoplay' || source === 'touch') {
  635. this.categoryId = currentItemId;
  636. this.swiperCur = current
  637. this.selectMenu(this.categoryList[this.swiperCur], this.swiperCur, false)
  638. if (this.categoryList.length > 3) {
  639. var tempIndex = this.swiperCur - 2;
  640. tempIndex = tempIndex <= 0 ? 0 : tempIndex;
  641. let tabLeft = (this.swiperCur - 2) * this.isWidth; //设置下划线位置
  642. this.$nextTick(function() {
  643. this.$set(this, 'tabLeft', tabLeft);
  644. });
  645. }
  646. }
  647. },
  648. swiperIdChange(e) {
  649. let {
  650. current,
  651. source,
  652. currentItemId
  653. } = e.detail;
  654. if (source === 'autoplay' || source === 'touch') {
  655. console.log(current, source, currentItemId)
  656. }
  657. },
  658. /*******************发现列表滑动中用到的方法结束*********************/
  659. // 去个人主人
  660. goUser() {
  661. if (!this.isLogin) {
  662. this.openAuto();
  663. } else {
  664. // #ifdef MP || H5
  665. uni.navigateTo({
  666. url: `/pages/trade_fair/trade_fair_user/index`
  667. })
  668. // #endif
  669. // #ifdef APP-PLUS
  670. uni.navigateTo({
  671. animationType: animationType.type,
  672. animationDuration: animationType.duration,
  673. url: `/pages/trade_fair/trade_fair_user/index`
  674. })
  675. // #endif
  676. }
  677. },
  678. // 打开授权
  679. openAuto() {
  680. this.$Cache.set(BACK_URL, '')
  681. toLogin();
  682. },
  683. //发现列表
  684. getDiscoverList() {
  685. let that = this;
  686. this.isShow = false;
  687. if (!this.discoverList[this.categoryId]) {
  688. this.$set(this.discoverList, this.categoryId, {
  689. where: {
  690. ...this.where,
  691. categoryId: this.categoryId,
  692. secondType: this.active
  693. },
  694. goods: []
  695. })
  696. }
  697. const data = this.discoverList[this.categoryId];
  698. const cateId = this.categoryId;
  699. if (data.loading || data.loadend) {
  700. this.triggeredDiscover = false;
  701. return
  702. };
  703. data.loading = true
  704. this.loading = true
  705. this.loadTitle = '';
  706. if (data.where.categoryId === 0) data.where.categoryId = ''
  707. discoverListApi(data.where).then(res => {
  708. data.loadend = res.data.list.length < that.where.limit;
  709. if (data.where.page == 1) {
  710. data.goods = [];
  711. }
  712. this.loadTitle = data.loadend ? '没有了' : '加载更多';
  713. data.goods.push.apply(data.goods, res.data.list);
  714. data.where.page = data.where.page + 1;
  715. that.$nextTick(() => {
  716. that.$set(that.discoverList, cateId, {
  717. ...data
  718. });
  719. });
  720. data.loading = false;
  721. this.loading = false;
  722. this.triggeredDiscover = false;
  723. this.$forceUpdate()
  724. console.log(that.discoverList)
  725. }).catch(err => {
  726. data.loading = false;
  727. this.loading = false;
  728. uni.showToast({
  729. title: err,
  730. icon: 'none'
  731. })
  732. this.$set(this.discoverList, cateId, data);
  733. });
  734. },
  735. //推荐作者列表
  736. getRecommendAuthorList() {
  737. if (this.loadend) return;
  738. this.loading = true
  739. recommendAuthorListApi(this.params).then(res => {
  740. this.$set(this.params, 'page', this.params.page + 1);
  741. this.loadend = this.params.page > res.data.totalPage;
  742. this.authorList = this.authorList.concat(res.data.list || []);
  743. this.loadTitle = this.loadend ? '没有了' : '加载更多';
  744. this.loading = false
  745. })
  746. },
  747. //分类列表
  748. getCommunityCategoryList() {
  749. communityCategoryListApi().then(res => {
  750. let arr = []
  751. let arrs = []
  752. arr.push(...res.data)
  753. arr.push(...res.data)
  754. arr.push(...res.data)
  755. arr.push(...res.data)
  756. arr.push(...res.data)
  757. arr.push(...res.data)
  758. arr.push(...res.data)
  759. let swperIndex = 1;
  760. let swperArr = [0];
  761. arr.forEach((item, index) => {
  762. item.id = index
  763. if ((index + 1) > (swperIndex * 10)) {
  764. swperIndex++
  765. swperArr.push(swperIndex - 1)
  766. item.swperIndex = (swperIndex - 1)
  767. } else {
  768. item.swperIndex = (swperIndex - 1)
  769. }
  770. arrs.push({ ...item
  771. })
  772. })
  773. this.swperIndex = swperArr
  774. this.categoryList = arrs
  775. })
  776. },
  777. // 点击列表头部
  778. selectMenu(item, index, isScroll) {
  779. if (this.tabClick == index) return
  780. this.active = 0
  781. this.triggeredDiscover = false;
  782. this.categoryId = item.id;
  783. this.swiperCurrent = index;
  784. this.isScroll = isScroll;
  785. this.tabClick = index; //设置导航点击了哪一个
  786. this.isLeft = index * this.isWidth; //设置下划线位置
  787. this.where.categoryId = item.id;
  788. this.showCateDrawer = false
  789. this.getDiscoverList();
  790. },
  791. onReachBottom() {
  792. this.$refs.recommendIndex.get_host_product();
  793. },
  794. getRecommendLength(val) {
  795. this.recommendIndexL = val
  796. },
  797. onCategoryClick(item) {
  798. console.log(item)
  799. uni.navigateTo({
  800. url: `/pages/goods/goods_list/index?fairCateId=${item.id}&title=${item.name}&rangeStr=${this.rangeStr}&tabActive=${this.tabActive}`
  801. })
  802. },
  803. onTabActiveClick(index, text) {
  804. if (this.tabActive == index) return
  805. this.tabActive = index
  806. console.log(this.tabActive, '父组件改变变变变')
  807. this.rangeStr = text
  808. this.searchBut()
  809. }
  810. }
  811. }
  812. </script>
  813. <style lang="scss" scoped>
  814. /deep/.wf-page {
  815. background-color: #fff !important;
  816. }
  817. .discover_video_icon {
  818. top: 50% !important;
  819. left: 50% !important;
  820. right: 0 !important;
  821. -webkit-transform: translate(-50%, -50%);
  822. transform: translate(-50%, -50%);
  823. }
  824. .mp-header {
  825. background-color: $bg-color-primary;
  826. }
  827. .select_nav {
  828. width: 170rpx !important;
  829. height: 60rpx !important;
  830. border-radius: 33rpx;
  831. // background: rgba(255, 255, 255, 0.6);
  832. // border: 1rpx solid rgba(0, 0, 0, 0.1);
  833. color: #000;
  834. position: fixed;
  835. font-size: 18px;
  836. line-height: 58rpx;
  837. z-index: 99999;
  838. left: 14rpx;
  839. }
  840. .nav_title {
  841. // width: 200rpx;
  842. color: #fff;
  843. font-size: 36rpx;
  844. position: fixed;
  845. z-index: 9999;
  846. text-align: center;
  847. left: 0;
  848. right: 0;
  849. margin-top: -1px;
  850. }
  851. .sys-head {
  852. width: 100%;
  853. position: fixed;
  854. z-index: 9999;
  855. }
  856. .banner-img {
  857. width: 100%;
  858. height: 100%;
  859. }
  860. .newsTitle {
  861. font-weight: 400;
  862. font-size: 21rpx;
  863. color: #646464;
  864. }
  865. .active-topic {
  866. @include main_color(theme);
  867. @include coupons_light_color(theme);
  868. @include coupons_border_color(theme);
  869. }
  870. .padbottom {
  871. /* #ifndef H5 */
  872. padding-bottom: calc(100rpx+ constant(safe-area-inset-bottom)) !important; ///兼容 IOS<11.2/
  873. padding-bottom: calc(100rpx + env(safe-area-inset-bottom)) !important;
  874. /* #endif */
  875. }
  876. .bottom {
  877. bottom: 218rpx !important;
  878. }
  879. .footerBottoms {
  880. width: 100%;
  881. /* #ifndef H5 */
  882. height: calc(200rpx+ constant(safe-area-inset-bottom)) !important; ///兼容 IOS<11.2/
  883. height: calc(200rpx + env(safe-area-inset-bottom)) !important;
  884. /* #endif */
  885. /* #ifdef H5 */
  886. height: calc(100rpx+ constant(safe-area-inset-bottom)) !important; ///兼容 IOS<11.2/
  887. height: calc(100rpx + env(safe-area-inset-bottom)) !important;
  888. /* #endif */
  889. }
  890. .discover_index {
  891. /deep/.no-border {
  892. bottom: 40rpx;
  893. }
  894. /deep/.author-list {
  895. padding-left: 24rpx;
  896. padding-right: 24rpx;
  897. }
  898. }
  899. .menu {
  900. // padding: 20rpx 34rpx 0 34rpx;
  901. // box-sizing: border-box;
  902. width: 100%;
  903. }
  904. .page_con {
  905. // position: fixed;
  906. top: 0;
  907. right: 0;
  908. bottom: 0;
  909. left: 0;
  910. display: flex;
  911. flex-direction: column;
  912. }
  913. .empty-boxs {
  914. margin: auto;
  915. }
  916. .goods {
  917. display: flex;
  918. flex-direction: column;
  919. justify-content: space-between;
  920. padding: 24rpx 24rpx 0 24rpx;
  921. background: #ffffff;
  922. }
  923. .publish {
  924. position: fixed;
  925. z-index: 999;
  926. width: 100rpx;
  927. height: 100rpx;
  928. opacity: 1;
  929. border-radius: 50%;
  930. bottom: 142rpx;
  931. right: 24rpx;
  932. color: #fff;
  933. line-height: 100rpx;
  934. text-align: center;
  935. @include linear-gradient(theme);
  936. .iconfont {
  937. font-size: 50rpx;
  938. }
  939. }
  940. .main {
  941. width: 100%;
  942. }
  943. .author {
  944. &-item {
  945. padding-bottom: 40rpx;
  946. }
  947. &-title {
  948. height: 120rpx;
  949. line-height: 120rpx;
  950. font-size: 32rpx;
  951. color: #333333;
  952. .iconfont {
  953. font-size: 170rpx;
  954. color: #454545;
  955. }
  956. .lefticon {
  957. transform: rotate(180deg);
  958. }
  959. }
  960. .name {
  961. margin: 0 28rpx;
  962. }
  963. &-head {
  964. width: 80rpx;
  965. height: 80rpx;
  966. border-radius: 50%;
  967. overflow: hidden;
  968. image {
  969. width: 100%;
  970. height: 100%;
  971. }
  972. margin-right: 20rpx;
  973. }
  974. &-name {
  975. font-size: 28rpx;
  976. font-family: PingFang SC-Medium, PingFang SC;
  977. font-weight: 600;
  978. color: #282828;
  979. }
  980. &-sign,
  981. &-fans {
  982. font-size: 22rpx;
  983. font-family: PingFang SC-Regular, PingFang SC;
  984. font-weight: 400;
  985. color: #999999;
  986. }
  987. &-sign {
  988. width: 370rpx;
  989. }
  990. &-pictrue {
  991. width: 222rpx;
  992. height: 222rpx;
  993. border-radius: 10px 10px 10px 10px;
  994. opacity: 1;
  995. margin-right: 18rpx;
  996. /deep/image,
  997. /deep/.easy-loadimage,
  998. uni-image {
  999. width: 100%;
  1000. height: 100%;
  1001. border-radius: 10px 10px 10px 10px;
  1002. overflow: hidden;
  1003. }
  1004. }
  1005. &-pictrue:nth-of-type(3n) {
  1006. margin-right: 0;
  1007. }
  1008. }
  1009. .noContent {
  1010. /deep/.empty-box {
  1011. padding-top: 80rpx !important;
  1012. }
  1013. }
  1014. .btn {
  1015. width: 440rpx;
  1016. height: 86rpx;
  1017. line-height: 86rpx;
  1018. text-align: center;
  1019. border-radius: 43rpx 43rpx 43rpx 43rpx;
  1020. opacity: 1;
  1021. border: 1px solid #E93323;
  1022. font-size: 32rpx;
  1023. margin: auto;
  1024. font-family: PingFang SC-Medium, PingFang SC;
  1025. @include main_color(theme);
  1026. @include coupons_border_color(theme);
  1027. font-weight: 600;
  1028. }
  1029. .cart_nav {
  1030. /deep/.nav_title {
  1031. font-size: 36rpx;
  1032. color: #333333;
  1033. }
  1034. }
  1035. .discover {
  1036. &-header {
  1037. background-size: cover;
  1038. top: 0;
  1039. left: 0;
  1040. .title {
  1041. font-size: 36rpx;
  1042. color: #333333;
  1043. }
  1044. }
  1045. &-navTab {
  1046. padding: 0 34rpx 0 34rpx;
  1047. justify-content: space-between;
  1048. .icon-xiazai5 {
  1049. color: #333;
  1050. }
  1051. .nav-item {
  1052. display: inline-block;
  1053. font-weight: 500;
  1054. font-size: 31rpx;
  1055. color: #B2B2B2;
  1056. &.on {
  1057. font-weight: 600;
  1058. font-size: 35rpx;
  1059. color: #141414;
  1060. border-bottom: 5rpx solid;
  1061. border-image: linear-gradient(90deg, #FFCA5F 0%, #FF1B95 100%);
  1062. border-image-slice: 1;
  1063. }
  1064. }
  1065. .release_btn {
  1066. width: 58rpx;
  1067. height: 58rpx;
  1068. border-radius: 100%;
  1069. background-image: linear-gradient(126deg, var(--view-bntColor21) 0%, var(--view-bntColor22) 100%);
  1070. color: #fff;
  1071. position: absolute;
  1072. top: 20rpx;
  1073. left: 0;
  1074. .iconfont {
  1075. font-size: 28rpx;
  1076. }
  1077. }
  1078. }
  1079. &-box {
  1080. flex: 1;
  1081. min-height: 83vh;
  1082. height: auto;
  1083. width: 100%;
  1084. background-color: #fff;
  1085. left: 0;
  1086. }
  1087. }
  1088. .avatar {
  1089. width: 64rpx;
  1090. height: 64rpx;
  1091. border-radius: 50%;
  1092. }
  1093. .h96 {
  1094. height: 96rpx;
  1095. }
  1096. .h36 {
  1097. /* #ifdef H5 */
  1098. height: 28rpx;
  1099. /* #endif */
  1100. /* #ifndef H5 */
  1101. height: 18rpx;
  1102. /* #endif */
  1103. }
  1104. .longTab {
  1105. width: 100%;
  1106. background: #fff;
  1107. border-radius: 16rpx 16rpx 0 0;
  1108. .longTab-item {
  1109. /*解决ios上滑动不流畅*/
  1110. -webkit-overflow-scrolling: touch;
  1111. position: relative;
  1112. }
  1113. .longItem {
  1114. height: 50upx;
  1115. display: inline-block;
  1116. text-align: center;
  1117. font-size: 30rpx;
  1118. color: #999999;
  1119. // margin-right: 56rpx;
  1120. text {
  1121. display: block;
  1122. max-width: 326rpx;
  1123. white-space: nowrap;
  1124. overflow: hidden;
  1125. text-overflow: ellipsis;
  1126. }
  1127. &:last-child {
  1128. margin-right: 0;
  1129. }
  1130. /*解决ios上滑动不流畅*/
  1131. -webkit-overflow-scrolling: touch;
  1132. position: relative;
  1133. &.click {
  1134. background: #EEF4FF;
  1135. // font-weight: bold;
  1136. // font-size: 34rpx;
  1137. // @include main_color(theme);
  1138. // &::after {
  1139. // content: "";
  1140. // display: block;
  1141. // width: 40rpx;
  1142. // height: 5rpx;
  1143. // @include main_bg_color(theme);
  1144. // display: flex;
  1145. // position: absolute;
  1146. // left: 50%;
  1147. // margin-left: -22rpx;
  1148. // bottom: -8rpx;
  1149. // }
  1150. // .underline {
  1151. // opacity: 1;
  1152. // }
  1153. }
  1154. }
  1155. .underlineBox {
  1156. height: 3px;
  1157. width: 20%;
  1158. display: flex;
  1159. align-content: center;
  1160. justify-content: center;
  1161. .underline {
  1162. opacity: 0;
  1163. width: 60rpx;
  1164. height: 4rpx;
  1165. background-color: #e93323;
  1166. }
  1167. }
  1168. }
  1169. .author-fans {
  1170. font-size: 24rpx !important;
  1171. }
  1172. .container {
  1173. overflow: hidden;
  1174. /* 隐藏超出部分 */
  1175. }
  1176. .swiper {
  1177. display: flex;
  1178. /* 使用flex布局 */
  1179. animation: scrollRight 10s linear infinite;
  1180. /* 应用动画 */
  1181. }
  1182. .swiper-item {
  1183. flex-shrink: 0;
  1184. /* 不允许缩小 */
  1185. width: 100%;
  1186. /* 每个item占满一行 */
  1187. height: 100%;
  1188. }
  1189. @keyframes scrollRight {
  1190. from {
  1191. transform: translateX(100%);
  1192. }
  1193. /* 从右向左移动 */
  1194. to {
  1195. transform: translateX(-100%);
  1196. }
  1197. /* 移出视图 */
  1198. }
  1199. .wall-nav {
  1200. font-weight: 500;
  1201. font-size: 23rpx;
  1202. color: #999999;
  1203. }
  1204. .wall-nav~.wall-nav {
  1205. margin-left: 38rpx;
  1206. }
  1207. .wall-nav-on {
  1208. font-weight: 600;
  1209. font-size: 27rpx;
  1210. color: #141414;
  1211. }
  1212. .discover-boxsss {
  1213. background-color: #fff;
  1214. width: 100%;
  1215. flex: 1;
  1216. }
  1217. .search {
  1218. background-color: #fff;
  1219. padding: 0rpx 10rpx 10rpx 38rpx;
  1220. }
  1221. .search .input {
  1222. width: 590rpx;
  1223. background-color: #f7f7f7;
  1224. border-radius: 33rpx;
  1225. padding: 0 24rpx;
  1226. box-sizing: border-box;
  1227. height: 66rpx;
  1228. }
  1229. .search .input input {
  1230. width: 460rpx;
  1231. font-size: 28rpx;
  1232. }
  1233. .search .input .iconfont {
  1234. color: #000;
  1235. font-size: 35rpx;
  1236. }
  1237. .search .bnt {
  1238. text-align: center;
  1239. height: 66rpx;
  1240. line-height: 66rpx;
  1241. font-size: 28rpx;
  1242. color: #282828;
  1243. margin-left: 24rpx;
  1244. }
  1245. </style>