index.vue 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250
  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 MP -->
  6. <view class="cart_nav">
  7. <nav-bar iconColor='#fff' ref="navBarRef" :navTitle="'二手交易'" backgroundColor="#FF6702" :isBackgroundColor="false">
  8. </nav-bar>
  9. </view>
  10. <!-- #endif -->
  11. <view class="discover-navTab acea-row row-middle bg--w111-fff mt-4">
  12. <view class="acea-row row-center-wrapper" :style="[textBoxStyle]">
  13. <view style="margin-right: 52rpx;" :class="tabActive == 0 ? 'on' : ''" class="nav-item" @click="tabActive=0;showCateDrawer = false">本校</view>
  14. <view style="margin-right: 52rpx;" :class="tabActive == 1 ? 'on' : ''" class="nav-item pb-10" @click="tabActive=1;">同城</view>
  15. <view :class="tabActive == 2 ? 'on' : ''" class="nav-item pb-10" @click="tabActive=2;">全国</view>
  16. </view>
  17. <!-- #ifndef MP -->
  18. <view style="width: 32rpx;"></view>
  19. <!-- #endif -->
  20. </view>
  21. <view class='search acea-row '>
  22. <view class='input acea-row row-middle'>
  23. <text class='iconfont icon-sousuo2'></text>
  24. <input class="placeholder" type='text' :value='searchValue' :focus="focus" placeholder='请输入标题' placeholder-class='placeholder' @input="setValue" confirm-type="search" @confirm="searchBut()"></input>
  25. </view>
  26. <view class='bnt' @tap='searchBut'>搜索</view>
  27. </view>
  28. <!-- banner轮播图 -->
  29. <view class="mb-10" v-if="bannerList.length">
  30. <swiper :indicator-dots="true" :autoplay="true" :interval="2500" :duration="500" circular="true">
  31. <block v-for="(item,index) in bannerList" :key='item.id'>
  32. <swiper-item>
  33. <view class="swiper-item">
  34. <image class="banner-img" :src="item.imageUrl" mode="scaleToFill" />
  35. </view>
  36. </swiper-item>
  37. </block>
  38. </swiper>
  39. </view>
  40. <!-- 话题分类 -->
  41. <view class="longTab mb-10" scroll-y enhanced>
  42. <view class="flex h-116">
  43. <view class="flex-1 h-full flex-center longTab-item" :style="{background: index === tabClick ? '#EEF4FF' : ''}"
  44. v-for="(item, index) in categoryList" :key="index" :id="'id' + index" @click.stop="selectMenu(item, index, true)">
  45. <view class="flex-col flex-center">
  46. <image class="w-44 h-44 mb-10" :src="item.icon" mode=""></image>
  47. <view class="wall-font f-s-24 f-w-500">{{item.name}}</view>
  48. </view>
  49. </view>
  50. <view class="flex-1 h-full flex-center longTab-item">
  51. <navigator hover-class='none' url='/pages/merchant/user_sgin/index' class="item">
  52. <view class="flex-col flex-center">
  53. <image class="w-44 h-44 mb-10" :src="'/static/img/ic-wall-type-4.png'" mode=""></image>
  54. <view class="wall-font f-s-24 f-w-500">签到</view>
  55. </view>
  56. </navigator>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="discover-boxsss">
  62. <!-- 发现 -->
  63. <scroll-view scroll-y="true" @scroll="followScroll" class="main h-full">
  64. <view class="tab-cont h-full" id="main">
  65. <!-- 发现 -->
  66. <view class="h-full">
  67. <swiper class="h-full" :interval="interval" indicator-color="rgba(255,255,255,0.6)" :current="swiperCurrent" @change="swiperChange">
  68. <block v-for="(item,index) in categoryList" :key="index">
  69. <swiper-item class="h-full" :item-id="`${item.id}`">
  70. <scroll-view @scroll="scrollLeft" scroll-y="true" :show-scrollbar="false" class="scroll-view h-full"
  71. id="goods" refresher-enabled="true" :refresher-threshold="100" :refresher-triggered="triggeredDiscover"
  72. @refresherrefresh="onRefreshDiscover" @refresherpulling="onPulling" @refresherrestore="onRestore"
  73. @refresherabort="onAbort">
  74. <view class="goods padbottom">
  75. <view class="goods-wrap flex-1" id="goods" v-if="discoverList[item.id] && discoverList[item.id].goods.length">
  76. <view>
  77. <WaterfallsFlow v-if="discoverList[item.id].goods.length" :wfList="discoverList[item.id].goods" :type="1">
  78. <template slot-scope="{items}">
  79. <WaterfallsFlowItem :item="items" :type="1" :isStore="1" />
  80. </template>
  81. </WaterfallsFlow>
  82. </view>
  83. </view>
  84. <view class='loadingicon acea-row row-center-wrapper'>
  85. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{discoverList[item.id] &&discoverList[item.id].goods.length>0?loadTitle:''}}
  86. </view>
  87. <view class="empty-boxs noContent" v-if="discoverList[item.id] && discoverList[item.id].goods.length == 0 && !loading">
  88. <emptyPage title="暂无内容~" mTop="13%" :imgSrc="urlDomain+'crmebimage/presets/noguanzhu.png'">
  89. </emptyPage>
  90. </view>
  91. <view class="footerBottoms"></view>
  92. </view>
  93. </scroll-view>
  94. </swiper-item>
  95. </block>
  96. </swiper>
  97. </view>
  98. </view>
  99. </scroll-view>
  100. </view>
  101. <view class="publish" @click="publish" :class="bottomNavigationIsCustom?'bottom':''">
  102. <image class="w-116 h-116" src="/static/img/ic-fatie.png" mode=""></image>
  103. </view>
  104. </view>
  105. <!-- <pageFooter v-if="isShowFooter"></pageFooter> -->
  106. <!-- 评论 -->
  107. <uni-popup type="bottom" ref="comment">
  108. <view :style="'width: '+ windowWidth +'px; background-color: #fff; border-top-left-radius: 10px; border-top-right-radius: 10px;'">
  109. <discoverComment v-if="showComment" @getReplyNum="getReplyNum" :noteId="noteDetails.id" :noteDetails="noteDetails"
  110. @close="close">
  111. </discoverComment>
  112. </view>
  113. </uni-popup>
  114. <!-- 商品列表 -->
  115. <uni-popup type="bottom" ref="goods">
  116. <mentioned v-if="popupShow" :list="proList" @close="popup" class=""></mentioned>
  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. getReplyInfo
  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 onShare from "@/mixins/onShare";
  148. import discoverComment from '@/components/discoverComment/index.vue';
  149. import animationType from '@/utils/animationType.js'
  150. import pageFooter from "@/components/pageFooter/index.vue";
  151. import navBar from '@/components/navBar';
  152. import emptyPage from '@/components/emptyPage.vue';
  153. import easyLoadimage from '@/components/base/easy-loadimage.vue';
  154. import WaterfallsFlow from '@/components/WaterfallsFlow/WaterfallsFlow.vue'
  155. import WaterfallsFlowItem from '@/components/discoverFlowItem/discoverFlowItem.vue'
  156. import discoverDetails from '@/components/discoverDetails/index.vue'
  157. import mentioned from '@/components/mentioned.vue';
  158. import TitleBox from '@/components/titleBox/index.vue';
  159. let app = getApp();
  160. let sysHeight = uni.getSystemInfoSync().statusBarHeight;
  161. export default {
  162. mixins: [onShare],
  163. components: {
  164. pageFooter,
  165. navBar,
  166. emptyPage,
  167. easyLoadimage,
  168. WaterfallsFlowItem,
  169. WaterfallsFlow,
  170. discoverDetails,
  171. discoverComment,
  172. mentioned,
  173. TitleBox
  174. },
  175. computed: {
  176. ...mapGetters(['globalData', 'isLogin', 'userInfo', 'bottomNavigationIsCustom']),
  177. headerBoxStyle() {
  178. return {
  179. // #ifndef MP
  180. paddingTop: '4rpx',
  181. // #endif
  182. // #ifdef MP
  183. paddingTop: this.marTop + "px",
  184. marginRight: this.statusWidth + this.searchRight + 'px',
  185. // #endif
  186. }
  187. },
  188. textBoxStyle() {
  189. return {
  190. // #ifdef MP
  191. width: '100%',
  192. height: this.searchHeight + 'rpx',
  193. // lineHeight: this.searchHeight + 'rpx',
  194. // #endif
  195. }
  196. }
  197. },
  198. onLoad(options) {
  199. //分销码
  200. getUserSpread(options);
  201. this.windowWidth = uni.getSystemInfoSync().screenWidth; //获取屏幕宽度
  202. tokenIsExistApi().then(res => {
  203. this.tokenIsExist = res.data;
  204. if (this.tokenIsExist && this.isLogin) {
  205. this.getFollowList();
  206. setTimeout(() => {
  207. if (this.noteRecommendList.length === 0 || this.loadendfollow) this
  208. .getRecommendAuthorList();
  209. }, 500)
  210. }
  211. if (!this.tokenIsExist) {
  212. this.$store.commit('UPDATE_LOGIN', '');
  213. this.$store.commit('UPDATE_USERINFO', {});
  214. }
  215. })
  216. getReplyInfo().then(res => {
  217. this.bannerList = res.data.banner
  218. this.wallHeadline = res.data.headline
  219. console.log(res.data, 111111111111111)
  220. }).catch(err => {
  221. console.log(err)
  222. })
  223. this.getDiscoverList();
  224. this.getCommunityCategoryList();
  225. this._freshing = false;
  226. },
  227. data() {
  228. return {
  229. returnShow: false,
  230. urlDomain: this.$Cache.get("imgHost"),
  231. sysHeight: sysHeight,
  232. navH: '',
  233. windowWidth: 0, //获取屏幕宽度🌟💗
  234. interval: 3000,
  235. swiperHeight: 0,
  236. listMarTop: 0,
  237. tabClick: 0, //设置导航点击了哪一个
  238. tabLeft: 0, //设置下划线位置
  239. isLeft: 0, //导航栏下划线位置
  240. isWidth: 0, //每个导航栏占位
  241. tabActive: 1, // 顶部关注、发现切换
  242. windowHeight: 0,
  243. theme: app.globalData.theme,
  244. marTop: 0,
  245. categoryList: [], //分类列表
  246. categoryId: '-1', //分类id
  247. swiperCurrent: 0, //分类索引
  248. isScroll: false, //是否是滑动
  249. params: { //推荐作者
  250. page: 1,
  251. limit: 10
  252. },
  253. followParams: { //关注内容
  254. page: 1,
  255. limit: 10
  256. },
  257. noteRecommendList: [], //关注内容
  258. loadendfollow: false, //关注内容
  259. loadingfollow: false, //关注内容
  260. where: {
  261. categoryId: 0,
  262. page: 1,
  263. limit: 10
  264. },
  265. loadend: false,
  266. loading: false,
  267. loadTitle: '加载更多',
  268. loadTitleFollow: '加载更多',
  269. onnnn: {
  270. good: [{
  271. authorId: 1
  272. }]
  273. },
  274. discoverList: {}, //内容信息
  275. authorList: [], //推荐作者列表
  276. isOpenRefresh: true, // 是否开启下拉
  277. triggered: false,
  278. triggeredDiscover: false,
  279. isShow: false, //加载完成
  280. tokenIsExist: false, //校验token是否有效,true为有效,false为无效
  281. isRefresher: false, //下拉刷新状态
  282. noteDetails: {}, //内容详情
  283. popupShow: false, //商品弹窗
  284. showComment: false, //评论弹窗
  285. proList: [], //提到的商品
  286. isShowFooter: true,
  287. loadingAuthor: false, //推荐作者
  288. showCateDrawer: false, //分类下拉展示
  289. searchRight: 0,
  290. statusWidth: 0,
  291. searchHeight: 0,
  292. bannerList: [],
  293. wallHeadline: [],
  294. navList: [{
  295. id: 0,
  296. name: '默认'
  297. }, {
  298. id: 1,
  299. name: '评论'
  300. }, {
  301. id: 2,
  302. name: '点赞'
  303. }, {
  304. id: 3,
  305. name: '有图'
  306. }],
  307. active: 0,
  308. }
  309. },
  310. // 滚动监听
  311. onPageScroll(e) {
  312. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  313. uni.$emit('scroll');
  314. },
  315. onShow() {
  316. this.showCateDrawer = false;
  317. this.getTokenIsExist();
  318. //分销绑定
  319. silenceBindingSpread(this.isLogin, this.globalData.spread);
  320. },
  321. mounted() {
  322. this.$nextTick(function() {
  323. const query = uni.createSelectorQuery().in(this);
  324. query.select('.discover-header').boundingClientRect(data => {
  325. // #ifndef H5
  326. this.listMarTop = data.height
  327. // #endif
  328. // #ifdef H5
  329. this.listMarTop = data.height
  330. // #endif
  331. }).exec();
  332. });
  333. },
  334. created() {
  335. var pages = getCurrentPages();
  336. this.returnShow = pages.length === 1 ? false : true;
  337. var that = this;
  338. // 获取设备宽度
  339. uni.getSystemInfo({
  340. success(e) {
  341. that.isWidth = e.windowWidth / 6;
  342. that.windowHeight = e.windowHeight;
  343. that.swiperHeight = that.windowHeight - 205
  344. that.$set(that, 'swiperHeight', that.windowHeight - 55);
  345. }
  346. });
  347. // #ifdef MP || APP-PLUS
  348. // 获取导航高度;
  349. this.navH = this.globalData.navHeight;
  350. // #endif
  351. // #ifdef H5
  352. this.navH = 80;
  353. // #endif
  354. that.getNavH()
  355. // #ifdef MP
  356. const res = uni.getMenuButtonBoundingClientRect()
  357. const jnHeight = res.height //胶囊高度
  358. const statusHeight = res.top //胶囊距离顶部
  359. const statusRight = res.right //胶囊右边界坐标
  360. this.statusWidth = res.width
  361. this.searchHeight = 96
  362. console.log('999', statusHeight, this.sysHeight);
  363. this.marTop = statusHeight - this.sysHeight
  364. //搜索框宽度计算
  365. uni.getSystemInfo({
  366. success: res => {
  367. this.searchRight = res.windowWidth - statusRight
  368. }
  369. })
  370. // #endif
  371. },
  372. //uniapp小程序用deep重写组件样式不生效
  373. options: {
  374. styleIsolation: 'shared'
  375. },
  376. methods: {
  377. returns: function() {
  378. if (this.returnShow) {
  379. uni.navigateBack(-1);
  380. } else {
  381. uni.switchTab({
  382. url: '/pages/index/index'
  383. })
  384. }
  385. },
  386. 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`
  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`
  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. /*******************发现列表滑动中用到的方法结束*********************/
  619. // 去个人主人
  620. goUser() {
  621. if (!this.isLogin) {
  622. this.openAuto();
  623. } else {
  624. // #ifdef MP || H5
  625. uni.navigateTo({
  626. url: '/pages/discover/discover_user/index'
  627. })
  628. // #endif
  629. // #ifdef APP-PLUS
  630. uni.navigateTo({
  631. animationType: animationType.type,
  632. animationDuration: animationType.duration,
  633. url: '/pages/discover/discover_user/index'
  634. })
  635. // #endif
  636. }
  637. },
  638. // 打开授权
  639. openAuto() {
  640. this.$Cache.set(BACK_URL, '')
  641. toLogin();
  642. },
  643. //发现列表
  644. getDiscoverList() {
  645. let that = this;
  646. this.isShow = false;
  647. if (!this.discoverList[this.categoryId]) {
  648. this.$set(this.discoverList, this.categoryId, {
  649. where: {
  650. ...this.where,
  651. categoryId: this.categoryId,
  652. secondType: this.active
  653. },
  654. goods: []
  655. })
  656. }
  657. const data = this.discoverList[this.categoryId];
  658. const cateId = this.categoryId;
  659. if (data.loading || data.loadend) {
  660. this.triggeredDiscover = false;
  661. return
  662. };
  663. data.loading = true
  664. this.loading = true
  665. this.loadTitle = '';
  666. if (data.where.categoryId === 0) data.where.categoryId = ''
  667. discoverListApi(data.where).then(res => {
  668. data.loadend = res.data.list.length < that.where.limit;
  669. if (data.where.page == 1) {
  670. data.goods = [];
  671. }
  672. this.loadTitle = data.loadend ? '没有了' : '加载更多';
  673. data.goods.push.apply(data.goods, res.data.list);
  674. data.where.page = data.where.page + 1;
  675. that.$nextTick(() => {
  676. that.$set(that.discoverList, cateId, {
  677. ...data
  678. });
  679. });
  680. data.loading = false;
  681. this.loading = false;
  682. this.triggeredDiscover = false;
  683. this.$forceUpdate()
  684. console.log(that.discoverList)
  685. }).catch(err => {
  686. data.loading = false;
  687. this.loading = false;
  688. uni.showToast({
  689. title: err,
  690. icon: 'none'
  691. })
  692. this.$set(this.discoverList, cateId, data);
  693. });
  694. },
  695. //推荐作者列表
  696. getRecommendAuthorList() {
  697. if (this.loadend) return;
  698. this.loading = true
  699. recommendAuthorListApi(this.params).then(res => {
  700. this.$set(this.params, 'page', this.params.page + 1);
  701. this.loadend = this.params.page > res.data.totalPage;
  702. this.authorList = this.authorList.concat(res.data.list || []);
  703. this.loadTitle = this.loadend ? '没有了' : '加载更多';
  704. this.loading = false
  705. })
  706. },
  707. //分类列表
  708. getCommunityCategoryList() {
  709. let data = [{
  710. name: "全部",
  711. id: '-1',
  712. icon: '/static/img/ic-wall-type--1.png'
  713. }];
  714. communityCategoryListApi().then(res => {
  715. this.categoryList = Array.from(new Set([...data, ...res.data]));
  716. })
  717. },
  718. // 点击列表头部
  719. selectMenu(item, index, isScroll) {
  720. if (this.tabClick == index) return
  721. this.active = 0
  722. this.triggeredDiscover = false;
  723. this.categoryId = item.id;
  724. this.swiperCurrent = index;
  725. this.isScroll = isScroll;
  726. this.tabClick = index; //设置导航点击了哪一个
  727. this.isLeft = index * this.isWidth; //设置下划线位置
  728. this.where.categoryId = item.id;
  729. this.showCateDrawer = false
  730. this.getDiscoverList();
  731. }
  732. }
  733. }
  734. </script>
  735. <style lang="scss" scoped>
  736. /deep/.wf-page {
  737. background-color: #fff !important;
  738. }
  739. .discover_video_icon {
  740. top: 50% !important;
  741. left: 50% !important;
  742. right: 0 !important;
  743. -webkit-transform: translate(-50%, -50%);
  744. transform: translate(-50%, -50%);
  745. }
  746. .mp-header {
  747. background-color: $bg-color-primary;
  748. }
  749. .select_nav {
  750. width: 170rpx !important;
  751. height: 60rpx !important;
  752. border-radius: 33rpx;
  753. // background: rgba(255, 255, 255, 0.6);
  754. // border: 1rpx solid rgba(0, 0, 0, 0.1);
  755. color: #000;
  756. position: fixed;
  757. font-size: 18px;
  758. line-height: 58rpx;
  759. z-index: 1000;
  760. left: 14rpx;
  761. }
  762. .nav_title {
  763. // width: 200rpx;
  764. color: #fff;
  765. font-size: 36rpx;
  766. position: fixed;
  767. text-align: center;
  768. left: 0;
  769. right: 0;
  770. margin: auto;
  771. }
  772. .banner-img {
  773. width: 100%;
  774. height: 100%;
  775. }
  776. .newsTitle {
  777. font-weight: 400;
  778. font-size: 21rpx;
  779. color: #646464;
  780. }
  781. .active-topic {
  782. @include main_color(theme);
  783. @include coupons_light_color(theme);
  784. @include coupons_border_color(theme);
  785. }
  786. .padbottom {
  787. /* #ifndef H5 */
  788. padding-bottom: calc(100rpx+ constant(safe-area-inset-bottom)) !important; ///兼容 IOS<11.2/
  789. padding-bottom: calc(100rpx + env(safe-area-inset-bottom)) !important;
  790. /* #endif */
  791. }
  792. .bottom {
  793. bottom: 218rpx !important;
  794. }
  795. .footerBottoms {
  796. width: 100%;
  797. /* #ifndef H5 */
  798. height: calc(200rpx+ constant(safe-area-inset-bottom)) !important; ///兼容 IOS<11.2/
  799. height: calc(200rpx + env(safe-area-inset-bottom)) !important;
  800. /* #endif */
  801. /* #ifdef H5 */
  802. height: calc(100rpx+ constant(safe-area-inset-bottom)) !important; ///兼容 IOS<11.2/
  803. height: calc(100rpx + env(safe-area-inset-bottom)) !important;
  804. /* #endif */
  805. }
  806. .discover_index {
  807. /deep/.no-border {
  808. bottom: 40rpx;
  809. }
  810. /deep/.author-list {
  811. padding-left: 24rpx;
  812. padding-right: 24rpx;
  813. }
  814. }
  815. .menu {
  816. // padding: 20rpx 34rpx 0 34rpx;
  817. // box-sizing: border-box;
  818. width: 100%;
  819. }
  820. .page_con {
  821. // position: fixed;
  822. top: 0;
  823. right: 0;
  824. bottom: 0;
  825. left: 0;
  826. display: flex;
  827. flex-direction: column;
  828. }
  829. .empty-boxs {
  830. margin: auto;
  831. }
  832. .goods {
  833. display: flex;
  834. flex-direction: column;
  835. justify-content: space-between;
  836. padding: 24rpx 24rpx 0 24rpx;
  837. background: #ffffff;
  838. }
  839. .publish {
  840. position: fixed;
  841. z-index: 9999;
  842. width: 100rpx;
  843. height: 100rpx;
  844. opacity: 1;
  845. border-radius: 50%;
  846. bottom: 142rpx;
  847. right: 24rpx;
  848. color: #fff;
  849. line-height: 100rpx;
  850. text-align: center;
  851. @include linear-gradient(theme);
  852. .iconfont {
  853. font-size: 50rpx;
  854. }
  855. }
  856. .main {
  857. width: 100%;
  858. }
  859. .author {
  860. &-item {
  861. padding-bottom: 40rpx;
  862. }
  863. &-title {
  864. height: 120rpx;
  865. line-height: 120rpx;
  866. font-size: 32rpx;
  867. color: #333333;
  868. .iconfont {
  869. font-size: 170rpx;
  870. color: #454545;
  871. }
  872. .lefticon {
  873. transform: rotate(180deg);
  874. }
  875. }
  876. .name {
  877. margin: 0 28rpx;
  878. }
  879. &-head {
  880. width: 80rpx;
  881. height: 80rpx;
  882. border-radius: 50%;
  883. overflow: hidden;
  884. image {
  885. width: 100%;
  886. height: 100%;
  887. }
  888. margin-right: 20rpx;
  889. }
  890. &-name {
  891. font-size: 28rpx;
  892. font-family: PingFang SC-Medium, PingFang SC;
  893. font-weight: 600;
  894. color: #282828;
  895. }
  896. &-sign,
  897. &-fans {
  898. font-size: 22rpx;
  899. font-family: PingFang SC-Regular, PingFang SC;
  900. font-weight: 400;
  901. color: #999999;
  902. }
  903. &-sign {
  904. width: 370rpx;
  905. }
  906. &-pictrue {
  907. width: 222rpx;
  908. height: 222rpx;
  909. border-radius: 10px 10px 10px 10px;
  910. opacity: 1;
  911. margin-right: 18rpx;
  912. /deep/image,
  913. /deep/.easy-loadimage,
  914. uni-image {
  915. width: 100%;
  916. height: 100%;
  917. border-radius: 10px 10px 10px 10px;
  918. overflow: hidden;
  919. }
  920. }
  921. &-pictrue:nth-of-type(3n) {
  922. margin-right: 0;
  923. }
  924. }
  925. .noContent {
  926. /deep/.empty-box {
  927. padding-top: 80rpx !important;
  928. }
  929. }
  930. .btn {
  931. width: 440rpx;
  932. height: 86rpx;
  933. line-height: 86rpx;
  934. text-align: center;
  935. border-radius: 43rpx 43rpx 43rpx 43rpx;
  936. opacity: 1;
  937. border: 1px solid #E93323;
  938. font-size: 32rpx;
  939. margin: auto;
  940. font-family: PingFang SC-Medium, PingFang SC;
  941. @include main_color(theme);
  942. @include coupons_border_color(theme);
  943. font-weight: 600;
  944. }
  945. .cart_nav {
  946. /deep/.nav_title {
  947. font-size: 36rpx;
  948. color: #333333;
  949. }
  950. }
  951. .discover {
  952. &-header {
  953. background-size: cover;
  954. top: 0;
  955. left: 0;
  956. .title {
  957. font-size: 36rpx;
  958. color: #333333;
  959. }
  960. }
  961. &-navTab {
  962. padding: 0 34rpx 0 34rpx;
  963. justify-content: space-between;
  964. .icon-xiazai5 {
  965. color: #333;
  966. }
  967. .nav-item {
  968. display: inline-block;
  969. font-weight: 500;
  970. font-size: 31rpx;
  971. color: #B2B2B2;
  972. &.on {
  973. font-weight: 600;
  974. font-size: 35rpx;
  975. color: #141414;
  976. border-bottom: 5rpx solid;
  977. border-image: linear-gradient(90deg, #FFCA5F 0%, #FF1B95 100%);
  978. border-image-slice: 1;
  979. }
  980. }
  981. .release_btn {
  982. width: 58rpx;
  983. height: 58rpx;
  984. border-radius: 100%;
  985. background-image: linear-gradient(126deg, var(--view-bntColor21) 0%, var(--view-bntColor22) 100%);
  986. color: #fff;
  987. position: absolute;
  988. top: 20rpx;
  989. left: 0;
  990. .iconfont {
  991. font-size: 28rpx;
  992. }
  993. }
  994. }
  995. &-box {
  996. flex: 1;
  997. min-height: 83vh;
  998. height: auto;
  999. width: 100%;
  1000. background-color: #fff;
  1001. left: 0;
  1002. }
  1003. }
  1004. .avatar {
  1005. width: 64rpx;
  1006. height: 64rpx;
  1007. border-radius: 50%;
  1008. }
  1009. .h96 {
  1010. height: 96rpx;
  1011. }
  1012. .h36 {
  1013. /* #ifdef H5 */
  1014. height: 28rpx;
  1015. /* #endif */
  1016. /* #ifndef H5 */
  1017. height: 18rpx;
  1018. /* #endif */
  1019. }
  1020. .longTab {
  1021. width: 100%;
  1022. background: #fff;
  1023. border-radius: 16rpx 16rpx 0 0;
  1024. .longTab-item {
  1025. /*解决ios上滑动不流畅*/
  1026. -webkit-overflow-scrolling: touch;
  1027. position: relative;
  1028. }
  1029. .longItem {
  1030. height: 50upx;
  1031. display: inline-block;
  1032. text-align: center;
  1033. font-size: 30rpx;
  1034. color: #999999;
  1035. // margin-right: 56rpx;
  1036. text {
  1037. display: block;
  1038. max-width: 326rpx;
  1039. white-space: nowrap;
  1040. overflow: hidden;
  1041. text-overflow: ellipsis;
  1042. }
  1043. &:last-child {
  1044. margin-right: 0;
  1045. }
  1046. /*解决ios上滑动不流畅*/
  1047. -webkit-overflow-scrolling: touch;
  1048. position: relative;
  1049. &.click {
  1050. background: #EEF4FF;
  1051. // font-weight: bold;
  1052. // font-size: 34rpx;
  1053. // @include main_color(theme);
  1054. // &::after {
  1055. // content: "";
  1056. // display: block;
  1057. // width: 40rpx;
  1058. // height: 5rpx;
  1059. // @include main_bg_color(theme);
  1060. // display: flex;
  1061. // position: absolute;
  1062. // left: 50%;
  1063. // margin-left: -22rpx;
  1064. // bottom: -8rpx;
  1065. // }
  1066. // .underline {
  1067. // opacity: 1;
  1068. // }
  1069. }
  1070. }
  1071. .underlineBox {
  1072. height: 3px;
  1073. width: 20%;
  1074. display: flex;
  1075. align-content: center;
  1076. justify-content: center;
  1077. .underline {
  1078. opacity: 0;
  1079. width: 60rpx;
  1080. height: 4rpx;
  1081. background-color: #e93323;
  1082. }
  1083. }
  1084. }
  1085. .author-fans {
  1086. font-size: 24rpx !important;
  1087. }
  1088. .container {
  1089. overflow: hidden;
  1090. /* 隐藏超出部分 */
  1091. }
  1092. .swiper {
  1093. display: flex;
  1094. /* 使用flex布局 */
  1095. animation: scrollRight 10s linear infinite;
  1096. /* 应用动画 */
  1097. }
  1098. .swiper-item {
  1099. flex-shrink: 0;
  1100. /* 不允许缩小 */
  1101. width: 100%;
  1102. /* 每个item占满一行 */
  1103. height: 100%;
  1104. }
  1105. @keyframes scrollRight {
  1106. from {
  1107. transform: translateX(100%);
  1108. }
  1109. /* 从右向左移动 */
  1110. to {
  1111. transform: translateX(-100%);
  1112. }
  1113. /* 移出视图 */
  1114. }
  1115. .wall-nav {
  1116. font-weight: 500;
  1117. font-size: 23rpx;
  1118. color: #999999;
  1119. }
  1120. .wall-nav~.wall-nav {
  1121. margin-left: 38rpx;
  1122. }
  1123. .wall-nav-on {
  1124. font-weight: 600;
  1125. font-size: 27rpx;
  1126. color: #141414;
  1127. }
  1128. .discover-boxsss {
  1129. background-color: #fff;
  1130. width: 100%;
  1131. flex: 1;
  1132. }
  1133. .search {
  1134. background-color: #fff;
  1135. padding: 0rpx 10rpx 10rpx 38rpx;
  1136. }
  1137. .search .input {
  1138. width: 590rpx;
  1139. background-color: #f7f7f7;
  1140. border-radius: 33rpx;
  1141. padding: 0 24rpx;
  1142. box-sizing: border-box;
  1143. height: 66rpx;
  1144. }
  1145. .search .input input {
  1146. width: 460rpx;
  1147. font-size: 28rpx;
  1148. }
  1149. .search .input .iconfont {
  1150. color: #000;
  1151. font-size: 35rpx;
  1152. }
  1153. .search .bnt {
  1154. text-align: center;
  1155. height: 66rpx;
  1156. line-height: 66rpx;
  1157. font-size: 28rpx;
  1158. color: #282828;
  1159. margin-left: 24rpx;
  1160. }
  1161. </style>