index.vue 31 KB

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