Files
dvcp_v2_wxcp_app/src/project/pidu/AppConversation/conversationDetail.vue
2023-07-17 15:20:36 +08:00

632 lines
18 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div class="conversationDetail">
<AiTopFixed>
<u-tabs :list="tabList" :is-scroll="false" :current="currentTabs" height="96" bg-color="#ffffff"
inactive-color="#666666" :bar-style="barStyle" :active-item-style="activeStyle" active-color="#3975C6 " @change="change">
</u-tabs>
<div class="top-search">
<div class="left" @click="isShowDate=true">
<div class="color-999" v-if="!dateList.length">开始时间-结束时间</div>
<div v-else>{{dateList[0]}}{{dateList[1]}}</div>
<img src="./img/del-icon.png" alt="" v-if="dateList.length" @click.stop="clearDate()">
</div>
<div class="right">
<u-search v-model="keyword" :clearabled="true" placeholder="请输入关键词" :show-action="false" bg-color="#F5F5F5"
search-icon-color="#999" color="#999" height="58" @search="getListInit" @clear="getListInit">
</u-search>
</div>
</div>
</AiTopFixed>
<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scroll="scroll" v-if="list.length" :style="{height: scrollHeight+'px'}">
<div class="conversation-list">
<div v-for="(item, index) in list" :key="index">
<div class="item" :class="item.userId == id ? 'item-right' : 'item-left'">
<!-- <img src="./img/fail-icon.png" alt="" class="fail-img" v-if="item.userId == user.wxUserId"> -->
<img :src="item.userAvatar" alt="" class="user-img" v-if="item.userId != id && item.userAvatar">
<img src="./img/user-img.png" alt="" class="user-img" v-if="item.userId != id && !item.userAvatar">
<p class="user-name">{{item.userName}}<span>{{item.msgSendTime}}</span></p>
<div class="content">
<span class="cir" v-if="item.msgType == 'text'"></span>
<p class="content-text" v-if="item.msgType == 'text'">{{item.content}}</p>
<div class="img-list" v-if="item.msgType == 'image'">
<img :src="item.sdkFileUrl" alt="" @click="previewImage(item.sdkFileUrl)">
</div>
<audio :src="item.sdkFileUrl" controls style="display: block;" v-if="item.msgType == 'voice'"></audio>
<video :src="item.sdkFileUrl" v-if="item.msgType == 'video'" />
<div class="file" @click="prevFile(item)" v-if="item.msgType == 'file'">
<u-row justify="between">
<label class="left">
<img :src="$cdn + 'common/appendix.png'" alt="">
<span>{{ item.sdkFileName }}</span>
</label>
<span>{{ item.fileSizeStr }}</span>
</u-row>
</div>
<div class="revoke-text" v-if="item.msgType == 'revoke'">{{item.userName}}撤回了一条消息</div>
<div class="revoke-text" v-if="item.msgType == 'disagree'">对方不同意会话存档内容你将无法继续提供服务</div>
<div class="revoke-text" v-if="item.msgType == 'agree'">对方同意会话存档内容你可以继续提供服务</div>
<div class="card-info" v-if="item.msgType == 'card'" @click="openUser(item.type, item.cardUserId)">
<div class="top">
<div class="card-left">
<h3>{{item.cardCorpName}}</h3>
<p>{{item.cardUserName}}</p>
<!-- <div>{{item.cardUserId}}</div> -->
</div>
<div class="card-right">
<img :src="item.cardUserAvatar" alt="" v-if="item.cardUserAvatar">
<img src="./img/user-img.png" alt="" v-else>
</div>
</div>
<div class="bottom">个人名片</div>
</div>
<img :src="item.sdkFileUrl" alt="" v-if="item.msgType == 'emotion'" :style="[{width: item.width/2+'px'}, {height: item.height/2+'px'}]">
<div class="map-info" v-if="item.msgType == 'location'" @click="openMap(item)">
<map style="width: 100%; height: 100%;" :latitude="item.lat" :longitude="item.lng" :scale="item.zoom" :enable-zoom="false" :enable-scroll="false">
<cover-view style='width:100%;height:100%'></cover-view>
</map>
<div class="address-text">
<p>{{item.title}}</p>
<p>{{item.address}}</p>
</div>
</div>
<div class="card-info" v-if="item.msgType == 'weapp'" @click="openApp(item)">
<div class="top">
<div class="card-left">
<h3 class="display-name">{{item.displayName}}</h3>
<p>{{item.title}}</p>
</div>
<div class="card-right">
<img src="./img/app-icon.png" alt="" >
</div>
</div>
<div class="bottom"><img src="./img/app-mini-icon.png" alt="" >小程序</div>
</div>
<div class="card-info" v-if="item.msgType == 'link'" @click="openLink(item)">
<div class="top">
<div class="card-left">
<p>{{item.title}}</p>
<div>{{item.username}}</div>
</div>
<div class="card-right" v-if="item.imageUrl">
<img :src="item.imageUrl" alt="" >
</div>
</div>
<div class="bottom">分享链接</div>
</div>
</div>
<img :src="item.userAvatar" alt="" class="user-img" v-if="item.userId == id">
<!-- <img src="./img/fail-icon.png" alt="" class="fail-img" v-if="item.userId != user.wxUserId"> -->
</div>
</div>
</div>
</scroll-view>
<AiEmpty v-else/>
<u-calendar v-model="isShowDate" @change="onDateChange" mode="range"></u-calendar>
<!-- <div class="footer" @click="toGroup">{{type == 1 ? '群详情' : '个人信息'}}</div> -->
</div>
</template>
<script>
import {mapState, mapActions} from "vuex";
export default {
name: "conversationDetail",
data() {
return {
tabList: [
{name: '全部', value: ''},
{name: '图片/视频', value: 'imagevideo'},
{name: '语音', value: 'voice'},
{name: '文件', value: 'file'},
],
currentTabs: 0,
barStyle: {
'width': '24px',
'height': '2px',
'border-radius': '0',
'bottom': '5px'
},
activeStyle: {
'font-weight' : '400',
'color': '#000000'
},
keyword: '',
toUserId: '',
roomId: '',
current: 1,
pages: 2,
list: [],
type: '',
isShowDate: false,
dateList: [],
scrollTop: 0,
scrollHeight: '',
preveHeight: '',
id: ''
};
},
computed: {
...mapState(['user']),
},
onLoad(option) {
if(option.toUserId) {
this.toUserId = option.toUserId
}else {
this.roomId = option.roomId
}
this.type = option.type
this.id = option.id
this.getList()
console.log()
this.scrollHeight = uni.getSystemInfoSync().windowHeight - 150
this.injectJWeixin('openLocation')
},
onShow() {
document.title = '会话详情'
},
// onPullDownRefresh() {
// if(this.current > this.pages) {
// uni.stopPullDownRefresh()
// return this.$u.toast('已加载完成,没有更多数据')
// }else {
// this.current ++
// this.getList()
// setTimeout(() => {
// uni.stopPullDownRefresh()
// }, 1000)
// }
// },
methods: {
scroll(e) {
if(e.detail.scrollTop == 0) {
if(this.current > this.pages) {
return this.$u.toast('已加载完成,没有更多数据')
}else {
this.current ++
this.getList()
}
}
},
toGroup() {
if(this.type == 1) {
uni.navigateTo({url: `./groupDetail`})
}else {
uni.navigateTo({url: `./userInfo`})
}
},
change(index) {
this.keyword = ''
this.currentTabs = index
this.getListInit()
},
onDateChange (e) {
this.dateList = [e.startDate, e.endDate]
this.getListInit()
},
clearDate() {
this.dateList = []
this.getListInit()
},
getListInit() {
this.current = 1
this.pages = 2
this.list = []
this.getList()
},
getList() {
if(this.current > 1) {
uni.createSelectorQuery().select(".conversation-list").boundingClientRect((res) => {
this.preveHeight = res.height
}).exec();
}
this.$http.post(`/app/appsessionarchiveinfo/list`, null, {
params: {
current: this.current,
size: 10,
msgType: this.tabList[this.currentTabs].value,
// msgType: 'link',
userId: this.id,
toUserId: this.toUserId,
roomId: this.roomId,
type: this.type,
content: this.keyword,
startTime: this.dateList.length ? this.dateList[0] : '',
endTime: this.dateList.length ? this.dateList[1] : ''
}
}).then(res=> {
if(res?.data) {
res.data.records.map((item) => {
if(item.msgType == 'location') {
item.covers = [{
latitude: item.lat,
longitude: item.lng,
label: {
content: item.address
},
callout: {
content: item.title
}
}]
}
})
this.list = this.current > 1 ? [ ...res.data.records, ...this.list]: res.data.records
this.pages = res.data.pages
this.$nextTick(() => {
uni.createSelectorQuery().select(".conversation-list").boundingClientRect((res) => {
if(this.current == 1) {
this.scrollTop = res.height - this.scrollHeight
}else {
this.scrollTop = res.height - this.preveHeight
}
}).exec();
})
}
})
},
previewImage(img) {
uni.previewImage({
urls: [img],
current: img
})
},
...mapActions(['previewFile', 'injectJWeixin']),
prevFile(file) {
var fileInfo = {url: file.sdkFileUrl, name: file.sdkFileName, size: file.fileSizeStr}
this.$loading()
this.previewFile({ ...fileInfo }).then(()=>{
this.$hideLoading()
})
},
openLink(row) {
window.open(row.linkUrl);
},
openApp(row) {
uni.navigateToMiniProgram({
// appId: row.goodsJdAppid,
// path: row.goodsJdUrl
})
},
openUser(type, userid) { //缺少名片人员区分内部还是外部
console.log(row)
// userid && this.injectJWeixin('openUserProfile').then(() => {
// this.wxInvoke(['openUserProfile', {type, userid}, () => 0])
// })
},
openMap(row) {
wx.openLocation({
latitude: row.lat, // 纬度浮点数范围为90 ~ -90
longitude: row.lng, // 经度浮点数范围为180 ~ -180。
name: row.title, // 位置名
address: row.address, // 地址详情说明
scale: row.zoom, // 地图缩放级别,整形值,范围从1~28。默认为16
fail: () => {
location.reload()
}
});
}
},
onReachBottom() {
// this.current ++
// this.getList()
}
};
</script>
<style lang="scss" scoped>
.conversationDetail {
height: 100%;
::v-deep .AiTopFixed {
.placeholder {
.content {
padding: 0 !important;
}
}
.fixed {
margin: 0 !important;
.content {
padding: 0 !important;
}
}
}
.top-search {
padding: 20px 32px;
display: flex;
.left {
width: 400px;
div {
display: inline-block;
line-height: 64px;
}
img {
display: inline-block;
width: 32px;
height: 32px;
margin-left: 8px;
vertical-align: middle;
}
}
.right {
width: calc(100% - 400px);
}
}
.conversation-list {
padding: 48px 32px 160px;
// background-color: #EBECF0;
.item {
margin-bottom: 48px;
display: flex;
position: relative;
.user-name {
position: absolute;
top: 0;
left: 24px;
font-family: PingFangSC-Regular;
font-size: 22px;
color: #666;
padding:0 0 0 64px;
span {
display: inline-block;
margin: 0 12px;
font-family: PingFangSC-Regular;
font-size: 20px;
color: #999;
}
}
.user-img {
width: 72px;
height: 72px;
margin-right: 20px;
border-radius: 50%;
}
.content {
max-width: calc(100% - 144px);
position: relative;
margin-top: 44px;
.cir {
width: 0px;
height: 0px;
border: 10px solid transparent;
position: absolute;
top: 20px;
}
.content-text {
display: inline-block;
padding: 14px 54px 14px 32px;
width: 100%;
background-color: #fff;
font-family: PingFangSC-Regular;
font-size: 32px;
color: #333;
word-break: break-all;
box-sizing: border-box;
}
}
.fail-img {
width: 32px;
height: 32px;
margin: auto 0 auto 24px;
}
.img-list {
img {
max-width: 400px;
margin: 0 16px 16px 0;
}
}
::v-deep .uni-audio-default {
height: 72px;
width: 280px!important;
min-width: 0!important;
}
::v-deep .uni-audio-left {
height: 72px;
width: 72px;
.uni-audio-button {
margin: 14px;
}
}
::v-deep .uni-audio-right {
height: 72px;
margin-left: 72px;
padding: 10px 32px 10px 0;
}
.revoke-text {
line-height: 54px;
padding: 0 24px;
border-radius: 8px;
background-color: #EEE;
color: #999;
margin-top: 16px;
}
.file {
height: 128px;
background: #FFFFFF;
border-radius: 8px;
border: 1px solid #CCCCCC;
box-sizing: border-box;
padding: 0 16px;
margin-bottom: 32px;
& > .u-row {
height: 100%;
.left {
width: 522px;
display: flex;
align-items: center;
& > img {
width: 96px;
height: 96px;
}
& > span {
font-size: 32px;
color: #333333;
display: inline-block;
line-height: 44px;
text-overflow: ellipsis;
overflow-x: hidden;
white-space: nowrap;
}
}
& > span {
font-size: 28px;
color: #999;
margin: -8px 0 0 16px;
}
}
}
.card-info {
width: 450px;
background: #FFF;
.top {
padding: 16px 32px;
display: flex;
.card-left {
width: calc(100% - 120px);
h3 {
font-family: PingFangSC-Regular;
font-size: 32px;
color: #333;
line-height: 44px;
margin-bottom: 30px;
}
p {
font-family: PingFangSC-SNaNpxibold;
font-size: 32px;
color: #333;
line-height: 44px;
}
div {
font-family: PingFangSC-Regular;
font-size: 24px;
color: #999;
line-height: 34px;
}
.display-name {
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 24px;
color: #999;
line-height: 34px;
margin-bottom: 10px;
}
}
.card-right {
img {
width: 84px;
height: 84px;
}
}
}
.bottom {
padding-left: 32px;
line-height: 48px;
font-family: PingFangSC-Regular;
font-size: 22px;
color: #999;
border-top: 1px solid #eee;
img {
width: 20px;
height: 20px;
margin-right: 8px;
}
}
}
.map-info {
width: 560px;
height: 400px;
.address-text {
position: absolute;
bottom: 0;
left: 0;
width: 560px;
background-color: rgba(0, 0, 0, .7);
p {
color: #fff;
line-height: 44px;
font-size: 24px;
padding-left: 32px;
word-break: break-all;
}
}
}
}
.item-left {
.content {
.cir {
left: -18px;
border-right-color: #fff;
}
}
}
.item-right {
width: 100%;
justify-content: right;
.user-name {
left: 0;
right: 82px;
text-align: right;
}
.user-img {
margin: 0 0 0 20px;
}
.content {
.cir {
border-left-color: #C7E7FE;
right: -18px;
}
.content-text {
background-color: #C7E7FE;
padding: 14px 32px 14px 54px;
}
.img-list {
img {
max-width: 400px;
margin: 0 0 16px 16px;
}
}
}
.fail-img {
margin: auto 24px auto 0;
}
}
}
.footer{
width: 100%;
height: 112px;
line-height: 112px;
background: #1365DD;
box-shadow: inset 0px 1px 0px 0px #EEEEEE;
font-size: 32px;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #FFF;
text-align: center;
position: fixed;
bottom: 0;
left: 0;
z-index: 99;
}
}
</style>