298 lines
7.6 KiB
Vue
298 lines
7.6 KiB
Vue
<template>
|
|
<view class="common-roomLogs">
|
|
<image
|
|
v-if="showImg"
|
|
:src="settingInfo.messageEnterImage"
|
|
mode="widthFix"
|
|
class="common-ai-img"
|
|
@click="enterAiChat()"
|
|
/>
|
|
<view class="v12-align-center" @click="toMessage">
|
|
<view class="call-message">
|
|
<u-icon :name="webUrl + '/icon/message.png'" size="25"></u-icon>
|
|
</view>
|
|
<view class="v12-ml-2" style="width: 80%">
|
|
<view class="v12-font-bold v12-font-32">互动消息</view>
|
|
<view class="v12-secondary-dark-text v12-font-28 v12-mt-3 v12-justify-between">
|
|
<text>{{ unreadNum > 0 ? `收到${unreadNum}条回复` : '暂无通知'}}</text>
|
|
<view v-if="unreadNum > 0" class="bage-num v12-font-24 v12-primary v12-white-text v12-radius-100">{{ unreadNum > 99 ? '99+' : unreadNum }}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view v-if="list.length > 0" class="v12-mt-3">
|
|
<view
|
|
>
|
|
<u-swipe-action
|
|
class="v12-mt-3"
|
|
>
|
|
<u-swipe-action-item
|
|
:options="options1"
|
|
v-for="(item) in list"
|
|
:key="item.room_id"
|
|
:name="item.room_id"
|
|
style="margin-bottom: 10px;"
|
|
@click.stop="removeRoom(item.room_id)"
|
|
>
|
|
<view class="item">
|
|
<view class="v12-justify-start flex item-cont" @click="goRoom(item)">
|
|
<image
|
|
:src="item.store_avatar || webUrl+'/20221114155314348118.png'"
|
|
class="cover flex-0"
|
|
/>
|
|
<view class="cont">
|
|
<view class="flex jc-between ai-center" style="position: relative">
|
|
<view class="v12-align-center name-wrap">
|
|
<view class="name more-t">{{ item.store_name }}</view>
|
|
<view v-if="item.is_official" class="guanfang">官方</view>
|
|
<view v-else class="shangjia">商家</view>
|
|
</view>
|
|
<view class="datetime" v-if="item.last_msg">{{ item.last_msg.created_at }}</view>
|
|
</view>
|
|
<view class="sub v12-align-center v12-justify-between" v-if="item.last_msg">
|
|
<view class="one-t" style="width: 80%;">{{ item.last_msg.msg_type=== 0 ? item.last_msg.msg_content : '[图片]' }}</view>
|
|
<view v-if="item.unread_num > 0" class="unread-num v12-primary">{{ item.unread_num < 99 ? item.unread_num : '99+' }}</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</u-swipe-action-item>
|
|
</u-swipe-action>
|
|
</view>
|
|
</view>
|
|
<view class="v4-nodata" v-if="list.length===0">
|
|
<!-- <image src="@/static/images/img_nodata.png" mode="scaleToFill"/> -->
|
|
<view class="text">暂无数据</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapGetters } from 'vuex'
|
|
import { getUnreadMessageCount, markMessagesAsRead } from '@/api/rooms'
|
|
import {
|
|
getAiSystemInfoSetting
|
|
} from '@/api/public'
|
|
export default {
|
|
name: 'RoomLogs',
|
|
data() {
|
|
return {
|
|
showImg: false,
|
|
settingInfo: {},
|
|
webUrl:this.$VUE_APP_RESOURCES_URL,
|
|
uid: null,
|
|
list: [],
|
|
options1: [{text: '删除', style: {color: '#fff', backgroundColor: '#C52733'} }],
|
|
unreadNum: 0,
|
|
webUrl: this.$VUE_APP_RESOURCES_URL
|
|
}
|
|
},
|
|
computed: mapGetters(['userInfo']),
|
|
onShow() {
|
|
this.uid = this.userInfo.uid
|
|
this.fetchList()
|
|
this.getUnreadMessageCount()
|
|
getAiSystemInfoSetting().then(res => {
|
|
const { success, data } = res
|
|
if (success) {
|
|
this.settingInfo = data
|
|
this.showImg = data.showOnAppIndex === 1
|
|
}
|
|
})
|
|
},
|
|
methods: {
|
|
enterAiChat() {
|
|
const cityName = uni.getStorageSync('locationCityName') || ''
|
|
uni.navigateTo({
|
|
url: `/aiChat/views/index?click=1&cityName=${cityName}`
|
|
})
|
|
},
|
|
/**
|
|
* 去消息
|
|
*/
|
|
toMessage() {
|
|
markMessagesAsRead().then(res => {
|
|
uni.$emit('updateUnreadMessageCount', 0)
|
|
uni.navigateTo({url: '/pkg_common/views/message'})
|
|
})
|
|
},
|
|
/**
|
|
* 获取互动消息
|
|
* @param {*} item
|
|
*/
|
|
getUnreadMessageCount(item) {
|
|
getUnreadMessageCount().then(res => {
|
|
const count = res.data || 0
|
|
this.unreadNum = count
|
|
uni.request({
|
|
url: this.$SERVICE_API_URL + '/customer-chat-list',
|
|
method: 'POST',
|
|
data: {uid: this.uid},
|
|
success: res => {
|
|
if (res.data.status_code === 200) {
|
|
const _count = res.data.content + count
|
|
uni.$emit('updateUnreadMessageCount', _count)
|
|
} else {
|
|
uni.$emit('updateUnreadMessageCount', count)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
goRoom(item) {
|
|
uni.navigateTo({url: `/pkg_common/views/room?id=${item.store_id}&name=${item.store_name}`})
|
|
},
|
|
fetchList() {
|
|
const _this = this
|
|
uni.request({
|
|
url: _this.$SERVICE_API_URL + '/customer-chat-list',
|
|
method: 'POST',
|
|
data: {uid: _this.uid},
|
|
success: res => {
|
|
if (res.data.status_code === 200) {
|
|
_this.list = res.data.content
|
|
}
|
|
}
|
|
})
|
|
},
|
|
removeRoom(id) {
|
|
const _this = this
|
|
uni.showModal({
|
|
title:'确定删除消息?',
|
|
success:(res)=>{
|
|
if(res.confirm) {
|
|
uni.request({
|
|
url: _this.$SERVICE_API_URL + '//chat-remove',
|
|
method: 'POST',
|
|
data: {
|
|
room_id: id,
|
|
remove_from: 'user'
|
|
},
|
|
success:(res)=>{
|
|
if(res.data.status_code === 200) {
|
|
_this.fetchList()
|
|
}
|
|
},
|
|
})
|
|
}
|
|
},
|
|
})
|
|
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style scoped lang="less">
|
|
.common-ai-img {
|
|
width: 100%;
|
|
margin: 0 0 24rpx 0;
|
|
}
|
|
.call-message{
|
|
width: 120rpx;
|
|
height: 120rpx;
|
|
background: #C52733;
|
|
border-radius: 20rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.common-roomLogs{
|
|
background: #fff;
|
|
}
|
|
.common-roomLogs .u-swipe-action-item{
|
|
margin-bottom: 20rpx;
|
|
}
|
|
</style>
|
|
<style scoped lang="less">
|
|
.unread-num{
|
|
color: #FFFFFF;
|
|
height: 38rpx;
|
|
width: 38rpx;
|
|
border-radius: 50%;
|
|
line-height: 38rpx;
|
|
text-align: center;
|
|
font-size: 20rpx;
|
|
}
|
|
.guanfang{
|
|
color: #ee6f6e;
|
|
background: #fad7d7;
|
|
width: fit-content;
|
|
font-size: 16rpx;
|
|
padding: 0 4rpx;
|
|
border-radius: 4rpx;
|
|
z-index: 9;
|
|
top: 0;
|
|
white-space: nowrap;
|
|
}
|
|
.shangjia{
|
|
color: #5791fe;
|
|
background: #dce9ff;
|
|
width: fit-content;
|
|
font-size: 16rpx;
|
|
padding: 0 4rpx;
|
|
border-radius: 4rpx;
|
|
z-index: 9;
|
|
top: 0;
|
|
white-space: nowrap;
|
|
}
|
|
.common-roomLogs {
|
|
min-height: 100vh;
|
|
box-sizing: border-box;
|
|
padding: 24rpx;
|
|
background: #fff;
|
|
|
|
.item {
|
|
padding: 24rpx 0;
|
|
border-radius: 8rpx;
|
|
border-top: 1rpx solid #eee;
|
|
background: #FFFFFF;
|
|
.item-cont {
|
|
display: flex;
|
|
.cont {
|
|
flex: 1;
|
|
width: calc(100% - 140rpx);
|
|
}
|
|
}
|
|
|
|
.cover {
|
|
width: 120rpx;
|
|
height: 120rpx;
|
|
margin-right: 18rpx;
|
|
border-radius: 20rpx;
|
|
}
|
|
|
|
.name-wrap {
|
|
width: calc(100% - 240rpx);
|
|
}
|
|
.name {
|
|
font-size: 26rpx;
|
|
font-weight: bold;
|
|
line-height: 38rpx;
|
|
color: #333333;
|
|
}
|
|
|
|
.datetime {
|
|
font-size: 22rpx;
|
|
line-height: 32rpx;
|
|
color: #999999;
|
|
flex-wrap: nowrap;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.sub {
|
|
width: 100%;
|
|
margin-top: 12rpx;
|
|
font-size: 24rpx;
|
|
line-height: 34rpx;
|
|
color: #666666;
|
|
}
|
|
}
|
|
}
|
|
.bage-num {
|
|
min-width: 40rpx;
|
|
height: 40rpx;
|
|
text-align: center;
|
|
box-sizing: border-box;
|
|
padding: 4rpx;
|
|
}
|
|
</style>
|