index.vue 30 KB

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