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