alipay-emulator/components/call-log/nav-bar/nav-bar.vue

269 lines
5.3 KiB
Vue

<template>
<uni-nav-bar :backgroundColor="navBgColor" class="nav-bar" :border="false" :title="title" fixed="true" statusBar="true">
<template v-slot:left>
<slot name="left">
<view :class="[type+'LeftTitle']" :style="{opacity:(type!='huawei'&&type!='oppo'?1: navOpacity)}">
{{LeftTitle}}
</view>
</slot>
</template>
<view class="nav-bar-title " :class="['nav-bar-title-'+type]">
<slot>
<view class="iosBox" v-if="type=='ios'">
<view class="btn " :class="{'active':active}" @click.stop="setActive(true)">
全部来电
</view>
<view class="btn" :class="{'active':!active}" @click.stop="setActive(false)">
未接来电
</view>
</view>
<view class="oppoBox" v-if="type=='oppo'" :style="{opacity: navOpacity?1-navOpacity:1}">
<view class="btn " :class="{'active':active}" @click.stop="setActive(true)">
全部
</view>
<view class="btn" :class="{'active':!active}" @click.stop="setActive(false)">
未接
</view>
</view>
<view class="title" v-else-if="type=='xiaomi'" :style="{opacity: navOpacity}">
通话
</view>
</slot>
</view>
<template v-slot:right>
<slot name="right">
<view class="rightImgBox" :class="['rightImgBox'+type]">
<image v-if="type=='oppo'||type=='vivo'" class="rightImg" :src="`/static/image/call/${type}NavRightImg2.png`"></image>
<image v-if="type!='ios'" class="rightImg" :class="['rightImg_'+type]"
:src="`/static/image/call/${type}NavRightImg.png`"></image>
</view>
</slot>
</template>
</uni-nav-bar>
</template>
<script setup>
import {
onMounted,
reactive,
ref,
toRefs,
watch
} from 'vue'
const topPopup = ref()
// 定义组件属性
const props = defineProps({
bgColor: {
type: String,
default: '#fff'
},
textColor: {
type: String,
default: '#000'
},
title: {
type: String,
default: ''
},
type: {
type: String,
default: 'ios'
},
scrollTop: {
type: Number,
default: 0
}
})
const data = reactive({
active:true,
statusBarHeight: 0,
LeftTitle:'',
showTipLayer: true,
navOpacity: 0, // 导航栏透明度
navBgColor: props.bgColor // 导航栏背景色
})
let {
active,
LeftTitle,
showTipLayer,
navOpacity,
navBgColor
} = toRefs(data)
// 监听 scrollTop 变化
watch(() => props.scrollTop, (newValue, oldValue) => {
// console.log('scrollTop changed:', newValue);
// 根据 scrollTop 的值计算导航栏透明度
if (newValue > 0) {
// 当 scrollTop 大于 0 时,透明度逐渐增加
navOpacity.value = Math.min(1, newValue / 100);
// 可以根据需要调整背景色
// navBgColor.value = `rgba(255, 255, 255, ${navOpacity.value})`;
} else {
// 当 scrollTop 为 0 时,透明度为 1
navOpacity.value = 0;
// navBgColor.value = props.bgColor;
}
});
onMounted(() => {
if(props.type=='ios'){
LeftTitle.value='编辑'
}else if(props.type=='vivo'){
LeftTitle.value='拨号'
}else if(props.type=='oppo'){
LeftTitle.value='通话'
}else if(props.type=='huawei'){
LeftTitle.value='电话'
}else {
LeftTitle.value=''
}
})
function setActive(status){
active.value=status
uni.$emit('setActive',status)
}
</script>
<style scoped lang="scss">
::v-deep .uni-navbar__header-btns {
width: 27vw !important;
}
.iosLeftTitle {
font-weight: 400;
font-size: 16px;
color: #018AE0;
}
.rightImgBox {
display: flex;
align-items: center;
image {
width: 24px ;
height: 24px;
}
}
.rightImg_oppo {
margin-left: 26px;
}
.rightImg_vivo {
margin-left: 26px;
margin-right: 16px;
}
.oppoLeftTitle {
padding-left: 8px;
font-weight: bold;
font-size: 32px;
color: #1A1A1A;
}
.huaweiLeftTitle {
padding-left: 8px;
font-weight: bold;
font-size: 30px;
color: #1A1A1A;
}
.vivoLeftTitle {
padding-left: 34px;
font-weight: bold;
font-size: 30px;
color: #1A1A1A;
}
.nav-bar-title-xiaomi {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
font-weight: bold;
font-size: 18px;
color: #1A1A1A;
}
.nav-bar-title-oppo {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
.oppoBox {
padding: 0 2px;
width: 100%;
display: flex;
align-items: center;
justify-content: space-around;
width: 137px;
height: 34px;
background: #E9E9E9;
border-radius: 17px 17px 17px 17px;
.btn {
font-size: 12px;
color: #6B6B6B;
width: 67px;
height: 30px;
text-align: center;
line-height: 30px;
}
.active {
color: #1A1A1A;
background: #FFFFFF;
border-radius: 17px 17px 17px 17px;
}
}
}
.nav-bar-title-ios {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
.iosBox {
width: 100%;
display: flex;
align-items: center;
justify-content: space-around;
width: 145px;
height: 30px;
background: #EEEEEE;
border-radius: 8px 8px 8px 8px;
.btn {
font-size: 12px;
color: #1A1A1A;
width: 69px;
height: 26px;
text-align: center;
line-height: 26px;
}
.active {
background: #FFFFFF;
box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.1);
border-radius: 6px 6px 6px 6px;
margin: 0 2px;
}
}
}
.rightImg_xiaomi {
width: 20px !important;
height: 20px !important;
}
.rightImg_huawei {
width: 38px !important;
height: 38px !important;
}
</style>