cashier_weapp/components/navseat.vue

295 lines
6.8 KiB
Vue

<template>
<view class="navbarcontent">
<!-- 导航栏 -->
<view class="navbar" :class="{active:opacity}">
<!-- #ifndef APP-PLUS || MP-WEIXIN || MP-ALIPAY -->
<view class="status-bar"></view>
<view class="navbar_tow flex-between"
:style="{'height':HeighT.customBar+'px','padding-right':HeighT.custwidth + 'px'}">
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<view class="navbar_tow flex-between" :style="{'marginTop':HeighT.heightBar /2+'px'}">
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<view class="navbar_tow flex-between"
:style="{'height':HeighT.customBar + ( (HeighT.heightBar - systemInfo.statusBarHeight)*2 )+'px','marginTop': ( HeighT.heightBar - (HeighT.heightBar - systemInfo.statusBarHeight))+'px','padding-right':HeighT.custwidth + 'px'}">
<!-- #endif -->
<!-- #ifdef MP-ALIPAY -->
<view class="navbar_tow flex-between"
:style="{'height':systemInfo.titleBarHeight+'px','marginTop':systemInfo.statusBarHeight+'px','padding-right':menuButtonInfo.width+50 + 'px'}">
<!-- #endif -->
<!-- 标题搜索框 -->
<view class="flex-between" v-if="opacity&&inputshow">
<!-- #ifndef MP-ALIPAY -->
<view class="navbar_tow_one flex-start" v-if="iconshow" @click="clicknavigateBack">
<u-icon name="arrow-left" :color="iconcolor" size="40"></u-icon>
</view>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<view class="navbar_tow_tow " @click="inputFocus" style="position: relative">
<!-- #endif -->
<!-- #ifdef MP-ALIPAY -->
<view class="navbar_tow_tow " @click="inputFocus" style="position: relative;padding-left: 60rpx;">
<!-- #endif -->
<u--input
placeholder="请输入内容"
class="custom-input"
border="surround"
:focus="focus"
@confirm="confirmSearch"
v-model="searchVal"
:readonly="readonly"
prefixIcon="search"
prefixIconStyle="font-size: 18px;color: #909399"
placeholderStyle="font-size: 14px;color: #999"
fontSize="14px"
:customStyle="{padding: '3rpx 10rpx ',width: '400rpx',borderRadius: '30rpx',backgroundColor: '#eee'}"
>
</u--input>
</view>
</view>
<!-- 正常导航栏 -->
<view class="flex-between" @click="clicknavigateBack" v-else>
<!-- #ifndef MP-ALIPAY -->
<view class="navbar_tow_one flex-start" v-if="iconshow">
<u-icon name="arrow-left" :color="iconcolor" size="40"></u-icon>
</view>
<!-- #endif -->
<!-- #ifndef MP-WEIXIN || MP-ALIPAY -->
<view class="navbar_tow_tow" v-if="opacity || titleshow" :style="{color: namecolor}">
<!-- #endif -->
<!-- #ifdef MP-WEIXIN -->
<view class="navbar_tow_tow" v-if="opacity || titleshow"
:style="{'padding-left':HeighT.custwidth-14 + 'px',color: namecolor}">
<!-- #endif -->
<!-- #ifdef MP-ALIPAY -->
<view class="navbar_tow_tow" v-if="opacity || titleshow"
:style="{'padding-left': 60 + 'rpx','textAlign': 'left',color: namecolor}">
<!-- #endif -->
{{title}}
</view>
</view>
</view>
</view>
<view class="" v-if="heightshow" :style="{height:Topdistance +'px'}">
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
Topdistance: '',
searchVal: "",
systemInfo: '',
// keyword
};
},
props: {
title: {
type: String,
default: ''
},
namecolor: {
type: String,
default: '#333333'
},
search: {
type: Boolean,
default: false
},
opacity: {
type: Boolean,
default: false
},
titleshow: { //标题是否显示
type: Boolean,
default: false
},
heightshow: { //是否要占位高度
type: Boolean,
default: false
},
iconshow: { //返回键是否显示
type: Boolean,
default: true
},
iconcolor: { //返回键颜色
type: String,
default: '#000'
},
navigateBacknavtitle: {
type: Boolean,
default: false
},
inputshow:{
type: Boolean,
default: false
},
focus:{
type: Boolean,
default: false
},
readonly: {
type: Boolean,
default: false
}
},
computed: {
HeighT() { //手机类型的尺寸
return this.$store.getters.is_BarHeight
},
menuButtonInfo() { //手机类型的尺寸
return uni.getMenuButtonBoundingClientRect()
},
},
mounted() {
this.$nextTick(() => {
this.GetTop()
wx.getSystemInfo({
success: res => {
this.systemInfo = res;
}
})
});
// 当组件挂载完成后获取距离
},
methods: {
GetTop() {
this.$u.getRect('.navbar').then(res => {
this.Topdistance = res.height //滚动距离
this.$emit('Topdistance', res.height)
})
},
clicknavigateBack() {
if (this.navigateBacknavtitle) {
this.$emit('navigateBacknav')
} else {
uni.navigateBack()
}
},
/**
* 搜索点击处理
*/
inputFocus() {
console.log(123)
this.$emit('searchStatus', 'searchClick')
},
confirmSearch () {
this.$emit('searchVal', this.searchVal)
}
}
};
</script>
<style scoped lang="scss">
page {
background: #F7F7F7;
}
.navbarcontent {
position: relative;
top: 0;
left: 0;
width: 100%;
z-index: 9999;
.active {
background: rgba(249, 249, 249, 1);
}
.status-bar {
// #ifdef APP-PLUS
height: calc(var(--status-bar-height) / 2);
// #endif
// #ifdef MP-WEIXIN
height: var(--status-bar-height);
// #endif
}
// #ifdef APP-PLUS
.statusbarmargin {
margin-top: var(--status-bar-height);
}
// #endif
.navbar {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 99;
.navbar_tow {
width: 100%;
position: relative;
font-size: 36rpx;
.flex-between {
// #ifdef APP-PLUS || H5
margin: 28rpx;
// #endif
// #ifdef MP-WEIXIN
margin-left: 28rpx;
// #endif
width: 100%;
flex-wrap: nowrap;
height: 100%;
line-height: 100%;
.navbar_tow_one {
height: 100%;
line-height: 100%;
text:nth-child(1) {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: bold;
font-size: 28rpx;
color: #333333;
}
text:nth-child(2) {
margin-left: 16rpx;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 28rpx;
color: #333333;
}
}
.navbar_tow_tow {
width: 200rpx;
text-align: center;
flex: auto;
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
font-size: 28rpx;
position: relative;
.u--input {
width: 200rpx;
input{
font-size: 28rpx;
}
}
}
}
}
}
}
</style>