|
@@ -4,8 +4,8 @@
|
|
|
<el-col :span="24" class="info chat_frame" id="chat">
|
|
|
<template v-for="(i, index) in talk">
|
|
|
<template v-if="isSender(i, index)">
|
|
|
- <span :key="`senderTime${i.id}${index}`">[{{ i.send_time }}] {{ i.sender_name }}</span>
|
|
|
- <span v-html="i.content" :key="`senderContent${i.id}${index}`"></span>
|
|
|
+ <span style="text-align:right" :key="`senderTime${i.id}${index}`">[{{ i.send_time }}] {{ i.sender_name }}</span>
|
|
|
+ <span style="text-align:right" v-html="i.content" :key="`senderContent${i.id}${index}`"></span>
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
<span :key="`receverTime${i.id}${index}`">[{{ i.send_time }}] {{ i.receiver_name }}</span>
|
|
@@ -54,7 +54,7 @@ export default {
|
|
|
if (this.content != '') {
|
|
|
let obj = { personroom_id: this.room.id, content: this.content, sender_id: this.user.uid, sender_name: this.user.name, send_time: '13:00' };
|
|
|
let keys = Object.keys(this.room);
|
|
|
- let fres = keys.filter(f => this.room[f] == this.user.uid);
|
|
|
+ let fres = keys.find(f => this.room[f] == this.user.uid);
|
|
|
obj.receiver_id = fres === 'buyer_id' ? this.room['seller_id'] : this.room['buyer_id'];
|
|
|
obj.receiver_name = fres === 'buyer_id' ? this.room['seller_name'] : this.room['buyer_name'];
|
|
|
let res = await this.create(obj);
|
|
@@ -62,6 +62,7 @@ export default {
|
|
|
this.$set(this, `content`, '');
|
|
|
this.$forceUpdate();
|
|
|
if (this.$checkRes(res, null, res.errmsg || '发言失败')) {
|
|
|
+ console.log(`in 交易 chat`);
|
|
|
this.talk.push(res.data);
|
|
|
this.turnBottom();
|
|
|
}
|
|
@@ -73,22 +74,20 @@ export default {
|
|
|
console.warn('未获取到房间id,无法进行订阅');
|
|
|
return;
|
|
|
}
|
|
|
+ console.log(`this.user.uid`);
|
|
|
+ console.log(this.user.uid);
|
|
|
+ console.log(`${this.room.id}_${this.user.uid}`);
|
|
|
this.$stomp({
|
|
|
[`/exchange/person_chat/${this.room.id}_${this.user.uid}`]: this.onMessage,
|
|
|
});
|
|
|
},
|
|
|
onMessage(message) {
|
|
|
+ console.log(`in 交易 message`);
|
|
|
let body = _.get(message, 'body');
|
|
|
if (body) {
|
|
|
body = JSON.parse(body);
|
|
|
- console.log(body);
|
|
|
- // let is_seller = this.sellerList.find(f => f.user_id == body.sender_id);
|
|
|
- // if (is_seller) this.mainTalk.push({ id: body._id, sender_name: body.sender_name, send_time: body.send_time, content: body.content });
|
|
|
- // else this.otherTalk.push({ id: body._id, sender_name: body.sender_name, send_time: body.send_time, content: body.content });
|
|
|
- this.$nextTick(() => {
|
|
|
- // document.getElementById('chatBuy').scrollTop = document.getElementById('chatBuy').scrollHeight + 150;
|
|
|
- // document.getElementById('chat').scrollTop = document.getElementById('chat').scrollHeight + 150;
|
|
|
- });
|
|
|
+ this.talk.push(body);
|
|
|
+ this.turnBottom();
|
|
|
}
|
|
|
},
|
|
|
turnBottom() {
|
|
@@ -97,7 +96,7 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
isSender(data) {
|
|
|
- return this.user.uid == data.sender_id;
|
|
|
+ return this.user.uid != data.sender_id;
|
|
|
},
|
|
|
},
|
|
|
watch: {
|