search.html 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. {extend name="public/container"}
  2. {block name="title"}搜索{/block}
  3. {block name="head_top"}
  4. <style>
  5. .underline {
  6. min-width: 0;
  7. }
  8. .index-search .form {
  9. display: -webkit-box;
  10. display: -webkit-flex;
  11. display: flex;
  12. -webkit-box-align: center;
  13. -webkit-align-items: center;
  14. align-items: center;
  15. padding: .18rem .3rem;
  16. }
  17. .index-search .form .label {
  18. -webkit-box-flex: 1;
  19. -webkit-flex: 1;
  20. flex: 1;
  21. display: -webkit-box;
  22. display: -webkit-flex;
  23. display: flex;
  24. -webkit-box-align: center;
  25. -webkit-align-items: center;
  26. align-items: center;
  27. height: .66rem;
  28. padding-right: .3rem;
  29. padding-left: .3rem;
  30. border-radius: .33rem;
  31. background-color: #f7f7f7;
  32. }
  33. .index-search .form .iconfont {
  34. font-weight: 500;
  35. font-size: .24rem;
  36. color: #999;
  37. }
  38. .index-search .form .input {
  39. -webkit-box-flex: 1;
  40. -webkit-flex: 1;
  41. flex: 1;
  42. margin-left: .13rem;
  43. font-weight: 500;
  44. font-size: .26rem;
  45. color: #333;
  46. }
  47. .index-search .form .input::placeholder {
  48. color: #999;
  49. }
  50. .index-search .form .button {
  51. height: .66rem;
  52. padding-right: .1rem;
  53. padding-left: .1rem;
  54. margin-left: .2rem;
  55. font-weight: 500;
  56. font-size: .28rem;
  57. font-family: inherit;
  58. color: #282828;
  59. }
  60. .index-search .section .head {
  61. display: -webkit-box;
  62. display: -webkit-flex;
  63. display: flex;
  64. -webkit-box-align: center;
  65. -webkit-align-items: center;
  66. align-items: center;
  67. padding: .35rem .3rem;
  68. }
  69. .index-search .section .head .name {
  70. -webkit-box-flex: 1;
  71. -webkit-flex: 1;
  72. flex: 1;
  73. font-weight: bold;
  74. font-size: .28rem;
  75. color: #282828;
  76. }
  77. .index-search .section .head .iconfont {
  78. font-size: .26rem;
  79. color: #999;
  80. cursor: pointer;
  81. }
  82. .index-search .section .cont {
  83. padding-right: .3rem;
  84. padding-left: .3rem;
  85. }
  86. .index-search .section .cont .item {
  87. display: inline-block;
  88. height: .44rem;
  89. padding-right: .22rem;
  90. padding-left: .22rem;
  91. border-radius: .22rem;
  92. margin-right: .2rem;
  93. margin-bottom: .22rem;
  94. background-color: #f2f2f2;
  95. vertical-align: middle;
  96. font-weight: 500;
  97. font-size: .24rem;
  98. line-height: .44rem;
  99. color: #666;
  100. cursor: pointer;
  101. }
  102. .del-search{
  103. color: #666;
  104. font-size: .24rem;
  105. }
  106. .nothing {
  107. position: absolute;
  108. top: 50%;
  109. left: 50%;
  110. width: 4rem;
  111. height: 4rem;
  112. -webkit-transform: translate(-50%, -50%);
  113. transform: translate(-50%, -50%);
  114. }
  115. </style>
  116. {/block}
  117. {block name="content"}
  118. <div v-cloak id="app">
  119. <div class="index-search">
  120. <form class="form">
  121. <label class="label">
  122. <span class="iconfont icon-sousuo"></span>
  123. <input v-model.trim="search" class="input" placeholder="输入搜索内容">
  124. </label>
  125. <button class="button" type="button" @click="goSearch">搜索</button>
  126. </form>
  127. <div v-if="history.length" class="section">
  128. <div class="head">
  129. <div class="name">历史记录</div><span class="del-search" @click="delSearchHistory">清除</span>
  130. <div class="iconfont"></div>
  131. </div>
  132. <div class="cont">
  133. <ul class="list">
  134. <li v-for="(item, index) in history" :key="index" class="item" @click="goSearch(item.search)">{{ item.search }}</li>
  135. </ul>
  136. </div>
  137. </div>
  138. <div v-if="hotSearch.length" class="section">
  139. <div class="head">
  140. <div class="name">热门搜索</div>
  141. </div>
  142. <div class="cont">
  143. <ul class="list">
  144. <li v-for="(item, index) in hotSearch" :key="index" class="item" @click="goSearch(item)">{{ item }}</li>
  145. </ul>
  146. </div>
  147. </div>
  148. </div>
  149. <div class="search-page">
  150. <div class="searchResult swiper-details" v-if="(searchList.special.length) && search"
  151. v-cloak="">
  152. <div class="title acea-row row-middle line1" v-if="searchList.special.length">专题</div>
  153. <div class="swiper-list2">
  154. <div class="item acea-row row-between-wrapper" v-for="item in searchList.special">
  155. <a class="pictrue" :href="getSpecialUrl(item.id)"><img :src="item.image"></a>
  156. <div class="underline">
  157. <a class="text-pic acea-row row-column" :href="getSpecialUrl(item.id)">
  158. <div class="name line1" v-text="item.title"></div>
  159. <div class="notes line1" v-text="item.abstract"></div>
  160. <div class="bottom acea-row row-between-wrapper">
  161. <div class="acea-row row-middle">
  162. <div class="num acea-row row-center-wrapper" v-for="(vo,index) in item.label"
  163. v-text="vo" v-if="index <= 1"></div>
  164. </div>
  165. <div class="money">
  166. {{item.is_pink ? (item.pink_money == 0 ? '免费':'¥'+item.pink_money): (item.money <= 0 ? '免费':'¥'+item.money) }}
  167. </div>
  168. </div>
  169. </a>
  170. </div>
  171. </div>
  172. </div>
  173. <a class="more acea-row row-middle row-right" v-if="searchList.special.length > limit"
  174. :href="getMoreList(0)">查看更多></a>
  175. </div>
  176. <p class="loading-line" style="background-color: #ffffff" v-cloak=""
  177. v-if="searchList.special.length < 1 && search && is_search">
  178. <img class="nothing" src="/wap/first/zsff/images/no_result.png">
  179. </p>
  180. </div>
  181. <shortcut></shortcut>
  182. </div>
  183. {/block}
  184. {block name='foot'}
  185. <script>
  186. var phone="{$phone}";
  187. require(['vue', 'helper', 'store', '{__WAP_PATH}zsff/js/shortcut.js'], function (Vue, $h, app) {
  188. new Vue({
  189. el: '#app',
  190. data: {
  191. search: '',
  192. hotSearch: [],
  193. history: [],
  194. searchList: { special: []},
  195. loading: false,
  196. limit: 2,
  197. is_search: false,
  198. },
  199. watch: {
  200. search: function (n) {
  201. if (n == '') this.$set(this, 'searchList', { special: [] });
  202. }
  203. },
  204. methods: {
  205. getMoreList: function (type) {
  206. return $h.U({ c: 'index', a: 'more_list', p: { type: type }, q: { search: this.search } });
  207. },
  208. getSpecialUrl: function (id) {
  209. return $h.U({ c: 'special', a: 'details', q: { id: id } });
  210. },
  211. getTashUrl: function (id) {
  212. return $h.U({ c: 'special', a: 'details', q: { id: id } }) + '#act2';
  213. },
  214. get_search_history: function () {
  215. app.baseGet($h.U({ c: 'index', a: 'get_search_history' }), function (res) {
  216. this.$set(this, 'history', res.data.data);
  217. }.bind(this));
  218. },
  219. get_host_search: function () {
  220. app.baseGet($h.U({ c: 'index', a: 'get_host_search' }), function (res) {
  221. this.$set(this, 'hotSearch', res.data.data);
  222. }.bind(this));
  223. },
  224. delSearchHistory: function () {
  225. var that=this;
  226. app.baseGet($h.U({ c: 'index', a: 'del_search_history' }), function (res) {
  227. that.get_search_history();
  228. that.$set(that, 'search', '');
  229. that.$set(that, 'searchList', { special: []});
  230. return $h.pushMsgOnce('清除缓存');
  231. }.bind(this));
  232. },
  233. goSearch: function (name) {
  234. if (typeof name == 'string' && name) this.search = name;
  235. if (this.search == '') return;
  236. if (this.loading) return;
  237. this.loading = true;
  238. app.baseGet($h.U({ c: 'index', a: 'go_search', q: { search: this.search, limit: this.limit + 1 } }), function (res) {
  239. this.loading = false;
  240. this.$set(this, 'searchList', res.data.data);
  241. this.is_search = res.data.data.special.length < 1 ? true : false;
  242. if(phone){
  243. this.get_search_history();
  244. }
  245. }.bind(this), function () {
  246. this.loading = false;
  247. }.bind(this));
  248. }
  249. },
  250. mounted: function () {
  251. var that = this;
  252. this.get_host_search();
  253. if(phone){
  254. that.get_search_history();
  255. }
  256. }
  257. })
  258. })
  259. </script>
  260. {/block}