index.vue 30 KB

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