Commit 2c0a03bd by HouTiZhuo

全网搜优化

parent 954ca8fa
......@@ -14,6 +14,7 @@ Component({
* 组件的初始数据
*/
data: {
searchValue: '',
backgroundColor : '',
borderColor : '',
placeholderValue : '',
......@@ -47,27 +48,35 @@ Component({
*/
methods: {
toSearchPage(e){
if (this.data.datas.componentData['searchModel'] == 1) return;
app.trackCpn(e, this.data.datas.componentName)
const placeHolderText = this.data.datas.componentData["placeHolderVal"] || "";
let query = `?placeHolderText=${placeHolderText}`;
if (this.data.datas.componentData['searchModel'] == 1) {
query += `&searchScopeFlag=${this.data.searchScopeFlag}`;
}
let link = `/contentSearch/contentSearch${query}`;
if (this.data.datas.componentData['searchModel'] == 1 && this.data.searchScopeFlag == 0) {
app.$themeToLink({ type: 1, link });
},
// 全网搜和本店搜
toSearchAllOrLocal() {
const placeHolderText = this.data.datas.componentData["placeHolderVal"] || "";
const query = `?placeHolderText=${placeHolderText}&searchScopeFlag=${this.data.searchScopeFlag}&searchValue=${this.data.searchValue}`;
let link = `/contentSearch/contentSearch${query}`;
if (this.data.searchScopeFlag == 0) {
link = `/goodsSearch/searchAllGoods${query}`;
}
// 重置默认全网搜
this.setData({ searchScopeFlag: 0 });
app.$themeToLink({ type: 1, link });
},
// 本店搜
handleSearchLocal() {
this.setData({ searchScopeFlag: 1 });
this.toSearchAllOrLocal();
},
// 全网搜
handleSearchAll() {
this.setData({ searchScopeFlag: 0 });
this.toSearchAllOrLocal();
},
onInput(e) {
this.setData({ searchValue: e.detail.value });
},
// 扫码搜功能
handleScan() {
......
......@@ -10,8 +10,13 @@
</view>
<view class="svg-divider"></view>
</block>
<input style="width:{{placeholderValue.length*40}}rpx" disabled type="text" placeholder="{{placeholderValue}}">
</input>
<block wx:if="{{datas.componentData['searchModel'] != 1}}">
<input style="width:{{placeholderValue.length*40}}rpx" disabled type="text" placeholder="{{placeholderValue}}">
</input>
</block>
<block wx:else>
<input class="search-input" type="text" placeholder="{{placeholderValue}}" bindinput="onInput" value="{{searchValue}}"></input>
</block>
<view class="flex search-btn" wx:if="{{datas.componentData['searchModel'] == 1}}">
<view class="search-btn__local" style="color:{{datas.componentData.leftBtn.color}};background-color:{{datas.componentData['leftBtn'].backgroundColor}};font-size:{{datas.componentData['leftBtn'].fontSize*2}}rpx;padding:{{datas.componentData['leftBtn'].paddingTop*2}}rpx {{datas.componentData['leftBtn'].paddingRight*2}}rpx {{datas.componentData['leftBtn'].paddingBottom*2}}rpx {{datas.componentData['leftBtn'].paddingLeft*2}}rpx;margin:{{datas.componentData['leftBtn'].marginTop*2}}rpx {{datas.componentData['leftBtn'].marginRight*2}}rpx {{datas.componentData['leftBtn'].marginBottom*2}}rpx {{datas.componentData['leftBtn'].marginLeft*2}}rpx;" bindtap="handleSearchLocal">搜本店</view>
<view class="search-btn__all" style="color:{{datas.componentData['rightBtn'].color}};background-color:{{datas.componentData['rightBtn'].backgroundColor}};font-size:{{datas.componentData['rightBtn'].fontSize*2}}rpx;padding:{{datas.componentData['rightBtn'].paddingTop*2}}rpx {{datas.componentData['rightBtn'].paddingRight*2}}rpx {{datas.componentData['rightBtn'].paddingBottom}}rpx {{datas.componentData['rightBtn'].paddingLeft*2}}rpx;margin:{{datas.componentData['rightBtn'].marginTop*2}}rpx {{datas.componentData['rightBtn'].marginRight*2}}rpx {{datas.componentData['rightBtn'].marginBottom*2}}rpx {{datas.componentData['rightBtn'].marginLeft*2}}rpx;" bindtap="handleSearchAll">搜全网</view>
......
......@@ -32,8 +32,13 @@
justify-content: center;
}
.search-input {
flex: 1;
color: #000 !important;
}
.search-btn {
position: absolute;
position: relative;
right: 0;
justify-content: end;
margin-right: 2px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment