newkeycode.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  1. <template>
  2. <div class="search-wrapper">
  3. <!-- 头部搜索 -->
  4. <div class="main-search-header">
  5. <div class="main-search-header-controll clearfix">
  6. <div style="display: flex;align-items: center;justify-content: space-between;width:100%;">
  7. <div :class="ChooseTop === 'component' ? 'active' : ''" @click="setChangelistHander('component')"><a>型号</a></div>
  8. <div :class="ChooseTop === 'kind' ? 'active' : ''" @click="setChangelistHander('kind')"><a>物料名称</a></div>
  9. <div :class="ChooseTop === 'store' ? 'active' : ''" @click="setChangelistHander('store')"><a>卖家</a></div>
  10. <div :class="ChooseTop === 'brand' ? 'active' : ''" @click="setChangelistHander('brand')"><a>品牌</a></div>
  11. </div>
  12. </div>
  13. <input type="text" id="search-box" v-model="keyword" @keyup.13="onClickSearchHander()" :placeholder="placeholder" @input="changeKeyWord()">
  14. <span @click="onClickSearchHander()">搜索</span>
  15. <a @click="cancelSearchHander()" style="margin-top: 0.14rem;display: inline-block;">取消</a>
  16. </div>
  17. <ul class="associate-list" v-show="associate.show" @click="associate.show = false">
  18. <li @click.stop="onAssociateClick(similar)" v-for="similar in similarKeywords.result">
  19. <i class="icon-sousuo iconfont"></i>
  20. <span>{{Getsimilar(similar)}}</span>
  21. <!--<span v-if="ChooseTop === 'component'">{{similar.code}}</span>-->
  22. <!--<span v-else-if="ChooseTop === 'product'">{{similar}}</span>-->
  23. <!--<span v-else-if="ChooseTop === 'store'">{{similar}}</span>-->
  24. <!--<span v-else-if="ChooseTop === 'brand'">{{similar.nameEn}}</span>-->
  25. </li>
  26. <li @click.stop="onClickTosearch(keyword)">查找“{{baseUtils.filterStringEllipsis(keyword, 30)}}”</li>
  27. </ul>
  28. <!-- 主体内容 -->
  29. <div class="main-search-wrapper">
  30. <div class="search-title">搜索“<span>{{displayKeyword}}</span>”,为您找到{{allTotal}}条信息</div>
  31. <template>
  32. <!-- 品牌精确查找 -->
  33. <template v-if="ChooseTop === 'brand' && brandIsAccurate">
  34. <div class="search-content" style="margin-bottom: 0.2rem;height: auto;position: static">
  35. <div class="middle">
  36. <div class="list clearfix" style="border-bottom: 1px solid #dcdcdc;padding-bottom: 0.1rem;line-height: 0.8rem;">
  37. <img :src="resourceList.brand && resourceList.brand.logoUrl || '/images/component/default.png'" class="pull-left">
  38. <div class="name pull-left overHidden" style="max-width: 5rem;">{{resourceList.brand && resourceList.brand.nameEn}}</div>
  39. </div>
  40. <div class="list">
  41. <div class="name">主打产品:</div>
  42. <div class="text">
  43. {{resourceList.brand && resourceList.brand.series}}
  44. </div>
  45. </div>
  46. <div class="list">
  47. <div class="name">应用领域:</div>
  48. <div class="text">
  49. {{resourceList.brand && resourceList.brand.application}}
  50. </div>
  51. </div>
  52. <div class="list">
  53. <div class="name">品牌介绍:</div>
  54. <div class="text">
  55. {{resourceList.brand && resourceList.brand.brief}}
  56. </div>
  57. </div>
  58. <div class="list">
  59. <div class="name" style="color:#4290f7">官网地址:</div>
  60. <div class="text" style="width: 4.5rem">
  61. <a :href="resourceList.brand && resourceList.brand.url" target="_blank">{{resourceList.brand && resourceList.brand.url}}</a>
  62. </div>
  63. <div class="pull-right lookMoreBtn" @click="showBrandDetails = true" style="color:#4290f7">
  64. 查看更多
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </template>
  70. <div class="search-nav clearfix" v-if="brandIsAccurate || (!brandIsAccurate && ChooseTop !== 'brand')">
  71. <span class="pull-left" :class="navType === 'hasStore' ? 'active' : ''" @click="getReloadList('hasStore')">
  72. {{ChooseTop === 'component' ? '现货': '现货卖家'}}({{stockallTotal}})条
  73. </span>
  74. <span class="pull-left" :class="navType === 'noHasStore' ? 'active' : ''" @click="getReloadList('noHasStore')">
  75. {{ChooseTop === 'component' ? '期货': '期货卖家'}}({{futuresallTotal}})条</span>
  76. </div>
  77. <div class="search-content" id="main-search-wrapper" :class="{'searchContent2' : ChooseTop === 'brand' && brandIsAccurate, 'searchContent3': ChooseTop === 'brand' && !brandIsAccurate}">
  78. <!-- 品牌模糊查询 -->
  79. <template v-if="!brandIsAccurate && ChooseTop === 'brand'">
  80. <div class="middle" v-for="item in resourceList.content">
  81. <div class="list clearfix" style="border-bottom: 1px solid #dcdcdc;padding-bottom: 0.1rem;line-height: 0.8rem;" @click="goToBrandAccurate(item)">
  82. <img :src="item.logoUrl || '/images/component/default.png'" class="pull-left">
  83. <div class="name pull-left overHidden" style="max-width: 5rem;">{{item.nameEn}}</div>
  84. <div class="more_icon pull-right"><i class="iconfont icon-swiper-right"></i></div>
  85. </div>
  86. <div class="list">
  87. <div class="name">主打产品:</div>
  88. <div class="text">
  89. {{item.series}}
  90. </div>
  91. </div>
  92. <div class="list">
  93. <div class="name">应用领域:</div>
  94. <div class="text">
  95. {{item.application}}
  96. </div>
  97. </div>
  98. <div class="list">
  99. <div class="name">品牌介绍:</div>
  100. <div class="text">
  101. {{item.brief}}
  102. </div>
  103. </div>
  104. <div class="list">
  105. <div class="name">官网地址:</div>
  106. <div class="text">
  107. <a :href="item.url" target="_blank">{{item.url}}</a>
  108. </div>
  109. </div>
  110. </div>
  111. </template>
  112. <!-- /end 品牌模糊查询 -->
  113. <template v-if="brandIsAccurate || (!brandIsAccurate && ChooseTop !== 'brand')">
  114. <!-- 现货 -->
  115. <template v-if="navType === 'hasStore'">
  116. <!-- 型号结果 -->
  117. <template v-if="ChooseTop === 'component'">
  118. <div v-if="resourceList&&resourceList.stock&&resourceList.stock.content.length > 0">
  119. <div v-for="(item, index) in resourceList.stock.content">
  120. <!--@click="goProductDetail(item)"-->
  121. <component-item :item="item" @cancatSeller="cancatSeller"></component-item>
  122. </div>
  123. </div>
  124. </template>
  125. <!-- 卖家 物料名称 品牌-->
  126. <template v-else-if="ChooseTop === 'kind' || ChooseTop === 'store' || ChooseTop === 'brand'">
  127. <div v-if="resourceList&&resourceList.stock&&resourceList.stock.content.length > 0">
  128. <div class="middle" v-for="(item, index) in resourceList.stock.content">
  129. <nuxt-link :to="`/mobile/shop/${item.storeUuid}`" tag="div" class="list clearfix" style="border-bottom: 1px solid #dcdcdc;padding-bottom: 0.1rem">
  130. <div class="name pull-left">{{item.enName}}</div>
  131. <div class="more_icon pull-right"><i class="iconfont icon-swiper-right"></i></div>
  132. </nuxt-link>
  133. <div class="middle_bottom clearfix">
  134. <div class="middle_bottom-left">
  135. <img :src="item.storeLogoUrl || '/images/component/default.png'">
  136. </div>
  137. <div class="middle_bottom-left">
  138. <div class="middle_bottom-leftitem clearfix">
  139. <div class="bottom-title">电话</div><label style="float: left">:</label>
  140. <div class="overHidden" style="width: 3.9rem">
  141. <a :href="'tel:' + AlertstoreInfo.enterprise.enTel" target="_blank" class="content-line" style="color: #2d8cf0">{{item.enTel}}</a>
  142. </div>
  143. </div>
  144. <!--<div class="middle_bottom-leftitem clearfix">-->
  145. <!--<div class="bottom-title">邮箱</div><label style="float: left">:</label><div class="overHidden" style="width: 3.9rem">{{item.enEmail}}</div>-->
  146. <!--</div>-->
  147. <div class="middle_bottom-leftitem clearfix">
  148. <div class="bottom-title">执照号</div><label style="float: left">:</label><div class="overHidden" style="width: 3.9rem">{{item.enBusinesscode}}</div>
  149. </div>
  150. <div class="middle_bottom-leftitem clearfix">
  151. <div class="bottom-title">地址</div><label style="float: left">:</label><div style="width: 3.9rem;">{{item.enAddress}}</div>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. </template>
  158. </template>
  159. <!-- 期货 -->
  160. <template v-else>
  161. <!-- 型号结果 -->
  162. <template v-if="ChooseTop === 'component'">
  163. <div v-if="resourceList && resourceList.futures && resourceList.futures.content.length > 0">
  164. <div class="middle" v-for="(item, index) in resourceList.futures.content">
  165. <div class="list">
  166. <div class="name">品牌:</div>
  167. <div class="text overHidden">{{item.brandNameEn || item.brand || '—'}}</div>
  168. </div>
  169. <div class="list">
  170. <div class="name">物料名称(类目):</div>
  171. <div class="text overHidden">{{item.kindNameCn || item.kind || '-'}}</div>
  172. </div>
  173. <div class="list">
  174. <div class="name">型号:</div>
  175. <div class="text overHidden">{{item.code || item.cmpCode || '-'}}</div>
  176. </div>
  177. <div class="list">
  178. <div class="name">规格:</div>
  179. <div class="text overHidden">{{item.spec || '-'}}</div>
  180. </div>
  181. <div class="list">
  182. <div class="name">单位:</div>
  183. <div class="text overHidden">{{item.unit || 'PCS'}}</div>
  184. </div>
  185. <div class="list clearfix" style="overflow: inherit;">
  186. <div class="fl">
  187. <div class="name">卖家:</div>
  188. <div class="text overHidden" style="width: 4rem">{{item.storeName || item.enName || '-'}}</div>
  189. </div>
  190. <div class="pull-right sayPriBtn" @click="publish(item)">立即询价</div>
  191. </div>
  192. </div>
  193. </div>
  194. </template>
  195. <!-- 卖家 物料名称 品牌-->
  196. <template v-else-if="ChooseTop === 'kind' || ChooseTop === 'store' || ChooseTop === 'brand'">
  197. <div v-if="resourceList&&resourceList.futures &&resourceList.futures.content.length > 0">
  198. <div class="middle" v-for="(item, index) in resourceList.futures.content" @click="goSupplierDetail(item)">
  199. <div class="list clearfix" style="border-bottom: 1px solid #dcdcdc;padding-bottom: 0.1rem">
  200. <div class="name pull-left">{{item.enName}}</div>
  201. <div class="more_icon pull-right"><i class="iconfont icon-swiper-right"></i></div>
  202. </div>
  203. <div class="middle_bottom clearfix">
  204. <div class="middle_bottom-left">
  205. <img :src="item.storeLogoUrl || item.enLogoUrl || '/images/component/default.png'">
  206. </div>
  207. <div class="middle_bottom-left">
  208. <div class="middle_bottom-leftitem clearfix">
  209. <div class="bottom-title">电话</div><label style="float: left">:</label>
  210. <div class="overHidden" style="width: 3.9rem">
  211. <a :href="'tel:' + AlertstoreInfo.enterprise.enTel" target="_blank" class="content-line" style="color: #2d8cf0">{{item.enTel}}</a>
  212. </div>
  213. </div>
  214. <!--<div class="middle_bottom-leftitem clearfix">-->
  215. <!--<div class="bottom-title">邮箱</div><label style="float: left">:</label><div class="overHidden" style="width: 3.9rem">{{item.enEmail}}</div>-->
  216. <!--</div>-->
  217. <div class="middle_bottom-leftitem clearfix">
  218. <div class="bottom-title">执照号</div><label style="float: left">:</label><div class="overHidden" style="width: 3.9rem">{{item.enBusinesscode}}</div>
  219. </div>
  220. <div class="middle_bottom-leftitem clearfix">
  221. <div class="bottom-title">地址</div><label style="float: left">:</label><div style="width: 3.9rem;word-wrap:break-word;">{{item.enAddress}}</div>
  222. </div>
  223. </div>
  224. </div>
  225. </div>
  226. </div>
  227. </template>
  228. </template>
  229. </template>
  230. </div>
  231. </template>
  232. <template v-if="allPage === 0">
  233. <div class="none-state">
  234. <img src="/images/mobile/@2x/search-empty.png">
  235. <p>暂无数据</p>
  236. <nuxt-link to="/">返回首页</nuxt-link>
  237. </div>
  238. </template>
  239. </div>
  240. <!-- 联系卖买家 -->
  241. <div class="mobile-modal" v-if="showStoreInfo" @touchmove="preventTouchMove($event)">
  242. <div class="mobile-modal-box mobile-link-en">
  243. <div class="mobile-modal-header">联系方式<i @click="showStoreInfo = false" class="icon-guanbi iconfont"></i></div>
  244. <div class="mobile-modal-content">
  245. <div v-if="AlertstoreInfo.enterprise.enTel"><span >电话:</span><a :href="'tel:' + AlertstoreInfo.enterprise.enTel" target="_blank" class="content-line link-url">{{AlertstoreInfo.enterprise.enTel}}</a></div>
  246. <div v-if="AlertstoreInfo.enterprise.enPhone"><span >手机:</span><a :href="'tel:' + AlertstoreInfo.enterprise.enPhone" target="_blank" class="content-line link-url">{{AlertstoreInfo.enterprise.enPhone}}</a></div>
  247. <div v-if="AlertstoreInfo.enterprise.enWeixin"><span >微信:</span><span class="content-line">{{AlertstoreInfo.enterprise.enWeixin}}</span></div>
  248. <div v-if="AlertstoreInfo.enterprise.enQQ"><span >Q&nbsp;Q:</span><span class="content-line">{{AlertstoreInfo.enterprise.enQQ}}</span></div>
  249. <div v-if="!empty">暂无联系方式</div>
  250. </div>
  251. </div>
  252. </div>
  253. <!-- 询价 -->
  254. <publish-supplier-seek :product="currentProduct" :showPublishBox="showPublishBox" @cancelAction="showPublishBox = false" @remindAction="setRemindText"></publish-supplier-seek>
  255. <!-- 查看品牌更多信息 -->
  256. <modal-wrapper :showModal="showBrandDetails" :title="currentBrandItem.nameEn" @closeAction="showBrandDetails=false">
  257. <div class="store-info" >
  258. <div class="store-description">
  259. <h4>主营产品</h4>
  260. <p class="content" v-if="currentBrandItem.series">
  261. {{currentBrandItem.series}}
  262. </p>
  263. <div class="com-none-state" v-else>
  264. <p>抱歉,暂无主营产品信息</p>
  265. </div>
  266. </div>
  267. <div class="store-description">
  268. <h4>应用领域</h4>
  269. <p class="content" v-if="currentBrandItem.application">
  270. {{currentBrandItem.application}}
  271. </p>
  272. <div class="com-none-state" v-else>
  273. <p>抱歉,暂无应用领域信息</p>
  274. </div>
  275. </div>
  276. <div class="store-description">
  277. <h4>品牌介绍</h4>
  278. <p class="content" v-if="currentBrandItem.brief">
  279. {{currentBrandItem.brief}}
  280. </p>
  281. <div class="com-none-state" v-else>
  282. <p>抱歉,暂无企业介绍</p>
  283. </div>
  284. </div>
  285. <div class="contact-info">
  286. <h4>联系我们</h4>
  287. <ul class="list-unstyled clearfix">
  288. <li>
  289. <div>电&nbsp;&nbsp;话:</div>
  290. <div v-if="currentBrandItem.userDefine.userTel"><a :href="'tel:' + currentBrandItem.userDefine.userTel" >{{currentBrandItem.userDefine.userTel}}</a></div>
  291. <div v-else><span>-</span></div>
  292. </li>
  293. <!-- <li>
  294. <div>店铺地址:</div>
  295. <div v-if="store.enterprise.address">{{store.enterprise.address}}</div>
  296. <div v-else><span>-</span></div>
  297. </li>-->
  298. </ul>
  299. </div>
  300. </div>
  301. </modal-wrapper>
  302. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  303. <!--<loading v-if="isSearchSearchingMore"></loading>-->
  304. <login-box @onLoginBoxClose="showLoginBox = false" v-if="showLoginBox" :url="url"></login-box>
  305. <pull-up v-if="addShowPullup" :fixId="'main-search-wrapper'" :searchMore="isSearchSearchingMore" :allPage="allPage" :page="page" @pullUpAction="onPullUp" :FixedEl="true"></pull-up>
  306. </div>
  307. </template>
  308. <script>
  309. import { PublishSupplierSeek } from '~components/mobile/applyPurchase'
  310. import { RemindBox, Loading, LoginBox, PullUp } from '~components/mobile/common'
  311. import { ModalWrapper } from '~components/mobile/base'
  312. import axios from '~plugins/axios'
  313. import componentItem from '~components/mobile/search/componet-item'
  314. export default {
  315. layout: 'mobile',
  316. data() {
  317. return {
  318. collectResult: '', // 提示性文字
  319. timeoutCount: 0, // 弹出框计时数
  320. isSearchSearchingMore: false, // 是否正在请求数据
  321. showLoginBox: false, // 是否显示登录弹窗
  322. url: '', // 登录后跳转回来的地址
  323. keyword: '', // 关键字搜索
  324. showStoreInfo: false, // 联系买卖家弹窗
  325. AlertstoreInfo: { // 买卖家弹窗信息
  326. enterprise: {}
  327. },
  328. navType: 'hasStore', // 现货 期货
  329. ChooseTop: 'component', // 型号, 物料名称, 卖家, 品牌
  330. page: 1,
  331. currentProduct: {},
  332. currentBrandItem: { // 查看品牌详情信息
  333. userDefine: {}
  334. }, // 存放当前点击的品牌内容
  335. showBrandDetails: false, // 是否展示品牌详情
  336. brandIsAccurate: false, // 品牌是否处于精确查找
  337. showPublishBox: false, // 询价弹窗
  338. resourceList: [],
  339. futuresallTotal: 0,
  340. stockallTotal: 0,
  341. allPage: 0, // 总页数
  342. allTotal: 0, // 总条数
  343. associate: {
  344. show: false
  345. },
  346. displayKeyword: '',
  347. addShowPullup: true
  348. }
  349. },
  350. computed: {
  351. getNowChooseType() {
  352. if (this.ChooseTop === 'component') {
  353. return '型号'
  354. } else if (this.ChooseTop === 'kind') {
  355. return '物料'
  356. } else if (this.ChooseTop === 'store') {
  357. return '卖家'
  358. } else if (this.ChooseTop === 'brand') {
  359. return '品牌'
  360. }
  361. },
  362. empty () {
  363. return this.checkInfo(this.AlertstoreInfo.enterprise.enTel) || this.checkInfo(this.AlertstoreInfo.enterprise.enPhone) || this.checkInfo(this.AlertstoreInfo.enterprise.enWeixin) || this.checkInfo(this.AlertstoreInfo.enterprise.enQQ)
  364. },
  365. placeholder() {
  366. if (this.ChooseTop === 'component') {
  367. return '请输入您要搜索的型号'
  368. } else if (this.ChooseTop === 'kind') {
  369. return '请输入您要搜索的物料名称'
  370. } else if (this.ChooseTop === 'store') {
  371. return '请输入您要搜索的卖家名称'
  372. } else if (this.ChooseTop === 'brand') {
  373. return '请输入您要搜索的品牌'
  374. }
  375. },
  376. similarKeywords () {
  377. return this.$store.state.search.keywords.data
  378. }
  379. },
  380. async asyncData({store, route}) {
  381. let ChooseTop = route.query.choosetype || 'component'
  382. let keyword = route.query.keyword || ''
  383. let brandIsAccurate = false
  384. let { data } = await axios.get(`/search/201819`, {params: {count: 10, page: 1, keyword: keyword, type: ChooseTop}})
  385. let allTotal = 0
  386. let futuresallTotal = data.futures ? data.futures.total : 0
  387. let stockallTotal = data.stock ? data.stock.total : 0
  388. let allPage = 0
  389. let currentBrandItem = {
  390. userDefine: {}
  391. }
  392. if (ChooseTop === 'brand') {
  393. if (data.futures && data.stock) {
  394. // 品牌查询 精准查找
  395. brandIsAccurate = true
  396. currentBrandItem = data.brand
  397. // 则总条数等于 现货 + 期货
  398. allTotal = stockallTotal + futuresallTotal
  399. allPage = Math.ceil(data.stock.total / 10)
  400. } else {
  401. allTotal = data.total || 0
  402. allPage = Math.ceil(data.total / 10)
  403. }
  404. } else {
  405. // 其他情况
  406. allTotal = stockallTotal + futuresallTotal
  407. allPage = Math.ceil(data.stock.total / 10)
  408. }
  409. return {
  410. ChooseTop: ChooseTop,
  411. keyword: keyword,
  412. resourceList: data,
  413. allPage: allPage,
  414. stockallTotal: stockallTotal,
  415. futuresallTotal: futuresallTotal,
  416. allTotal: allTotal,
  417. brandIsAccurate: brandIsAccurate,
  418. currentBrandItem: currentBrandItem,
  419. displayKeyword: keyword
  420. }
  421. },
  422. methods: {
  423. onPullUp() {
  424. this.page++
  425. this.ReloadList()
  426. },
  427. // 搜索点击事件
  428. onClickSearchHander() {
  429. console.log(this.keyword)
  430. if (!this.keyword) { this.setRemindText('请输入关键字') }
  431. this.$router.push(`/mobile/search/newkeycode?choosetype=${this.ChooseTop}&keyword=${this.keyword}`)
  432. // this.setChangelistHander(this.ChooseTop)
  433. // window.location.href =
  434. },
  435. // 现货 期货切换
  436. getReloadList(_tp) {
  437. this.navType = _tp
  438. this.page = 1
  439. this.resourceList.futures.content = []
  440. this.resourceList.stock.content = []
  441. this.ReloadList()
  442. },
  443. // 刷新数据
  444. ReloadList(param) {
  445. // 如果有值,则代表 是品牌 模糊到精确
  446. // 这里发送数据请求
  447. this.isSearchSearchingMore = true
  448. this.$http.get(`/search/201819`, {params: {count: 10, page: this.page, keyword: this.displayKeyword, type: this.ChooseTop}}).then(res => {
  449. this.isSearchSearchingMore = false
  450. if (!this.brandIsAccurate && this.ChooseTop === 'brand') {
  451. // 品牌模糊查询
  452. this.resourceList.content = [...this.resourceList.content, ...res.data.content]
  453. return
  454. }
  455. if (this.navType === 'hasStore') {
  456. this.resourceList.stock.content = [...this.resourceList.stock.content, ...res.data.stock.content]
  457. this.allPage = Math.ceil(res.data.stock.total / 10) || 0
  458. } else {
  459. this.resourceList.futures.content = [...this.resourceList.futures.content, ...res.data.futures.content]
  460. this.allPage = Math.ceil(res.data.futures.total / 10) || 0
  461. }
  462. }, err => {
  463. this.isSearchSearchingMore = false
  464. })
  465. },
  466. // 模糊品牌查询结果点击
  467. goToBrandAccurate(item) {
  468. this.currentBrandItem = item
  469. this.keyword = item.nameEn
  470. this.setChangelistHander(this.ChooseTop)
  471. },
  472. // 取消返回事件
  473. cancelSearchHander() {
  474. this.$router.replace('/')
  475. },
  476. // 购买 加入购物车
  477. buy: function (item, flag, e) {
  478. this.baseUtils.buyOrCar(flag, e, this, item, '/mobile/center/user/pay/')
  479. },
  480. // 联系买卖家
  481. cancatSeller(item) {
  482. this.$http.get(`/api/store-service/stores?uuid=${item.storeid}`).then(res => {
  483. this.AlertstoreInfo = res.data
  484. this.showStoreInfo = true
  485. })
  486. },
  487. // 切换顶部一级标题
  488. setChangelistHander(str) {
  489. this.addShowPullup = false
  490. if (document.querySelector('#main-search-wrapper')) document.querySelector('#main-search-wrapper').scrollTop = 0
  491. this.ChooseTop = str
  492. this.page = 1
  493. if (!this.keyword) { this.setRemindText('请输入关键字') }
  494. this.displayKeyword = this.keyword
  495. this.brandIsAccurate = false
  496. this.isSearchSearchingMore = true
  497. this.$http.get(`/search/201819`, {params: {count: 10, page: 1, keyword: this.keyword, type: this.ChooseTop}}).then(data => {
  498. data = data.data
  499. this.resourceList = data
  500. this.futuresallTotal = data.futures ? data.futures.total : 0
  501. this.stockallTotal = data.stock ? data.stock.total : 0
  502. let allTotal = 0 // 总条数
  503. if (this.ChooseTop === 'brand') {
  504. if (data.futures && data.stock) {
  505. // 品牌查询 精准查找
  506. this.brandIsAccurate = true
  507. // 则总条数等于 现货 + 期货
  508. allTotal = this.stockallTotal + this.futuresallTotal
  509. this.currentBrandItem = data.brand
  510. } else {
  511. allTotal = data.total || 0
  512. }
  513. } else {
  514. // 其他情况
  515. allTotal = this.stockallTotal + this.futuresallTotal
  516. }
  517. this.allTotal = allTotal
  518. this.isSearchSearchingMore = false
  519. if (!this.brandIsAccurate && this.ChooseTop === 'brand') {
  520. // 品牌 模糊查找
  521. this.allPage = Math.ceil(this.resourceList.total / 10) || 0
  522. } else {
  523. if (this.navType === 'hasStore') {
  524. this.allPage = this.resourceList.stock && Math.ceil(this.resourceList.stock.total / 10) || 0
  525. } else {
  526. this.allPage = this.resourceList.futures && Math.ceil(this.resourceList.futures.total / 10) || 0
  527. }
  528. }
  529. this.associate.show = false
  530. this.addShowPullup = true
  531. })
  532. },
  533. // 供应商详情
  534. goSupplierDetail: function (item) {
  535. this.$http.get('/vendor/introduction/product/count', {params: {vendUU: item.enUU}})
  536. .then(response => {
  537. if (response.data.success && response.data.count > 0) {
  538. this.$router.push(`/mobile/supplier/detail/${item.enUU}?isStore=${item.isStore}`)
  539. } else {
  540. this.setRemindText('供应商正在完善产品信息,暂时不能查看更多。')
  541. }
  542. })
  543. },
  544. checkInfo: function (str) {
  545. return str && str.trim() !== ''
  546. },
  547. publish: function (product) {
  548. if (this.user.logged) {
  549. let item = {
  550. cmpCode: product.cmpCode,
  551. pbranden: product.brand,
  552. brand: product.brand,
  553. spec: product.spec,
  554. kind: product.cmpCode
  555. }
  556. console.log(item)
  557. console.log(product)
  558. this.currentProduct = item
  559. this.showPublishBox = true
  560. } else {
  561. this.url = this.$route.fullPath
  562. this.showLoginBox = true
  563. }
  564. },
  565. setRemindText(str) {
  566. this.timeoutCount++
  567. this.collectResult = str
  568. },
  569. onAssociateClick (word) {
  570. if (this.ChooseTop === 'component') {
  571. this.keyword = word.code
  572. } else if (this.ChooseTop === 'kind') {
  573. this.keyword = word.nameCn
  574. } else if (this.ChooseTop === 'store') {
  575. this.keyword = word.name
  576. } else if (this.ChooseTop === 'brand') {
  577. this.keyword = word.nameEn
  578. }
  579. this.associate.show = false
  580. this.setChangelistHander(this.ChooseTop)
  581. },
  582. Getsimilar(word) {
  583. if (this.ChooseTop === 'component') {
  584. return word.code
  585. } else if (this.ChooseTop === 'kind') {
  586. return word.nameCn
  587. } else if (this.ChooseTop === 'store') {
  588. return word.name
  589. } else if (this.ChooseTop === 'brand') {
  590. return word.nameEn
  591. }
  592. },
  593. onChange () {
  594. if (!this.keyword) {
  595. this.associate.show = false
  596. this.$store.dispatch('resetSearchKeywords')
  597. } else {
  598. this.searchKeywords()
  599. }
  600. },
  601. changeKeyWord() {
  602. this.associate.show = true
  603. this.onChange()
  604. },
  605. searchKeywords () {
  606. this.$store.dispatch('searchKeywords', {keyword: this.keyword, type: this.ChooseTop})
  607. },
  608. onClickTosearch(str) {
  609. this.keyword = str
  610. this.setChangelistHander(this.ChooseTop)
  611. }
  612. },
  613. components: {
  614. RemindBox,
  615. Loading,
  616. LoginBox,
  617. PublishSupplierSeek,
  618. ModalWrapper,
  619. PullUp,
  620. componentItem
  621. },
  622. watch: {
  623. '$route' (to, from) {
  624. this.keyword = to.query.keyword
  625. this.displayKeyword = to.query.keyword
  626. this.setChangelistHander(to.query.choosetype)
  627. }
  628. }
  629. }
  630. </script>
  631. <style lang="scss" scoped>
  632. @mixin overFlowHidden {
  633. overflow: hidden;
  634. text-overflow: ellipsis;
  635. white-space: nowrap;
  636. }
  637. @mixin lineHeight($value) {
  638. height: $value;
  639. line-height: $value;
  640. }
  641. .search-wrapper {
  642. background: #f1f3f6;
  643. width: 100%;
  644. position: fixed;
  645. z-index: 1000;
  646. top: 0;
  647. bottom: 0;
  648. .main-search-header {
  649. position: absolute;
  650. background: #3e82f5;
  651. padding: .15rem 0;
  652. margin-top: 0;
  653. z-index: 1;
  654. width: 100%;
  655. input {
  656. width: 5.1rem;
  657. height: .58rem;
  658. line-height: .58rem;
  659. font-size: .26rem;
  660. color: #333;
  661. margin-left: 0.11rem;
  662. /*padding-left: 1.26rem;*/
  663. border: .04rem solid #fff;
  664. background: #fff;
  665. outline: none;
  666. border-radius: 0;
  667. float: left;
  668. -webkit-appearance: none;
  669. border-top-left-radius: .14rem;
  670. border-bottom-left-radius: .14rem;
  671. padding-left: 0.21rem;
  672. }
  673. span {
  674. display: inline-block;
  675. width: 1.02rem;
  676. text-align: center;
  677. height: .58rem;
  678. line-height: .58rem;
  679. color: #366df3;
  680. font-size: .28rem;
  681. margin-left: .02rem;
  682. border-top-right-radius: .14rem;
  683. border-bottom-right-radius: .14rem;
  684. background: #fff;
  685. float: left;
  686. }
  687. a {
  688. font-size: .28rem;
  689. color: #fff;
  690. margin-left: .2rem;
  691. }
  692. .main-search-header-controll {
  693. width: 5.48rem;
  694. margin-left: 0.21rem;
  695. transform: translateY(1px);
  696. div {
  697. div {
  698. color: #f1f1f1;
  699. margin: 0;
  700. background: rgba(0, 0, 0, 0);
  701. border-radius: 0;
  702. padding: 0.1rem 0.1rem;
  703. &.active a {
  704. color: #40b6fc;
  705. }
  706. &.active {
  707. background: #fff;
  708. border-top-left-radius: 0.05rem;
  709. border-top-right-radius: 0.05rem;
  710. }
  711. a {
  712. color: #f1f1f1;
  713. font-size: 0.26rem;
  714. margin-left: 0 !important;
  715. }
  716. }
  717. }
  718. }
  719. }
  720. .main-search-wrapper {
  721. margin-top: 1.71rem;
  722. }
  723. .search-title {
  724. font-size: 0.26rem;
  725. text-align: center;
  726. color: #999;
  727. margin: 0 auto 0.2rem;
  728. span {
  729. color: #4290f7
  730. }
  731. }
  732. .search-nav {
  733. background: #fff;
  734. @include lineHeight(1rem);
  735. padding: 0 0.2rem;
  736. position: relative;
  737. z-index: 10;
  738. span {
  739. width: 50%;
  740. color: #666;
  741. font-size: 0.28rem;
  742. text-align: center;
  743. border-bottom: 0.04rem solid #dcdcdc;
  744. @include lineHeight(0.7rem);
  745. margin-top: 0.15rem;
  746. &.active {
  747. border-bottom: 0.04rem solid #4290f7;
  748. color: #4290f7
  749. }
  750. }
  751. }
  752. .search-content {
  753. padding-top: 0;
  754. top: 3.41rem;
  755. /*height: calc(100vh - 3.41rem);*/
  756. overflow-y: auto;
  757. position: absolute;
  758. width: 100%;
  759. bottom: 0;
  760. }
  761. .searchContent2 {
  762. /*height: calc(100vh - 7.3rem);*/
  763. top: 7.3rem;
  764. }
  765. .searchContent3 {
  766. /*height: calc(100vh - 2.25rem);*/
  767. top: 2.25rem;
  768. }
  769. .store-info {
  770. background: #f7f7f7;
  771. h4{
  772. width: 100%;
  773. text-align: left;
  774. font-size: 0.3rem;
  775. line-height: 0.6rem;
  776. height: 0.6rem;
  777. letter-spacing: 0px;
  778. color: #333;
  779. font-weight: normal;
  780. border-bottom: 1px solid #efeded;
  781. padding-left: 0.11rem;
  782. &:before{
  783. content: '';
  784. display: inline-block;
  785. width: 0.08rem;
  786. height: 0.26rem;
  787. background-color: #145dee;
  788. margin-right: 0.13rem;
  789. position: relative;
  790. top: 0.02rem;
  791. }
  792. }
  793. .contact-info{
  794. background: #fff;
  795. margin: .2rem auto;
  796. border-radius: .1rem;
  797. ul{
  798. padding: 0.22rem 0rem;
  799. li{
  800. div{
  801. float: left;
  802. font-size: .28rem;
  803. color: #666;
  804. line-height: .53rem;
  805. width:80%;
  806. text-align: left;
  807. &:first-child{
  808. width: 20%;
  809. padding-left: 0.36rem;
  810. text-align: justify;
  811. }
  812. a{
  813. color: #145dee;
  814. }
  815. .click-tel, .click-phone{
  816. color: #f44336;
  817. }
  818. }
  819. /* &:last-child{
  820. div{
  821. width: 74%;
  822. padding-right:.34rem;
  823. word-wrap: break-word;
  824. &:first-child{
  825. text-align: left;
  826. padding: 0rem 0rem 0rem .36rem;
  827. width: 26%;
  828. }
  829. }
  830. }*/
  831. }
  832. }
  833. }
  834. .store-description{
  835. background: #fff;
  836. /*width: 6.96rem;*/
  837. margin: 0 auto .2rem;
  838. border-radius: .1rem;
  839. .content {
  840. text-indent:2em;
  841. background: #fff;
  842. margin: .2rem auto 0;
  843. padding: .04rem .34rem .4rem .34rem;
  844. width: 100%;
  845. font-size: .28rem;
  846. color: #666;
  847. text-align: left;
  848. height: 95%;
  849. /*box-shadow: 0 .03rem .01rem 0 #cdcbcb96;*/
  850. line-height: .5rem;
  851. word-break: break-all;
  852. }
  853. }
  854. }
  855. .none-state{
  856. text-align: center;
  857. padding:1.5rem 0;
  858. background: #fff;
  859. margin-top:.1rem;
  860. width:100%;
  861. img{
  862. margin:0 auto;
  863. width: 4.08rem;
  864. height: 2.62rem;
  865. }
  866. p {
  867. font-size: .32rem;
  868. color: #999;
  869. margin: 1.19rem 0 0 0;
  870. }
  871. a {
  872. display: block;
  873. font-size: .28rem;
  874. color: #fff;
  875. width: 1.88rem;
  876. height: .54rem;
  877. line-height: .54rem;
  878. background: #418bf6;
  879. margin: .7rem auto 0;
  880. border-radius: .05rem;
  881. }
  882. }
  883. .associate-list {
  884. position: absolute;
  885. width: 100%;
  886. background: #fff;
  887. top: 0.8rem;
  888. border: 1px solid #dcdcdc;
  889. z-index: 100;
  890. height: 100%;
  891. left: 0;
  892. bottom: 0;
  893. right: 0;
  894. li {
  895. height: 0.7rem;
  896. line-height: .9rem;
  897. margin: 0 .45rem;
  898. border-bottom: .04rem solid #f1f0f0;
  899. @include overFlowHidden();
  900. i {
  901. font-size: .36rem;
  902. margin-right: .24rem;
  903. color: #ddd;
  904. }
  905. span {
  906. color: #999;
  907. font-size: .28rem;
  908. line-height: .58rem;
  909. height: .58rem;
  910. display: inline-block;
  911. }
  912. &:active, &:hover {
  913. background: #eee;
  914. }
  915. &:last-child {
  916. text-align: center;
  917. font-size: .3rem;
  918. color: #3976f4;
  919. border-bottom: none;
  920. &:active, &:hover {
  921. background: #fff;
  922. }
  923. }
  924. }
  925. }
  926. }
  927. </style>