index.vue 33 KB

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