diff --git a/pageB/search/out.vue b/pageB/search/out.vue index bb497ac..19e24cf 100644 --- a/pageB/search/out.vue +++ b/pageB/search/out.vue @@ -77,17 +77,37 @@ export default { } }, onLoad(option) { - this.value = option.value + this.value = option.value; this.setViewHeight(); this.ShopSearch() + this.setNavSearchInput(); }, onNavigationBarSearchInputConfirmed(value) { this.value = value.text console.log(this.value) this.ShopSearch() - }, methods: { + // 动态设置导航栏搜索框内容 + setNavSearchInput(keyword) { + // #ifdef APP-PLUS + let webView = this.$mp.page.$getAppWebview(); + webView.setTitleNViewSearchInputText(keyword); + // #endif + // #ifdef H5 + let inputSearch=document.querySelector('.uni-input-input[type=search]'); + var evt = new InputEvent('input', { + inputType: 'insertText', + data: keyword, + dataTransfer: null, + isComposing: false + }); + if(inputSearch){ + inputSearch.value = keyword; + inputSearch.dispatchEvent(evt); + } + // #endif + }, changeType(member_id){ console.log(member_id); this.$emit("pChangeType") diff --git a/pageB/search/searchGoods.vue b/pageB/search/searchGoods.vue index 845b1f4..f61b3fe 100644 --- a/pageB/search/searchGoods.vue +++ b/pageB/search/searchGoods.vue @@ -58,9 +58,28 @@ export default { onNavigationBarSearchInputConfirmed(value) { this.value = value.text this.ShopSearch() - }, methods: { + setNavSearchInput(keyword) { + console.log(keyword); + // #ifdef APP-PLUS + let webView = this.$mp.page.$getAppWebview(); + webView.setTitleNViewSearchInputText(keyword); + // #endif + // #ifdef H5 + let inputSearch=document.querySelector('.uni-input-input[type=search]'); + const evt = new InputEvent('input', { + inputType: 'insertText', + data: keyword, + dataTransfer: null, + isComposing: false + }); + if(inputSearch){ + inputSearch.value = keyword; + inputSearch.dispatchEvent(evt); + } + // #endif + }, setOrderSort() { let sort = ''; if(this.current == 0) { @@ -75,6 +94,8 @@ export default { }, // 排序方式 goods_salenum:销量 evaluation_count:评价 goods_price_asc:价格从低到高 goods_price_desc:价格从高到低 async ShopSearch({ load = 'reload' } = {}) { + console.log(this.value); + this.setNavSearchInput(this.value); const sort = this.setOrderSort(); const res = await this.$u.api.ShopSearch({ keyword: this.value,