pc发布商品不显示IM
parent
0dc3124bba
commit
aaa2deef85
|
@ -68,7 +68,7 @@
|
||||||
<pre v-html="item.text" />
|
<pre v-html="item.text" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else-if="item.messageType == 'GOODS' && item.text != null" class="text-message" :class="{
|
<div v-if="item.messageType == 'GOODS' && item.text != null" class="text-message" :class="{
|
||||||
left: item.float == 'left',
|
left: item.float == 'left',
|
||||||
right: item.float == 'right',
|
right: item.float == 'right',
|
||||||
}">
|
}">
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.messageType == 'ORDER' && item.text != null" class="text-message" :class="{
|
<div v-if="item.messageType == 'ORDER' && item.text != null" class="text-message" :class="{
|
||||||
left: item.float == 'left',
|
left: item.float == 'left',
|
||||||
right: item.float == 'right',
|
right: item.float == 'right',
|
||||||
}">
|
}">
|
||||||
|
@ -483,10 +483,10 @@ export default {
|
||||||
if (item.toUser > 0) {
|
if (item.toUser > 0) {
|
||||||
item.float = item.fromUser == user_id ? "right" : "left";
|
item.float = item.fromUser == user_id ? "right" : "left";
|
||||||
}
|
}
|
||||||
if (item.messageType === 'GOODS') {
|
if (item.messageType == 'GOODS') {
|
||||||
item.text = JSON.parse(item.text)
|
item.text = JSON.parse(item.text)
|
||||||
}
|
}
|
||||||
if (item.messageType === 'ORDER') {
|
if (item.messageType == 'ORDER') {
|
||||||
item.text = JSON.parse(item.text)
|
item.text = JSON.parse(item.text)
|
||||||
}
|
}
|
||||||
return { ...item, [key]: key };
|
return { ...item, [key]: key };
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<dd v-for="(item, index) in orderList" v-infinite-scroll="loadMore" :key="index">
|
<dd v-for="(item, index) in orderList" v-infinite-scroll="loadMore" :key="index">
|
||||||
<div style="margin-bottom: 20px;">
|
<div style="margin-bottom: 20px;">
|
||||||
<span class="orderSn">订单号:{{ item.sn }}</span>
|
<span class="orderSn">订单号:{{ item.sn }}</span>
|
||||||
<img :src="item.groupImages" alt="暂无图片"
|
<img :src="item.groupImages" alt=""
|
||||||
style="height: 100px; width: 100px;margin-top: 10px; vertical-align: middle; ">
|
style="height: 100px; width: 100px;margin-top: 10px; vertical-align: middle; ">
|
||||||
<span class="orderGoodsName" @click="linkToOrders(item.sn)"> {{ item.groupName }}</span>
|
<span class="orderGoodsName" @click="linkToOrders(item.sn)"> {{ item.groupName }}</span>
|
||||||
<span style="margin-left: 10px; color: red;">{{ item.paymentTime }}</span>
|
<span style="margin-left: 10px; color: red;">{{ item.paymentTime }}</span>
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Base {
|
||||||
* 获取当前登录用户的ID
|
* 获取当前登录用户的ID
|
||||||
*/
|
*/
|
||||||
getAccountId() {
|
getAccountId() {
|
||||||
console.log("store.state", store.state.user);
|
// console.log("store.state", store.state.user);
|
||||||
return store.state.user.id;
|
return store.state.user.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,6 @@ class Talk extends Base {
|
||||||
*/
|
*/
|
||||||
constructor(resource) {
|
constructor(resource) {
|
||||||
super();
|
super();
|
||||||
console.log("接口构造 resource", resource);
|
|
||||||
this.sender_id = resource.fromUser; //发送
|
this.sender_id = resource.fromUser; //发送
|
||||||
this.receiver_id = resource.toUser; //接收
|
this.receiver_id = resource.toUser; //接收
|
||||||
this.talk_type = resource.messageType; //类型
|
this.talk_type = resource.messageType; //类型
|
||||||
|
@ -60,7 +59,7 @@ class Talk extends Base {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
isCurrSender() {
|
isCurrSender() {
|
||||||
console.log("sender_id", this.sender_id);
|
// console.log("sender_id", this.sender_id);
|
||||||
return this.sender_id == this.getAccountId();
|
return this.sender_id == this.getAccountId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +107,7 @@ class Talk extends Base {
|
||||||
|
|
||||||
handle() {
|
handle() {
|
||||||
let store = this.getStoreInstance();
|
let store = this.getStoreInstance();
|
||||||
console.log("触发handle");
|
// console.log("触发handle");
|
||||||
// 判断当前是否在聊天页面
|
// 判断当前是否在聊天页面
|
||||||
if (!this.isTalkPage()) {
|
if (!this.isTalkPage()) {
|
||||||
store.commit("INCR_UNREAD_NUM");
|
store.commit("INCR_UNREAD_NUM");
|
||||||
|
@ -116,10 +115,10 @@ class Talk extends Base {
|
||||||
// 判断消息是否来自于我自己,否则会提示消息通知
|
// 判断消息是否来自于我自己,否则会提示消息通知
|
||||||
return !this.isCurrSender() && this.showMessageNocice();
|
return !this.isCurrSender() && this.showMessageNocice();
|
||||||
}
|
}
|
||||||
console.log("this.receiver_id", this.receiver_id);
|
// console.log("this.receiver_id", this.receiver_id);
|
||||||
console.log("this.sender_id", this.sender_id);
|
// console.log("this.sender_id", this.sender_id);
|
||||||
let isTrue = this.isTalk(1, this.receiver_id, this.sender_id);
|
let isTrue = this.isTalk(1, this.receiver_id, this.sender_id);
|
||||||
console.log("判断当前是否正在和好友对话", isTrue);
|
// console.log("判断当前是否正在和好友对话", isTrue);
|
||||||
// 判断当前是否正在和好友对话
|
// 判断当前是否正在和好友对话
|
||||||
if (isTrue) {
|
if (isTrue) {
|
||||||
this.insertTalkRecord();
|
this.insertTalkRecord();
|
||||||
|
@ -177,7 +176,7 @@ class Talk extends Base {
|
||||||
} else if (talk_type == 2) {
|
} else if (talk_type == 2) {
|
||||||
receiver_id = this.receiver_id;
|
receiver_id = this.receiver_id;
|
||||||
}
|
}
|
||||||
console.log("加载对接节点", this.resource);
|
// console.log("加载对接节点", this.resource);
|
||||||
|
|
||||||
ServeCreateTalkList(receiver_id).then(({ code, data }) => {
|
ServeCreateTalkList(receiver_id).then(({ code, data }) => {
|
||||||
if (code == 200) {
|
if (code == 200) {
|
||||||
|
@ -192,7 +191,7 @@ class Talk extends Base {
|
||||||
insertTalkRecord() {
|
insertTalkRecord() {
|
||||||
let store = this.getStoreInstance();
|
let store = this.getStoreInstance();
|
||||||
let record = this.resource;
|
let record = this.resource;
|
||||||
console.log("插入谈话记录", record);
|
// console.log("插入谈话记录", record);
|
||||||
|
|
||||||
record.float = this.getFloatType();
|
record.float = this.getFloatType();
|
||||||
|
|
||||||
|
@ -213,13 +212,13 @@ class Talk extends Base {
|
||||||
el.scrollTop = el.scrollHeight;
|
el.scrollTop = el.scrollHeight;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log("%c SET_TLAK_UNREAD_MESSAGE %c", "color:red");
|
// console.log("%c SET_TLAK_UNREAD_MESSAGE %c", "color:red");
|
||||||
store.commit("SET_TLAK_UNREAD_MESSAGE", {
|
store.commit("SET_TLAK_UNREAD_MESSAGE", {
|
||||||
content: this.getTalkText(),
|
content: this.getTalkText(),
|
||||||
nickname: record.name,
|
nickname: record.name,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log("%c 准备更新...UPDATE_TALK_ITEM ", "color:red");
|
// console.log("%c 准备更新...UPDATE_TALK_ITEM ", "color:red");
|
||||||
|
|
||||||
store.commit("UPDATE_TALK_ITEM", {
|
store.commit("UPDATE_TALK_ITEM", {
|
||||||
index_name: this.getIndexName(),
|
index_name: this.getIndexName(),
|
||||||
|
@ -228,7 +227,7 @@ class Talk extends Base {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.talk_type == 1 && this.getAccountId() !== this.sender_id) {
|
if (this.talk_type == 1 && this.getAccountId() !== this.sender_id) {
|
||||||
console.log("%c 清除 未读数...ServeClearTalkUnreadNum ", "color:blue");
|
// console.log("%c 清除 未读数...ServeClearTalkUnreadNum ", "color:blue");
|
||||||
ServeClearTalkUnreadNum({
|
ServeClearTalkUnreadNum({
|
||||||
talk_type: 1,
|
talk_type: 1,
|
||||||
receiver_id: this.sender_id,
|
receiver_id: this.sender_id,
|
||||||
|
@ -240,7 +239,6 @@ class Talk extends Base {
|
||||||
* 更新对话列表记录
|
* 更新对话列表记录
|
||||||
*/
|
*/
|
||||||
updateTalkItem() {
|
updateTalkItem() {
|
||||||
console.log("%c 更新对话列表记录", "color:#32ccbc");
|
|
||||||
let store = this.getStoreInstance();
|
let store = this.getStoreInstance();
|
||||||
|
|
||||||
store.commit("INCR_UNREAD_NUM");
|
store.commit("INCR_UNREAD_NUM");
|
||||||
|
|
|
@ -50,7 +50,7 @@ class SocketInstance {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 连接 WebSocket 服务
|
// 连接 WebSocket 服务
|
||||||
connect() {
|
connect () {
|
||||||
console.log("🔗连接 WebSocket");
|
console.log("🔗连接 WebSocket");
|
||||||
this.socket.connection();
|
this.socket.connection();
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ class SocketInstance {
|
||||||
/**
|
/**
|
||||||
* 注册回调消息处理事件
|
* 注册回调消息处理事件
|
||||||
*/
|
*/
|
||||||
registerEvents() {
|
registerEvents () {
|
||||||
this.socket.on("event_talk", (data) => {
|
this.socket.on("event_talk", (data) => {
|
||||||
console.log("接收到消息,event_talk", data);
|
console.log("接收到消息,event_talk", data);
|
||||||
new TalkEvent(data).handle();
|
new TalkEvent(data).handle();
|
||||||
|
@ -99,7 +99,7 @@ class SocketInstance {
|
||||||
*
|
*
|
||||||
* @param {Boolean} status 连接状态
|
* @param {Boolean} status 连接状态
|
||||||
*/
|
*/
|
||||||
updateSocketStatus(status) {
|
updateSocketStatus (status) {
|
||||||
store.commit("UPDATE_SOCKET_STATUS", status);
|
store.commit("UPDATE_SOCKET_STATUS", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ class SocketInstance {
|
||||||
* @param {String} event 事件名
|
* @param {String} event 事件名
|
||||||
* @param {Object} data 数据
|
* @param {Object} data 数据
|
||||||
*/
|
*/
|
||||||
emit(event, data) {
|
emit (event, data) {
|
||||||
this.socket.emit(event, data);
|
this.socket.emit(event, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,19 +21,19 @@ import '@/assets/css/global.less'
|
||||||
|
|
||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
Vue.mixin(MainMixin) // 引入mixins
|
Vue.mixin(MainMixin) // 引入mixins
|
||||||
Vue.component('face',face)
|
Vue.component('face', face)
|
||||||
Vue.component('face-null',faceNull)
|
Vue.component('face-null', faceNull)
|
||||||
|
|
||||||
Vue.prototype.linkToGoods = function (goodsId, skuId) { // 跳转买家端商品
|
Vue.prototype.linkToGoods = function (goodsId, skuId) { // 跳转买家端商品
|
||||||
console.log(`${config.PC_URL}/goodsDetail?skuId=${skuId}&goodsId=${goodsId}`)
|
console.log(`${config.PC_URL}/goodsDetail?skuId=${skuId}&goodsId=${goodsId}`)
|
||||||
window.open(`${config.PC_URL}/goodsDetail?skuId=${skuId}&goodsId=${goodsId}`, '_blank')
|
window.open(`${config.PC_URL}/goodsDetail?skuId=${skuId}&goodsId=${goodsId}`, '_blank')
|
||||||
};
|
};
|
||||||
Vue.prototype.linkToStore = function (storeId) { // 跳转买家端商品
|
Vue.prototype.linkToStore = function (storeId) { // 跳转买家端商品
|
||||||
console.log(`${config.PC_URL}/Merchant?id=${storeId}`)
|
console.log(`${config.PC_URL}/Merchant?id=${storeId}`)
|
||||||
window.open(`${config.PC_URL}/Merchant?id=${storeId}`, '_blank')
|
window.open(`${config.PC_URL}/Merchant?id=${storeId}`, '_blank')
|
||||||
};
|
};
|
||||||
// 订单跳转商家订单页面
|
// 订单跳转商家订单页面
|
||||||
Vue.prototype.linkToOrders = function (sn) { // 跳转买家端商品
|
Vue.prototype.linkToOrders = function (sn) { // 跳转买家端订单
|
||||||
window.open(`${config.STORE_URL}/order-detail?sn=${sn}`, '_blank')
|
window.open(`${config.STORE_URL}/order-detail?sn=${sn}`, '_blank')
|
||||||
};
|
};
|
||||||
const Instance = new Vue({
|
const Instance = new Vue({
|
||||||
|
|
|
@ -49,9 +49,9 @@ class WsSocket {
|
||||||
// 定义 WebSocket 原生方法
|
// 定义 WebSocket 原生方法
|
||||||
this.events = Object.assign(
|
this.events = Object.assign(
|
||||||
{
|
{
|
||||||
onError: (evt) => {},
|
onError: (evt) => { },
|
||||||
onOpen: (evt) => {},
|
onOpen: (evt) => { },
|
||||||
onClose: (evt) => {},
|
onClose: (evt) => { },
|
||||||
},
|
},
|
||||||
events
|
events
|
||||||
);
|
);
|
||||||
|
@ -63,7 +63,7 @@ class WsSocket {
|
||||||
* @param {String} event 事件名
|
* @param {String} event 事件名
|
||||||
* @param {Function} callBack 回调方法
|
* @param {Function} callBack 回调方法
|
||||||
*/
|
*/
|
||||||
on(event, callBack) {
|
on (event, callBack) {
|
||||||
// 对应 socket-instance.js
|
// 对应 socket-instance.js
|
||||||
console.log("事件绑定", event, callBack);
|
console.log("事件绑定", event, callBack);
|
||||||
this.onCallBacks[event] = callBack;
|
this.onCallBacks[event] = callBack;
|
||||||
|
@ -73,7 +73,7 @@ class WsSocket {
|
||||||
/**
|
/**
|
||||||
* 加载 WebSocket
|
* 加载 WebSocket
|
||||||
*/
|
*/
|
||||||
loadSocket() {
|
loadSocket () {
|
||||||
// 判断当前是否已经连接
|
// 判断当前是否已经连接
|
||||||
if (this.connect != null) {
|
if (this.connect != null) {
|
||||||
this.connect.close();
|
this.connect.close();
|
||||||
|
@ -93,14 +93,14 @@ class WsSocket {
|
||||||
/**
|
/**
|
||||||
* 连接 Websocket
|
* 连接 Websocket
|
||||||
*/
|
*/
|
||||||
connection() {
|
connection () {
|
||||||
this.loadSocket();
|
this.loadSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 掉线重连 Websocket
|
* 掉线重连 Websocket
|
||||||
*/
|
*/
|
||||||
reconnect() {
|
reconnect () {
|
||||||
console.log("掉线重连接");
|
console.log("掉线重连接");
|
||||||
let reconnect = this.config.reconnect;
|
let reconnect = this.config.reconnect;
|
||||||
if (reconnect.lockReconnect || reconnect.number == 0) {
|
if (reconnect.lockReconnect || reconnect.number == 0) {
|
||||||
|
@ -129,8 +129,8 @@ class WsSocket {
|
||||||
*
|
*
|
||||||
* @param {Object} evt Websocket 消息
|
* @param {Object} evt Websocket 消息
|
||||||
*/
|
*/
|
||||||
onParse(evt) {
|
onParse (evt) {
|
||||||
|
|
||||||
const res = JSON.parse(evt.data).result;
|
const res = JSON.parse(evt.data).result;
|
||||||
|
|
||||||
//如果创建时间是时间戳类型则转换为 日期类型,否则新压入栈的消息的创建时间和从数据库读取出来的创建时间格式对不上,处理的时候会出异常。
|
//如果创建时间是时间戳类型则转换为 日期类型,否则新压入栈的消息的创建时间和从数据库读取出来的创建时间格式对不上,处理的时候会出异常。
|
||||||
|
@ -146,7 +146,7 @@ class WsSocket {
|
||||||
* @param format 转换格式
|
* @param format 转换格式
|
||||||
* @returns {*|string}
|
* @returns {*|string}
|
||||||
*/
|
*/
|
||||||
unixToDate(unix, format) {
|
unixToDate (unix, format) {
|
||||||
if (!unix) return unix;
|
if (!unix) return unix;
|
||||||
let _format = format || "yyyy-MM-dd hh:mm:ss";
|
let _format = format || "yyyy-MM-dd hh:mm:ss";
|
||||||
const d = new Date(unix);
|
const d = new Date(unix);
|
||||||
|
@ -161,16 +161,16 @@ class WsSocket {
|
||||||
};
|
};
|
||||||
if (/(y+)/.test(_format))
|
if (/(y+)/.test(_format))
|
||||||
_format = _format.replace(
|
_format = _format.replace(
|
||||||
RegExp.$1,
|
RegExp.$1,
|
||||||
(d.getFullYear() + "").substr(4 - RegExp.$1.length)
|
(d.getFullYear() + "").substr(4 - RegExp.$1.length)
|
||||||
);
|
);
|
||||||
for (const k in o)
|
for (const k in o)
|
||||||
if (new RegExp("(" + k + ")").test(_format))
|
if (new RegExp("(" + k + ")").test(_format))
|
||||||
_format = _format.replace(
|
_format = _format.replace(
|
||||||
RegExp.$1,
|
RegExp.$1,
|
||||||
RegExp.$1.length === 1
|
RegExp.$1.length === 1
|
||||||
? o[k]
|
? o[k]
|
||||||
: ("00" + o[k]).substr(("" + o[k]).length)
|
: ("00" + o[k]).substr(("" + o[k]).length)
|
||||||
);
|
);
|
||||||
return _format;
|
return _format;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ class WsSocket {
|
||||||
*
|
*
|
||||||
* @param {Object} evt Websocket 消息
|
* @param {Object} evt Websocket 消息
|
||||||
*/
|
*/
|
||||||
onOpen(evt) {
|
onOpen (evt) {
|
||||||
this.events.onOpen(evt);
|
this.events.onOpen(evt);
|
||||||
|
|
||||||
if (this.config.heartbeat.enabled) {
|
if (this.config.heartbeat.enabled) {
|
||||||
|
@ -193,7 +193,7 @@ class WsSocket {
|
||||||
*
|
*
|
||||||
* @param {Object} evt Websocket 消息
|
* @param {Object} evt Websocket 消息
|
||||||
*/
|
*/
|
||||||
onClose(evt) {
|
onClose (evt) {
|
||||||
console.log("关闭连接", evt);
|
console.log("关闭连接", evt);
|
||||||
if (this.config.heartbeat.enabled) {
|
if (this.config.heartbeat.enabled) {
|
||||||
clearInterval(this.config.heartbeat.setInterval);
|
clearInterval(this.config.heartbeat.setInterval);
|
||||||
|
@ -212,7 +212,7 @@ class WsSocket {
|
||||||
*
|
*
|
||||||
* @param {Object} evt Websocket 消息
|
* @param {Object} evt Websocket 消息
|
||||||
*/
|
*/
|
||||||
onError(evt) {
|
onError (evt) {
|
||||||
this.events.onError(evt);
|
this.events.onError(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,20 +221,23 @@ class WsSocket {
|
||||||
*
|
*
|
||||||
* @param {Object} evt Websocket 消息
|
* @param {Object} evt Websocket 消息
|
||||||
*/
|
*/
|
||||||
onMessage(evt) {
|
onMessage (evt) {
|
||||||
let result = this.onParse(evt);
|
let result = this.onParse(evt);
|
||||||
console.log("接收消息", result, "color:red");
|
console.log("接收消息", result, "color:red");
|
||||||
// 判断消息事件是否被绑定
|
// 判断消息事件是否被绑定
|
||||||
// event_talk;
|
// event_talk;
|
||||||
|
let params = {
|
||||||
|
...this.onParse(evt),
|
||||||
|
text: JSON.parse(this.onParse(evt).text)
|
||||||
|
}
|
||||||
// 指定推送消息
|
// 指定推送消息
|
||||||
this.onCallBacks["event_talk"](result);
|
this.onCallBacks["event_talk"](params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WebSocket心跳检测
|
* WebSocket心跳检测
|
||||||
*/
|
*/
|
||||||
heartbeat() {
|
heartbeat () {
|
||||||
console.log("WebSocket心跳检测");
|
console.log("WebSocket心跳检测");
|
||||||
this.config.heartbeat.setInterval = setInterval(() => {
|
this.config.heartbeat.setInterval = setInterval(() => {
|
||||||
this.connect.send("PING");
|
this.connect.send("PING");
|
||||||
|
@ -246,14 +249,14 @@ class WsSocket {
|
||||||
*
|
*
|
||||||
* @param {Object} message
|
* @param {Object} message
|
||||||
*/
|
*/
|
||||||
send(message) {
|
send (message) {
|
||||||
this.connect.send(JSON.stringify(message));
|
this.connect.send(JSON.stringify(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭连接
|
* 关闭连接
|
||||||
*/
|
*/
|
||||||
close() {
|
close () {
|
||||||
this.connect.close();
|
this.connect.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +266,7 @@ class WsSocket {
|
||||||
* @param {String} event 事件名
|
* @param {String} event 事件名
|
||||||
* @param {Object} data 数据
|
* @param {Object} data 数据
|
||||||
*/
|
*/
|
||||||
emit(event, data) {
|
emit (event, data) {
|
||||||
if (this.connect && this.connect.readyState === 1) {
|
if (this.connect && this.connect.readyState === 1) {
|
||||||
this.connect.send(JSON.stringify(data));
|
this.connect.send(JSON.stringify(data));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,7 +27,7 @@ export default {
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
// 更新对话
|
// 更新对话
|
||||||
UPDATE_DIALOGUE_MESSAGE(state, resource) {
|
UPDATE_DIALOGUE_MESSAGE (state, resource) {
|
||||||
state.records = [];
|
state.records = [];
|
||||||
state.talk_type = parseInt(resource.talk_type);
|
state.talk_type = parseInt(resource.talk_type);
|
||||||
state.receiver_id = parseInt(resource.receiver_id);
|
state.receiver_id = parseInt(resource.receiver_id);
|
||||||
|
@ -41,26 +41,26 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
// 数组头部压入对话记录1494593861786271744 1494593778193793024
|
// 数组头部压入对话记录1494593861786271744 1494593778193793024
|
||||||
UNSHIFT_DIALOGUE(state, records) {
|
UNSHIFT_DIALOGUE (state, records) {
|
||||||
// console.log("%c 数组头部压入对话记录", "color:green");
|
// console.log("%c 数组头部压入对话记录", "color:green");
|
||||||
// console.log("state", state);
|
// console.log("state", state);
|
||||||
// console.log("records", records);
|
// console.log("records", records);
|
||||||
if(state.records.length>0){
|
if (state.records.length > 0) {
|
||||||
state.records.unshift(...records);
|
state.records.unshift(...records);
|
||||||
}else{
|
} else {
|
||||||
state.records.push(...records);
|
state.records.push(...records);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("最后的数据",state.records)
|
// console.log("最后的数据",state.records)
|
||||||
},
|
},
|
||||||
|
|
||||||
// 推送对话记录
|
// 推送对话记录
|
||||||
PUSH_DIALOGUE(state, record) {
|
PUSH_DIALOGUE (state, record) {
|
||||||
state.records.push(record);
|
state.records.push(record);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 更新对话记录
|
// 更新对话记录
|
||||||
UPDATE_DIALOGUE(state, resource) {
|
UPDATE_DIALOGUE (state, resource) {
|
||||||
for (let i in state.records) {
|
for (let i in state.records) {
|
||||||
if (state.records[i].id === resource.id) {
|
if (state.records[i].id === resource.id) {
|
||||||
Object.assign(state.records[i], resource);
|
Object.assign(state.records[i], resource);
|
||||||
|
@ -70,11 +70,11 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
// 删除对话记录
|
// 删除对话记录
|
||||||
DELETE_DIALOGUE(state, index) {
|
DELETE_DIALOGUE (state, index) {
|
||||||
state.records.splice(index, 1);
|
state.records.splice(index, 1);
|
||||||
},
|
},
|
||||||
|
|
||||||
BATCH_DELETE_DIALOGUE(state, ids) {
|
BATCH_DELETE_DIALOGUE (state, ids) {
|
||||||
ids.forEach((record_id) => {
|
ids.forEach((record_id) => {
|
||||||
let index = state.records.findIndex((item) => item.id == record_id);
|
let index = state.records.findIndex((item) => item.id == record_id);
|
||||||
if (index >= 0) state.records.splice(index, 1);
|
if (index >= 0) state.records.splice(index, 1);
|
||||||
|
@ -82,7 +82,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
// 数组头部压入对话记录
|
// 数组头部压入对话记录
|
||||||
SET_DIALOGUE(state, records) {
|
SET_DIALOGUE (state, records) {
|
||||||
state.records = records;
|
state.records = records;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,6 +21,7 @@ const Talk = {
|
||||||
getters: {
|
getters: {
|
||||||
// 过滤所有置顶对话列表
|
// 过滤所有置顶对话列表
|
||||||
topItems: (state) => {
|
topItems: (state) => {
|
||||||
|
console.log(state.items, 'state.items');
|
||||||
return state.items.filter((item) => item.is_top == 1);
|
return state.items.filter((item) => item.is_top == 1);
|
||||||
},
|
},
|
||||||
talkItems: (state) => {
|
talkItems: (state) => {
|
||||||
|
@ -38,18 +39,18 @@ const Talk = {
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
// 设置对话列表
|
// 设置对话列表
|
||||||
SET_TALK_ITEMS(state, resource) {
|
SET_TALK_ITEMS (state, resource) {
|
||||||
console.log("设置对话列表", resource.items);
|
console.log("设置对话列表", resource.items);
|
||||||
Vue.set(state,'items',resource.items)
|
Vue.set(state, 'items', resource.items)
|
||||||
},
|
},
|
||||||
|
|
||||||
// 更新对话节点
|
// 更新对话节点
|
||||||
UPDATE_TALK_ITEM(state, resource) {
|
UPDATE_TALK_ITEM (state, resource) {
|
||||||
console.log("%c 更新对话节点", "color:#32c");
|
// console.log("%c 更新对话节点", "color:#32c");
|
||||||
console.log("state", state);
|
// console.log("state", state);
|
||||||
console.log("resource", resource);
|
// console.log("resource", resource);
|
||||||
|
|
||||||
console.log("%c 更新对话节点结束", "color:#32c",state.items);
|
// console.log("%c 更新对话节点结束", "color:#32c",state.items);
|
||||||
let index = state.items.findIndex(
|
let index = state.items.findIndex(
|
||||||
(item) => item.userId === resource.index_name.split("_")[1]
|
(item) => item.userId === resource.index_name.split("_")[1]
|
||||||
);
|
);
|
||||||
|
@ -59,13 +60,13 @@ const Talk = {
|
||||||
},
|
},
|
||||||
|
|
||||||
// 新增对话节点
|
// 新增对话节点
|
||||||
PUSH_TALK_ITEM(state, resource) {
|
PUSH_TALK_ITEM (state, resource) {
|
||||||
console.log(state)
|
// console.log(state)
|
||||||
state.items.push(resource);
|
state.items.push(resource);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 移除对话节点
|
// 移除对话节点
|
||||||
REMOVE_TALK_ITEM(state, index_name) {
|
REMOVE_TALK_ITEM (state, index_name) {
|
||||||
for (let i in state.items) {
|
for (let i in state.items) {
|
||||||
if (state.items[i].index_name === index_name) {
|
if (state.items[i].index_name === index_name) {
|
||||||
state.items.splice(i, 1);
|
state.items.splice(i, 1);
|
||||||
|
@ -84,17 +85,15 @@ const Talk = {
|
||||||
// },
|
// },
|
||||||
|
|
||||||
// 更新对话消息
|
// 更新对话消息
|
||||||
UPDATE_TALK_MESSAGE(state, resource) {
|
UPDATE_TALK_MESSAGE (state, resource) {
|
||||||
console.log("%c 更新对话消息", "color:green");
|
// console.log("%c 更新对话消息", "color:green");
|
||||||
|
// console.log("state", state);
|
||||||
|
// console.log("resource", resource);
|
||||||
console.log("state", state);
|
// console.log("%c 更新对话结束", "color:green",state.items);
|
||||||
console.log("resource", resource);
|
|
||||||
console.log("%c 更新对话结束", "color:green",state.items);
|
|
||||||
|
|
||||||
let enableGetTalkList = true
|
let enableGetTalkList = true
|
||||||
state.items.forEach(item=>{
|
state.items.forEach(item => {
|
||||||
if(item.userId == resource.index_name.split("_")[1]){
|
if (item.userId == resource.index_name.split("_")[1]) {
|
||||||
item.unread++;
|
item.unread++;
|
||||||
item.msg_text = resource.msg_text;
|
item.msg_text = resource.msg_text;
|
||||||
item.lastTalkTime = resource.updated_at;
|
item.lastTalkTime = resource.updated_at;
|
||||||
|
@ -104,22 +103,22 @@ const Talk = {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 循环如果当前用户不在对话记录列表中 就重新请求对话列表接口
|
// 循环如果当前用户不在对话记录列表中 就重新请求对话列表接口
|
||||||
enableGetTalkList ? this.commit('getTalkList'):''
|
enableGetTalkList ? this.commit('getTalkList') : ''
|
||||||
},
|
},
|
||||||
|
|
||||||
// 触发对话列表重新加载
|
// 触发对话列表重新加载
|
||||||
TRIGGER_TALK_ITEMS_LOAD(state, status = false) {
|
TRIGGER_TALK_ITEMS_LOAD (state, status = false) {
|
||||||
state.heavyLoad = status;
|
state.heavyLoad = status;
|
||||||
},
|
},
|
||||||
|
|
||||||
SET_TLAK_UNREAD_MESSAGE(state, resource) {
|
SET_TLAK_UNREAD_MESSAGE (state, resource) {
|
||||||
state.unreadMessage.num++;
|
state.unreadMessage.num++;
|
||||||
state.unreadMessage.nickname = resource.nickname;
|
state.unreadMessage.nickname = resource.nickname;
|
||||||
state.unreadMessage.content = resource.content;
|
state.unreadMessage.content = resource.content;
|
||||||
},
|
},
|
||||||
|
|
||||||
// 清除最后一条未读消息
|
// 清除最后一条未读消息
|
||||||
CLEAR_TLAK_UNREAD_MESSAGE(state) {
|
CLEAR_TLAK_UNREAD_MESSAGE (state) {
|
||||||
state.unreadMessage = {
|
state.unreadMessage = {
|
||||||
num: 0,
|
num: 0,
|
||||||
nickname: "未知",
|
nickname: "未知",
|
||||||
|
|
|
@ -108,6 +108,7 @@
|
||||||
<div class="talk-message">
|
<div class="talk-message">
|
||||||
<span v-if="item.lastMessageType === 'MESSAGE'">{{ item.lastTalkMessage }}</span>
|
<span v-if="item.lastMessageType === 'MESSAGE'">{{ item.lastTalkMessage }}</span>
|
||||||
<span v-if="item.lastMessageType === 'GOODS'">[商品链接]</span>
|
<span v-if="item.lastMessageType === 'GOODS'">[商品链接]</span>
|
||||||
|
<span v-if="item.lastMessageType === 'ORDER'">[订单链接]</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<template v-if="
|
<template v-if="
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {getCategoryTree} from '@/api/goods.js'
|
import { getCategoryTree } from '@/api/goods.js'
|
||||||
export default {
|
export default {
|
||||||
updated() {
|
updated () {
|
||||||
if (!localStorage.getItem('category') && this.$route.path !== '/login') {
|
if (!localStorage.getItem('category') && this.$route.path !== '/login') {
|
||||||
getCategoryTree(0).then(res => {
|
getCategoryTree(0).then(res => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
|
@ -49,7 +49,8 @@ body {
|
||||||
.ivu-tag {
|
.ivu-tag {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.tox-notifications-container{
|
|
||||||
|
.tox-notifications-container {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -253,11 +253,12 @@ export default {
|
||||||
// 获取访问Token
|
// 获取访问Token
|
||||||
let accessToken = this.getStore("accessToken");
|
let accessToken = this.getStore("accessToken");
|
||||||
await this.getIMDetailMethods();
|
await this.getIMDetailMethods();
|
||||||
|
let res = await getIMDetail();
|
||||||
if (!accessToken) {
|
if (!accessToken) {
|
||||||
this.$Message.error("请登录后再联系客服");
|
this.$Message.error("请登录后再联系客服");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.open(" http://192.168.0.139:8000?token=" + accessToken);
|
window.open(`${res.result}?token=` + accessToken);
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取im信息
|
// 获取im信息
|
||||||
|
|
Loading…
Reference in New Issue