index.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334
  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" @click="tabActive=0;rangeStr='school';showCateDrawer = false">本校</view>
  23. <view style="margin-right: 52rpx;" :class="tabActive == 1 ? 'on' : ''" class="nav-item pb-10" @click="tabActive=1;rangeStr='city';">同城</view>
  24. <view :class="tabActive == 2 ? 'on' : ''" class="nav-item pb-10" @click="tabActive=2;rangeStr='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="/static/img/ic-school.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. console.log(this.searchValue)
  374. console.log(this.$refs.recommendIndex)
  375. this.$refs.recommendIndex.where.page = 1;
  376. this.$refs.recommendIndex.tempArr = []
  377. this.$refs.recommendIndex.get_host_product();
  378. },
  379. returns: function() {
  380. if (this.returnShow) {
  381. uni.navigateBack(-1);
  382. } else {
  383. uni.switchTab({
  384. url: '/pages/index/index'
  385. })
  386. }
  387. },
  388. getHandInfo() {
  389. getSecondHandInfo().then(res => {
  390. this.bannerList = res.data.banner
  391. this.wallHeadline = res.data.headline
  392. let arr = res.data.navigatList
  393. let arrs = []
  394. let swperIndex = 1;
  395. let swperArr = [0];
  396. arr.forEach((item, index) => {
  397. if ((index + 1) > (swperIndex * 10)) {
  398. swperIndex++
  399. swperArr.push(swperIndex - 1)
  400. item.swperIndex = (swperIndex - 1)
  401. } else {
  402. item.swperIndex = (swperIndex - 1)
  403. }
  404. arrs.push({...item})
  405. })
  406. this.swperIndex = swperArr
  407. this.categoryList = arrs
  408. console.log(res.data, 111111111111111)
  409. if (!res.data.school) {
  410. this.$refs.schoolRef.open('top')
  411. } else {
  412. this.$refs.schoolRef.close()
  413. }
  414. }).catch(err => {
  415. console.log(err)
  416. })
  417. },
  418. getNavH(marTop) {
  419. // #ifdef H5
  420. this.marTop = 30;
  421. // #endif
  422. // #ifdef APP
  423. this.marTop = marTop - 60;
  424. // #endif
  425. },
  426. getPro(item) {
  427. this.noteDetails = item;
  428. this.proList = item.productList;
  429. this.$refs.goods.open('bottom');
  430. this.popupShow = true;
  431. setTimeout(() => {
  432. if (!this.bottomNavigationIsCustom) {
  433. uni.hideTabBar();
  434. } else {
  435. this.isShowFooter = false;
  436. }
  437. }, 50)
  438. },
  439. popup() {
  440. if (!this.bottomNavigationIsCustom) {
  441. uni.showTabBar();
  442. } else {
  443. this.isShowFooter = true;
  444. }
  445. setTimeout(() => {
  446. this.$refs.goods.close();
  447. this.popupShow = false;
  448. }, 100)
  449. },
  450. close() {
  451. if (!this.bottomNavigationIsCustom) {
  452. uni.showTabBar();
  453. } else {
  454. this.isShowFooter = true;
  455. }
  456. setTimeout(() => {
  457. this.$refs.comment.close();
  458. this.showComment = false;
  459. }, 100);
  460. },
  461. getReplyNum(n) {
  462. this.noteDetails.replyNum = n;
  463. },
  464. getComment(item) {
  465. this.noteDetails = item;
  466. this.$refs.comment.open('bottom');
  467. this.showComment = true;
  468. setTimeout(() => {
  469. if (!this.bottomNavigationIsCustom) {
  470. uni.hideTabBar();
  471. } else {
  472. this.isShowFooter = false;
  473. }
  474. }, 50)
  475. },
  476. //校验token是否有效,true为有效,false为无效
  477. getTokenIsExist() {
  478. tokenIsExistApi().then(res => {
  479. this.tokenIsExist = res.data;
  480. if (!this.tokenIsExist) {
  481. this.$store.commit('UPDATE_LOGIN', '');
  482. this.$store.commit('UPDATE_USERINFO', {});
  483. }
  484. })
  485. },
  486. // 去推荐作者个人主人
  487. goAuthor(item) {
  488. // #ifdef MP || H5
  489. uni.navigateTo({
  490. url: `/pages/discover/discover_user/index?id=${item.authorId}`
  491. })
  492. // #endif
  493. // #ifdef APP-PLUS
  494. uni.navigateTo({
  495. animationType: animationType.type,
  496. animationDuration: animationType.duration,
  497. url: `/pages/discover/discover_user/index?id=${item.authorId}`
  498. })
  499. // #endif
  500. },
  501. // 自定义下拉刷新被中止
  502. onAbort() {
  503. console.error("onAbort");
  504. },
  505. onPulling(e) {
  506. if (e.detail.deltaY < 0) return // 防止上滑页面也触发下拉
  507. if (this.tabActive == 1) {
  508. this.triggeredDiscover = true;
  509. } else {
  510. this.triggered = true;
  511. }
  512. },
  513. // 下拉刷新触发
  514. refresherpullingFun() {
  515. this.isRefresher = true
  516. },
  517. onRefreshDiscover() {
  518. if (this._freshing) return;
  519. this._freshing = true;
  520. setTimeout(() => {
  521. this._freshing = false;
  522. this.discoverList = {}
  523. this.getDiscoverList();
  524. this.triggeredDiscover = false;
  525. uni.stopPullDownRefresh();
  526. this._freshing = false;
  527. }, 1000)
  528. },
  529. onRefresh() {
  530. if (this._freshing) return;
  531. this._freshing = true;
  532. setTimeout(() => {
  533. this.loadendfollow = false;
  534. this.loadend = false;
  535. this.noteRecommendList = [];
  536. this.followParams.page = 1;
  537. this.authorList = [];
  538. this.params.page = 1;
  539. this.getFollowList();
  540. setTimeout(() => {
  541. if (this.noteRecommendList.length === 0 || this.loadendfollow) this
  542. .getRecommendAuthorList();
  543. }, 400)
  544. this.triggered = false
  545. uni.stopPullDownRefresh();
  546. this._freshing = false;
  547. }, 1000)
  548. },
  549. onRestore() {
  550. this.triggeredDiscover = false;
  551. },
  552. //关注内容
  553. getFollowList() {
  554. if (this.loadendfollow) {
  555. this.triggered = false;
  556. return;
  557. }
  558. this.loadingfollow = true;
  559. followListApi(this.followParams).then(res => {
  560. this.$set(this.followParams, 'page', this.followParams.page + 1);
  561. this.loadendfollow = this.followParams.page > res.data.totalPage;
  562. this.loadTitleFollow = this.loadendfollow ? '' : '加载更多';
  563. this.noteRecommendList = this.noteRecommendList.concat(res.data.list || []);
  564. this.loadingfollow = false
  565. this.triggered = false;
  566. }).catch(err => {
  567. this.loadingfollow = false;
  568. this.triggered = false;
  569. uni.showToast({
  570. title: err,
  571. icon: 'none'
  572. })
  573. });
  574. },
  575. // 关注作者
  576. followAuthor(item) {
  577. if (this.isLogin) {
  578. discoverFollowAuthor(item.authorId).then(() => {
  579. this.$set(item, 'isConcerned', !item.isConcerned);
  580. });
  581. } else {
  582. toLogin();
  583. }
  584. },
  585. //回退页面之后重新加载页面
  586. reFresh() {
  587. this.loading = true
  588. this.discoverList = {};
  589. this.getDiscoverList();
  590. },
  591. //发布内容
  592. publish() {
  593. if (this.isLogin) {
  594. // #ifdef MP || H5
  595. uni.navigateTo({
  596. url: `/pages/discover/discover_release/index?fair=${true}`
  597. })
  598. // #endif
  599. // #ifdef APP-PLUS
  600. uni.navigateTo({
  601. animationType: animationType.type,
  602. animationDuration: animationType.duration,
  603. url: `/pages/discover/discover_release/index?fair=${true}`
  604. })
  605. // #endif
  606. } else {
  607. toLogin();
  608. }
  609. },
  610. /**
  611. * 发现列表滑动中用到的方法
  612. */
  613. followScroll() {
  614. uni.$emit('scroll');
  615. },
  616. onTouchmoveRecommend(e) {
  617. if (!this.loadendfollow) this.getFollowList();
  618. if (this.loadendfollow && !this.loadend) this.getRecommendAuthorList();
  619. },
  620. onTouchmove(e) {
  621. this.getDiscoverList();
  622. },
  623. scrollLeft: function(e) {
  624. uni.$emit('scroll');
  625. if (e.detail.scrollTop > e.detail.scrollHeight - 1500) {
  626. this.getDiscoverList();
  627. }
  628. this.swiperHeight = this.windowHeight - 55
  629. },
  630. swiperChange(e) {
  631. let {
  632. current,
  633. source,
  634. currentItemId
  635. } = e.detail;
  636. if (source === 'autoplay' || source === 'touch') {
  637. this.categoryId = currentItemId;
  638. this.swiperCur = current
  639. this.selectMenu(this.categoryList[this.swiperCur], this.swiperCur, false)
  640. if (this.categoryList.length > 3) {
  641. var tempIndex = this.swiperCur - 2;
  642. tempIndex = tempIndex <= 0 ? 0 : tempIndex;
  643. let tabLeft = (this.swiperCur - 2) * this.isWidth; //设置下划线位置
  644. this.$nextTick(function() {
  645. this.$set(this, 'tabLeft', tabLeft);
  646. });
  647. }
  648. }
  649. },
  650. swiperIdChange(e) {
  651. let {
  652. current,
  653. source,
  654. currentItemId
  655. } = e.detail;
  656. if (source === 'autoplay' || source === 'touch') {
  657. console.log(current, source, currentItemId)
  658. }
  659. },
  660. /*******************发现列表滑动中用到的方法结束*********************/
  661. // 去个人主人
  662. goUser() {
  663. if (!this.isLogin) {
  664. this.openAuto();
  665. } else {
  666. // #ifdef MP || H5
  667. uni.navigateTo({
  668. url: `/pages/trade_fair/trade_fair_user/index`
  669. })
  670. // #endif
  671. // #ifdef APP-PLUS
  672. uni.navigateTo({
  673. animationType: animationType.type,
  674. animationDuration: animationType.duration,
  675. url: `/pages/trade_fair/trade_fair_user/index`
  676. })
  677. // #endif
  678. }
  679. },
  680. // 打开授权
  681. openAuto() {
  682. this.$Cache.set(BACK_URL, '')
  683. toLogin();
  684. },
  685. //发现列表
  686. getDiscoverList() {
  687. let that = this;
  688. this.isShow = false;
  689. if (!this.discoverList[this.categoryId]) {
  690. this.$set(this.discoverList, this.categoryId, {
  691. where: {
  692. ...this.where,
  693. categoryId: this.categoryId,
  694. secondType: this.active
  695. },
  696. goods: []
  697. })
  698. }
  699. const data = this.discoverList[this.categoryId];
  700. const cateId = this.categoryId;
  701. if (data.loading || data.loadend) {
  702. this.triggeredDiscover = false;
  703. return
  704. };
  705. data.loading = true
  706. this.loading = true
  707. this.loadTitle = '';
  708. if (data.where.categoryId === 0) data.where.categoryId = ''
  709. discoverListApi(data.where).then(res => {
  710. data.loadend = res.data.list.length < that.where.limit;
  711. if (data.where.page == 1) {
  712. data.goods = [];
  713. }
  714. this.loadTitle = data.loadend ? '没有了' : '加载更多';
  715. data.goods.push.apply(data.goods, res.data.list);
  716. data.where.page = data.where.page + 1;
  717. that.$nextTick(() => {
  718. that.$set(that.discoverList, cateId, {
  719. ...data
  720. });
  721. });
  722. data.loading = false;
  723. this.loading = false;
  724. this.triggeredDiscover = false;
  725. this.$forceUpdate()
  726. console.log(that.discoverList)
  727. }).catch(err => {
  728. data.loading = false;
  729. this.loading = false;
  730. uni.showToast({
  731. title: err,
  732. icon: 'none'
  733. })
  734. this.$set(this.discoverList, cateId, data);
  735. });
  736. },
  737. //推荐作者列表
  738. getRecommendAuthorList() {
  739. if (this.loadend) return;
  740. this.loading = true
  741. recommendAuthorListApi(this.params).then(res => {
  742. this.$set(this.params, 'page', this.params.page + 1);
  743. this.loadend = this.params.page > res.data.totalPage;
  744. this.authorList = this.authorList.concat(res.data.list || []);
  745. this.loadTitle = this.loadend ? '没有了' : '加载更多';
  746. this.loading = false
  747. })
  748. },
  749. //分类列表
  750. getCommunityCategoryList() {
  751. communityCategoryListApi().then(res => {
  752. let arr = []
  753. let arrs = []
  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. arr.push(...res.data)
  760. arr.push(...res.data)
  761. let swperIndex = 1;
  762. let swperArr = [0];
  763. arr.forEach((item, index) => {
  764. item.id = index
  765. if ((index + 1) > (swperIndex * 10)) {
  766. swperIndex++
  767. swperArr.push(swperIndex - 1)
  768. item.swperIndex = (swperIndex - 1)
  769. } else {
  770. item.swperIndex = (swperIndex - 1)
  771. }
  772. arrs.push({ ...item
  773. })
  774. })
  775. this.swperIndex = swperArr
  776. this.categoryList = arrs
  777. })
  778. },
  779. // 点击列表头部
  780. selectMenu(item, index, isScroll) {
  781. if (this.tabClick == index) return
  782. this.active = 0
  783. this.triggeredDiscover = false;
  784. this.categoryId = item.id;
  785. this.swiperCurrent = index;
  786. this.isScroll = isScroll;
  787. this.tabClick = index; //设置导航点击了哪一个
  788. this.isLeft = index * this.isWidth; //设置下划线位置
  789. this.where.categoryId = item.id;
  790. this.showCateDrawer = false
  791. this.getDiscoverList();
  792. },
  793. onReachBottom() {
  794. this.$refs.recommendIndex.get_host_product();
  795. },
  796. getRecommendLength(val) {
  797. this.recommendIndexL = val
  798. },
  799. onCategoryClick(item) {
  800. console.log(item)
  801. uni.navigateTo({
  802. url: `/pages/goods/goods_list/index?fairCateId=${item.id}&title=${item.name}&rangeStr=${this.rangeStr}&tabActive=${this.tabActive}`
  803. })
  804. }
  805. }
  806. }
  807. </script>
  808. <style lang="scss" scoped>
  809. /deep/.wf-page {
  810. background-color: #fff !important;
  811. }
  812. .discover_video_icon {
  813. top: 50% !important;
  814. left: 50% !important;
  815. right: 0 !important;
  816. -webkit-transform: translate(-50%, -50%);
  817. transform: translate(-50%, -50%);
  818. }
  819. .mp-header {
  820. background-color: $bg-color-primary;
  821. }
  822. .select_nav {
  823. width: 170rpx !important;
  824. height: 60rpx !important;
  825. border-radius: 33rpx;
  826. // background: rgba(255, 255, 255, 0.6);
  827. // border: 1rpx solid rgba(0, 0, 0, 0.1);
  828. color: #000;
  829. position: fixed;
  830. font-size: 18px;
  831. line-height: 58rpx;
  832. z-index: 99999;
  833. left: 14rpx;
  834. }
  835. .nav_title {
  836. // width: 200rpx;
  837. color: #fff;
  838. font-size: 36rpx;
  839. position: fixed;
  840. z-index: 9999;
  841. text-align: center;
  842. left: 0;
  843. right: 0;
  844. margin-top: -1px;
  845. }
  846. .sys-head {
  847. width: 100%;
  848. position: fixed;
  849. z-index: 9999;
  850. }
  851. .banner-img {
  852. width: 100%;
  853. height: 100%;
  854. }
  855. .newsTitle {
  856. font-weight: 400;
  857. font-size: 21rpx;
  858. color: #646464;
  859. }
  860. .active-topic {
  861. @include main_color(theme);
  862. @include coupons_light_color(theme);
  863. @include coupons_border_color(theme);
  864. }
  865. .padbottom {
  866. /* #ifndef H5 */
  867. padding-bottom: calc(100rpx+ constant(safe-area-inset-bottom)) !important; ///兼容 IOS<11.2/
  868. padding-bottom: calc(100rpx + env(safe-area-inset-bottom)) !important;
  869. /* #endif */
  870. }
  871. .bottom {
  872. bottom: 218rpx !important;
  873. }
  874. .footerBottoms {
  875. width: 100%;
  876. /* #ifndef H5 */
  877. height: calc(200rpx+ constant(safe-area-inset-bottom)) !important; ///兼容 IOS<11.2/
  878. height: calc(200rpx + env(safe-area-inset-bottom)) !important;
  879. /* #endif */
  880. /* #ifdef H5 */
  881. height: calc(100rpx+ constant(safe-area-inset-bottom)) !important; ///兼容 IOS<11.2/
  882. height: calc(100rpx + env(safe-area-inset-bottom)) !important;
  883. /* #endif */
  884. }
  885. .discover_index {
  886. /deep/.no-border {
  887. bottom: 40rpx;
  888. }
  889. /deep/.author-list {
  890. padding-left: 24rpx;
  891. padding-right: 24rpx;
  892. }
  893. }
  894. .menu {
  895. // padding: 20rpx 34rpx 0 34rpx;
  896. // box-sizing: border-box;
  897. width: 100%;
  898. }
  899. .page_con {
  900. // position: fixed;
  901. top: 0;
  902. right: 0;
  903. bottom: 0;
  904. left: 0;
  905. display: flex;
  906. flex-direction: column;
  907. }
  908. .empty-boxs {
  909. margin: auto;
  910. }
  911. .goods {
  912. display: flex;
  913. flex-direction: column;
  914. justify-content: space-between;
  915. padding: 24rpx 24rpx 0 24rpx;
  916. background: #ffffff;
  917. }
  918. .publish {
  919. position: fixed;
  920. z-index: 999;
  921. width: 100rpx;
  922. height: 100rpx;
  923. opacity: 1;
  924. border-radius: 50%;
  925. bottom: 142rpx;
  926. right: 24rpx;
  927. color: #fff;
  928. line-height: 100rpx;
  929. text-align: center;
  930. @include linear-gradient(theme);
  931. .iconfont {
  932. font-size: 50rpx;
  933. }
  934. }
  935. .main {
  936. width: 100%;
  937. }
  938. .author {
  939. &-item {
  940. padding-bottom: 40rpx;
  941. }
  942. &-title {
  943. height: 120rpx;
  944. line-height: 120rpx;
  945. font-size: 32rpx;
  946. color: #333333;
  947. .iconfont {
  948. font-size: 170rpx;
  949. color: #454545;
  950. }
  951. .lefticon {
  952. transform: rotate(180deg);
  953. }
  954. }
  955. .name {
  956. margin: 0 28rpx;
  957. }
  958. &-head {
  959. width: 80rpx;
  960. height: 80rpx;
  961. border-radius: 50%;
  962. overflow: hidden;
  963. image {
  964. width: 100%;
  965. height: 100%;
  966. }
  967. margin-right: 20rpx;
  968. }
  969. &-name {
  970. font-size: 28rpx;
  971. font-family: PingFang SC-Medium, PingFang SC;
  972. font-weight: 600;
  973. color: #282828;
  974. }
  975. &-sign,
  976. &-fans {
  977. font-size: 22rpx;
  978. font-family: PingFang SC-Regular, PingFang SC;
  979. font-weight: 400;
  980. color: #999999;
  981. }
  982. &-sign {
  983. width: 370rpx;
  984. }
  985. &-pictrue {
  986. width: 222rpx;
  987. height: 222rpx;
  988. border-radius: 10px 10px 10px 10px;
  989. opacity: 1;
  990. margin-right: 18rpx;
  991. /deep/image,
  992. /deep/.easy-loadimage,
  993. uni-image {
  994. width: 100%;
  995. height: 100%;
  996. border-radius: 10px 10px 10px 10px;
  997. overflow: hidden;
  998. }
  999. }
  1000. &-pictrue:nth-of-type(3n) {
  1001. margin-right: 0;
  1002. }
  1003. }
  1004. .noContent {
  1005. /deep/.empty-box {
  1006. padding-top: 80rpx !important;
  1007. }
  1008. }
  1009. .btn {
  1010. width: 440rpx;
  1011. height: 86rpx;
  1012. line-height: 86rpx;
  1013. text-align: center;
  1014. border-radius: 43rpx 43rpx 43rpx 43rpx;
  1015. opacity: 1;
  1016. border: 1px solid #E93323;
  1017. font-size: 32rpx;
  1018. margin: auto;
  1019. font-family: PingFang SC-Medium, PingFang SC;
  1020. @include main_color(theme);
  1021. @include coupons_border_color(theme);
  1022. font-weight: 600;
  1023. }
  1024. .cart_nav {
  1025. /deep/.nav_title {
  1026. font-size: 36rpx;
  1027. color: #333333;
  1028. }
  1029. }
  1030. .discover {
  1031. &-header {
  1032. background-size: cover;
  1033. top: 0;
  1034. left: 0;
  1035. .title {
  1036. font-size: 36rpx;
  1037. color: #333333;
  1038. }
  1039. }
  1040. &-navTab {
  1041. padding: 0 34rpx 0 34rpx;
  1042. justify-content: space-between;
  1043. .icon-xiazai5 {
  1044. color: #333;
  1045. }
  1046. .nav-item {
  1047. display: inline-block;
  1048. font-weight: 500;
  1049. font-size: 31rpx;
  1050. color: #B2B2B2;
  1051. &.on {
  1052. font-weight: 600;
  1053. font-size: 35rpx;
  1054. color: #141414;
  1055. border-bottom: 5rpx solid;
  1056. border-image: linear-gradient(90deg, #FFCA5F 0%, #FF1B95 100%);
  1057. border-image-slice: 1;
  1058. }
  1059. }
  1060. .release_btn {
  1061. width: 58rpx;
  1062. height: 58rpx;
  1063. border-radius: 100%;
  1064. background-image: linear-gradient(126deg, var(--view-bntColor21) 0%, var(--view-bntColor22) 100%);
  1065. color: #fff;
  1066. position: absolute;
  1067. top: 20rpx;
  1068. left: 0;
  1069. .iconfont {
  1070. font-size: 28rpx;
  1071. }
  1072. }
  1073. }
  1074. &-box {
  1075. flex: 1;
  1076. min-height: 83vh;
  1077. height: auto;
  1078. width: 100%;
  1079. background-color: #fff;
  1080. left: 0;
  1081. }
  1082. }
  1083. .avatar {
  1084. width: 64rpx;
  1085. height: 64rpx;
  1086. border-radius: 50%;
  1087. }
  1088. .h96 {
  1089. height: 96rpx;
  1090. }
  1091. .h36 {
  1092. /* #ifdef H5 */
  1093. height: 28rpx;
  1094. /* #endif */
  1095. /* #ifndef H5 */
  1096. height: 18rpx;
  1097. /* #endif */
  1098. }
  1099. .longTab {
  1100. width: 100%;
  1101. background: #fff;
  1102. border-radius: 16rpx 16rpx 0 0;
  1103. .longTab-item {
  1104. /*解决ios上滑动不流畅*/
  1105. -webkit-overflow-scrolling: touch;
  1106. position: relative;
  1107. }
  1108. .longItem {
  1109. height: 50upx;
  1110. display: inline-block;
  1111. text-align: center;
  1112. font-size: 30rpx;
  1113. color: #999999;
  1114. // margin-right: 56rpx;
  1115. text {
  1116. display: block;
  1117. max-width: 326rpx;
  1118. white-space: nowrap;
  1119. overflow: hidden;
  1120. text-overflow: ellipsis;
  1121. }
  1122. &:last-child {
  1123. margin-right: 0;
  1124. }
  1125. /*解决ios上滑动不流畅*/
  1126. -webkit-overflow-scrolling: touch;
  1127. position: relative;
  1128. &.click {
  1129. background: #EEF4FF;
  1130. // font-weight: bold;
  1131. // font-size: 34rpx;
  1132. // @include main_color(theme);
  1133. // &::after {
  1134. // content: "";
  1135. // display: block;
  1136. // width: 40rpx;
  1137. // height: 5rpx;
  1138. // @include main_bg_color(theme);
  1139. // display: flex;
  1140. // position: absolute;
  1141. // left: 50%;
  1142. // margin-left: -22rpx;
  1143. // bottom: -8rpx;
  1144. // }
  1145. // .underline {
  1146. // opacity: 1;
  1147. // }
  1148. }
  1149. }
  1150. .underlineBox {
  1151. height: 3px;
  1152. width: 20%;
  1153. display: flex;
  1154. align-content: center;
  1155. justify-content: center;
  1156. .underline {
  1157. opacity: 0;
  1158. width: 60rpx;
  1159. height: 4rpx;
  1160. background-color: #e93323;
  1161. }
  1162. }
  1163. }
  1164. .author-fans {
  1165. font-size: 24rpx !important;
  1166. }
  1167. .container {
  1168. overflow: hidden;
  1169. /* 隐藏超出部分 */
  1170. }
  1171. .swiper {
  1172. display: flex;
  1173. /* 使用flex布局 */
  1174. animation: scrollRight 10s linear infinite;
  1175. /* 应用动画 */
  1176. }
  1177. .swiper-item {
  1178. flex-shrink: 0;
  1179. /* 不允许缩小 */
  1180. width: 100%;
  1181. /* 每个item占满一行 */
  1182. height: 100%;
  1183. }
  1184. @keyframes scrollRight {
  1185. from {
  1186. transform: translateX(100%);
  1187. }
  1188. /* 从右向左移动 */
  1189. to {
  1190. transform: translateX(-100%);
  1191. }
  1192. /* 移出视图 */
  1193. }
  1194. .wall-nav {
  1195. font-weight: 500;
  1196. font-size: 23rpx;
  1197. color: #999999;
  1198. }
  1199. .wall-nav~.wall-nav {
  1200. margin-left: 38rpx;
  1201. }
  1202. .wall-nav-on {
  1203. font-weight: 600;
  1204. font-size: 27rpx;
  1205. color: #141414;
  1206. }
  1207. .discover-boxsss {
  1208. background-color: #fff;
  1209. width: 100%;
  1210. flex: 1;
  1211. }
  1212. .search {
  1213. background-color: #fff;
  1214. padding: 0rpx 10rpx 10rpx 38rpx;
  1215. }
  1216. .search .input {
  1217. width: 590rpx;
  1218. background-color: #f7f7f7;
  1219. border-radius: 33rpx;
  1220. padding: 0 24rpx;
  1221. box-sizing: border-box;
  1222. height: 66rpx;
  1223. }
  1224. .search .input input {
  1225. width: 460rpx;
  1226. font-size: 28rpx;
  1227. }
  1228. .search .input .iconfont {
  1229. color: #000;
  1230. font-size: 35rpx;
  1231. }
  1232. .search .bnt {
  1233. text-align: center;
  1234. height: 66rpx;
  1235. line-height: 66rpx;
  1236. font-size: 28rpx;
  1237. color: #282828;
  1238. margin-left: 24rpx;
  1239. }
  1240. </style>