index.vue 30 KB

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