index.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340
  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="`${urlDomain}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>