index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <view :style="viewColor">
  3. <view class="main">
  4. <view class='search acea-row row-between-wrapper'>
  5. <view class='input acea-row row-between-wrapper'>
  6. <text class='iconfont icon-sousuo2'></text>
  7. <input type='text' v-model="where.keyword" :focus="focus" placeholder='请输入关键字' placeholder-class='placeholder' @input="setValue" confirm-type="search" @confirm="searchBut()"></input>
  8. <i v-if="where.keyword" class="iconfont icon-guanbi1 icon-zhanwei" @click="where.keyword = ''"></i>
  9. <i v-else class="iconfont icon-zhanwei"></i>
  10. </view>
  11. <view class='bnt' @tap='searchBut'>搜索</view>
  12. </view>
  13. <view class="search-tabs acea-row">
  14. <view v-for="(item,index) in tabList" :key="index" @click="getList(item,index)" class="item" :class="{on : activeIndex == index}">{{item.title}}</view>
  15. </view>
  16. <view v-if="activeIndex == 2" class="tab-cont">
  17. <view class="author-wrap">
  18. <view class="user_plant_item" v-for="(item,index) in goods" :key="index" @click="goAuthor(item)">
  19. <image :src="(item.author&&item.author.avatar) || '/static/images/f.png'" mode=""></image>
  20. <view v-if="item.author" class="info">
  21. <view class="line1">
  22. <text class="name line1">{{item.author.nickname}}</text>
  23. </view>
  24. <view class="acea-row plant-des">
  25. <view class="des">
  26. 内容<text>{{(item.author.count_content<10000&&item.author.count_content>0) ? item.author.count_content : item.author.count_content>1000 ? (item.author.count_content/10000).toFixed(2)+'万' : 0}}</text>
  27. </view>
  28. <view class="des">
  29. 粉丝<text>{{(item.author.count_fans<10000&&item.author.count_fans>0) ? item.author.count_fans : item.author.count_fans>1000 ? (item.author.count_fans/10000).toFixed(2)+'万' : 0}}</text>
  30. </view>
  31. </view>
  32. <view class="btn" :class="!item.is_fans ? 'focusBtn' : ''" @click.stop="focusToggle(item)">
  33. <text v-if="!item.is_fans" class="iconfont icon-jiahao2"></text>
  34. {{item.is_fans ? '已关注' : '关注'}}
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view :hidden="!loading" class="acea-row row-center-wrapper loadingicon">
  40. <text class="iconfont icon-jiazai loading"></text>
  41. </view>
  42. <emptyPage v-if="authorList.length == 0 && !loading" title="暂无作者~"></emptyPage>
  43. </view>
  44. <view v-else class="tab-cont">
  45. <view v-if="goods.length" class="goods-wrap">
  46. <view class="goods">
  47. <WaterfallsFlow :wfList='goods' :isFind="false" :isAuth="0"/>
  48. </view>
  49. </view>
  50. </view>
  51. <view :hidden="!loading" class="acea-row row-center-wrapper loadingicon">
  52. <text class="iconfont icon-jiazai loading"></text>
  53. </view>
  54. <emptyPage v-if="goods.length == 0 && !loading" title="暂无内容~"></emptyPage>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. // +----------------------------------------------------------------------
  60. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  61. // +----------------------------------------------------------------------
  62. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  63. // +----------------------------------------------------------------------
  64. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  65. // +----------------------------------------------------------------------
  66. // | Author: CRMEB Team <admin@crmeb.com>
  67. // +----------------------------------------------------------------------
  68. import WaterfallsFlow from '@/components/plantWaterfallsFlow/WaterfallsFlow.vue'
  69. import { graphicLstApi, followAuthorApi } from '@/api/community.js';
  70. import { toLogin } from '@/libs/login.js';
  71. import { mapGetters } from "vuex";
  72. import { configMap } from '@/utils';
  73. import emptyPage from '@/components/emptyPage.vue'
  74. const app = getApp();
  75. export default {
  76. components: {
  77. emptyPage,
  78. WaterfallsFlow,
  79. },
  80. data() {
  81. return {
  82. focus: false,
  83. goods: [],
  84. authorList: [
  85. {avatar: "",nickname: '爱吃酥脆紫菜的小西', count: 35, count_fans: 0, is_fans: 1},
  86. {avatar: "https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKZw2XnQEyK8f1BIcNGVegibE9tPZBtjyu0AgyaPDEEwmyZnWydhXwXUnbrtGnXmam6WTzichTBcLgQ/132",nickname: '猪猪甜甜圈', count: 35, count_fans: 951, is_fans: 0},
  87. {avatar: "",nickname: '爱吃酥脆紫菜的小西', count: 35, count_fans: 951, is_fans: 1},
  88. ],
  89. keyword: '',
  90. loaded: false,
  91. loading: false,
  92. loadTitle: '加载更多',
  93. where: {
  94. keyword: "",
  95. search_type: "all",
  96. page: 1,
  97. limit: 30,
  98. topic_id: ''
  99. },
  100. searchValue: "",
  101. activeIndex: 0,
  102. tabList:[
  103. {title: "全部", value: 0, type: "all"},
  104. {title: "内容", value: 1, type: "content"},
  105. {title: "用户", value: 2, type: "user"},
  106. ]
  107. }
  108. },
  109. created() {},
  110. computed: {
  111. ...mapGetters(['isLogin', 'uid', 'viewColor']),
  112. ...configMap({community_status: 0})
  113. },
  114. watch: {},
  115. onLoad: function(options) {
  116. this.where.keyword = this.searchValue = options.searchValue ? options.searchValue : ''
  117. this.where.topic_id = options.id ? options.id : ''
  118. this.getGoods();
  119. },
  120. onShow() {},
  121. mounted: function() {},
  122. methods: {
  123. setValue: function(event) {
  124. this.$set(this.where, 'keyword', event.detail.value);
  125. },
  126. searchBut(){
  127. this.loadend = this.loading = false
  128. this.where.page = 1
  129. this.goods = []
  130. this.getGoods()
  131. },
  132. goAuthor(item){
  133. if(this.isLogin && this.community_status==1){
  134. uni.navigateTo({
  135. url: '/pages/plantGrass/plant_user/index?id='+item.uid
  136. })
  137. }else{
  138. toLogin()
  139. }
  140. },
  141. // 获取列表数据
  142. getList(item,index){
  143. this.activeIndex = index;
  144. this.where={
  145. keyword: this.where.keyword,
  146. search_type: item.type,
  147. page: 1,
  148. limit: 30,
  149. topic_id: ''
  150. }
  151. this.goods = []
  152. this.loadend = false
  153. this.loading = false
  154. this.getGoods()
  155. },
  156. // 获取社区内容列表
  157. getGoods: function() {
  158. let that = this;
  159. if (that.loadend) return;
  160. if (that.loading) return;
  161. that.loading = true;
  162. that.loadTitle = '';
  163. graphicLstApi(that.where).then(res => {
  164. that.loading = false;
  165. let list = res.data.list;
  166. let goodsList = that.$util.SplitArray(list, that.goods);
  167. let loadend = list.length < that.where.limit;
  168. that.loadend = loadend;
  169. that.loading = false;
  170. that.loadTitle = loadend ? '已全部加载' : '加载更多';
  171. that.$set(that, 'goods', goodsList);
  172. that.$set(that.where, 'page', that.where.page + 1);
  173. }).catch(err => {
  174. that.loading = false;
  175. that.goodsLoading = false;
  176. uni.showToast({
  177. title: err,
  178. icon: 'none'
  179. })
  180. });
  181. },
  182. /*关注*/
  183. focusToggle(item){
  184. let status = item.is_fans ? 0 : 1
  185. followAuthorApi(item.author.uid,{status: status}).then(res => {
  186. if (res.status === 200) {
  187. item.is_fans = item.is_fans ? false : true
  188. }
  189. this.$util.Tips({
  190. title: res.message
  191. });
  192. }).catch(err => {
  193. this.$util.Tips({
  194. title: err
  195. });
  196. });
  197. },
  198. },
  199. onReachBottom() {
  200. this.getGoods();
  201. },
  202. // 滚动监听
  203. onPageScroll(e) {
  204. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  205. uni.$emit('scroll');
  206. }
  207. }
  208. </script>
  209. <style lang="scss" scoped>
  210. @import '../style/main.scss';
  211. .main .search {
  212. padding: 20rpx 0 0 10rpx;
  213. }
  214. .main .search .input {
  215. width: 580rpx;
  216. background-color: #f7f7f7;
  217. border-radius: 33rpx;
  218. padding: 0 20rpx 0 30rpx;
  219. box-sizing: border-box;
  220. height: 66rpx;
  221. position: relative;
  222. }
  223. .main .search .input input {
  224. width: 440rpx;
  225. font-size: 28rpx;
  226. }
  227. .main .search .input .placeholder {
  228. color: #bbb;
  229. }
  230. .main .search .input .iconfont {
  231. color: #000;
  232. font-size: 35rpx;
  233. }
  234. .main .search .input .icon-guanbi1 {
  235. font-size: 32rpx;
  236. color: #cccccc;
  237. }
  238. .main .search .bnt {
  239. width: 120rpx;
  240. text-align: center;
  241. height: 66rpx;
  242. line-height: 66rpx;
  243. font-size: 28rpx;
  244. color: #282828;
  245. }
  246. .search-tabs{
  247. align-items: center;
  248. padding: 40rpx 30rpx 30rpx;
  249. .item{
  250. color: #999999;
  251. font-size: 30rpx;
  252. position: relative;
  253. +.item{
  254. margin-left: 55rpx;
  255. }
  256. &.on{
  257. color: var(--view-theme);
  258. font-size: 34rpx;
  259. font-weight: bold;
  260. &::after{
  261. content: "";
  262. display: block;
  263. width: 40rpx;
  264. height: 5rpx;
  265. background: var(--view-theme);
  266. position: absolute;
  267. left: 50%;
  268. margin-left: -20rpx;
  269. bottom: -18rpx;
  270. }
  271. }
  272. }
  273. }
  274. .author-wrap{
  275. .focusBtn{
  276. color: var(--view-theme)!important;
  277. border-color: var(--view-theme)!important;
  278. }
  279. }
  280. .main {
  281. background: #ffffff;
  282. padding: 0 20rpx;
  283. min-height: 100vh;
  284. .goods-wrap{
  285. margin-top: 20rpx;
  286. }
  287. }
  288. .goods {
  289. display: flex;
  290. flex-wrap: wrap;
  291. justify-content: space-between;
  292. }
  293. .empty-box{
  294. display: flex;
  295. flex-direction: column;
  296. justify-content: center;
  297. align-items: center;
  298. margin-top: 0;
  299. padding-top: 200rpx;
  300. image{
  301. width: 414rpx;
  302. height: 240rpx;
  303. }
  304. .txt{
  305. font-size: 26rpx;
  306. color: #999;
  307. }
  308. }
  309. </style>