search-supplier.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <view class="container supplier clearfix">
  3. <view class="supplier-search clearfix">
  4. <view class="search-from name">
  5. <text class="iconfont icon-sousuo"></text>
  6. <input class="input"
  7. type="text"
  8. confirm-type="search"
  9. v-model="listQuery.keyword"
  10. :focus="isFocus"
  11. @input="onShowClose"
  12. @confirm="GetSearchSupplierList()"
  13. placeholder="请输入供应商名称"
  14. maxlength="16"/>
  15. <text class="iconfont icon-shanchu1" v-if="isShowClose" @click="delInputText()"></text>
  16. </view>
  17. <view class="search-btn">
  18. <button class="search-btn" type="default" @click.stop="searchsupplierList">搜索</button>
  19. </view>
  20. </view>
  21. <view class="supplier-main">
  22. <view v-if="isEmpty" class="empty-container">
  23. <image class="empty-container-image" :src="productNoneImage" mode="aspectFit"></image>
  24. <view class="txt">暂无供应商数据^_^</view>
  25. </view>
  26. <view v-else class="supplier-list">
  27. <view class="list clearfix" v-for="(item, index) in supplierList" :key="index">
  28. <view class="list-top">
  29. <view class="list-top-supplier" @click="goSupplier(item.shopId)">
  30. <view class="logo"><img :src="item.logo" alt=""></view>
  31. <view class="main">
  32. <view class="name">{{ item.name }}</view>
  33. <view class="massgs">
  34. <view class="label">满意度:</view>
  35. <view class="p-stars">
  36. <uni-stars :stars="6" :iconClass="iconClass" :iconColor="iconColor" :fontSize="36" :widthInfo="176"></uni-stars>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="right"><text class="iconfont icon-xiayibu"></text></view>
  41. </view>
  42. <view class="list-top-msg">
  43. <view class="msg-pin clearfix">
  44. <view class="label">经营品项:</view>
  45. <view class="label-li" v-if="item.business">
  46. <text class="text" v-for="(label, idx) in SetNewBusiness(item.business)" :key="idx">{{ label }}</text>
  47. </view>
  48. <view class="label-li" v-else>
  49. <text class="none">暂无</text>
  50. </view>
  51. </view>
  52. <view class="msg-pin clearfix">
  53. <view class="label">所在地区:</view>
  54. <view class="label-text">{{ item.address ? item.address : '暂无'}}</view>
  55. </view>
  56. </view>
  57. </view>
  58. <view class="list-bottom">
  59. <view class="pros-item" v-for="(pros, pdx) in item.products" :key="pdx" @click.stop="navToDetailPage(pros.productId)">
  60. <image class="pros-item-image" :src="pros.image" mode="scaleToFill"></image>
  61. <view class="pros-name">{{ pros.name }}</view>
  62. </view>
  63. </view>
  64. </view>
  65. <!--加载loadding-->
  66. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  67. <tui-nomore :visible="!pullUpOn" :backgroundColor="'#ffffff'" :text='nomoreText'></tui-nomore>
  68. <!--加载loadding-->
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import tuiLoadmore from '@/components/tui-components/loadmore/loadmore'
  75. import tuiNomore from '@/components/tui-components/nomore/nomore'
  76. import uniStars from '@/components/uni-stars/uni-stars.vue'
  77. import authorize from '@/common/config/authorize.js'
  78. import wxLogin from '@/common/config/wxLogin.js'
  79. import { mapState } from 'vuex'
  80. export default {
  81. components:{
  82. tuiLoadmore,
  83. tuiNomore,
  84. uniStars
  85. },
  86. data() {
  87. return {
  88. iconClass:'icon-aixin',
  89. iconColor:'#ff9100',
  90. serviceProviderId:'',
  91. isShowClose:false,
  92. isEmpty:false,
  93. isFocus:true,
  94. productNoneImage:'https://static.caimei365.com/app/img/icon/icon-pnone.png',
  95. nomoreText: '上拉显示更多',
  96. loadding: false,
  97. pullUpOn: true,
  98. pullFlag: true,
  99. supplierList:[],
  100. isIphoneX:this.$store.state.isIphoneX,
  101. listQuery:{
  102. keyword: '',
  103. pageSize: 10,
  104. pageNum: 1,
  105. identity: 0
  106. },
  107. total:0
  108. }
  109. },
  110. onLoad(option){
  111. this.initGetStotage(option)
  112. },
  113. computed: {
  114. ...mapState(['identity'])
  115. },
  116. methods: {
  117. initGetStotage(option) {
  118. this.listQuery.identity = this.identity
  119. if(option.type =='share'){
  120. wxLogin.wxLoginAuthorize()
  121. }
  122. if(option.keyWord){
  123. console.log(option.keyWord)
  124. this.listQuery.keyword = option.keyWord
  125. this.GetSearchSupplierList()
  126. }
  127. },
  128. searchsupplierList(){//搜索
  129. this.listQuery.pageNum=1
  130. this.GetSearchSupplierList()
  131. // 友盟埋点供应商搜索点击
  132. if(process.env.NODE_ENV != 'development'){
  133. this.$uma.trackEvent('Um_Event_SearchSupplierButton', {
  134. Um_Key_Keyword: `${this.listQuery.keyword}`,
  135. Um_Key_PageName: '供应商',
  136. Um_Key_SourcePage: '搜索供应商',
  137. })
  138. }
  139. },
  140. GetSearchSupplierList(){//查询供应商列表
  141. this.ShopService.GetSearchSupplierList(this.listQuery).then(response =>{
  142. let data = JSON.parse(response.data)
  143. let dataList = data.items
  144. console.log(data)
  145. this.total = data.total
  146. if(dataList && dataList.length > 0){
  147. this.isEmpty = false
  148. this.supplierList = dataList
  149. this.pullFlag = false
  150. setTimeout(()=>{this.pullFlag = true},500)
  151. if(this.total>this.supplierList.length){
  152. this.pullUpOn = false
  153. this.nomoreText = '上拉显示更多'
  154. }else{
  155. this.pullUpOn = true
  156. this.loadding = false
  157. this.nomoreText = '已至底部'
  158. }
  159. }else{
  160. this.isEmpty = true
  161. }
  162. }).catch(error =>{
  163. this.$util.msg(error.msg,2000)
  164. })
  165. },
  166. GetSearchSupplierListBottomData(){//上滑加载
  167. this.listQuery.pageNum+=1
  168. this.ShopService.GetSearchSupplierList(this.listQuery).then(response =>{
  169. let data = JSON.parse(response.data)
  170. console.log(data)
  171. this.total = data.total
  172. this.supplierList = this.supplierList.concat(data.items)
  173. if(this.total>this.supplierList.length){
  174. this.pullUpOn = false
  175. this.nomoreText = '上拉显示更多'
  176. }else{
  177. this.pullUpOn = true
  178. this.loadding = false
  179. this.nomoreText = '已至底部'
  180. }
  181. }).catch(error =>{
  182. this.$util.msg(error.msg,2000)
  183. })
  184. },
  185. onShowClose () {//输入框失去焦点时触发
  186. if(this.listQuery.keyword != ''){
  187. this.isShowClose = true
  188. }else{
  189. this.isShowClose = false
  190. this.listQuery.pageNum=1
  191. this.GetSearchSupplierList()
  192. }
  193. },
  194. delInputText(){//清除输入框内容
  195. this.listQuery.keyword = ''
  196. this.isShowClose = false
  197. this.listQuery.pageNum=1
  198. this.GetSearchSupplierList()
  199. },
  200. navToDetailPage(id) {//跳转商品详情页
  201. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  202. },
  203. SetNewBusiness(value){//回显处理主营内容
  204. let Array = []
  205. value.split('/').forEach((item,index) =>{
  206. Array.push(item)
  207. })
  208. return Array
  209. },
  210. goSupplier(value){//跳供应商资料页
  211. this.$api.navigateTo('/pages/supplier/user/my-shop?shopId='+value)
  212. },
  213. },
  214. onReachBottom() {
  215. if(this.total>this.supplierList.length){
  216. this.loadding = true
  217. this.pullUpOn = true
  218. this.GetSearchSupplierListBottomData()
  219. }
  220. },
  221. onShareAppMessage(res){//分享转发
  222. if (res.from === 'button') {
  223. // 来自页面内转发按钮
  224. }
  225. return {
  226. title: '采美正品供应商,质量有保证!',
  227. path: `pages/search/search-supplier?type=share&keyWord=${this.listQuery.keyword}`
  228. }
  229. },
  230. onShow() {
  231. }
  232. }
  233. </script>
  234. <style lang='scss'>
  235. page {
  236. height: auto;
  237. }
  238. page,.container{
  239. /* padding-bottom: 120upx; */
  240. background: #F7F7F7;
  241. }
  242. .container{
  243. position: relative;
  244. }
  245. .supplier {
  246. width: 100%;
  247. height: auto;
  248. box-sizing: border-box;
  249. }
  250. .supplier-search{
  251. height: 84rpx;
  252. width: 100%;
  253. padding:10rpx 24rpx;
  254. background: #FFFFFF;
  255. display: flex;
  256. align-items: center;
  257. position: fixed;
  258. top: 0;
  259. left: 0;
  260. z-index: 999;
  261. box-sizing: border-box;
  262. .search-from{
  263. width: 582rpx;
  264. height: 64rpx;
  265. background: #F7F7F7;
  266. border-radius: 32rpx;
  267. float: left;
  268. position: relative;
  269. .input{
  270. width: 500rpx;
  271. height: 64rpx;
  272. float: left;
  273. line-height: 64rpx;
  274. color: $text-color;
  275. font-size: $font-size-24;
  276. }
  277. .icon-sousuo{
  278. width: 64rpx;
  279. height: 64rpx;
  280. line-height: 64rpx;
  281. text-align: center;
  282. display: block;
  283. font-size: $font-size-38;
  284. float: left;
  285. color: #999999;
  286. }
  287. .icon-shanchu1{
  288. font-size: $font-size-32;
  289. color: #999999;
  290. position: absolute;
  291. width: 64rpx;
  292. height: 64rpx;
  293. line-height: 64rpx;
  294. text-align: center;
  295. top: 0;
  296. right: 0;
  297. z-index: 10;
  298. }
  299. }
  300. .search-btn{
  301. width: 120rpx;
  302. line-height: 64rpx;
  303. text-align: center;
  304. font-size: $font-size-28;
  305. color: #666666;
  306. float: left;
  307. background: #FFFFFF;
  308. }
  309. }
  310. .supplier-main{
  311. margin-top: 94rpx;
  312. }
  313. .list{
  314. box-sizing: border-box;
  315. padding: 0 24rpx;
  316. background-color:#FFFFFF ;
  317. margin-bottom: 20rpx;
  318. }
  319. .list-top{
  320. width: 100%;
  321. height: auto;
  322. }
  323. .list-top-msg{
  324. width: 100%;
  325. height: auto;
  326. box-sizing: border-box;
  327. padding-left: 115rpx;
  328. .msg-pin{
  329. width: 100%;
  330. height: auto;
  331. margin-bottom: 16rpx;
  332. .label{
  333. float: left;
  334. line-height: 37rpx;
  335. font-size: $font-size-26;
  336. color: #999999;
  337. }
  338. .label-li{
  339. width: 476rpx;
  340. float: left;
  341. line-height: 37rpx;
  342. .text{
  343. display: inline-block;
  344. padding: 0 8rpx;
  345. height: 33rpx;
  346. border-radius: 6rpx;
  347. background-color: #86b2fb;
  348. color: #FFFFFF;
  349. line-height: 33rpx;
  350. float: left;
  351. font-size: $font-size-20;
  352. text-align: center;
  353. margin: 10rpx;
  354. margin-top: 5rpx;
  355. }
  356. .none{
  357. font-size: $font-size-20;
  358. color: #999999;
  359. }
  360. }
  361. .label-text{
  362. line-height: 37rpx;
  363. font-size: $font-size-26;
  364. color: #999999;
  365. margin-left: 10rpx;
  366. float: left;
  367. }
  368. }
  369. }
  370. .list-top-supplier{
  371. width: 100%;
  372. height: 140rpx;
  373. padding: 30rpx 0 10rpx 0;
  374. box-sizing: border-box;
  375. background-color: #FFFFFF;
  376. position: relative;
  377. box-sizing: border-box;
  378. .logo{
  379. width: 90rpx;
  380. height: 72rpx;
  381. float: left;
  382. border: 1px solid #efefef;
  383. border-radius: 6rpx;
  384. image{
  385. width: 100%;
  386. height: 100%;
  387. display: block;
  388. border-radius: 6rpx;
  389. }
  390. }
  391. .main{
  392. width: 470rpx;
  393. height: 92rpx;
  394. float: left;
  395. margin-left: 20rpx;
  396. .name{
  397. width: 100%;
  398. line-height: 46rpx;
  399. float: left;
  400. font-size: $font-size-28;
  401. color: $text-color;
  402. float: right;
  403. overflow: hidden;
  404. text-overflow:ellipsis;
  405. white-space: nowrap;
  406. text-align: left;
  407. }
  408. .massgs{
  409. width: 100%;
  410. line-height: 46rpx;
  411. float: left;
  412. font-size: $font-size-24;
  413. color: #999999;
  414. .label{
  415. float: left;
  416. }
  417. .p-stars{
  418. float: left;
  419. margin-left: 20rpx;
  420. }
  421. }
  422. }
  423. .icon-xiayibu{
  424. line-height: 154rpx;
  425. display: inline-block;
  426. position: absolute;
  427. width: 48rpx;
  428. top: 0;
  429. right: 0;
  430. color: #b2b2b2;
  431. }
  432. }
  433. .list-bottom{
  434. width: 100%;
  435. height: auto;
  436. float: left;
  437. padding: 20rpx 0;
  438. .pros-item{
  439. width: 220rpx;
  440. height: auto;
  441. float: left;
  442. margin-right: 20rpx;
  443. &:last-child{
  444. margin-right: 0;
  445. }
  446. .pros-item-image{
  447. width: 218rpx;
  448. height: 218rpx;
  449. display: block;
  450. float: left;
  451. border: 1px solid #EBEBEB;
  452. border-radius: 6rpx;
  453. }
  454. .pros-name{
  455. width: 100%;
  456. height: 54rpx;
  457. line-height: 54rpx;
  458. box-sizing: border-box;
  459. padding: 0 10rpx;
  460. font-size: $font-size-24;
  461. color: #666666;
  462. white-space: normal;
  463. word-break: break-all;
  464. overflow: hidden;
  465. text-overflow: ellipsis;
  466. display: -webkit-box;
  467. -webkit-box-orient: vertical;
  468. -webkit-line-clamp: 1;
  469. }
  470. }
  471. }
  472. </style>