重写搜索界面样式

main
26947 2024-05-09 12:19:48 +08:00
parent 7fce32b33e
commit 6a0d93b85b
8 changed files with 1067 additions and 954 deletions

View File

@ -1,8 +1,8 @@
// 应用全局配置 // 应用全局配置
export default { export default {
// baseUrl: 'https://vue.ruoyi.vip/prod-api', // baseUrl: 'https://vue.ruoyi.vip/prod-api',
// baseUrl: 'http://47.93.242.168:8080', baseUrl: 'http://47.93.242.168:8080',
baseUrl: 'http://localhost:8080', // baseUrl: 'http://localhost:8080',
// 应用信息 // 应用信息
appInfo: { appInfo: {
// 应用名称 // 应用名称

View File

@ -90,7 +90,9 @@
}, { }, {
"path": "pages/search/index", "path": "pages/search/index",
"style": { "style": {
"navigationBarTitleText": "搜索"
"navigationStyle": "custom" ,
"navigationBarTextStyle": "white"
} }
}], }],
"tabBar": { "tabBar": {

File diff suppressed because it is too large Load Diff

View File

@ -1,182 +1,241 @@
<template> <template>
<view class=""> <view style="position: relative; ">
<view class="top">
<view class="search"> <u-navbar leftText="" title="搜索"
<view style="width: 550rpx; height: 61.94rpx;"> :placeholder="true"
<!-- <up-search placeholder="日照香炉生紫烟" v-model="keyword" :show-action="false" placeholder-color="#FF0000"></up-search> --> leftIcon="arrow-left"
<view style="position: relative;"> :leftIconSize="32"
<u-search :clearabled="false" color="#414141" @leftClick="leftClick"
v-model="keyword" :show-action="false" borderColor="#B3D7FF" bgColor="#ffffff20"></u-search> :safeAreaInsetTop="true" :bgColor="bgColor">
<view class="scan"> </u-navbar>
<u-icon name="scan" size="22" @click="toScan()"></u-icon> <view class="top">
</view>
</view>
</view>
<view class=""> <view class="bj"></view>
<up-text @click.stop="onSearch" bold="true" size="28rpx" text="搜索"></up-text> <view class="sousuoBox1">
</view> <view class="sousuoBox">
<view class="souBOx">
</view> <image src="../../static/images/search/tu2-2.png" class="img3"></image>
</view> <view class="shuruText">在食堂捡到一张饭卡</view>
<!-- 无内容 --> </view>
<view class="noSearch" v-if="noSearch"> <image src="../../static/images/search/tu2-3.png" class="img4"></image>
<view class="row">
<img style="width: 400rpx;" src="../../static/images/icon/noSearchData.png" alt="" />
</view>
<view class="row">
<text>没有找到相关内容噢换个词试试吧</text>
</view>
</view>
<!-- 搜索历史 -->
<view class="history" v-else>
<view class="history-title">
<text>搜索历史</text>
<uni-icons @click.stop="clearHistory()" type="trash" size="20" color="#C0C0C0" ></uni-icons>
</view>
<view class="history-content" v-if="historyList.length!=0">
<view class="history-item" v-for="(historyItem,historyIndex) in historyList" :key="historyIndex">
{{historyItem}}
</view> </view>
</view> <view class="sousuoText" @click="deletehistory"></view>
<view class="history-none" v-else>
<text style="color: #757575;">无搜索历史</text> </view>
</view> </view>
</view>
</view>
</template> <!-- 搜索历史 -->
<view class="history" v-if="!histortOpen">
<view class="hustortTop">
<view class="historyTopText">搜索历史</view>
<image src="../../static//images/search/shanchu.png" class="img5"></image>
</view>
<view class="hustoryCenter">
<view v-for="(item,index) in historyList" :key="index" class="hustoryList">
<view class="item">
{{ item }}
</view>
</view>
</view>
</view>
<!-- 无内容 -->
<view v-if="histortOpen">
<view class="noContent">
<image src="../../static/images/search/noContent.png" class="img6"></image>
<view class="noContentText">没有找到相关内容奥,换个词试试吧!</view>
</view>
</view>
</view>
</template>
<script setup> <script setup>
import {
ref, import {
reactive, ref,
toRefs, reactive,
getCurrentInstance toRefs,
} from 'vue'; getCurrentInstance
} from 'vue';
const keyword = ref('')
const noSearch = ref(false)
const bgColor = ref('#ffffff80')
const leftClick = ()=> {
uni.navigateBack({
delta: 1
})
}
const histortOpen = ref(false)
const historyList = ref(['三毛流浪记','假如给我三天光明','遥望无期',
'假如给我三天光明(青少年儿童读物)','遥望无期',
'过年','遥望无期','纵横还第三万里'])
const deletehistory = () => {
histortOpen.value = !histortOpen.value
}
</script>
<style lang="scss" scoped>
:deep(.u-navbar__content__title.data-v-f631659b ){
const keyword = ref('') text-align: center;
const historyList = ref(['丢东西了']) font-size: 36rpx;
const noSearch = ref(false) color: #303133;
function onSearch() { }
console.log('搜索 ' + keyword.value)
//historyList .top {
saveHistory() position: relative;
if(keyword.value == 'null') { background: #ffffff80;
noSearch.value = true .img1BOX{
display: flex;
align-items: center;
width: 750rpx;
height: 88rpx;
margin-top: 88rpx;
}
.bj{
background-color: #FAF9FA;
z-index: -1;
width: 750rpx;
height: 268rpx;
position: fixed;
top: 0rpx;
left: 0rpx;
}
.sousuoBox1 {
display: flex;
justify-content: space-between;
align-content: center;
align-items: center;
padding: 16rpx 32rpx 16rpx 32rpx;
width: auto;
.sousuoBox{
display: flex;
align-content: center;
width: 538rpx;
height: 60rpx;
border: #B3D7FF solid 2rpx;
border-radius: 30rpx 30rpx 30rpx 30rpx;
justify-content: space-between;
align-items: center;
.souBOx {
margin-left: 32rpx;
display: flex;
align-content: center;
.shuruText {
font-weight: 400;
font-size: 28rpx;
text-align: left;
color: #999999;
margin-left: 18rpx;
}
.img3 {
width: 35rpx;
height: 35rpx;
}
}
.img4 {
width: 32rpx;
height: 32rpx;
margin-right: 32rpx;
}
}
.sousuoText {
width: 62rpx;
height: 31rpx;
font-size: 30rpx;
}
}
}
.history {
margin-top: 30rpx;
.hustortTop{
display: flex;
justify-content: space-between;
margin-left: 32rpx;
margin-right: 32rpx;
.historyTopText{
width: 139rpx;
height: 35rpx;
font-size: 34rpx;
font-weight: 400;
}
.img5{
width: 42rpx;
height: 42rpx;
} }
} }
.hustoryCenter{
// margin: 32rpx;
function saveHistory() { display: flex;
// if (historyList.value.indexOf(keyword.value) == -1) {
historyList.value.unshift(keyword.value);
//
uni.setStorageSync('kw', JSON.stringify(historyList.value));
// }
}
//
function clearHistory(){
historyList.value=[]
uni.setStorageSync('kw','[]')
// if(his.length==0){
// this.his=!this.his
}
function onLoad() {
//
historyList.value=JSON.parse(uni.getStorageSync('kw'))
}
onLoad() align-items: center;
</script> flex-wrap: wrap;
.hustoryList{
<style lang="scss" scoped> margin-right: 24rpx;
.top { height: 58rpx;
background-color: #FAF9FA; border-radius: 28rpx 28rpx 28rpx 28rpx;
height: 80rpx; background: #f6f6f6;
margin-top: 15rpx; margin-bottom: 22rpx;
} display: flex;
justify-content: center;
.search { align-items: center;
display: flex; .item{
justify-content: space-evenly; font-weight: 400;
align-items: center; height: 29rpx;
} font-size: 28rpx;
// margin: 14rpx 20rpx;
.scan { padding-bottom: 20px;
position: absolute; padding-left: 20rpx;
top: 12rpx; padding-right: 20rpx;
right: 30rpx; }
z-index: 100; }
} }
.noSearch {
display: flex;
flex-direction: column; /* 垂直方向排列 */
align-items: center; /* 垂直居中 */
justify-content: center; /* 水平居中 */
height: 600rpx; /* 设置合适的高度,可以是页面的高度 */
} }
.noContent{
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
.row { .noContentText{
display: flex; font-weight: 400;
justify-content: center; /* 水平居中 */ width: 490rpx;
margin-bottom: 20rpx; /* 可以根据需要调整行之间的间距 */ height: 30rpx;
font-size: 30rpx;
}
.img6{
width: 326rpx;
height: 280rpx;
margin-bottom: 56rpx;
margin-top: 150rpx;
}
} }
/* 图片样式 */
.noSearch .row img {
/* 图片样式 */
}
/* 文字样式 */
.noSearch .row text {
/* 文字样式 */
font-size: 32rpx;
color: #333333;
}
.history{
margin-top: 30rpx;
.history-title{
width: 90%;
display: flex;
justify-content: space-between;
align-items: center;
margin: 0 auto;
text{
font-weight: bold;
font-size: 34rpx;
}
}
.history-content{
width: 90%;
margin: 10rpx auto;
display: flex;
flex-wrap: wrap;
.history-item{
font-size: 27rpx;
height: 50rpx;
line-height: 50rpx;
color: #797979;
background-color: #F8F8F8;
margin-top: 25rpx;
margin-right: 10rpx;
padding:0 20rpx;
border-radius: 20rpx;
}
}
.history-none{
width: 100%;
height: 100rpx;
text-align: center;
line-height: 100rpx;
}
}
</style> </style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB