Skip to content

Commit

Permalink
聊天信息
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown committed Jun 14, 2017
1 parent e61b9f8 commit 2832f0a
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 62 deletions.
Binary file modified printscreen/nav.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 9 additions & 15 deletions src/frames/conversation/chatmessage/chatmessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<section class="groupchat">
<ul class="groupchat_ul clear">
<li>
<img src="../../../images/a.jpg" alt="">
<span class="ellipsis">百里辰</span>
<img :src="this.infor.headurl" alt="">
<span class="ellipsis">{{this.infor.remark ? this.infor.remark : this.infor.petname}}</span>
</li>
</ul>
</section>
Expand All @@ -32,15 +32,6 @@
<div>表情管理</div>
</li>
</ul>
<h1 class="chatrecord">聊天记录</h1>
<ul>
<li>
<div>聊天记录迁移</div>
</li>
<li>
<div>清空聊天记录</div>
</li>
</ul>
</section>
<transition name="router-show">
<router-view></router-view>
Expand All @@ -50,6 +41,7 @@

<script>
import headTop from 'src/components/header/head'
import {mapState, mapActions, mapMutations} from 'vuex';
export default{
data(){
return{
Expand All @@ -58,15 +50,17 @@
},
created(){
},
computed:{
...mapState([
"infor", "userInfo","allgroup"
]),
},
mounted(){
console.log(this.infor)
},
components:{
headTop,
},
computed:{
},
methods:{
Expand Down
36 changes: 21 additions & 15 deletions src/frames/conversation/chatmessage/groupchatmessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<ul class="groupchat_ul clear">
<li v-for="item in allPeople">
<img :src="imgurl + item.avatar" alt="">
<span class="ellipsis">{{item.username}}</span>
<span class="ellipsis">{{item.name}}</span>
</li>
</ul>
</section>
<section class="chat">
<ul>
<li>
<div>群聊名称</div>
<div class="voice-music">开饭啦~</div>
<div class="voice-music">{{gropname}}</div>
</li>
<li>
<div>群公告</div>
Expand Down Expand Up @@ -56,34 +56,39 @@
<script>
import headTop from 'src/components/header/head';
import {mapState} from 'vuex';
import {allgroup,groupChat} from 'src/service/getData';
import {imgurl} from 'src/config/env';
export default{
data(){
return{
allPeople:[]
allPeople:[],
imgurl:imgurl,
gropname:''
}
},
created(){
},
computed:{
...mapState([
"allgroup"
]),
},
mounted(){
this.$nextTick(()=>{
console.log(this.allgroup)
})
//this.allPeople=this.allGroup
allgroup().then((res)=>{
if(res.status == 200){
this.allPeople=res.users
}else{
alert("获取数据失败,请检查网络是否正常!")
}
});
groupChat().then((res) => {
this.gropname=res.petname;
//this.groupconversine=[...res.grouphead];
});
},
components:{
headTop,
},
computed:{
},
methods:{
Expand Down Expand Up @@ -121,11 +126,12 @@
img{
display:block;
width:2.048rem;
width:2.048rem;
height:2.048rem;
}
span{
display:block;
width:2.048rem;
line-height:.7rem;
font-size:0.5333333333rem;
color:#666;
text-align:center;
Expand Down
13 changes: 6 additions & 7 deletions src/frames/conversation/groupchat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
chatData:{},
imgurl,
userId:'',
allgroup:[], //所有群聊信息
allgroups:[], //所有群聊信息
}
},
created(){
Expand All @@ -159,7 +159,7 @@
//this.groupconversine=[...res.grouphead];
});
socket.on('chat', function (data) {
//console.log(data);
//console.log(data);//聊天返回内容
});
chatData().then((res) => {
this.chatData=res;
Expand All @@ -176,7 +176,7 @@
},
computed:{
...mapState([
"infor", "userInfo","allGroup"
"infor", "userInfo","allgroup"
]),
},
beforeDestroy(){
Expand Down Expand Up @@ -208,8 +208,8 @@
}
this.groupconversine = [...groupData.history, ...this.groupconversine]
this.allgroup=[...this.groupconversine]
Array.prototype.unique = function(){//去重
this.allgroups=[...this.groupconversine]
Array.prototype.unique = function(){//数组去重
var res = [this[0]];
for(var l = 1; l < this.length; l++){
var repeat = false;
Expand All @@ -225,9 +225,8 @@
}
return res;
}
var arr = this.allgroup;
var arr = this.allgroups;
this.GET_ALLGROUP(arr.unique())//保存所有人数据信息
console.log(this.allgroup)
}
this.$nextTick(() => {
Expand Down
1 change: 1 addition & 0 deletions src/service/getData.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ export const album = () => setpromise(albumData.album); //获取我的钱包
export const chatData = () => setpromise(chatmoreData.chatmore); //获取聊天页面轮播数据
export const login = data => fetch('/user/login', data); //登陆
export const getHistory = data => fetch('/chat/history', data); //聊天记录
export const allgroup = data => fetch('/user/all', data); //聊天记录
49 changes: 24 additions & 25 deletions src/vuex/mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,51 @@ import {

export default {
//记录是否电脑静音
[RECORD_MUTE](status,mutestatus){
status.mute=mutestatus;
[RECORD_MUTE](state,mutestatus){
state.mute=mutestatus;
},
//是否电脑登录
[COMPUTER_SHOW](status, computerstatus){
status.computershow=computerstatus;
[COMPUTER_SHOW](state, computerstatus){
state.computershow=computerstatus;
},
//保存联系人信息
[SAVE_MESSAGE](status, infor){
status.infor={};
status.infor=infor;
[SAVE_MESSAGE](state, infor){
state.infor={};
state.infor=infor;
},
//获取的数据先保存
[SAVE_BEGINDIALOGUE](status, arrayData){
status.contactList = arrayData;
[SAVE_BEGINDIALOGUE](state, arrayData){
state.contactList = arrayData;
},
//增加对话人列表
[SAVE_DIALOGUE](status, obj){
status.contactList=[obj, ...status.contactList];
[SAVE_DIALOGUE](state, obj){
state.contactList=[obj, ...state.contactList];

//数组去重
const newArr = new Set(status.contactList);
status.contactList = [...newArr];
const newArr = new Set(state.contactList);
state.contactList = [...newArr];
},
//获取用户信息
[GET_USERINFO](status,userInfo){
status.userInfo=userInfo
[GET_USERINFO](state,userInfo){
state.userInfo=userInfo
},
//上传主题图片
[SAVE_THEMIMG](status,{
[SAVE_THEMIMG](state,{
newImg,
imagestatus
}){
status.newImg=newImg;
status.imagestatus=imagestatus
state.newImg=newImg;
state.imagestatus=imagestatus
},
//改变朋友圈红色提醒显隐
[CHANGE_RED](status,firendwarn){
status.firendwarn=firendwarn;
[CHANGE_RED](state,firendwarn){
state.firendwarn=firendwarn;
},
[LOGIN_COVER](status,consumerthing){
status.consumerthing=consumerthing;
[LOGIN_COVER](state,consumerthing){
state.consumerthing=consumerthing;
},
//获取所有群聊人信息
[GET_ALLGROUP](status,allgroup){
status.allgroup=allgroup
console.log(status.allgroup)
[GET_ALLGROUP](state,allgroup){
state.allgroup=allgroup
}
}

0 comments on commit 2832f0a

Please sign in to comment.