Fix:3114 【商城小程序】首页及搜索页面搜索框没有显示浮动词条

This commit is contained in:
modendeveloper
2025-01-22 01:15:10 +08:00
parent 94536b0876
commit 626e747049
4 changed files with 79 additions and 12 deletions
+20 -2
View File
@@ -20,6 +20,9 @@
:src="webUrl + '/home/icon-search2.png'" :src="webUrl + '/home/icon-search2.png'"
class="icon" class="icon"
/> />
<view class="swpier-bar">
<u-notice-bar duration="4000" :text="recommendKeyword" :icon="' '" color="#333" fontSize="12" bgColor="transparent" direction="column"></u-notice-bar>
</view>
</view> </view>
</view> </view>
<view class="slider-banner" id="slider-banner-id"> <view class="slider-banner" id="slider-banner-id">
@@ -354,6 +357,9 @@ import ProductWindow from '@/components/ProductWindow'
import goCartMixin from '@/mixins/goCartMixins' import goCartMixin from '@/mixins/goCartMixins'
import FunctionGuide from '@/components/FunctionGuide' import FunctionGuide from '@/components/FunctionGuide'
import GuideMixins from '@/mixins/GuideMixins' import GuideMixins from '@/mixins/GuideMixins'
import {
getSearchPageConfig
} from '@/api/search'
import { import {
getCurAddress, getCurAddress,
getLocationPromise, getLocationPromise,
@@ -409,7 +415,8 @@ export default {
videoContext: null, videoContext: null,
isPlay: true, isPlay: true,
tabIconPostion: {}, tabIconPostion: {},
messageIcon: {} messageIcon: {},
recommendKeyword: []
} }
}, },
onLoad() { onLoad() {
@@ -417,6 +424,7 @@ export default {
const _this = this const _this = this
_this.init() _this.init()
_this.queryGuide('index') _this.queryGuide('index')
this.getSearch()
uni.getSystemInfo({ uni.getSystemInfo({
success: (e) => { success: (e) => {
let statusBar = 0 let statusBar = 0
@@ -444,7 +452,14 @@ export default {
this.scrollTop = e.scrollTop this.scrollTop = e.scrollTop
}, },
methods: { methods: {
getSearch() {
getSearchPageConfig().then(res => {
const { success, data } = res
if (success) {
this.recommendKeyword = data.recommendKeyword.split(',')
}
})
},
elementData(e) { elementData(e) {
this.tabIconPostion = e this.tabIconPostion = e
}, },
@@ -1707,6 +1722,9 @@ export default {
} }
} }
} }
.swpier-bar{
width: 100%;
}
.fix-header { .fix-header {
position: fixed; position: fixed;
top: 0; top: 0;
+53 -9
View File
@@ -5,15 +5,22 @@
<input <input
v-model.trim="search" v-model.trim="search"
type="text" type="text"
placeholder="请输入" :placeholder="showkey ? '' : '请输入'"
placeholder-style="color:#999" placeholder-style="color:#999"
@confirm="submit" @confirm="submit"
@blur="showHistory"
@focus="hideHistory"
@input="hideHistory"
/> />
<view class="btn flex-0 flex jc-center ai-center" @click="submit"> <view class="btn flex-0 flex jc-center ai-center" @click.stop="submit">
<text class="iconfont icon-sousuo2"></text> <text class="iconfont icon-sousuo2"></text>
<text>搜索</text> <text>搜索</text>
</view> </view>
<view class="swpier-bar" v-if="showkey">
<u-notice-bar duration="4000" @change="change" :text="recommendKeyword" :icon="' '" color="#999" fontSize="12" bgColor="transparent" direction="column"></u-notice-bar>
</view>
</view> </view>
</view> </view>
<view v-if="historyKey.length" class="page-content"> <view v-if="historyKey.length" class="page-content">
<view <view
@@ -111,10 +118,13 @@ export default {
name: 'GoodSearch', name: 'GoodSearch',
data: function () { data: function () {
return { return {
showkey: true,
currentSearch: '',
keywords: [], keywords: [],
search: '', search: '',
historyKey: [], historyKey: [],
rankingArr: [] rankingArr: [],
recommendKeyword: []
} }
}, },
mounted: function () { mounted: function () {
@@ -124,12 +134,40 @@ export default {
this.getHistory() this.getHistory()
}, },
methods: { methods: {
showHistory() {
if(this.search) {
this.showkey = false
return
}
this.showkey = true
},
hideHistory() {
if(!this.search) {
this.showkey = true
return
}
this.showkey = false
},
change(e) {
this.currentSearch = this.recommendKeyword[e]
},
submit() { submit() {
const search = trim(this.search) || '' if (this.showkey) {
if (!search) return const search = trim(this.currentSearch) || ''
this.setHistory(search) console.log(search);
this.search = ''
this.toSearch(search) if (!search) return
this.setHistory(search)
this.search = ''
this.toSearch(search)
} else {
const search = trim(this.search) || ''
if (!search) return
this.setHistory(search)
this.search = ''
this.toSearch(search)
}
}, },
toSearch(s) { toSearch(s) {
this.setHistory(s) this.setHistory(s)
@@ -142,6 +180,7 @@ export default {
this.keywords = data.hotKeyword this.keywords = data.hotKeyword
this.rankingArr.push(data.ranking1) this.rankingArr.push(data.ranking1)
this.rankingArr.push(data.ranking2) this.rankingArr.push(data.ranking2)
this.recommendKeyword = data.recommendKeyword.split(',')
} }
}) })
}, },
@@ -202,7 +241,12 @@ export default {
border-radius: 36rpx; border-radius: 36rpx;
background: #fff; background: #fff;
font-size: 24rpx; font-size: 24rpx;
position: relative;
.swpier-bar{
position: absolute;
width: calc(100% - 128rpx);
top: 0;
}
input { input {
width: 100%; width: 100%;
} }
@@ -108,6 +108,7 @@
methods: { methods: {
noticeChange(e){ noticeChange(e){
this.index = e.detail.current this.index = e.detail.current
this.$emit('change', this.index)
}, },
// 点击通告栏 // 点击通告栏
clickHandler() { clickHandler() {
@@ -19,6 +19,7 @@
:duration="duration" :duration="duration"
@close="close" @close="close"
@click="click" @click="click"
@change="change"
></u-column-notice> ></u-column-notice>
</template> </template>
<template v-else> <template v-else>
@@ -73,6 +74,9 @@
} }
}, },
methods: { methods: {
change(index) {
this.$emit('change', index)
},
// 点击通告栏 // 点击通告栏
click(index) { click(index) {
this.$emit('click', index) this.$emit('click', index)