Authored by shuaiguo

Merge branch 'refs/heads/feature/search-word' into develop

... ... @@ -9,11 +9,11 @@
@scroll="scrollHandler"
@scroll-end="scrollEndHandler"
@pulling-up="onPullingUp" >
<div class="channel-body" ref="body">
<div ref="body">
<div ref="topSource" class="channel-html">
<div class="search-header middle" @click="goSearch">
<div class="search-img"></div>
<input class="search-input" type="search" disabled="true" placeholder="搜索商品名称或货号"/>
<input class="search-input" type="search" disabled="true" :placeholder="defaultSearchWord || '搜索商品名称或货号'"/>
</div>
<template v-for="(item, index) in channelList.list">
<Swiper :list="item.data" :ref="index" :PAGE_URL="PAGE_URL" :key="index" v-if="item.template_name == 'threePicture'"/>
... ... @@ -111,7 +111,7 @@ export default {
};
},
computed: {
...mapState(['channelList', 'contentCode']),
...mapState(['channelList', 'contentCode', 'defaultSearchWord']),
navList() {
return get(find(this.channelList.list, ['template_name', 'guessLike']), 'data') || [];
},
... ... @@ -151,6 +151,8 @@ export default {
this.init();
// this.getAllInboxCatInfo();
this.fetchDefaultSearchWord()
this.PAGE_URL = window.location.href;
if (!this.reported) {
... ... @@ -189,7 +191,7 @@ export default {
this.reported = true;
},
methods: {
...mapActions(['fetchChannelList', 'getAllInboxCatInfo']),
...mapActions(['fetchChannelList', 'getAllInboxCatInfo', 'fetchDefaultSearchWord']),
...mapActionsList(['fetchProductList']),
init() {
this.$nextTick(() => {
... ... @@ -489,7 +491,7 @@ export default {
content: "";
width: 520px;
height: 28px;
background-image: url("~statics/image/channel/server.png");
background-image: url("~statics/image/channel/service-info.png");
background-size: 100% 100%;
margin: 10px auto 20px;
display: block;
... ...
... ... @@ -3,7 +3,7 @@
<form action="javascript:void(0)">
<div class="search-header middle">
<div class="search-img"></div>
<input class="search-input" type="search" v-model="query" placeholder="Search" @input="suggest"
<input class="search-input" type="search" v-model="query" :placeholder="defaultSearchWord || 'Search'" @input="suggest"
@keyup.13="searchGoods"/>
<div class="search-clear" :class="query && 'search-clear-img'" @click="clear()"></div>
</div>
... ... @@ -51,7 +51,7 @@ export default {
},
query: '',
localHistory: [],
SEARCH_POS: 1
SEARCH_POS: 1,
};
},
activated() {
... ... @@ -70,7 +70,7 @@ export default {
});
},
computed: {
...mapState(['searchWord', 'defaultSearchWord', 'searchSuggestList']),
...mapState(['searchWord','defaultSearchWord', 'searchSuggestList']),
},
methods: {
...mapActions(['fetchSearchWords', 'fetchDefaultSearchWords', 'fetchSearchSuggest']),
... ... @@ -79,6 +79,9 @@ export default {
this.query = '';
},
searchGoods: function() {
if(!this.query && this.defaultSearchWord) {
this.query = this.defaultSearchWord;
}
this.addLocalWord();
this.yasInput({type: 0, index: 0, query: this.query});
this.$router.push({
... ...
... ... @@ -19,6 +19,7 @@ export default function() {
current: 0,
},
contentCode: contentCode,
defaultSearchWord: '',
showMsg: false,
},
mutations: {
... ... @@ -62,6 +63,9 @@ export default function() {
}
});
},
[Types.FETCH_DEFAULT_SEARCH_WORD](state, [{search_word} = {}] = []) {
state.defaultSearchWord = search_word;
},
},
actions: {
async fetchProductList({ commit, state }, obj) {
... ... @@ -93,6 +97,19 @@ export default function() {
if (result.code === 200) {
commit(Types.FETCH_NEWSACTIVE, { list: result.data || [] });
}
},
/**
* ufo.product.searchWord
word_type=2 搜索默认词
client_type= iphone android h5
*/
async fetchDefaultSearchWord({commit}) {
const res = await this.$api.get('/api/ufo/list/searchWords', {word_type: 1});
if (res.code === 200) {
commit(Types.FETCH_DEFAULT_SEARCH_WORD, res.data);
}
}
},
};
... ...
... ... @@ -12,3 +12,5 @@ export const FETCH_NEWSACTIVE = 'FETCH_NEWSACTIVE';
export const FETCH_FAVORITE_LIST_REQUEST = 'FETCH_FAVORITE_LIST_REQUEST';
export const FETCH_FAVORITE_LIST_FAILD = 'FETCH_FAVORITE_LIST_FAILD';
export const FETCH_FAVORITE_LIST_SUCCESS = 'FETCH_FAVORITE_LIST_SUCCESS';
export const FETCH_DEFAULT_SEARCH_WORD = 'FETCH_DEFAULT_SEARCH_WORD';
... ...
... ... @@ -4,7 +4,7 @@ export default function() {
state: {
filterVisible: false,
searchWord: [],
defaultSearchWord: [],
defaultSearchWord: '',
searchSuggestList: [],
},
mutations: {
... ... @@ -15,8 +15,10 @@ export default function() {
setSearchWords(state, {searchWord}) {
state.searchWord = searchWord;
},
setDefaultSearchWords(state, {defaultSearchWord}) {
state.defaultSearchWord = defaultSearchWord;
setDefaultSearchWords(state, {defaultSearchWord = []}) {
const [{search_word} = {}] = defaultSearchWord;
state.defaultSearchWord = search_word;
}
},
actions: {
... ...