|
@@ -11,14 +11,12 @@
|
|
<el-col :span="16" class="right" v-else>
|
|
<el-col :span="16" class="right" v-else>
|
|
<right-1
|
|
<right-1
|
|
:chatRecordList="chatRecordList"
|
|
:chatRecordList="chatRecordList"
|
|
- :address="address"
|
|
|
|
:customer="customer"
|
|
:customer="customer"
|
|
:shop="shop"
|
|
:shop="shop"
|
|
@toUp="toUp"
|
|
@toUp="toUp"
|
|
@onSubmit="onSubmit"
|
|
@onSubmit="onSubmit"
|
|
:form="form"
|
|
:form="form"
|
|
:srcList="srcList"
|
|
:srcList="srcList"
|
|
- :add="add"
|
|
|
|
></right-1>
|
|
></right-1>
|
|
</el-col>
|
|
</el-col>
|
|
</el-col>
|
|
</el-col>
|
|
@@ -90,7 +88,7 @@ export default {
|
|
methods: {
|
|
methods: {
|
|
...users({ userFetch: 'fetch' }),
|
|
...users({ userFetch: 'fetch' }),
|
|
...address({ addFetch: 'fetch' }),
|
|
...address({ addFetch: 'fetch' }),
|
|
- ...room({ roomQuery: 'query', roomFetch: 'fetch' }),
|
|
|
|
|
|
+ ...room({ roomQuery: 'query', roomFetch: 'fetch', roomDelete: 'delete' }),
|
|
...chatRecord(['query', 'delete', 'fetch', 'update', 'create', 'read']),
|
|
...chatRecord(['query', 'delete', 'fetch', 'update', 'create', 'read']),
|
|
// 查询
|
|
// 查询
|
|
async search() {
|
|
async search() {
|
|
@@ -100,45 +98,51 @@ export default {
|
|
},
|
|
},
|
|
// 订单和售后跳转页面,联系买家
|
|
// 订单和售后跳转页面,联系买家
|
|
async searchDetail() {
|
|
async searchDetail() {
|
|
- let res = await this.userFetch(this.customer_id);
|
|
|
|
- if (this.$checkRes(res)) this.$set(this, `customer`, res.data);
|
|
|
|
- res = await this.roomQuery({ customer: this.customer_id });
|
|
|
|
- if (this.$checkRes(res)) this.toView(res.data[0]);
|
|
|
|
- // res = await this.addFetch(this.address_id);
|
|
|
|
- // if (this.$checkRes(res)) this.$set(this, `address`, res.data);
|
|
|
|
- this.show = '1';
|
|
|
|
- this.add = '1';
|
|
|
|
|
|
+ let res = await this.roomQuery({ customer: this.customer_id, shop: this.user.shop._id });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ if (res.total > 0) this.toView(res.data[0]);
|
|
|
|
+ else {
|
|
|
|
+ let aee = await this.userFetch(this.customer_id);
|
|
|
|
+ if (this.$checkRes(aee)) {
|
|
|
|
+ let data = { customer: aee.data, shop: this.user.shop };
|
|
|
|
+ this.toView(data);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
},
|
|
},
|
|
// 查看
|
|
// 查看
|
|
async toView(data) {
|
|
async toView(data) {
|
|
- this.$set(this, `customer`, data.customer);
|
|
|
|
- this.$set(this, `shop`, data.shop);
|
|
|
|
- this.$set(this, `form`, { room: data._id });
|
|
|
|
- // 处理已读
|
|
|
|
- let list = [];
|
|
|
|
- let res = await this.query({ room: data._id });
|
|
|
|
- if (this.$checkRes(res)) {
|
|
|
|
|
|
+ if (this.customer._id != data.customer._id) this.$set(this, `customer`, data.customer);
|
|
|
|
+ if (data._id) {
|
|
|
|
+ this.$set(this, `form`, { room: data._id });
|
|
// 处理已读
|
|
// 处理已读
|
|
- for (const p1 of res.data) {
|
|
|
|
- if (p1.speaker != this.user.shop._id && p1.is_read == '0') list.push(p1._id);
|
|
|
|
|
|
+ let list = [];
|
|
|
|
+ let res = await this.query({ room: data._id });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ // 聊天记录列表
|
|
|
|
+ let arr1 = res.data.reverse();
|
|
|
|
+ this.$set(this, `chatRecordList`, arr1);
|
|
|
|
+ // 处理已读
|
|
|
|
+ for (const p1 of res.data) {
|
|
|
|
+ if (p1.speaker != this.user.shop._id && p1.is_read == '0') list.push(p1._id);
|
|
|
|
+ }
|
|
|
|
+ // 处理聊天图片,大图预览
|
|
|
|
+ let arr = [];
|
|
|
|
+ for (const p1 of this.chatRecordList) {
|
|
|
|
+ if (p1.msg_type == '1') arr.push(p1.content);
|
|
|
|
+ }
|
|
|
|
+ this.$set(this, `srcList`, arr);
|
|
}
|
|
}
|
|
- // 处理聊天图片,大图预览
|
|
|
|
- let arr = [];
|
|
|
|
- for (const p1 of this.chatRecordList) {
|
|
|
|
- if (p1.msg_type == '1') arr.push(p1.content);
|
|
|
|
|
|
+ // 处理已读
|
|
|
|
+ if (list.length != 0) {
|
|
|
|
+ let form = { ids: list };
|
|
|
|
+ res = await this.read(form);
|
|
|
|
+ if (this.$checkRes(res)) this.search();
|
|
}
|
|
}
|
|
- this.$set(this, `srcList`, arr);
|
|
|
|
- // 聊天记录列表
|
|
|
|
- let arr1 = res.data.reverse();
|
|
|
|
- this.$set(this, `chatRecordList`, arr1);
|
|
|
|
}
|
|
}
|
|
this.show = '1';
|
|
this.show = '1';
|
|
- if (list.length != 0) {
|
|
|
|
- let form = { ids: list };
|
|
|
|
- res = await this.read(form);
|
|
|
|
- if (this.$checkRes(res)) this.search();
|
|
|
|
- }
|
|
|
|
},
|
|
},
|
|
|
|
+ // 发送图片
|
|
toUp() {
|
|
toUp() {
|
|
this.dialog = { title: '信息管理', show: true, type: '1' };
|
|
this.dialog = { title: '信息管理', show: true, type: '1' };
|
|
},
|
|
},
|
|
@@ -161,28 +165,27 @@ export default {
|
|
let res = await this.create(form);
|
|
let res = await this.create(form);
|
|
if (this.$checkRes(res, '操作成功', '操作失败')) {
|
|
if (this.$checkRes(res, '操作成功', '操作失败')) {
|
|
let data = { _id: res.data.room, customer: this.customer, shop: this.shop };
|
|
let data = { _id: res.data.room, customer: this.customer, shop: this.shop };
|
|
- this.toView(data);
|
|
|
|
- this.search();
|
|
|
|
this.toClose();
|
|
this.toClose();
|
|
|
|
+ this.search();
|
|
|
|
+ if (this.customer_id) this.searchDetail(data);
|
|
|
|
+ if (!this.customer_id) this.toView(data);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
-
|
|
|
|
// 关闭
|
|
// 关闭
|
|
toClose() {
|
|
toClose() {
|
|
this.file = [];
|
|
this.file = [];
|
|
this.dialog = { title: '信息管理', show: false, type: '1' };
|
|
this.dialog = { title: '信息管理', show: false, type: '1' };
|
|
},
|
|
},
|
|
// 查询其他信息
|
|
// 查询其他信息
|
|
- async searchOthers() {},
|
|
|
|
|
|
+ async searchOthers() {
|
|
|
|
+ this.$set(this, `shop`, this.user.shop);
|
|
|
|
+ },
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
...mapState(['user']),
|
|
...mapState(['user']),
|
|
customer_id() {
|
|
customer_id() {
|
|
return this.$route.query.customer_id;
|
|
return this.$route.query.customer_id;
|
|
},
|
|
},
|
|
- address_id() {
|
|
|
|
- return this.$route.query.address_id;
|
|
|
|
- },
|
|
|
|
},
|
|
},
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
@@ -202,6 +205,8 @@ export default {
|
|
font-size: 300px;
|
|
font-size: 300px;
|
|
color: #ccc;
|
|
color: #ccc;
|
|
padding: 10% 0;
|
|
padding: 10% 0;
|
|
|
|
+ height: 80vh;
|
|
|
|
+ overflow-y: auto;
|
|
}
|
|
}
|
|
.right {
|
|
.right {
|
|
height: 80vh;
|
|
height: 80vh;
|