web/im/src/components/chat/panel/OtherLink.vue

228 lines
6.2 KiB
Vue
Raw Normal View History

2022-12-28 10:08:51 +08:00
<template>
2022-12-28 18:31:26 +08:00
<el-tabs v-model="activeName" @tab-click="handleClick" type="card" :stretch=true>
2022-12-28 14:54:57 +08:00
<el-tab-pane :label="toUser.storeFlag ? '正在咨询' : '他的足迹'" name="history">
<div style="margin-left: 12px;" v-if="toUser.storeFlag">
2022-12-28 18:31:26 +08:00
<GoodsLink :goodsDetail="goodsDetail" v-if="toUser.userId === goodsDetail.storeId"
@sendMessage="submitSendMessage" />
2022-12-29 18:20:06 +08:00
<FootPrint :list="footPrintList" @loadMore="loadMoreFootPrint()" :orderList="orderPrintList"
@sendMessage="submitSendMessage" />
2022-12-28 14:54:57 +08:00
</div>
</el-tab-pane>
<el-tab-pane label="店铺信息" name="UserInfo" v-if="toUser.storeFlag">
<div v-if="toUser.storeFlag">
<StoreDetail :storeInfo="storeInfo" />
</div>
</el-tab-pane>
</el-tabs>
2022-12-28 10:08:51 +08:00
</template>
<script>
import { Tabs, TabPane } from 'element-ui'
2022-12-29 18:20:06 +08:00
import { ServeGetStoreDetail, ServeGetUserDetail, ServeGetFootPrint, ServeGetOrderPrint } from '@/api/user'
2022-12-28 10:08:51 +08:00
import { ServeGetGoodsDetail } from '@/api/goods'
import StoreDetail from "@/components/chat/panel/template/storeDetail.vue";
import FootPrint from "@/components/chat/panel/template/footPrint.vue";
import GoodsLink from "@/components/chat/panel/template/goodsLink.vue";
2022-12-28 18:31:26 +08:00
import SocketInstance from "@/im-server/socket-instance";
import { mapState, mapGetters } from "vuex";
2022-12-28 10:08:51 +08:00
export default {
2022-12-28 14:54:57 +08:00
components: {
"el-tabs": Tabs,
"el-tab-pane": TabPane,
StoreDetail,
FootPrint,
GoodsLink
},
props: {
toUser: {
type: Object,
default: null,
},
id: {
type: String,
default: '',
2022-12-28 10:08:51 +08:00
},
2022-12-28 14:54:57 +08:00
goodsParams: {
type: Object,
default: null,
2022-12-28 10:08:51 +08:00
},
2022-12-28 14:54:57 +08:00
},
2022-12-28 18:31:26 +08:00
computed: {
...mapGetters(["talkItems"]),
...mapState({
index_name: (state) => state.dialogue.index_name,
}),
},
2022-12-28 14:54:57 +08:00
data () {
return {
activeName: 'history',
storeInfo: {}, //店铺信息
memberInfo: {}, //会员信息
footPrintParams: {
pageSize: 10,
pageNumber: 1,
memberId: '',
storeId: '',
},
goodsDetail: {},
2022-12-29 18:20:06 +08:00
footPrintList: [], // 商品
orderPrintList: []// 订单
2022-12-28 14:54:57 +08:00
}
},
mounted () {
2023-01-10 18:44:39 +08:00
localStorage.setItem('storeFlag', this.toUser.storeFlag)
console.log(this.toUser.storeFlag, 'this.toUser.storeFlag');
2022-12-28 14:54:57 +08:00
if (this.toUser.storeFlag) {
this.getStoreDetail()
} else {
this.getMemberDetail()
}
this.getFootPrint()
if (this.goodsParams) {
this.getGoodsDetail()
}
},
methods: {
getStoreDetail () {
ServeGetStoreDetail(this.toUser.userId).then(res => {
if (res.success) {
this.storeInfo = res.result
2022-12-28 10:08:51 +08:00
}
2022-12-28 14:54:57 +08:00
})
2022-12-28 10:08:51 +08:00
},
2022-12-28 14:54:57 +08:00
loadMoreFootPrint (e) {
//触底再次调接口
this.footPrintParams.pageNumber++
this.getFootPrint()
},
handleClick () { },
getMemberDetail () {
ServeGetUserDetail(this.toUser.userId).then(res => {
if (res.success) {
this.memberInfo = res.result
2022-12-28 10:08:51 +08:00
}
2022-12-28 14:54:57 +08:00
})
},
getGoodsDetail () {
ServeGetGoodsDetail(this.goodsParams).then(res => {
if (res.success) {
this.goodsDetail = res.result.data
2022-12-28 10:08:51 +08:00
}
2022-12-28 14:54:57 +08:00
})
2022-12-28 10:08:51 +08:00
},
2022-12-28 14:54:57 +08:00
getFootPrint () {
if (this.toUser.storeFlag) {
this.footPrintParams.memberId = this.id
this.footPrintParams.storeId = this.toUser.userId
} else {
this.footPrintParams.memberId = this.toUser.userId
this.footPrintParams.storeId = this.id
}
ServeGetFootPrint(this.footPrintParams).then(res => {
res.result.records.forEach((item, index) => {
2022-12-28 18:31:26 +08:00
if (localStorage.getItem(item.goodsId)) {
item.btnHide = 0
} else {
item.btnHide = 1
}
2022-12-28 14:54:57 +08:00
if (item.goodsId === this.goodsParams.goodsId) {
res.result.records.splice(index, 1)
}
});
this.footPrintList.push(...res.result.records)
})
2022-12-29 18:20:06 +08:00
// 订单列表
ServeGetOrderPrint(this.footPrintParams).then((res) => {
if (res.code == 200) {
res.result.records.forEach((item) => {
this.orderPrintList.push({
...item,
btnHide: 1
})
})
// this.orderPrintList.push(...res.result.records)
}
})
2022-12-28 14:54:57 +08:00
},
2022-12-28 18:31:26 +08:00
// 发送消息回调事件
2022-12-29 18:20:06 +08:00
submitSendMessage (record, context, messageType) {
2022-12-28 18:31:26 +08:00
SocketInstance.emit("event_talk", record);
this.$store.commit("UPDATE_TALK_ITEM", {
index_name: this.index_name,
draft_text: "",
});
/**
* 插入数据
*/
const insterChat = {
createTime: this.formateDateAndTimeToString(new Date()),
fromUser: this.id,
toUser: record.to,
isRead: false,
2022-12-29 18:20:06 +08:00
messageType: messageType,
2022-12-28 18:31:26 +08:00
text: context,
float: "right",
};
// 插入对话记录
this.$store.commit("PUSH_DIALOGUE", insterChat);
// 获取聊天面板元素节点
let el = document.getElementById("lumenChatPanel");
// 判断的滚动条是否在底部
let isBottom =
Math.ceil(el.scrollTop) + el.clientHeight >= el.scrollHeight;
if (isBottom || record.to == this.id) {
this.$nextTick(() => {
el.scrollTop = el.scrollHeight;
});
} else {
this.$store.commit("SET_TLAK_UNREAD_MESSAGE", {
content: content,
nickname: record.name,
});
}
},
formateDateAndTimeToString (date) {
var hours = date.getHours();
var mins = date.getMinutes();
var secs = date.getSeconds();
var msecs = date.getMilliseconds();
if (hours < 10) hours = "0" + hours;
if (mins < 10) mins = "0" + mins;
if (secs < 10) secs = "0" + secs;
if (msecs < 10) secs = "0" + msecs;
return (
this.formatDateToString(date) + " " + hours + ":" + mins + ":" + secs
);
},
formatDateToString (date) {
var year = date.getFullYear();
var month = date.getMonth() + 1;
var day = date.getDate();
if (month < 10) month = "0" + month;
if (day < 10) day = "0" + day;
return year + "-" + month + "-" + day;
},
2022-12-28 14:54:57 +08:00
}
2022-12-28 10:08:51 +08:00
}
</script>
<style scoped lang="less">
2022-12-28 18:31:26 +08:00
// /deep/ .el-tabs__nav.is-top {
// }
2022-12-28 10:08:51 +08:00
/deep/ .el-tabs__nav {
2022-12-28 14:54:57 +08:00
height: 60px;
line-height: 60px;
2022-12-28 10:08:51 +08:00
}
2022-12-28 14:54:57 +08:00
2022-12-28 10:08:51 +08:00
/deep/ .el-tab-pane {
2022-12-28 14:54:57 +08:00
margin-left: 12px;
2022-12-28 10:08:51 +08:00
}
</style>