|
@@ -61,10 +61,8 @@
|
|
|
<div class="searchFriendLineContent">通过账号添加</div>
|
|
|
</div> -->
|
|
|
<div class="searchFriendButton">
|
|
|
- <el-button type="primary" v-if="searchFriendList.isfriend==0||searchFriendList.isfriend==null" @click="openAddWindow(searchFriendList.id)">添加到通讯录</el-button>
|
|
|
- <el-button type="danger" v-else @click="deleteFriend(searchFriendList.id)">删除好友
|
|
|
-
|
|
|
- </el-button>
|
|
|
+ <el-button type="primary" v-if="searchFriendList.showBtn==false" @click="openAddWindow(searchFriendList.id)">添加到通讯录</el-button>
|
|
|
+ <el-button type="danger" v-if="searchFriendList.showBtn==true" @click="deleteFriend(searchFriendList)">删除好友</el-button>
|
|
|
</div>
|
|
|
<!-- <div class="searchFriendButton">
|
|
|
<div class="searchFriendButtonItem">
|
|
@@ -193,7 +191,7 @@
|
|
|
<div>删除好友</div>
|
|
|
</div> -->
|
|
|
<el-button type="primary" icon="el-icon-s-promotion" @click="sendMessage(friendInfo)">发送消息</el-button>
|
|
|
- <el-button type="danger" icon="el-icon-delete" @click="deleteFriend">删除好友</el-button>
|
|
|
+ <el-button type="danger" icon="el-icon-delete" @click="deleteFriend(friendInfo.friend_id)">删除好友</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -308,7 +306,7 @@ export default {
|
|
|
//5.发送好友申请 start------------------------------------------------------------>
|
|
|
addform:{
|
|
|
//好友id
|
|
|
- id:"",
|
|
|
+ friend_id:"",
|
|
|
//好友申请
|
|
|
remark:"",
|
|
|
},
|
|
@@ -385,14 +383,15 @@ export default {
|
|
|
if(res.data.length>0){
|
|
|
this.searchWindowStatus = true;
|
|
|
this.searchFriendList = res.data[0];
|
|
|
+ //搜出来以后查询两人是否为好友
|
|
|
+ this.searchIsFriend(this.searchFriendList)
|
|
|
+
|
|
|
}else{
|
|
|
this.$message.error('没有找到该联系人!')
|
|
|
}
|
|
|
}else{
|
|
|
this.$message.error('搜索关键字不能为空!')
|
|
|
}
|
|
|
- }).catch(() => {
|
|
|
- this.$message.error('网络错误!')
|
|
|
})
|
|
|
},
|
|
|
//1.好友列表 end------------------------------------------------------------>
|
|
@@ -415,21 +414,27 @@ export default {
|
|
|
if(res.code==200){
|
|
|
this.$message.success('成功添加好友!')
|
|
|
this.friendWindowStatus = false;
|
|
|
+ //重新加载用户列表
|
|
|
+ this.getUserFriendList();
|
|
|
+ //清空右侧
|
|
|
+ this.friendInfo = {};
|
|
|
+ this.pagestatus = 1;
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
//2.3 删除好友
|
|
|
deleteFriend(id){
|
|
|
if(id){
|
|
|
- this.editFriendId = id;
|
|
|
+ this.editFriendId = String(id);
|
|
|
}
|
|
|
+ console.log(id)
|
|
|
this.$confirm('此操作将永久删除该联系人, 是否继续?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning'
|
|
|
}).then(() => {
|
|
|
console.log(this.editFriendId);
|
|
|
- this.$store.dispatch('chat/delFriend',{id:editFriendId}).then(res=> {
|
|
|
+ this.$store.dispatch('chat/delFriend',{friend_id:this.editFriendId}).then(res=> {
|
|
|
this.$message.success('删除成功!')
|
|
|
//关闭用户详情显示
|
|
|
this.pagestatus = 1;
|
|
@@ -463,11 +468,25 @@ export default {
|
|
|
//2.5 发送好友申请
|
|
|
addMyFriend(){
|
|
|
console.log(this.addform);
|
|
|
- this.$store.dispatch('chat/applyFriend',this.addform).then(res=> {
|
|
|
- if(res.code==200){
|
|
|
- this.$message.success('成功添加好友!')
|
|
|
- this.friendWindowStatus = false;
|
|
|
+ this.$store.dispatch('chat/addFriend',this.addform).then(res=> {
|
|
|
+ this.$message.success(res.data)
|
|
|
+ this.addFriendWindowStatus = false;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //2.6 查询是否是好友
|
|
|
+ searchIsFriend(item){
|
|
|
+ let data = {
|
|
|
+ friend_id:item.isfriend
|
|
|
+ }
|
|
|
+ console.log(data);
|
|
|
+ this.$store.dispatch('chat/isFriend',data).then(res=>{
|
|
|
+ console.log(res);
|
|
|
+ if(res.code==0&&res.message=="不是好友"){
|
|
|
+ this.searchFriendList.showBtn = false;
|
|
|
+ }else{
|
|
|
+ this.searchFriendList.showBtn = true;
|
|
|
}
|
|
|
+ this.$forceUpdate();
|
|
|
})
|
|
|
},
|
|
|
//2.获得好友申请列表 end------------------------------------------------------------>
|
|
@@ -484,7 +503,8 @@ export default {
|
|
|
this.editWindowStatus = true;
|
|
|
},
|
|
|
openAddWindow(id){
|
|
|
- this.addform.id = id;
|
|
|
+ console.log(id);
|
|
|
+ this.addform.friend_id = String(id);
|
|
|
this.addFriendWindowStatus = true;
|
|
|
},
|
|
|
//发送消息
|
|
@@ -493,7 +513,7 @@ export default {
|
|
|
//带着friend_id跳转到hall页面
|
|
|
this.$router.push({
|
|
|
path:'/hall',
|
|
|
- query:{friend_id:friendInfo.user_id}
|
|
|
+ query:{friend_id:friendInfo.friend_id}
|
|
|
});
|
|
|
},
|
|
|
//3.操作弹出框 end------------------------------------------------------------>
|
|
@@ -504,6 +524,9 @@ export default {
|
|
|
this.getUserFriendList();
|
|
|
//2.获取好友申请列表
|
|
|
this.getFriendApplyList();
|
|
|
+
|
|
|
+ //打印当前用户id
|
|
|
+ console.log("当前的用户id为:" + this.$store.state.user.userid);
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
|