269 lines
6.1 KiB
Vue
269 lines
6.1 KiB
Vue
<template>
|
|
<view
|
|
:class="{
|
|
'show': showLayer
|
|
}"
|
|
class="history-wrap"
|
|
>
|
|
<view class="layer" @click="closeLayer" />
|
|
<view
|
|
:style="{
|
|
'padding-top': statusBarHeight + 'px'
|
|
}"
|
|
class="history-container"
|
|
>
|
|
<view class="history-type">
|
|
<view class="title">
|
|
<view class="txt">今日</view>
|
|
<image
|
|
v-if="todayList.length > 0"
|
|
:src="webUrl + '/aiChat/delete.png'"
|
|
class="icon"
|
|
mode="widthFix"
|
|
@click="deleteRecords(2)"
|
|
/>
|
|
</view>
|
|
<view v-if="todayList.length > 0" class="list-cont">
|
|
<view
|
|
v-for="(item, index) in todayList"
|
|
:key="index"
|
|
class="item"
|
|
@click="historyItemClick(item)"
|
|
>
|
|
<view class="item-txt one-t">
|
|
{{ item.title }}
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view v-else class="no-data">
|
|
<image
|
|
:src="webUrl + '/orderIcon/nodata1.png'"
|
|
class="img"
|
|
mode="widthFix"
|
|
/>
|
|
</view>
|
|
</view>
|
|
<view class="history-type">
|
|
<view class="title">
|
|
<view class="txt">30天内</view>
|
|
<image
|
|
v-if="list.length > 0"
|
|
:src="webUrl + '/aiChat/delete.png'"
|
|
class="icon"
|
|
mode="widthFix"
|
|
@click="deleteRecords(2)"
|
|
/>
|
|
</view>
|
|
<view v-if="list.length > 0" class="list-cont">
|
|
<view
|
|
v-for="(item, index) in list"
|
|
:key="index"
|
|
class="item"
|
|
@click="historyItemClick(item)"
|
|
>
|
|
<view class="item-txt one-t">
|
|
{{ item.title }}
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view v-else class="no-data">
|
|
<image
|
|
:src="webUrl + '/orderIcon/nodata1.png'"
|
|
class="img"
|
|
mode="widthFix"
|
|
/>
|
|
</view>
|
|
</view>
|
|
<view class="history-type">
|
|
<view class="title">
|
|
<view class="txt">超过30天</view>
|
|
<image
|
|
v-if="moreList.length > 0"
|
|
:src="webUrl + '/aiChat/delete.png'"
|
|
class="icon"
|
|
mode="widthFix"
|
|
@click="deleteRecords(3)"
|
|
/>
|
|
</view>
|
|
<view v-if="moreList.length > 0" class="list-cont">
|
|
<view
|
|
v-for="(item, index) in moreList"
|
|
:key="index"
|
|
class="item"
|
|
@click="historyItemClick(item)"
|
|
>
|
|
<view class="item-txt one-t">
|
|
{{ item.title }}
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view v-else class="no-data">
|
|
<image
|
|
:src="webUrl + '/orderIcon/nodata1.png'"
|
|
class="img"
|
|
mode="widthFix"
|
|
/>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
getChatList,
|
|
deleteChatListByType
|
|
} from '@/api/chat/index'
|
|
export default {
|
|
name: 'AiHistoryList',
|
|
props: {
|
|
statusBarHeight: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
// 来源模块:''-首页,'history'-历史记录
|
|
formModule: {
|
|
type: String,
|
|
default: ''
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
webUrl: this.$VUE_APP_RESOURCES_URL,
|
|
showLayer: false,
|
|
todayList: [],
|
|
list: [],
|
|
moreList: []
|
|
}
|
|
},
|
|
methods: {
|
|
showView() {
|
|
this.showLayer = true
|
|
this.getChatListReq()
|
|
},
|
|
getChatListReq() {
|
|
getChatList().then(res => {
|
|
const { success, data } = res
|
|
if (success) {
|
|
this.todayList = data['今天'] || []
|
|
this.list = data['30天内'] || []
|
|
this.moreList = data['超过30天'] || []
|
|
}
|
|
})
|
|
},
|
|
deleteRecords(type) {
|
|
deleteChatListByType(type).then(res => {
|
|
const { success } = res
|
|
if (success) {
|
|
this.getChatListReq()
|
|
}
|
|
})
|
|
},
|
|
historyItemClick(item) {
|
|
const paramsStr = `?chatNumber=${item.chatNumber}&title=${item.title}&click=1`
|
|
if (!this.formModule) {
|
|
uni.navigateTo({
|
|
url: '/aiChat/views/history' + paramsStr
|
|
})
|
|
} else {
|
|
uni.redirectTo({
|
|
url: '/aiChat/views/history' + paramsStr
|
|
})
|
|
}
|
|
this.closeLayer()
|
|
},
|
|
closeLayer() {
|
|
this.showLayer = false
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="less">
|
|
.history-wrap {
|
|
position: fixed;
|
|
left: 0;
|
|
top: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
z-index: 1001;
|
|
transform: translateX(-100%);
|
|
opacity: 0;
|
|
transition: all 0.3s;
|
|
.layer {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
z-index: 2;
|
|
background-color: rgba(0, 0, 0, 0.5);
|
|
}
|
|
.history-container {
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
z-index: 5;
|
|
width: 75%;
|
|
padding: 40rpx;
|
|
box-sizing: border-box;
|
|
border-top-right-radius: 60rpx;
|
|
border-bottom-right-radius: 60rpx;
|
|
overflow-y: auto;
|
|
background-color: #fff;
|
|
.history-type + .history-type {
|
|
padding: 40rpx 0 0 0;
|
|
}
|
|
.history-type {
|
|
.title {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
.txt {
|
|
font-size: 34rpx;
|
|
line-height: 50rpx;
|
|
}
|
|
.icon {
|
|
display: block;
|
|
width: 40rpx;
|
|
height: 40rpx;
|
|
}
|
|
}
|
|
.list-cont {
|
|
padding: 24rpx 0 0 0;
|
|
.item + .item {
|
|
margin: 12rpx 0 0 0;
|
|
}
|
|
.item {
|
|
.item-txt {
|
|
display: inline-block;
|
|
max-width: 100%;
|
|
height: 60rpx;
|
|
padding: 0 24rpx;
|
|
box-sizing: border-box;
|
|
border-radius: 30rpx;
|
|
color: #333;
|
|
font-size: 28rpx;
|
|
line-height: 60rpx;
|
|
background-color: #F1F2FF;
|
|
}
|
|
}
|
|
}
|
|
.no-data {
|
|
.img {
|
|
display: block;
|
|
width: 300rpx;
|
|
height: 300rpx;
|
|
margin: 40rpx auto 0 auto;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
&.show {
|
|
opacity: 1;
|
|
transform: translateX(0);
|
|
}
|
|
}
|
|
</style>
|