样式:增加tab栏切换

This commit is contained in:
xiao12feng8 2026-02-01 10:56:03 +08:00
parent 4286338fa0
commit 1c52847a02

View File

@ -25,26 +25,6 @@
</view> </view>
</template> </template>
</uni-nav-bar> </uni-nav-bar>
<!-- Tab -->
<view class="tab-bar">
<scroll-view class="tab-scroll" scroll-x="true" :scroll-left="tabScrollLeft" scroll-with-animation>
<view class="tab-list">
<view
v-for="(tab, index) in tabList"
:key="index"
class="tab-item"
:class="{ 'active': currentTab === index }"
@click="switchTab(index)">
<text class="tab-text">{{ tab.name }}</text>
<view v-if="currentTab === index" class="tab-indicator"></view>
</view>
</view>
</scroll-view>
</view>
<!-- 聊天内容区域 -->
<view v-show="currentTab === 0" class="tab-content">
<image class="back" <image class="back"
:src="loverBasicList.image_url ? loverBasicList.image_url : 'https://nvlovers.oss-cn-qingdao.aliyuncs.com/uploads/20251226/39c6f8899c15f60fc59207835f95e07a.png'" :src="loverBasicList.image_url ? loverBasicList.image_url : 'https://nvlovers.oss-cn-qingdao.aliyuncs.com/uploads/20251226/39c6f8899c15f60fc59207835f95e07a.png'"
mode="aspectFill"></image> mode="aspectFill"></image>
@ -184,103 +164,8 @@
</view> --> </view> -->
</view> </view>
</view> </view>
<!-- 唱歌页面 --> <!-- 录音弹框 -->
<view v-show="currentTab === 1" class="tab-content">
<view class="feature-page">
<view class="feature-title">唱歌功能</view>
<view class="feature-desc">让她为你唱一首歌</view>
<view class="song-list">
<view class="song-item" v-for="(item,index) in singSongsList" :key="index" @click="selectSongDirect(item)">
<view class="song-info">
<text class="song-title">{{item.title}}</text>
</view>
<image class="song-icon" src="/static/images/chat_a6.png" mode="widthFix"></image>
</view>
</view>
</view>
</view>
<!-- 跳舞页面 -->
<view v-show="currentTab === 2" class="tab-content">
<view class="feature-page">
<view class="feature-title">跳舞功能</view>
<view class="feature-desc">让她为你跳一支舞</view>
<view class="dance-input">
<input type="text" v-model="dancePrompt" placeholder="描述你想看的舞蹈动作" class="dance-input-field" />
<view class="dance-btn" @click="requestDance">生成舞蹈</view>
</view>
</view>
</view>
<!-- 换服装页面 -->
<view v-show="currentTab === 3" class="tab-content">
<view class="feature-page">
<view class="feature-title">换服装</view>
<view class="feature-desc">为她挑选不同的服装</view>
<view class="outfit-grid">
<view class="outfit-item" v-for="i in 6" :key="i">
<image class="outfit-image" src="/static/images/avatar.png" mode="aspectFill"></image>
<text class="outfit-name">服装 {{i}}</text>
</view>
</view>
</view>
</view>
<!-- 刷礼物页面 -->
<view v-show="currentTab === 4" class="tab-content">
<view class="feature-page">
<view class="feature-title">送礼物</view>
<view class="feature-desc">送她一份心意</view>
<view class="gift-grid">
<view class="gift-item" v-for="i in 8" :key="i" @click="sendGift(i)">
<image class="gift-image" src="/static/images/chat_a2.png" mode="widthFix"></image>
<text class="gift-name">礼物 {{i}}</text>
<text class="gift-price">{{i * 10}} 金币</text>
</view>
</view>
</view>
</view>
<!-- 商城页面 -->
<view v-show="currentTab === 5" class="tab-content">
<view class="feature-page">
<view class="feature-title">商城</view>
<view class="feature-desc">购买更多功能和道具</view>
<view class="shop-list">
<view class="shop-item" v-for="i in 4" :key="i">
<view class="shop-info">
<text class="shop-title">套餐 {{i}}</text>
<text class="shop-desc">包含多种功能和道具</text>
</view>
<view class="shop-price">
<text class="price-value">¥{{i * 30}}</text>
<view class="shop-buy-btn">购买</view>
</view>
</view>
</view>
</view>
</view>
<!-- 短剧页面 -->
<view v-show="currentTab === 6" class="tab-content">
<view class="feature-page">
<view class="feature-title">短剧</view>
<view class="feature-desc">观看精彩短剧内容</view>
<view class="drama-list">
<view class="drama-item" v-for="i in 3" :key="i">
<image class="drama-cover" src="/static/images/avatar.png" mode="aspectFill"></image>
<view class="drama-info">
<text class="drama-title">短剧标题 {{i}}</text>
<text class="drama-desc">精彩剧情简介...</text>
<view class="drama-play-btn">播放</view>
</view>
</view>
</view>
</view>
</view>
<!-- 唱歌/跳舞弹框提示 -->
<view class="alert" v-if="alertState"> <view class="alert" v-if="alertState">
<view class="alert_hide" @click="alertState = false"></view> <view class="alert_hide" @click="alertState = false"></view>
<view v-if="videoState" class="alert_opt fa sb"> <view v-if="videoState" class="alert_opt fa sb">
@ -384,19 +269,6 @@
}, },
data() { data() {
return { return {
// Tab
currentTab: 0,
tabScrollLeft: 0,
tabList: [
{ name: '聊天', icon: '' },
{ name: '唱歌', icon: '' },
{ name: '跳舞', icon: '' },
{ name: '换服装', icon: '' },
{ name: '刷礼物', icon: '' },
{ name: '商城', icon: '' },
{ name: '短剧', icon: '' }
],
dancePrompt: '', //
// //
// messages: [], // messages: [],
loverBasicList: uni.getStorageSync('loverBasicList'), loverBasicList: uni.getStorageSync('loverBasicList'),
@ -477,54 +349,6 @@
this.stopCurrentAudio(); this.stopCurrentAudio();
}, },
methods: { methods: {
// Tab
switchTab(index) {
this.currentTab = index;
// 使 tab
const tabWidth = 120; // tab rpx
const screenWidth = 750; // rpx
this.tabScrollLeft = Math.max(0, (index * tabWidth) - (screenWidth / 2) + (tabWidth / 2));
},
//
selectSongDirect(song) {
this.songId = song.id;
uni.showLoading({
title: '生成中...'
});
SingGenerate({
song_id: song.id
}).then(res => {
if (res.code == 1) {
this.getSingGenerateTask(res.data.task_id);
} else {
uni.hideLoading();
uni.showToast({
title: res.msg,
icon: 'none'
});
}
});
},
//
requestDance() {
if (!this.dancePrompt || !this.dancePrompt.trim()) {
uni.showToast({
title: '请输入舞蹈描述',
icon: 'none'
});
return;
}
this.messageprompt = this.dancePrompt;
this.savechatSing();
},
//
sendGift(giftId) {
uni.showToast({
title: `送出礼物 ${giftId}`,
icon: 'success'
});
// API
},
initAudio() { initAudio() {
// //
if (this.audioContext) { if (this.audioContext) {
@ -1926,311 +1750,6 @@
</style> </style>
<style scoped> <style scoped>
/* Tab 栏样式 */
.tab-bar {
position: relative;
z-index: 10;
background: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(10px);
padding: 0;
margin-top: 88rpx;
}
.tab-scroll {
width: 100%;
white-space: nowrap;
}
.tab-list {
display: inline-flex;
padding: 0 20rpx;
}
.tab-item {
position: relative;
padding: 20rpx 30rpx;
margin: 0 10rpx;
cursor: pointer;
transition: all 0.3s;
}
.tab-text {
font-size: 28rpx;
color: rgba(255, 255, 255, 0.6);
transition: all 0.3s;
white-space: nowrap;
}
.tab-item.active .tab-text {
color: #FFFFFF;
font-weight: bold;
font-size: 32rpx;
}
.tab-indicator {
position: absolute;
bottom: 10rpx;
left: 50%;
transform: translateX(-50%);
width: 40rpx;
height: 6rpx;
background: linear-gradient(90deg, #E1C7FF, #B794F6);
border-radius: 3rpx;
}
/* Tab 内容区域 */
.tab-content {
flex: 1;
position: relative;
overflow-y: auto;
}
/* 功能页面通用样式 */
.feature-page {
padding: 40rpx;
min-height: 100%;
}
.feature-title {
font-size: 48rpx;
font-weight: bold;
color: #FFFFFF;
text-align: center;
margin-bottom: 20rpx;
text-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.3);
}
.feature-desc {
font-size: 28rpx;
color: rgba(255, 255, 255, 0.8);
text-align: center;
margin-bottom: 60rpx;
}
/* 歌曲列表样式 */
.song-list {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 20rpx;
padding: 20rpx;
}
.song-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 30rpx;
background: rgba(255, 255, 255, 0.05);
border-radius: 15rpx;
margin-bottom: 20rpx;
}
.song-info {
flex: 1;
}
.song-title {
font-size: 32rpx;
color: #FFFFFF;
}
.song-icon {
width: 60rpx;
height: 60rpx;
}
/* 跳舞输入样式 */
.dance-input {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 20rpx;
padding: 40rpx;
}
.dance-input-field {
width: 100%;
padding: 30rpx;
background: rgba(255, 255, 255, 0.1);
border-radius: 15rpx;
color: #FFFFFF;
font-size: 28rpx;
margin-bottom: 30rpx;
}
.dance-btn {
width: 100%;
padding: 30rpx;
background: linear-gradient(90deg, #E1C7FF, #B794F6);
border-radius: 15rpx;
text-align: center;
color: #FFFFFF;
font-size: 32rpx;
font-weight: bold;
}
/* 服装网格样式 */
.outfit-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 30rpx;
}
.outfit-item {
text-align: center;
}
.outfit-image {
width: 100%;
height: 200rpx;
border-radius: 15rpx;
background: rgba(255, 255, 255, 0.1);
margin-bottom: 15rpx;
}
.outfit-name {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.8);
}
/* 礼物网格样式 */
.gift-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 30rpx;
}
.gift-item {
text-align: center;
padding: 20rpx;
background: rgba(255, 255, 255, 0.1);
border-radius: 15rpx;
}
.gift-image {
width: 80rpx;
height: 80rpx;
margin-bottom: 10rpx;
}
.gift-name {
font-size: 24rpx;
color: #FFFFFF;
display: block;
margin-bottom: 5rpx;
}
.gift-price {
font-size: 20rpx;
color: #FFD700;
}
/* 商城列表样式 */
.shop-list {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 20rpx;
padding: 20rpx;
}
.shop-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 30rpx;
background: rgba(255, 255, 255, 0.05);
border-radius: 15rpx;
margin-bottom: 20rpx;
}
.shop-info {
flex: 1;
}
.shop-title {
font-size: 32rpx;
color: #FFFFFF;
display: block;
margin-bottom: 10rpx;
}
.shop-desc {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.6);
}
.shop-price {
display: flex;
align-items: center;
gap: 20rpx;
}
.price-value {
font-size: 36rpx;
color: #FFD700;
font-weight: bold;
}
.shop-buy-btn {
padding: 15rpx 30rpx;
background: linear-gradient(90deg, #E1C7FF, #B794F6);
border-radius: 10rpx;
color: #FFFFFF;
font-size: 24rpx;
}
/* 短剧列表样式 */
.drama-list {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 20rpx;
padding: 20rpx;
}
.drama-item {
display: flex;
padding: 20rpx;
background: rgba(255, 255, 255, 0.05);
border-radius: 15rpx;
margin-bottom: 20rpx;
}
.drama-cover {
width: 200rpx;
height: 280rpx;
border-radius: 10rpx;
background: rgba(255, 255, 255, 0.1);
margin-right: 20rpx;
}
.drama-info {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.drama-title {
font-size: 32rpx;
color: #FFFFFF;
font-weight: bold;
margin-bottom: 10rpx;
}
.drama-desc {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.6);
line-height: 1.5;
}
.drama-play-btn {
align-self: flex-start;
padding: 15rpx 40rpx;
background: linear-gradient(90deg, #E1C7FF, #B794F6);
border-radius: 10rpx;
color: #FFFFFF;
font-size: 24rpx;
}
.body { .body {
position: relative; position: relative;
height: 100vh; height: 100vh;