You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.
< template >
< view >
< uni -popup
ref = "popup"
background -color = " # fff "
type = "left"
class = "history-popup"
@change ="changeShow"
>
< view class = "drawer-mask" >
< view class = "drawer" >
< scroll -view class = "drawer-scroll" scroll -y show -scrollbar = " false " >
< view v-for ="g in historyGroups" :key="g.date" class="drawer-group">
<view class="drawer-date">{{ g.date }}</view>
<view
v-for="(t, idx) in g.items"
:key="idx"
class="drawer-item overflow-one"
@tap="onHistoryItemTap(t)"
@longpress="onLongPressHistory(t)"
>
{{ t }}
</view>
<view class="drawer-divider" />
</view>
</scroll-view>
<view class="drawer-footer">
<view class="user-icon">👤</view>
<text class="user-name">用户<E794A8> </text>
<view class="footer-gear" @tap="clearAllHistory" > ⚙ ️ < / view >
< / view >
< / view >
< / view >
< / uni -popup >
< / view >
< / template >
< script >
export default {
props : {
historyGroups : {
type : Array ,
default ( ) {
return [ ]
}
}
} ,
methods : {
onHistoryItemTap ( text ) {
this . $emit ( 'onHistoryItemTap' , text )
} ,
onLongPressHistory ( text ) {
uni . showModal ( {
title : "删除记录" ,
content : "确定删除这条对话记录?" ,
success : ( res ) => {
if ( res . confirm ) {
this . $emit ( 'removeFromHistory' , text )
}
} ,
} ) ;
} ,
close ( ) {
this . $refs . popup . close ( )
} ,
open ( ) {
this . $refs . popup . open ( )
} ,
changeShow ( e ) {
this . $emit ( 'changeShow' , e . show )
} ,
clearAllHistory ( ) {
this . $emit ( 'clearAllHistory' )
}
}
} ;
< / script >
< style lang = "scss" scoped >
. history - popup {
z - index : 99999 ;
}
. drawer - mask {
width : 75 vw ;
height : 100 vh ;
}
. drawer {
width : 70 vw ;
height : 100 vh ;
background : # fff ;
border - top - right - radius : 8 px ;
border - bottom - right - radius : 8 px ;
display : flex ;
flex - direction : column ;
}
. drawer . show {
transform : translateX ( 0 ) ;
}
. drawer - scroll {
height : calc ( 100 vh - 64 px ) ;
padding : 12 px ;
box - sizing : border - box ;
}
. drawer - group {
padding : 10 px 8 px 0 ;
}
. drawer - date {
color : # 9 aa3b2 ;
font - size : 14 px ;
margin - bottom : 8 px ;
}
. drawer - item {
color : # 333 ;
font - size : 16 px ;
line - height : 20 px ;
margin : 12 px 0 ;
}
. drawer - divider {
height : 1 px ;
background : # eeeeee ;
margin : 12 px 0 ;
}
. drawer - footer {
padding : 12 px ;
border - top : 1 px solid # eeeeee ;
display : flex ;
align - items : center ;
}
. drawer - footer {
/* fixed height for calc above */
height : 64 px ;
}
. user - icon {
width : 24 px ;
text - align : center ;
}
. user - name {
flex : 1 ;
font - size : 14 px ;
color : # 333 ;
}
. footer - gear {
width : 24 px ;
text - align : center ;
}
< / style >