search1.html 10 KB

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