search.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044
  1. <template>
  2. <view class="search-container">
  3. <view class="search-main">
  4. <view class="search-tab">
  5. <view class="search-tab-btn" @click="topBubble">
  6. <text>{{ tabValue }}</text> <text class="iconfont icon-xiangxiajiantou"></text>
  7. </view>
  8. <tui-bubble-popup
  9. :show="show"
  10. :mask="true"
  11. position="absolute"
  12. direction="top"
  13. @close="topBubble"
  14. width="140rpx"
  15. left="10rpx"
  16. bottom="0rpx"
  17. translateY="100%"
  18. triangleRight="60rpx"
  19. triangleTop="-22rpx"
  20. :maskBgColor="maskBgColor"
  21. >
  22. <view class="tui-menu-item" @tap="selectTabs(1)">产品</view>
  23. <!-- <view class="tui-menu-item" @tap="selectTabs(2)">供应商</view> -->
  24. <view class="tui-menu-item" @tap="selectTabs(3)">项目仪器</view>
  25. </tui-bubble-popup>
  26. </view>
  27. <view class="gosearch-btn">
  28. <text class="iconfont icon-sousuo"></text>
  29. <input
  30. class="input"
  31. maxlength="20"
  32. :focus="isFocus"
  33. type="text"
  34. value=""
  35. confirm-type="search"
  36. @focus="onFocus"
  37. @input="onShowClose"
  38. @confirm="subMitSearch()"
  39. placeholder="请输入搜索关键字"
  40. v-model.trim="listQuery.keyword"
  41. />
  42. <text class="iconfont icon-shanchu1" v-if="isShowClose" @click.stop="delInputText()"></text>
  43. </view>
  44. <view class="search-btn" @click="subMitSearch()">搜索</view>
  45. </view>
  46. <view class="search-container-history" v-if="!isShowWrapper">
  47. <view :class="'s-' + themeClass" v-if="serachRecordList.length > 0">
  48. <view class="header"> 搜索历史<text class="iconfont icon-shanchu" @click="confirmDetele"></text> </view>
  49. <view class="list">
  50. <view class="list-main">
  51. <view
  52. v-for="(item, index) in serachRecordList"
  53. :key="index"
  54. @click="keywordsClick(item.searchWord)"
  55. >{{ item.searchWord }}</view
  56. >
  57. </view>
  58. </view>
  59. </view>
  60. <view class="s-block hot clearfix">
  61. <view class="header">热门搜索</view>
  62. <view class="list">
  63. <view class="list-title">产品</view>
  64. <view class="list-main">
  65. <view
  66. v-for="(item, index) in productHotSearch"
  67. :key="index"
  68. @click="keywordsClickPath(item)"
  69. :class="item.isHot == '1' ? 'list-active' : ''"
  70. >
  71. {{ item.name }} <text class="iconfont icon-resou" v-if="item.isHot === '1'"></text>
  72. </view>
  73. </view>
  74. </view>
  75. <view class="list">
  76. <view class="list-title">仪器</view>
  77. <view class="list-main">
  78. <view
  79. v-for="(item, index) in instrumentHotSearch"
  80. :key="index"
  81. @click="keywordsClickPath(item)"
  82. :class="item.isHot == '1' ? 'list-active' : ''"
  83. >
  84. {{ item.name }} <text class="iconfont icon-resou" v-if="item.isHot === '1'"></text>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. <view
  91. v-else
  92. class="commodity-list-wrapper"
  93. :style="{ overflow: 'auto', height: listData.length > 4 ? windowHeight + 'px' : 'auto' }"
  94. >
  95. <scroll-view
  96. :style="{ height: listData.length > 4 ? scrollHeight + 'px' : 'auto' }"
  97. @scrolltolower="scrolltolower"
  98. scroll-y
  99. v-if="!showEmpty"
  100. >
  101. <view
  102. v-for="(pros, index) in listData"
  103. :key="index"
  104. :id="pros.id"
  105. class="all-type-list-content commodity-list"
  106. @click.stop="navToDetailPage(pros.productId)"
  107. >
  108. <image mode="widthFix" :src="pros.image" class="list-img" alt="list-img"></image>
  109. <view class="list-details-info">
  110. <view class="list-details-title">
  111. <text class="mclap-tag" v-if="pros.beautyActFlag == 1">美博会</text>
  112. <text class="mclap" :class="pros.beautyActFlag == 1 ? 'indent' : ''">{{
  113. isInterceptHtmlFn(pros.name)
  114. }}</text>
  115. </view>
  116. <text class="list-details-specs">规格:{{ pros.unit }}</text>
  117. <view class="list-details-specs" v-if="pros.code != '' && pros.code != null">
  118. <view>商品编码:{{ pros.code }}</view>
  119. </view>
  120. <view class="list-details-price">
  121. <template v-if="userIdentity == 3">
  122. <view class="floor-item-act">
  123. <view class="coupon-tags" v-if="pros.couponsLogo">优惠券</view>
  124. <template v-if="pros.actStatus == 1">
  125. <view class="floor-tags" v-if="PromotionsFormat(pros.promotions)">
  126. {{ pros.promotions.name }}
  127. <text v-if="hasLogin && pros.shopId == shopId && pros.priceFlag != 1"
  128. >:¥{{ pros.price | NumFormat }}</text
  129. >
  130. </view>
  131. <view class="floor-tags" v-else>{{ pros.promotions.name }}</view>
  132. </template>
  133. <template v-if="pros.svipProductFlag == 1">
  134. <view class="svip-tags">
  135. <view class="tags">SVIP</view>
  136. <view
  137. class="price"
  138. v-if="hasLogin && pros.shopId == shopId && pros.priceFlag != 1"
  139. >{{ pros.svipPriceTag }}</view
  140. >
  141. </view>
  142. </template>
  143. </view>
  144. </template>
  145. <template v-else-if="userIdentity == 1">
  146. <view class="floor-item-act">
  147. <view class="coupon-tags" v-if="pros.couponsLogo">优惠券</view>
  148. <template v-if="pros.actStatus == 1">
  149. <view
  150. class="floor-tags"
  151. v-if="pros.actStatus == 1 && PromotionsFormat(pros.promotions)"
  152. >
  153. {{ pros.promotions.name }} <text>:¥{{ pros.price | NumFormat }}</text>
  154. </view>
  155. <view class="floor-tags" v-else>{{ pros.promotions.name }}</view>
  156. </template>
  157. <template v-if="pros.svipProductFlag == 1">
  158. <view class="svip-tags"><view class="tags none">SVIP</view> </view>
  159. </template>
  160. </view>
  161. </template>
  162. <template v-else>
  163. <view class="floor-item-act">
  164. <view class="coupon-tags" v-if="pros.couponsLogo">优惠券</view>
  165. <template v-if="pros.actStatus == 1">
  166. <view
  167. class="floor-tags"
  168. v-if="pros.actStatus == 1 && PromotionsFormat(pros.promotions)"
  169. >
  170. {{ pros.promotions.name }}
  171. <text v-if="pros.priceFlag != 1 && hasLogin && userIdentity == 2"
  172. >:¥{{ pros.price | NumFormat }}</text
  173. >
  174. </view>
  175. <view class="floor-tags" v-else>{{ pros.promotions.name }}</view>
  176. </template>
  177. <template v-if="pros.svipProductFlag == 1">
  178. <view class="svip-tags">
  179. <view class="tags" :class="{ none : vipFlag == 0 }">SVIP</view>
  180. <view class="price" v-if="isShowVipFlag(pros)">{{ pros.svipPriceTag }}</view>
  181. </view>
  182. </template>
  183. </view>
  184. </template>
  185. <view v-if="hasLogin" class="list-price">
  186. <template v-if="userIdentity == 1">
  187. <text v-if="priceLoading" class="price-larger small">正在获取价格...</text>
  188. <text
  189. v-else
  190. class="price-larger"
  191. :class="
  192. PromotionsFormat(pros.promotions) || pros.svipProductFlag == 1 ? 'none' : ''
  193. "
  194. >
  195. ¥{{
  196. (PromotionsFormat(pros.promotions) ? pros.originalPrice : pros.price)
  197. | NumFormat
  198. }}
  199. </text>
  200. </template>
  201. <template v-if="userIdentity == 4 && vipFlag != 1">
  202. <view class="price-larger" v-if="pros.priceFlag == 1">
  203. <text class="txt">¥未公开价格</text>
  204. </view>
  205. <text v-else-if="priceLoading" class="price-larger small">正在获取价格...</text>
  206. <template v-else>
  207. <view class="price-larger" v-if="pros.priceFlag == 2">
  208. <text class="txt">¥价格仅会员可见</text>
  209. </view>
  210. <text
  211. v-else
  212. class="price-larger"
  213. :class="
  214. PromotionsFormat(pros.promotions) || pros.svipProductFlag == 1
  215. ? 'none'
  216. : ''
  217. "
  218. >
  219. ¥{{
  220. (PromotionsFormat(pros.promotions) ? pros.originalPrice : pros.price)
  221. | NumFormat
  222. }}
  223. </text>
  224. </template>
  225. </template>
  226. <template v-if="userIdentity == 3">
  227. <template v-if="pros.supplierId == shopId">
  228. <view class="price-larger" v-if="pros.priceFlag == 1">
  229. <text class="txt">¥未公开价格</text>
  230. </view>
  231. <text v-else-if="priceLoading" class="price-larger small">正在获取价格...</text>
  232. <text
  233. v-else
  234. class="price-larger"
  235. :class="
  236. PromotionsFormat(pros.promotions) || pros.svipProductFlag == 1
  237. ? 'none'
  238. : ''
  239. "
  240. >
  241. ¥{{
  242. (PromotionsFormat(pros.promotions) ? pros.originalPrice : pros.price)
  243. | NumFormat
  244. }}
  245. </text>
  246. </template>
  247. <template v-else>
  248. <view class="list-login-now">
  249. <text class="p-no">¥</text>
  250. <uni-grader :grade="Number(pros.priceGrade)"></uni-grader>
  251. </view>
  252. </template>
  253. </template>
  254. <template v-if="userIdentity == 2 || (userIdentity == 4 && vipFlag == 1)">
  255. <view class="price-larger" v-if="pros.priceFlag == 1">
  256. <text class="txt">¥未公开价格</text>
  257. </view>
  258. <text v-else-if="priceLoading" class="price-larger small">正在获取价格...</text>
  259. <text
  260. v-else
  261. class="price-larger"
  262. :class="
  263. PromotionsFormat(pros.promotions) || pros.svipProductFlag == 1 ? 'none' : ''
  264. "
  265. >
  266. ¥{{
  267. (PromotionsFormat(pros.promotions) ? pros.originalPrice : pros.price)
  268. | NumFormat
  269. }}
  270. </text>
  271. </template>
  272. </view>
  273. <view v-else class="list-login-now">
  274. <text class="p-no">¥</text>
  275. <uni-grader :grade="Number(pros.priceGrade)"></uni-grader>
  276. </view>
  277. </view>
  278. </view>
  279. </view>
  280. <view v-if="showLoading && listData.length > 4">
  281. <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow"
  282. >{{ loadingText }}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view
  283. >
  284. <view class="loading-wrapper loading-wrapper-btm" v-else
  285. >———<text class="btm-text">已至底部</text>———</view
  286. >
  287. </view>
  288. </scroll-view>
  289. <view class="empty-container" v-if="showEmpty">
  290. <image
  291. class="empty-container-image"
  292. src="https://img.caimei365.com/group1/M00/03/8D/Cmis215XHXWAHCoqAAELHadZ9Xg365.png"
  293. ></image>
  294. <text class="error-text">抱歉,没有相关商品!</text>
  295. </view>
  296. </view>
  297. <!-- 透明模态层 -->
  298. <modal-layer v-if="isModallayer"></modal-layer>
  299. </view>
  300. </template>
  301. <script>
  302. import { mapState, mapMutations } from 'vuex'
  303. import modalLayer from '@/components/modal-layer'
  304. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  305. import authorize from '@/common/config/authorize.js'
  306. import wxLogin from '@/common/config/wxLogin.js'
  307. export default {
  308. components: {
  309. modalLayer,
  310. uniGrader
  311. },
  312. data() {
  313. return {
  314. shopId: 0,
  315. userId: 0,
  316. tabValue: '产品',
  317. themeClass: 'block',
  318. show: false,
  319. vipFlag:0,
  320. userIdentity: 0,
  321. searchKeyType: 1,
  322. isShowClose: false, //是否显示清空输入框图标
  323. isSearchHistory: false, //是都显示搜索历史
  324. serachRecordList: [], //历史搜索记录
  325. instrumentHotSearch: [],
  326. productHotSearch: [],
  327. isShowWrapper: false,
  328. isModallayer: false,
  329. isFocus: false,
  330. priceLoading: true,
  331. windowHeight: '',
  332. showEmpty: false,
  333. scrollHeight: '',
  334. listData: [],
  335. productIds: '', //查询价格的商品ID
  336. showLoading: false,
  337. loadingNow: true,
  338. loadingText: '上拉加载更多',
  339. pullFlag: true,
  340. listQuery: {
  341. identity: 0,
  342. keyword: '',
  343. sortField: '',
  344. sortType: '',
  345. pageNum: 1,
  346. pageSize: 20
  347. },
  348. total: 0
  349. }
  350. },
  351. computed: {
  352. ...mapState(['hasLogin', 'userInfo', 'isWxAuthorize', 'hasLogin', 'userInfo', 'identity'])
  353. },
  354. onLoad(option) {
  355. console.log(option)
  356. if (option.type == 'share') {
  357. wxLogin.wxLoginAuthorize()
  358. }
  359. this.initGetStotage(option)
  360. },
  361. filters: {
  362. NumFormat: function(text) {
  363. //处理金额
  364. return Number(text).toFixed(2)
  365. }
  366. },
  367. methods: {
  368. async initGetStotage(option) {
  369. const userInfo = await this.$api.getStorage()
  370. this.userId = userInfo.userId ? userInfo.userId : 0
  371. this.shopId = userInfo.shopId ? userInfo.shopId : 0
  372. this.vipFlag = userInfo.vipFlag ? userInfo.vipFlag : 0
  373. this.userIdentity = userInfo.userIdentity ? userInfo.userIdentity : 0
  374. this.listQuery.identity = this.identity
  375. if (option.keyWord) {
  376. this.listQuery.keyword = option.keyWord
  377. this.setSearchHistoryAdd()
  378. this.getListFromServer()
  379. this.isFocus = false
  380. } else {
  381. this.isFocus = true
  382. this.initGetSerachRecord()
  383. }
  384. },
  385. GetHomeHotSearchTerms() {
  386. //金刚区分类
  387. this.CommonService.GetHomeHotSearchTerms({})
  388. .then(response => {
  389. let data = response.data
  390. console.log(data)
  391. this.instrumentHotSearch = data.instrumentHotSearch
  392. this.productHotSearch = data.productHotSearch
  393. })
  394. .catch(error => {
  395. this.$util.msg(error.msg, 2000)
  396. })
  397. },
  398. initGetSerachRecord() {
  399. //查询搜索历史记录
  400. this.ProductService.GetProductSearchHistory({ userId: this.userId }).then(response => {
  401. if (response.code == 0) {
  402. this.serachRecordList = response.data
  403. }
  404. })
  405. },
  406. subMitSearch() {
  407. //搜索
  408. if (this.listQuery.keyword == '') {
  409. this.$util.msg('请输入搜索关键词', 2000)
  410. } else {
  411. switch (this.searchKeyType) {
  412. case 1:
  413. this.listData = []
  414. this.setSearchHistoryAdd()
  415. this.getListFromServer()
  416. this.isFocus = false
  417. // 友盟埋点商品搜索点击
  418. if (process.env.NODE_ENV != 'development') {
  419. this.$uma.trackEvent('Um_Event_SearchProductSubmit', {
  420. Um_Key_Keyword: `${this.listQuery.keyword}`,
  421. Um_Key_PageName: '商品',
  422. Um_Key_SourcePage: '搜索商品'
  423. })
  424. }
  425. break
  426. case 2:
  427. this.setSearchHistoryAdd()
  428. this.$api.navigateTo(`/pages/search/search-supplier?keyWord=${this.listQuery.keyword}`)
  429. break
  430. case 3:
  431. this.setSearchHistoryAdd()
  432. this.$api.navigateTo(`/pages/search/search-instrument?keyWord=${this.listQuery.keyword}`)
  433. break
  434. }
  435. }
  436. },
  437. scrolltolower() {
  438. if (this.total > this.listData.length && this.pullFlag) {
  439. this.getListFromServer(true)
  440. }
  441. },
  442. getListFromServer(loadMore) {
  443. this.showLoading = true
  444. this.loadingNow = true
  445. this.loadingText = '加载中'
  446. this.showEmpty = false
  447. if (loadMore) {
  448. this.listQuery.pageNum += 1
  449. }
  450. this.ProductService.GetProductSearchList(this.listQuery)
  451. .then(response => {
  452. this.isShowWrapper = true
  453. const resData = JSON.parse(response.data)
  454. const resList = resData.items
  455. if (resList && resList.length > 0) {
  456. this.total = resData.total
  457. this.showEmpty = false
  458. if (loadMore) {
  459. this.listData = [...this.listData, ...resList]
  460. this.getProductPrice()
  461. } else {
  462. this.listData = [...resList]
  463. this.getProductPrice()
  464. }
  465. // 防上拉暴滑
  466. this.pullFlag = false
  467. setTimeout(() => {
  468. this.pullFlag = true
  469. }, 500)
  470. // 底部提示文案
  471. if (this.totalPage > this.listData.length) {
  472. this.loadingText = '上拉加载更多'
  473. } else {
  474. this.showLoading = true
  475. this.loadingNow = false
  476. }
  477. } else {
  478. if (!loadMore) {
  479. this.showEmpty = true
  480. }
  481. }
  482. })
  483. .catch(error => {
  484. this.$util.msg(error.msg, 2000)
  485. })
  486. },
  487. setSearchHistoryAdd() {
  488. //添加搜索记录
  489. if (!this.hasLogin) {
  490. return false
  491. }
  492. this.ProductService.GetAddProductSearchHistory({ userId: this.userId, keyword: this.listQuery.keyword })
  493. .then(response => {
  494. //此为每次搜索同时添加用户的搜索记录
  495. })
  496. .catch(error => {
  497. this.$util.msg(error.msg, 2000)
  498. })
  499. },
  500. getProductPrice() {
  501. //获取价格
  502. let productIdArr = []
  503. this.listData.map(item => {
  504. // 0公开价格 1不公开价格 2仅对资质机构公开
  505. productIdArr.push(item.productId)
  506. })
  507. this.productIds = productIdArr.join(',')
  508. this.ProductService.querySearchProductPrice({
  509. userId: this.userId,
  510. productIds: this.productIds,
  511. source: 2 // 来源 1 WWW 2 小程序
  512. })
  513. .then(response => {
  514. if (response.data) {
  515. this.listData = this.ReturnNewProducts(this.listData, response.data)
  516. }
  517. this.priceLoading = false
  518. })
  519. .catch(error => {
  520. this.$util.msg(error.msg, 2000)
  521. })
  522. },
  523. ReturnNewProducts(Array, list) {
  524. //处理对应商品ID的商品价格
  525. let NewArray = []
  526. Array.map(item => {
  527. for (let i = 0; i < list.length; i++) {
  528. if (item.productId == list[i].productId) {
  529. NewArray.push(Object.assign(item, list[i]))
  530. }
  531. }
  532. })
  533. return NewArray
  534. },
  535. PromotionsFormat(promo) {
  536. //促销活动类型数据处理
  537. if (promo != null) {
  538. if (promo.type == 1 && promo.mode == 1) {
  539. return true
  540. } else {
  541. return false
  542. }
  543. }
  544. return false
  545. },
  546. isShowVipFlag(pros) {
  547. // 超级会员价格显示控制
  548. if (this.hasLogin && pros.priceFlag != 1) {
  549. if (this.userIdentity == 4 && this.vipFlag == 1) {
  550. return true
  551. } else if (this.userIdentity == 2) {
  552. return true
  553. }
  554. }
  555. },
  556. onShowClose() {
  557. //输入框输入时触发
  558. this.inputEmpty(this.listQuery.keyword)
  559. },
  560. onFocus() {
  561. //输入框获取焦点时触发
  562. this.inputEmpty(this.listQuery.keyword)
  563. this.initGetSerachRecord()
  564. },
  565. delInputText() {
  566. //清除输入框内容
  567. this.listQuery.keyword = ''
  568. this.isShowClose = false
  569. this.isShowWrapper = false
  570. this.inputEmpty(this.listQuery.keyword)
  571. this.initGetSerachRecord()
  572. },
  573. keywordsClick(item) {
  574. //关键词搜索与历史搜索
  575. this.listQuery.keyword = item
  576. this.isShowClose = true
  577. this.isFocus = false
  578. this.subMitSearch()
  579. },
  580. keywordsClickPath(item) {
  581. this.$api.FlooryNavigateTo(item)
  582. },
  583. confirmDetele() {
  584. //清空历史记录
  585. this.$util.modal('提示', '确定删除历史记录?', '确定', '取消', true, () => {
  586. this.ProductService.GetDeleteProductSearchHistory({ userId: this.userId })
  587. .then(response => {
  588. this.$util.msg('删除成功', 2000, true, 'success')
  589. this.serachRecordList = []
  590. })
  591. .catch(error => {
  592. this.$util.msg(error.msg, 2000)
  593. })
  594. })
  595. },
  596. inputEmpty(val) {
  597. this.isShowWrapper = false
  598. if (val != '') {
  599. this.isShowClose = true
  600. this.isFocus = true
  601. } else {
  602. this.isShowClose = false
  603. this.isFocus = true
  604. }
  605. },
  606. isInterceptHtmlFn(text) {
  607. let name = this.$reg.interceptHtmlFn(text)
  608. return name
  609. },
  610. navToDetailPage(id) {
  611. this.isModallayer = true
  612. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  613. this.isModallayer = false
  614. },
  615. setScrollHeight() {
  616. const { windowHeight, pixelRatio } = wx.getSystemInfoSync()
  617. this.windowHeight = windowHeight - 1
  618. this.scrollHeight = windowHeight - 1
  619. },
  620. toLoginPage() {
  621. let searchLoginType = 'search'
  622. uni.navigateTo({
  623. url: `/pages/login/login?type=${searchLoginType}`
  624. })
  625. },
  626. selectTabs(index) {
  627. //选择搜索项
  628. this.show = false
  629. this.searchKeyType = index
  630. switch (index) {
  631. case 1:
  632. this.tabValue = '产品'
  633. break
  634. case 2:
  635. this.tabValue = '供应商'
  636. break
  637. case 3:
  638. this.tabValue = '项目仪器'
  639. break
  640. }
  641. },
  642. topBubble() {
  643. //显隐搜索项
  644. this.show = !this.show
  645. }
  646. },
  647. onShareAppMessage(res) {
  648. //分享转发
  649. if (res.from === 'button') {
  650. // 来自页面内转发按钮
  651. }
  652. return {
  653. title: `点击查看“${this.listQuery.keyword}”相关的商品`,
  654. path: `pages/search/search?type=share&keyWord=${this.listQuery.keyword}`
  655. }
  656. },
  657. onShow() {
  658. this.setScrollHeight()
  659. this.GetHomeHotSearchTerms()
  660. }
  661. }
  662. </script>
  663. <style lang="scss">
  664. @import '@/uni.scss';
  665. page {
  666. background-color: #f7f7f7 !important;
  667. }
  668. .search-main {
  669. width: 100%;
  670. height: 88rpx;
  671. position: fixed;
  672. top: 0;
  673. left: 0;
  674. background: #ffffff;
  675. z-index: 1001;
  676. box-sizing: border-box;
  677. padding: 9rpx 0;
  678. .search-tab {
  679. width: 160rpx;
  680. height: 70rpx;
  681. line-height: 70rpx;
  682. color: #666666;
  683. font-size: $font-size-24;
  684. text-align: center;
  685. float: left;
  686. position: relative;
  687. .icon-xiangxiajiantou {
  688. margin-left: 10rpx;
  689. font-size: $font-size-30;
  690. }
  691. }
  692. .gosearch-btn {
  693. width: 470rpx;
  694. height: 100%;
  695. float: left;
  696. border-radius: 40rpx;
  697. background: #f0f0f0;
  698. margin: 0 auto;
  699. padding: 0 20rpx;
  700. font-size: 28rpx;
  701. line-height: 70rpx;
  702. padding-left: 70rpx;
  703. color: #8a8a8a;
  704. background: #f7f7f7;
  705. position: relative;
  706. box-sizing: border-box;
  707. .icon-sousuo {
  708. width: 70rpx;
  709. height: 70rpx;
  710. line-height: 70rpx;
  711. text-align: center;
  712. display: block;
  713. position: absolute;
  714. left: 0;
  715. top: 0;
  716. font-size: 34rpx;
  717. color: #8a8a8a;
  718. z-index: 10;
  719. }
  720. .icon-shanchu1 {
  721. font-size: 36rpx;
  722. color: #8a8a8a;
  723. position: absolute;
  724. right: 10rpx;
  725. top: 0;
  726. padding: 0 10rpx;
  727. z-index: 100;
  728. }
  729. .input {
  730. width: 400rpx;
  731. height: 100%;
  732. float: left;
  733. font-size: $font-size-24;
  734. box-sizing: border-box;
  735. padding-right: 66rpx;
  736. }
  737. }
  738. .search-btn {
  739. width: 120rpx;
  740. height: 70rpx;
  741. line-height: 70rpx;
  742. float: right;
  743. text-align: center;
  744. color: #666666;
  745. font-size: $font-size-24;
  746. }
  747. }
  748. .search-container {
  749. padding-top: 96rpx;
  750. }
  751. .s-block {
  752. background: #ffffff;
  753. &.hot {
  754. border-top: 20rpx solid #f7f7f7;
  755. }
  756. .header {
  757. font-size: 32rpx;
  758. padding: 40rpx 24rpx 22rpx 24rpx;
  759. line-height: 42rpx;
  760. font-size: 30rpx;
  761. font-weight: bold;
  762. position: relative;
  763. width: 100%;
  764. float: left;
  765. box-sizing: border-box;
  766. .icon-shanchu {
  767. font-size: 36rpx;
  768. color: #333333;
  769. float: right;
  770. padding: 0 10rpx;
  771. z-index: 10;
  772. font-weight: normal;
  773. }
  774. }
  775. .list {
  776. width: 100%;
  777. height: auot;
  778. float: left;
  779. padding: 0 24rpx 30rpx 24rpx;
  780. box-sizing: border-box;
  781. .list-title {
  782. width: 100%;
  783. height: 40rpx;
  784. font-size: $font-size-26;
  785. color: #333;
  786. }
  787. .list-main {
  788. width: 100%;
  789. float: left;
  790. display: flex;
  791. flex-wrap: wrap;
  792. view {
  793. color: #8a8a8a;
  794. font-size: 24rpx;
  795. box-sizing: border-box;
  796. text-align: center;
  797. height: 48rpx;
  798. line-height: 48rpx;
  799. border-radius: 24rpx;
  800. margin: 12rpx 12rpx 12rpx 0;
  801. padding: 0 20rpx;
  802. white-space: nowrap;
  803. text-overflow: ellipsis;
  804. background-color: #f3f3f3;
  805. .iconfont {
  806. font-size: $font-size-30;
  807. color: #e15616;
  808. margin-left: 12rpx;
  809. }
  810. &.list-active {
  811. background-color: #fef6f3;
  812. color: #e15616;
  813. }
  814. }
  815. }
  816. }
  817. }
  818. .s-circle {
  819. margin-top: 30rpx;
  820. .header {
  821. font-size: 32rpx;
  822. padding: 30rpx;
  823. border-bottom: 2rpx solid #f9f9f9;
  824. position: relative;
  825. image {
  826. width: 36rpx;
  827. height: 36rpx;
  828. padding: 10rpx;
  829. position: absolute;
  830. right: 40rpx;
  831. top: 24rpx;
  832. }
  833. }
  834. .list {
  835. display: flex;
  836. flex-wrap: wrap;
  837. padding: 0 30rpx 20rpx;
  838. view {
  839. padding: 8rpx 30rpx;
  840. margin: 20rpx 30rpx 0 0;
  841. font-size: 28rpx;
  842. color: #8a8a8a;
  843. background-color: #f7f7f7;
  844. box-sizing: border-box;
  845. text-align: center;
  846. border-radius: 20rpx;
  847. }
  848. }
  849. }
  850. .wanted-block {
  851. margin-top: 30rpx;
  852. .header {
  853. font-size: 32rpx;
  854. padding: 30rpx;
  855. }
  856. .list {
  857. display: flex;
  858. flex-wrap: wrap;
  859. view {
  860. width: 50%;
  861. color: #8a8a8a;
  862. font-size: 28rpx;
  863. box-sizing: border-box;
  864. text-align: center;
  865. padding: 20rpx 0;
  866. border-top: 2rpx solid #fff;
  867. border-left: 2rpx solid #fff;
  868. background-color: #f7f7f7;
  869. overflow: hidden;
  870. white-space: nowrap;
  871. text-overflow: ellipsis;
  872. }
  873. }
  874. }
  875. .wanted-circle {
  876. margin-top: 30rpx;
  877. .header {
  878. font-size: 32rpx;
  879. padding: 30rpx;
  880. }
  881. .list {
  882. display: flex;
  883. flex-wrap: wrap;
  884. padding: 0 30rpx 20rpx;
  885. view {
  886. padding: 8rpx 30rpx;
  887. margin: 20rpx 30rpx 0 0;
  888. font-size: 28rpx;
  889. color: #8a8a8a;
  890. background-color: #f7f7f7;
  891. box-sizing: border-box;
  892. text-align: center;
  893. border-radius: 20rpx;
  894. }
  895. }
  896. }
  897. .commodity-list-wrapper {
  898. scroll-view {
  899. height: 100%;
  900. overflow: scroll;
  901. }
  902. .empty-container-image {
  903. margin-top: -300rpx;
  904. }
  905. .toIndexPage {
  906. bottom: 390rpx;
  907. }
  908. .show-more-btn {
  909. width: 276rpx;
  910. height: 52rpx;
  911. line-height: 52rpx;
  912. border: 2rpx solid #d8d8d8;
  913. background: #f7f7f7;
  914. font-size: 26rpx;
  915. margin: 26rpx 0;
  916. position: absolute;
  917. left: 50%;
  918. margin-left: -138rpx;
  919. }
  920. }
  921. .all-type-list-content {
  922. height: 216rpx;
  923. padding: 24rpx;
  924. background: #fff;
  925. margin-bottom: 2rpx;
  926. display: flex;
  927. flex-direction: row;
  928. box-sizing: content-box;
  929. .list-img {
  930. width: 210rpx;
  931. height: 218rpx !important;
  932. margin-right: 26rpx;
  933. border-radius: 10rpx;
  934. border: 2rpx solid #f3f3f3;
  935. }
  936. }
  937. .list-details-info {
  938. width: 466rpx;
  939. display: flex;
  940. flex-direction: column;
  941. font-size: 26rpx;
  942. position: relative;
  943. .list-details-title {
  944. position: relative;
  945. .mclap {
  946. line-height: 38rpx;
  947. text-overflow: ellipsis;
  948. overflow: hidden;
  949. display: -webkit-box;
  950. -webkit-line-clamp: 2;
  951. line-clamp: 2;
  952. -webkit-box-orient: vertical;
  953. &.indent {
  954. text-indent: 95rpx;
  955. }
  956. }
  957. .mclap-tag {
  958. display: block;
  959. width: 84rpx;
  960. height: 32rpx;
  961. background-image: linear-gradient(270deg, #f9c023 0%, #f83600 100%);
  962. border-radius: 4rpx 48rpx 4px 4px;
  963. line-height: 32rpx;
  964. font-size: $font-size-22;
  965. color: #ffffff;
  966. text-align: center;
  967. position: absolute;
  968. left: 0;
  969. top: 0;
  970. }
  971. }
  972. .list-details-specs {
  973. margin-top: 8rpx;
  974. color: #666666;
  975. }
  976. .list-details-miniQuantity {
  977. margin-top: 7rpx;
  978. }
  979. }
  980. .list-details-price {
  981. width: 100%;
  982. height: 54rpx;
  983. line-height: 54rpx;
  984. position: absolute;
  985. bottom: -10rpx;
  986. right: 0;
  987. .floor-item-act {
  988. height: 54rpx;
  989. text-align: center;
  990. box-sizing: border-box;
  991. float: right;
  992. padding: 11rpx 0;
  993. }
  994. .price-icon {
  995. width: 22rpx;
  996. height: 28rpx;
  997. vertical-align: middle;
  998. margin-right: 10rpx;
  999. }
  1000. .price-icon + text {
  1001. font-size: 25rpx;
  1002. vertical-align: middle;
  1003. }
  1004. .list-login-now {
  1005. color: #f8c499;
  1006. float: left;
  1007. line-height: 54rpx;
  1008. .p-no {
  1009. float: left;
  1010. font-size: $font-size-24;
  1011. color: $text-color;
  1012. }
  1013. }
  1014. .login-now {
  1015. padding: 10rpx 10rpx 10rpx 0;
  1016. }
  1017. .list-price {
  1018. color: #ff2a2a;
  1019. height: 44rpx;
  1020. float: left;
  1021. .price-larger {
  1022. width: 100%;
  1023. font-size: 32rpx;
  1024. &.none {
  1025. text-decoration: line-through;
  1026. color: #999999;
  1027. }
  1028. &.small {
  1029. font-size: $font-size-24;
  1030. }
  1031. .txt {
  1032. font-size: $font-size-24;
  1033. display: inline-block;
  1034. line-height: 44rpx;
  1035. text-align: left;
  1036. float: left;
  1037. }
  1038. }
  1039. }
  1040. }
  1041. </style>