This commit is contained in:
shikong 2024-10-17 16:28:20 +08:00
parent a179c383e2
commit 7f51077706
Signed by: Shikong
GPG Key ID: BD85FF18B373C341
2 changed files with 49 additions and 30 deletions

View File

@ -0,0 +1,45 @@
<script setup>
import {reactive} from "vue";
const ctx = reactive({
navHeight: 0,
statusBarHeight: 0,
capsuleWidth: 0,
search: {
keyword: ""
}
})
let capsule = uni.getMenuButtonBoundingClientRect(); //
let system = uni.getSystemInfoSync(); //
ctx.navHeight = system.statusBarHeight + capsule.height; //
ctx.statusBarHeight = system.statusBarHeight //
ctx.capsuleWidth = capsule.width; //
function searchKeyword() {
console.log(ctx.search.keyword)
uni.showModal({
title: '发起搜索',
content: `搜索关键字:${ctx.search.keyword}`,
showCancel: false
})
}
</script>
<template>
<view class="navbar" :style="{ minHeight: ctx.navHeight + 'px' }" style="background: #1296db">
<view
class="topInfo"
:style="{
paddingTop: ctx.statusBarHeight + 'px',
paddingRight: ctx.capsuleWidth + 'px',
}">
<uni-search-bar v-model="ctx.search.keyword" bgColor="#EEEEEE" placeholder="请输入搜索内容" @confirm="searchKeyword" cancelButton="none"></uni-search-bar>
</view>
</view>
</template>
<style scoped>
</style>

View File

@ -1,14 +1,5 @@
<template> <template>
<view class="navbar" :style="{ minHeight: navHeight + 'px' }" style="background: #1296db"> <NavBar/>
<view
class="topInfo"
:style="{
paddingTop: statusBarHeight + 'px',
paddingRight: capsuleWidth + 'px',
}">
<uni-search-bar v-model="search.keyword" bgColor="#EEEEEE" placeholder="请输入搜索内容" @confirm="searchKeyword" cancelButton="none"></uni-search-bar>
</view>
</view>
<view class="content"> <view class="content">
<Banner/> <Banner/>
@ -25,36 +16,27 @@
<script> <script>
import moment from 'moment' import moment from 'moment'
import NavBar from "./components/nav-bar/index.vue"
import Banner from "./components/banner/index.vue" import Banner from "./components/banner/index.vue"
import ZhiHuHotList from "./components/zhihu-hot-list/index.vue" import ZhiHuHotList from "./components/zhihu-hot-list/index.vue"
let timer = null let timer = null
export default { export default {
components: { components: {
NavBar,
Banner, Banner,
ZhiHuHotList ZhiHuHotList
}, },
data() { data() {
return { return {
navHeight: 0,
statusBarHeight: 0,
capsuleWidth: 0,
now: moment().format('YYYY-MM-DD HH:mm:ss'), now: moment().format('YYYY-MM-DD HH:mm:ss'),
title: 'Hello', title: 'Hello',
search: {
keyword: ""
}
} }
}, },
onLoad() { onLoad() {
}, },
mounted() { mounted() {
let capsule = uni.getMenuButtonBoundingClientRect(); //
let system = uni.getSystemInfoSync(); //
this.navHeight = system.statusBarHeight + capsule.height; //
this.statusBarHeight = system.statusBarHeight //
this.capsuleWidth = capsule.width; //
if(timer){ if(timer){
clearInterval(timer) clearInterval(timer)
@ -66,15 +48,7 @@ export default {
}, },
methods: { methods: {
searchKeyword() {
console.log(this.search.keyword)
uni.showModal({
title: '发起搜索',
content: `搜索关键字:${this.search.keyword}`,
showCancel: false
})
}
} }
} }
</script> </script>