123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- {extend name="public/container"}
- {block name="title"}搜索{/block}
- {block name="head_top"}
- <style>
- .underline {
- min-width: 0;
- }
- .index-search .form {
- display: -webkit-box;
- display: -webkit-flex;
- display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
- align-items: center;
- padding: .18rem .3rem;
- }
- .index-search .form .label {
- -webkit-box-flex: 1;
- -webkit-flex: 1;
- flex: 1;
- display: -webkit-box;
- display: -webkit-flex;
- display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
- align-items: center;
- height: .66rem;
- padding-right: .3rem;
- padding-left: .3rem;
- border-radius: .33rem;
- background-color: #f7f7f7;
- }
- .index-search .form .iconfont {
- font-weight: 500;
- font-size: .24rem;
- color: #999;
- }
- .index-search .form .input {
- -webkit-box-flex: 1;
- -webkit-flex: 1;
- flex: 1;
- margin-left: .13rem;
- font-weight: 500;
- font-size: .26rem;
- color: #333;
- }
- .index-search .form .input::placeholder {
- color: #999;
- }
- .index-search .form .button {
- height: .66rem;
- padding-right: .1rem;
- padding-left: .1rem;
- margin-left: .2rem;
- font-weight: 500;
- font-size: .28rem;
- font-family: inherit;
- color: #282828;
- }
- .index-search .section .head {
- display: -webkit-box;
- display: -webkit-flex;
- display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
- align-items: center;
- padding: .35rem .3rem;
- }
- .index-search .section .head .name {
- -webkit-box-flex: 1;
- -webkit-flex: 1;
- flex: 1;
- font-weight: bold;
- font-size: .28rem;
- color: #282828;
- }
- .index-search .section .head .iconfont {
- font-size: .26rem;
- color: #999;
- cursor: pointer;
- }
- .index-search .section .cont {
- padding-right: .3rem;
- padding-left: .3rem;
- }
- .index-search .section .cont .item {
- display: inline-block;
- height: .44rem;
- padding-right: .22rem;
- padding-left: .22rem;
- border-radius: .22rem;
- margin-right: .2rem;
- margin-bottom: .22rem;
- background-color: #f2f2f2;
- vertical-align: middle;
- font-weight: 500;
- font-size: .24rem;
- line-height: .44rem;
- color: #666;
- cursor: pointer;
- }
- .del-search{
- color: #666;
- font-size: .24rem;
- }
- .nothing {
- position: absolute;
- top: 50%;
- left: 50%;
- width: 4rem;
- height: 4rem;
- -webkit-transform: translate(-50%, -50%);
- transform: translate(-50%, -50%);
- }
- </style>
- {/block}
- {block name="content"}
- <div v-cloak id="app">
- <div class="index-search">
- <form class="form">
- <label class="label">
- <span class="iconfont icon-sousuo"></span>
- <input v-model.trim="search" class="input" placeholder="输入搜索内容">
- </label>
- <button class="button" type="button" @click="goSearch">搜索</button>
- </form>
- <div v-if="history.length" class="section">
- <div class="head">
- <div class="name">历史记录</div><span class="del-search" @click="delSearchHistory">清除</span>
- <div class="iconfont"></div>
- </div>
- <div class="cont">
- <ul class="list">
- <li v-for="(item, index) in history" :key="index" class="item" @click="goSearch(item.search)">{{ item.search }}</li>
- </ul>
- </div>
- </div>
- <div v-if="hotSearch.length" class="section">
- <div class="head">
- <div class="name">热门搜索</div>
- </div>
- <div class="cont">
- <ul class="list">
- <li v-for="(item, index) in hotSearch" :key="index" class="item" @click="goSearch(item)">{{ item }}</li>
- </ul>
- </div>
- </div>
- </div>
- <div class="search-page">
- <div class="searchResult swiper-details" v-if="(searchList.special.length) && search"
- v-cloak="">
- <div class="title acea-row row-middle line1" v-if="searchList.special.length">专题</div>
- <div class="swiper-list2">
- <div class="item acea-row row-between-wrapper" v-for="item in searchList.special">
- <a class="pictrue" :href="getSpecialUrl(item.id)"><img :src="item.image"></a>
- <div class="underline">
- <a class="text-pic acea-row row-column" :href="getSpecialUrl(item.id)">
- <div class="name line1" v-text="item.title"></div>
- <div class="notes line1" v-text="item.abstract"></div>
- <div class="bottom acea-row row-between-wrapper">
- <div class="acea-row row-middle">
- <div class="num acea-row row-center-wrapper" v-for="(vo,index) in item.label"
- v-text="vo" v-if="index <= 1"></div>
- </div>
- <div class="money">
- {{item.is_pink ? (item.pink_money == 0 ? '免费':'¥'+item.pink_money): (item.money <= 0 ? '免费':'¥'+item.money) }}
- </div>
- </div>
- </a>
- </div>
- </div>
- </div>
- <a class="more acea-row row-middle row-right" v-if="searchList.special.length > limit"
- :href="getMoreList(0)">查看更多></a>
- </div>
- <p class="loading-line" style="background-color: #ffffff" v-cloak=""
- v-if="searchList.special.length < 1 && search && is_search">
- <img class="nothing" src="/wap/first/zsff/images/no_result.png">
- </p>
- </div>
- <shortcut></shortcut>
- </div>
- {/block}
- {block name='foot'}
- <script>
- var phone="{$phone}";
- require(['vue', 'helper', 'store', '{__WAP_PATH}zsff/js/shortcut.js'], function (Vue, $h, app) {
- new Vue({
- el: '#app',
- data: {
- search: '',
- hotSearch: [],
- history: [],
- searchList: { special: []},
- loading: false,
- limit: 2,
- is_search: false,
- },
- watch: {
- search: function (n) {
- if (n == '') this.$set(this, 'searchList', { special: [] });
- }
- },
- methods: {
- getMoreList: function (type) {
- return $h.U({ c: 'index', a: 'more_list', p: { type: type }, q: { search: this.search } });
- },
- getSpecialUrl: function (id) {
- return $h.U({ c: 'special', a: 'details', q: { id: id } });
- },
- getTashUrl: function (id) {
- return $h.U({ c: 'special', a: 'details', q: { id: id } }) + '#act2';
- },
- get_search_history: function () {
- app.baseGet($h.U({ c: 'index', a: 'get_search_history' }), function (res) {
- this.$set(this, 'history', res.data.data);
- }.bind(this));
- },
- get_host_search: function () {
- app.baseGet($h.U({ c: 'index', a: 'get_host_search' }), function (res) {
- this.$set(this, 'hotSearch', res.data.data);
- }.bind(this));
- },
- delSearchHistory: function () {
- var that=this;
- app.baseGet($h.U({ c: 'index', a: 'del_search_history' }), function (res) {
- that.get_search_history();
- that.$set(that, 'search', '');
- that.$set(that, 'searchList', { special: []});
- return $h.pushMsgOnce('清除缓存');
- }.bind(this));
- },
- goSearch: function (name) {
- if (typeof name == 'string' && name) this.search = name;
- if (this.search == '') return;
- if (this.loading) return;
- this.loading = true;
- app.baseGet($h.U({ c: 'index', a: 'go_search', q: { search: this.search, limit: this.limit + 1 } }), function (res) {
- this.loading = false;
- this.$set(this, 'searchList', res.data.data);
- this.is_search = res.data.data.special.length < 1 ? true : false;
- if(phone){
- this.get_search_history();
- }
- }.bind(this), function () {
- this.loading = false;
- }.bind(this));
- }
- },
- mounted: function () {
- var that = this;
- this.get_host_search();
- if(phone){
- that.get_search_history();
- }
- }
- })
- })
- </script>
- {/block}
|