index.vue 32 KB

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