diff --git a/pages/shop/GoodSearch/index.vue b/pages/shop/GoodSearch/index.vue index 29ce2bb..dec129c 100644 --- a/pages/shop/GoodSearch/index.vue +++ b/pages/shop/GoodSearch/index.vue @@ -14,10 +14,10 @@ @change="hideHistory" @compositionstart="hideHistory" /> - + @@ -145,11 +145,21 @@ export default { this.getCartCount() }, onLoad(opts){ - this.keywords1 = opts.keywords + this.search = opts.keywords }, onShow() { this.getHistory() }, + watch: { + search(val) { + if(val) { + this.showkey = false + } else { + this.showkey = true + this.currentSearch = this.recommendKeyword[0] + } + } + }, methods: { // 获取购物车数量 getCartCount () { @@ -166,6 +176,7 @@ export default { this.$yrouter.switchTab('/pages/cart') }, showHistory() { + if(this.showkey) return if(this.search) { this.showkey = false return @@ -174,10 +185,10 @@ export default { }, hideHistory() { - // if(!this.search) { - // this.showkey = true - // return - // } + if(!this.search) { + this.showkey = true + return + } this.showkey = false }, change(e) { @@ -186,17 +197,15 @@ export default { submit() { if (this.showkey) { const search = trim(this.currentSearch) || '' - console.log(search); - if (!search) return this.setHistory(search) - this.search = '' + // this.search = '' this.toSearch(search) } else { const search = trim(this.search) || '' if (!search) return this.setHistory(search) - this.search = '' + // this.search = '' this.toSearch(search) } @@ -213,8 +222,8 @@ export default { this.rankingArr.push(data.ranking1) this.rankingArr.push(data.ranking2) this.recommendKeyword = data.recommendKeyword.split(',') - const index = this.recommendKeyword.indexOf(this.keywords1) - [this.recommendKeyword[0], this.recommendKeyword[index]] = [this.recommendKeyword[index], this.recommendKeyword[0]]; + // const index = this.recommendKeyword.indexOf(this.keywords1) + // [this.recommendKeyword[0], this.recommendKeyword[index]] = [this.recommendKeyword[index], this.recommendKeyword[0]]; } }) }, @@ -311,7 +320,8 @@ export default { border-radius: 28rpx; color: #fff; font-weight: bold; - + padding: 0; + font-size: 26rpx; .icon-sousuo2 { margin-right: 4rpx; font-size: 28rpx;