Pārlūkot izejas kodu

社区模块对接完成

zxl 1 gadu atpakaļ
vecāks
revīzija
7500871a31
3 mainītis faili ar 282 papildinājumiem un 198 dzēšanām
  1. 1 1
      README.md
  2. 246 181
      src/components/communityPop/index.vue
  3. 35 16
      src/pages/client/tabBar/community/index.vue

+ 1 - 1
README.md

@@ -24,7 +24,7 @@ See [Configuration Reference](https://cli.vuejs.org/config/).
 
 ### 地址
 http://apidoc.chelvc.com/admin/
-http://apidoc.chelvc.com/maintain/
+http://apidoc.chelvc.com/
 
 wangzhongqing 564342
 

+ 246 - 181
src/components/communityPop/index.vue

@@ -1,189 +1,254 @@
 <template>
-	<view class="container">
-		<u-sticky>
-			<view class="pop-top">
-				<view class="top-box">
-					<view class="top-black-box"></view>
-				</view>
-				<view class="top-title"> 1244条回复 </view>
-			</view>
-		</u-sticky>
-
-		<view class="center-box">
-			<view class="center-item" v-for="item of 7">
-				<view class="item-top">
-					<view class="top-left">
-						<view class="top-img">
-							<image src="@/static/QR57a.jpg" class="img" mode=""></image>
-						</view>
-						<view class="top-text">
-							<view class="text-title">测试名称</view>
-							<view class="text-address"> 2天前 山东潍坊</view>
-						</view>
-					</view>
-					<view class="top-right">
-						<u-icon name="heart" size="22"></u-icon>
-					</view>
-				</view>
-
-				<view class="item-text">
-					啊水泡车【卡擦【帕克我看篇v喵帕斯【普外科哦v骄傲【什么码数来看是卡拉瓦乔扣篮十多年可怜那棵老派的尼克拉斯你的卡拉省的
-				</view>
-			</view>
-		</view>
-
-		<view class="bottom-box">
-			<view class="bottom-item">
-				<view class="item-left">
-					<u--input
-					    placeholder="写回复"
-					    border="surround"
-					    v-model="value"
-						shape='circle'
-						customStyle="background-color:#F2F2F2"
-					  ></u--input>
-				</view>
-				<view class="item-right">
-					<button @click="handlerPopPublishBtn" class="btn">发布</button>
-				</view>
-			</view>
-		</view>
-	</view>
+  <view class="container">
+    <u-sticky>
+      <view class="pop-top">
+        <view class="top-box">
+          <view class="top-black-box"></view>
+        </view>
+        <view class="top-title"> {{ total }}条回复 </view>
+      </view>
+    </u-sticky>
+
+    <view class="center-box">
+      <view class="center-item" v-for="(item,index) of init_list">
+        <view class="item-top">
+          <view class="top-left">
+            <view class="top-img">
+              <image :src="item.userDTO.avatar" class="img" mode=""></image>
+            </view>
+            <view class="top-text">
+              <view class="text-title">{{ item.userDTO.nickname }}</view>
+              <view class="text-address"> 2天前 山东潍坊</view>
+            </view>
+          </view>
+          <view class="top-right">
+            <u-icon :name="item.clickStatus == 0 ? 'heart' : 'heart-fill'" size='22' @click='handlerFocus(item)'></u-icon>
+          </view>
+        </view>
+
+        <view class="item-text"> {{ item.content }} </view>
+      </view>
+    </view>
+
+    <empty v-if="total == 0" />
+
+    <view class="bottom-box">
+      <view class="bottom-item">
+        <view class="item-left">
+          <u--input placeholder="写回复" border="surround" v-model="content" shape='circle'
+            customStyle="background-color:#F2F2F2"></u--input>
+        </view>
+        <view class="item-right">
+          <button @click="handlerPopPublishBtn" class="btn">发布</button>
+        </view>
+      </view>
+    </view>
+  </view>
 </template>
 
 <script>
-	export default {
-		data() {
-			return {
-				value:''
-			}
-		},
-		methods:{
-			// 发布评论
-			handlerPopPublishBtn(){
-
-			}
-		}
-	}
+  import { addClientComment, clientCommentList } from "@/api/client/message.js"
+  import { addEvaulateRecords } from '@/api/client/community.js';
+  import empty from "@/components/empty/index.vue"
+  export default {
+    components:{empty},
+    data() {
+      return {
+        content: '',
+        init_list: [],
+        total:0
+      }
+    },
+    props: ['dynamicId', 'dynamicUserId'],
+    watch: {
+      dynamicId(newValue) {
+        if(newValue != null){
+          this.handlerInitList()
+        }
+      }
+    },
+    methods: {
+      // 初始化评论列表
+      handlerInitList() {
+        let params = {
+          dynamicId: this.dynamicId,
+          parentId: 0,
+          userId: this.dynamicUserId,
+        }
+        clientCommentList(params).then(res => {
+          this.init_list = res.data.records
+          this.total = res.data.total
+        })
+      },
+      // 发布评论
+      handlerPopPublishBtn() {
+        let params = {
+          dynamicId: this.dynamicId,
+          parentId: 0,
+          content: this.content,
+          status: 0
+        }
+        addClientComment(params).then(res => {
+          if (res.code == 200) {
+            uni.showToast({
+              title: '发布成功',
+              icon: 'none'
+            })
+            this.content = ''
+            this.handlerInitList()
+            this.$emit('uploadComment')
+          }
+        })
+      },
+      // 关注按钮
+      handlerFocus(item){
+        let params = {
+          dynamicStatusType: 'GOOD', // 操作类型:1-点赞;2-踩 允许值: GOOD, BAD
+          recordType: 'COMMENT', // 内容类型:1-动态;2-评论/回复 允许值: DYNAMIC, COMMENT, USER
+          actionType: item.clickStatus == 0 ? 'ADD' : 'CANCEL', // 点击类型:1-点赞/踩;2-取消赞/取消踩   允许值: ADD, CANCEL
+          contentId: item.id,
+          targetUserId: item.userId
+        }
+        addEvaulateRecords(params).then(res => {
+          if (res.code == 200) {
+            uni.showToast({
+              title: '关注成功',
+              icon: 'none'
+            })
+            this.handlerInitList()
+          } else {
+            uni.showToast({
+              title: res.msg,
+              icon: 'none'
+            })
+            return
+          }
+        })
+      }
+    }
+  }
 </script>
 
 <style lang="scss" scoped>
-	.container {
-		height: 70vh;
-		overflow-y: auto;
-		box-sizing: border-box;
-		padding-bottom: 120rpx;
-
-		.pop-top {
-			background-color: #fff;
-			border-radius: 40rpx;
-			padding: 20rpx 0;
-		}
-
-		.top-box {
-			display: flex;
-			justify-content: center;
-
-			.top-black-box {
-				width: 10%;
-				height: 10rpx;
-				background-color: #000;
-				border-radius: 10%;
-			}
-		}
-
-		.top-title {
-			font-size: 32rpx;
-			font-weight: bold;
-			color: #000;
-			text-align: center;
-			margin-top: 20rpx;
-			letter-spacing: 2rpx;
-		}
-
-		.center-box {
-			margin-bottom: 20rpx;
-			padding: 0 20rpx;
-
-			.center-item {
-				margin-bottom: 40rpx;
-				border-radius: 20rpx;
-				.item-top {
-					display: flex;
-					justify-content: space-between;
-					align-items: center;
-
-					.top-left {
-						display: flex;
-						align-items: center;
-
-						.top-img {
-							.img {
-								width: 80rpx;
-								height: 80rpx;
-								border-radius: 50%;
-							}
-						}
-
-						.top-text {
-							display: flex;
-							flex-direction: column;
-							justify-content: space-around;
-							margin-left: 10rpx;
-
-							.text-title {
-								font-weight: bold;
-								font-size: 32rpx;
-								color: #000;
-							}
-
-							.text-address {
-								color: #8f8f8f;
-								font-size: 24rpx;
-							}
-						}
-					}
-				}
-
-				.item-text {
-					margin-top: 20rpx;
-					padding: 0 40rpx;
-				}
-			}
-		}
-
-		.bottom-box {
-			position: absolute;
-			bottom: 0;
-			background-color: #fff;
-			width: 100%;
-			height: 150rpx;
-
-			.bottom-item {
-				display: flex;
-				justify-content: space-around;
-				padding: 10rpx 20rpx 0;
-				box-sizing: border-box;
-				align-items: center;
-				.item-left{
-					width: 60%;
-					height: 70rpx;
-				}
-				.item-right{
-					width: 30%;
-					padding: 20rpx;
-					.btn{
-						border-radius: 20rpx;
-						text-align: center;
-						color: #fff;
-						background: linear-gradient(to right, #e8cbc0, #636fa4);
-						height: 70rpx;
-						font-size: 28rpx;
-						line-height: 70rpx;
-					}
-				}
-			}
-		}
-	}
-
+  .container {
+    height: 70vh;
+    overflow-y: auto;
+    box-sizing: border-box;
+    padding-bottom: 120rpx;
+
+    .pop-top {
+      background-color: #fff;
+      border-radius: 40rpx;
+      padding: 20rpx 0;
+    }
+
+    .top-box {
+      display: flex;
+      justify-content: center;
+
+      .top-black-box {
+        width: 10%;
+        height: 10rpx;
+        background-color: #000;
+        border-radius: 10%;
+      }
+    }
+
+    .top-title {
+      font-size: 32rpx;
+      font-weight: bold;
+      color: #000;
+      text-align: center;
+      margin-top: 20rpx;
+      letter-spacing: 2rpx;
+    }
+
+    .center-box {
+      margin-bottom: 20rpx;
+      padding: 0 20rpx;
+
+      .center-item {
+        margin-bottom: 40rpx;
+        border-radius: 20rpx;
+
+        .item-top {
+          display: flex;
+          justify-content: space-between;
+          align-items: center;
+
+          .top-left {
+            display: flex;
+            align-items: center;
+
+            .top-img {
+              .img {
+                width: 80rpx;
+                height: 80rpx;
+                border-radius: 50%;
+              }
+            }
+
+            .top-text {
+              display: flex;
+              flex-direction: column;
+              justify-content: space-around;
+              margin-left: 10rpx;
+
+              .text-title {
+                font-weight: bold;
+                font-size: 32rpx;
+                color: #000;
+              }
+
+              .text-address {
+                color: #8f8f8f;
+                font-size: 24rpx;
+              }
+            }
+          }
+        }
+
+        .item-text {
+          margin-top: 20rpx;
+          padding: 0 40rpx;
+        }
+      }
+    }
+
+    .bottom-box {
+      position: absolute;
+      bottom: 0;
+      background-color: #fff;
+      width: 100%;
+      height: 150rpx;
+
+      .bottom-item {
+        display: flex;
+        justify-content: space-around;
+        padding: 10rpx 20rpx 0;
+        box-sizing: border-box;
+        align-items: center;
+
+        .item-left {
+          width: 60%;
+          height: 70rpx;
+        }
+
+        .item-right {
+          width: 30%;
+          padding: 20rpx;
+
+          .btn {
+            border-radius: 20rpx;
+            text-align: center;
+            color: #fff;
+            background: linear-gradient(to right, #e8cbc0, #636fa4);
+            height: 70rpx;
+            font-size: 28rpx;
+            line-height: 70rpx;
+          }
+        }
+      }
+    }
+  }
 </style>

+ 35 - 16
src/pages/client/tabBar/community/index.vue

@@ -40,10 +40,10 @@
         </view>
         <view class="item-bottom">
           <view class="bottom-item">
-            <u-icon :name="item.clickStatus == 0 ? 'thumb-up' : 'thumb-up-fill'" :size='iconSize'
+            <u-icon :name="item.clickStatus == 0 ? 'heart' : 'heart-fill'" :size='iconSize'
               @click='handlerPraise(item)'></u-icon><span>{{ item.goodNum }}</span>
           </view>
-          <view class="bottom-item" @click='communityShow = true'>
+          <view class="bottom-item" @click='handlerRequireComment(item)'>
             <u-icon name="more-circle" :size='iconSize'></u-icon><span>{{ item.commentNum }}</span>
           </view>
         </view>
@@ -63,7 +63,7 @@
 
     <u-popup :show="communityShow" @close="communityShow = false" mode='bottom' overlayOpacity='0.1' round="20">
       <view class="pop-box">
-        <communityPop />
+        <communityPop :dynamicId='dynamicId' :dynamicUserId='dynamicUserId' @uploadComment='uploadComment'/>
       </view>
     </u-popup>
 
@@ -72,13 +72,8 @@
 </template>
 
 <script>
-  import {
-    clientContentList,
-    addEvaulateRecords
-  } from '@/api/client/community.js';
-  import {
-    intervalTime
-  } from "@/utils/tools.js"
+  import { clientContentList, addEvaulateRecords } from '@/api/client/community.js';
+  import { intervalTime } from "@/utils/tools.js"
   import communityPop from "@/components/communityPop/index.vue"
   import empty from "@/components/empty/index.vue"
   export default {
@@ -111,12 +106,26 @@
           keyWord: '',
         },
         initList: [], // 初始化列表
+        userId: '',
+        dynamicId: 0,
+        dynamicUserId: 0,
       }
     },
     onShow() {
       this.handlerInitList()
       // let a = intervalTime(1709797137000)
     },
+    watch:{
+      communityShow(newValue){
+        if(!newValue){
+          this.dynamicId = null
+          this.dynamicUserId = null
+        }
+      }
+    },
+    mounted() {
+      this.userId = this.$store.state.user.userMessage.id
+    },
     methods: {
       handlerInitList() {
         clientContentList(this.params).then(res => {
@@ -151,7 +160,7 @@
       // 点赞按钮
       handlerPraise(item) {
         let params = {
-          dynamicStatusType: item.clickStatus == 0 ? 'GOOD' : 'BAD', // 操作类型:1-点赞;2-踩 允许值: GOOD, BAD
+          dynamicStatusType: 'GOOD', // 操作类型:1-点赞;2-踩 允许值: GOOD, BAD
           recordType: 'DYNAMIC', // 内容类型:1-动态;2-评论/回复 允许值: DYNAMIC, COMMENT, USER
           actionType: item.clickStatus == 0 ? 'ADD' : 'CANCEL', // 点击类型:1-点赞/踩;2-取消赞/取消踩   允许值: ADD, CANCEL
           contentId: item.id,
@@ -160,18 +169,28 @@
         addEvaulateRecords(params).then(res => {
           if (res.code == 200) {
             uni.showToast({
-              title:'点赞成功',
-              icon:'none'
+              title: '关注成功',
+              icon: 'none'
             })
             this.handlerInitList()
-          }else{
+          } else {
             uni.showToast({
-              title:res.msg,
-              icon:'none'
+              title: res.msg,
+              icon: 'none'
             })
             return
           }
         })
+      },
+      // 查询动态评论
+      handlerRequireComment(item) {
+        this.dynamicId = item.id
+        this.dynamicUserId = item.userId
+        this.communityShow = true
+      },
+      // 动态发布评论后 更新list
+      uploadComment(){
+        this.handlerInitList()
       }
     }
   }