index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <view>
  3. <view class="main">
  4. <view class="tab-cont">
  5. <view v-if="featuredList.length" class="follow_count">
  6. <block v-for="(item, index) in featuredList" :key="index">
  7. <view class="list_count">
  8. <view v-if="item.author" class="title">
  9. <view class="author">
  10. <image class="picture" :src="item.author.avatar || '/static/images/f.png'"></image>
  11. <text class="name">{{item.author.nickname}}</text>
  12. </view>
  13. <view @click="followAuthor(item)">
  14. <view v-if="!item.relevance_id" class="follow focus">
  15. <text class="iconfont icon-jiahao2"></text>关注
  16. </view>
  17. <view v-else class="follow focused">已关注</view>
  18. </view>
  19. </view>
  20. <view class="product">
  21. <productConSwiper :imgUrls="item.image"></productConSwiper>
  22. </view>
  23. <view class="pro_describle">
  24. <view class="mentioned" v-if="item.relevance.length>0" @click="openMore(item)">
  25. <text class="title">查看TA提到的宝贝({{item.relevance.length}})</text>
  26. <view class="product_more">
  27. <view class="item">
  28. <image v-for="(itemn, indexn) in item.relevance" :key="indexn" :src="(itemn.spu&&itemn.spu.image)||itemn.image" class="more_image"></image>
  29. </view>
  30. <text class="iconfont icon-gengduo3"></text>
  31. </view>
  32. </view>
  33. <view class="product_info">
  34. <text class="text">
  35. {{item.content}}
  36. </text>
  37. <text class="unfold_btn">展开</text>
  38. </view>
  39. <navigator v-if="item.topic" hover-class="none" class="product_cate" :url="'/pages/plantGrass/plant_search_list/index?id='+item.topic.topic_id">
  40. <view>
  41. <text class="icon">#</text><text class="text">{{item.topic.topic_name}}</text>
  42. </view>
  43. </navigator>
  44. <view class="foot_bar">
  45. <view class="item iconfont icon-fenxiang2"></view>
  46. <view class="item">
  47. <view class="item_count" @click.stop="likeToggle(item)">
  48. <text class="iconfont" :class="item.relevance_id ? 'icon-shoucang1' : 'icon-dianzan'"></text>
  49. <text>{{item.count_start > 0 ? item.count_start : '点赞'}}</text>
  50. </view>
  51. <view class="item_count" @click="openCommon(item,index)">
  52. <text class="iconfont icon-pinglun"></text>
  53. <text>{{item.count_reply ? item.count_reply : '评论'}}</text>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </block>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 他提到的宝贝弹窗 -->
  64. <uni-popup ref="mentioned" type="bottom">
  65. <mentioned @close="close" :list="moreList"></mentioned>
  66. </uni-popup>
  67. <!-- 评论弹窗 -->
  68. <comment ref="comment" :isShow="showComment" @close="close" @successFul="commentSucces"></comment>
  69. </view>
  70. </template>
  71. <script>
  72. // +----------------------------------------------------------------------
  73. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  74. // +----------------------------------------------------------------------
  75. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  76. // +----------------------------------------------------------------------
  77. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  78. // +----------------------------------------------------------------------
  79. // | Author: CRMEB Team <admin@crmeb.com>
  80. // +----------------------------------------------------------------------
  81. import WaterfallsFlow from '@/components/plantWaterfallsFlow/WaterfallsFlow.vue'
  82. import mentioned from '@/components/mentioned.vue';
  83. import comment from '@/components/comment.vue';
  84. import {graphicLstApi, graphicStartApi, followAuthorApi} from '@/api/community.js';
  85. import { getUserInfo } from '@/api/user.js';
  86. import { mapGetters } from "vuex";
  87. import productConSwiper from '@/components/productConSwiper';
  88. const app = getApp();
  89. export default {
  90. components: {
  91. WaterfallsFlow,
  92. productConSwiper,
  93. mentioned,
  94. comment
  95. },
  96. data() {
  97. return {
  98. featuredList: [], // 商铺商品
  99. moreList: [],
  100. commList: [], //评论列表
  101. loading: false,
  102. loaded: false,
  103. loadTitle: '加载更多',
  104. where: {
  105. topic_id: '',
  106. page: 1,
  107. limit: 30
  108. },
  109. showComment: false,
  110. }
  111. },
  112. created() {
  113. },
  114. computed: {
  115. ...mapGetters(['isLogin']),
  116. },
  117. watch: {
  118. },
  119. onLoad: function(options) {
  120. this.where.topic_id = options.id
  121. this.getList();
  122. },
  123. onShow() {
  124. },
  125. mounted: function() {
  126. },
  127. methods: {
  128. // 获取关注商品
  129. getList: function() {
  130. let that = this;
  131. if (that.loaded || that.loading) return;
  132. that.loading = true;
  133. that.loadTitle = '';
  134. graphicLstApi(that.where).then(res => {
  135. that.loading = false;
  136. let list = res.data.list;
  137. let featuredList = that.$util.SplitArray(list, that.featuredList);
  138. that.loaded = list.length < that.where.limit;
  139. that.loadTitle = loaded ? '已全部加载' : '加载更多';
  140. that.$set(that, 'featuredList', featuredList);
  141. that.$set(that.where, 'page', that.where.page + 1);
  142. }).catch(err => {
  143. that.loading = false;
  144. uni.showToast({
  145. title: err,
  146. icon: 'none'
  147. })
  148. });
  149. },
  150. likeToggle(item){
  151. let status = item.relevance_id ? 0 : 1
  152. graphicStartApi(item.community_id,{status: status}).then(res => {
  153. if(item.relevance_id){
  154. item.count_start--;
  155. item.count_start = item.count_start == 0 ? 0 : item.count_start
  156. item.relevance_id = false
  157. }else{
  158. item.count_start++;
  159. item.relevance_id = true
  160. }
  161. });
  162. },
  163. // 关注作者
  164. followAuthor: function(item) {
  165. let status = item.relevance_id ? 0 : 1
  166. followAuthorApi(item.uid,{status: status}).then(res => {
  167. if (res.status === 200) {
  168. item.relevance_id = item.relevance_id ? false : true
  169. }
  170. this.$util.Tips({
  171. title: res.message
  172. });
  173. });
  174. },
  175. /*查看提到的宝贝*/
  176. openMore(item){
  177. this.$refs.mentioned.open();
  178. this.moreList = item.relevance;
  179. },
  180. openCommon(item,index){
  181. this.showComment = true
  182. this.$refs.comment.getData(item,index);
  183. },
  184. commentSucces(index){
  185. this.featuredList[index]['count_reply']++
  186. },
  187. close(){
  188. this.$refs.mentioned.close();
  189. this.showComment = false;
  190. }
  191. },
  192. onReachBottom() {
  193. this.getList();
  194. },
  195. onPullDownRefresh(){
  196. }
  197. }
  198. </script>
  199. <style lang="scss" scoped>
  200. .main{
  201. background: #ffffff;
  202. min-height: 100vh;
  203. }
  204. .tab-cont{
  205. background: #fff;
  206. border-radius: 16rpx 16rpx 0 0;
  207. }
  208. .follow_count{
  209. padding: 20rpx;
  210. .list_count{
  211. margin-bottom: 70rpx;
  212. }
  213. .title{
  214. display: flex;
  215. align-items: center;
  216. justify-content: space-between;
  217. }
  218. .author{
  219. display: flex;
  220. align-items: center;
  221. .picture, uni-image{
  222. width: 78rpx;
  223. height: 78rpx;
  224. border-radius: 100%;
  225. }
  226. .name{
  227. margin-left: 20rpx;
  228. color: #333333;
  229. font-size: 32rpx;
  230. font-weight: bold;
  231. }
  232. }
  233. .follow{
  234. margin-right: 10rpx;
  235. width: 112rpx;
  236. text-align: center;
  237. line-height: 42rpx;
  238. font-size: 22rpx;
  239. border-radius: 33rpx;
  240. &.focus{
  241. color: #E93323;
  242. border: 1px solid #E93323;
  243. .iconfont{
  244. font-size: 15rpx;
  245. margin-right: 5rpx;
  246. }
  247. }
  248. &.focused{
  249. background: #EEEEEE;
  250. border: 1px solid #EEEEEE;
  251. color: #999999;
  252. }
  253. }
  254. .product{
  255. margin-top: 20rpx;
  256. border-radius: 16rpx;
  257. }
  258. }
  259. .pro_describle{
  260. .mentioned{
  261. padding: 20rpx 0;
  262. display: flex;
  263. align-items: center;
  264. justify-content: space-between;
  265. border-bottom: 1px solid #F5F5F5;
  266. .title{
  267. color: #666666;
  268. font-size: 26rpx;
  269. }
  270. }
  271. .product_more{
  272. max-width: 360rpx;
  273. display: flex;
  274. align-items: center;
  275. .more_image{
  276. width: 58rpx;
  277. height: 58rpx;
  278. border-radius: 5rpx;
  279. border: 1px solid #BBBBBB;
  280. margin-right: 12rpx;
  281. }
  282. .iconfont{
  283. color: #CCCCCC;
  284. margin-left: 10rpx;
  285. }
  286. }
  287. .product_info{
  288. line-height: 45rpx;
  289. margin: 20rpx 0;
  290. .text{
  291. font-size: 28rpx;
  292. color: #282828;
  293. }
  294. .unfold_btn{
  295. margin-left: 30rpx;
  296. font-size: 30rpx;
  297. color: #282828;
  298. font-weight: bold;
  299. }
  300. }
  301. .product_cate{
  302. margin: 20rpx 0;
  303. display: inline-block;
  304. >view{
  305. display: flex;
  306. align-items: center;
  307. background: #FFF3F2;
  308. border-radius: 30rpx;
  309. padding: 0 25rpx;
  310. line-height: 56rpx;
  311. height: 56rpx;
  312. color: #E93323;
  313. .text{
  314. font-size: 28rpx;
  315. }
  316. .icon{
  317. font-size: 35rpx;
  318. font-weight: bold;
  319. margin-right: 10rpx;
  320. }
  321. }
  322. }
  323. .foot_bar{
  324. display: flex;
  325. align-items: center;
  326. justify-content: space-between;
  327. .item{
  328. display: flex;
  329. align-items: center;
  330. color: #282828;
  331. &.icon-fenxiang2{
  332. font-size: 46rpx;
  333. }
  334. }
  335. .item_count{
  336. font-size: 26rpx;
  337. display: flex;
  338. align-items: center;
  339. &:first-child{
  340. margin-right: 30rpx;
  341. }
  342. .iconfont{
  343. font-size: 40rpx;
  344. margin-right: 5rpx;
  345. }
  346. .icon-shoucang1{
  347. color: #E93323;
  348. }
  349. }
  350. }
  351. }
  352. </style>