|
|
@@ -7,12 +7,17 @@
|
|
|
<template>
|
|
|
<div class="page">
|
|
|
<div class="chat-list" @click="showAttach = false">
|
|
|
- <div class="product">
|
|
|
+ <!-- <div class="product">
|
|
|
<product-info :showBtn="false"></product-info>
|
|
|
- </div>
|
|
|
- <chat-info></chat-info>
|
|
|
- <chat-info isMine></chat-info>
|
|
|
- <chat-info isMine contentType="image"></chat-info>
|
|
|
+ </div> -->
|
|
|
+ <chat-info
|
|
|
+ v-for="(item, index) in list"
|
|
|
+ :key="index"
|
|
|
+ :info="item"
|
|
|
+ :isMine="userInfo && item.sendId === userInfo.id"
|
|
|
+ ></chat-info>
|
|
|
+ <!-- <chat-info isMine></chat-info>
|
|
|
+ <chat-info isMine contentType="image"></chat-info> -->
|
|
|
</div>
|
|
|
|
|
|
<div class="bottom-box">
|
|
|
@@ -39,19 +44,23 @@
|
|
|
<script>
|
|
|
import ChatInfo from '@/components/ChatInfo';
|
|
|
import ProductInfo from '@/components/ProductInfo';
|
|
|
+import { mapState } from 'vuex';
|
|
|
export default {
|
|
|
name: 'Chat',
|
|
|
components: {
|
|
|
- ChatInfo,
|
|
|
- ProductInfo
|
|
|
+ ChatInfo
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
message: '',
|
|
|
- showAttach: false
|
|
|
+ showAttach: false,
|
|
|
+ topicInfo: null,
|
|
|
+ list: [],
|
|
|
+ toUserId: 0
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
+ ...mapState(['userInfo']),
|
|
|
attachHeight() {
|
|
|
return this.showAttach ? 114 : 0;
|
|
|
}
|
|
|
@@ -62,12 +71,56 @@ export default {
|
|
|
title: options.toName
|
|
|
});
|
|
|
}
|
|
|
+ if (options.toUserId) {
|
|
|
+ this.toUserId = options.toUserId;
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
+ loginMethods() {
|
|
|
+ this.$http
|
|
|
+ .post('/topic/newTopic', {
|
|
|
+ targetId: this.toUserId
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ this.topicInfo = res;
|
|
|
+ return this.getList();
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ // this.newMessage('欢迎管理本店,小店客服会尽快为您提供服务。', false, 'TEXT', true);
|
|
|
+ });
|
|
|
+ },
|
|
|
sendImg() {
|
|
|
this.choosePhoto().then(res => {
|
|
|
console.log(res);
|
|
|
});
|
|
|
+ },
|
|
|
+ getList() {
|
|
|
+ return this.$http
|
|
|
+ .get('/message/findTopicMessages', {
|
|
|
+ topicId: this.topicInfo.id
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ this.list = res;
|
|
|
+ return Promise.resolve();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ newMessage(info, isSend = true, messageType = 'TEXT', beenRead = false) {
|
|
|
+ let data = {
|
|
|
+ topicId: this.topicInfo.id,
|
|
|
+ info: info,
|
|
|
+ messageType: messageType,
|
|
|
+ beenRead: beenRead
|
|
|
+ };
|
|
|
+ if (isSend) {
|
|
|
+ data.sendId = this.$store.state.userInfo.id;
|
|
|
+ data.resId = this.toUserId;
|
|
|
+ } else {
|
|
|
+ data.sendId = this.toUserId;
|
|
|
+ data.resId = this.$store.state.userInfo.id;
|
|
|
+ }
|
|
|
+ this.$http.postJson('/message/save', data).then(res => {
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
};
|