search-supplier.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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)">
  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 wxLogin from '@/common/config/wxLogin.js'
  75. import { mapState } from 'vuex'
  76. import tuiLoadmore from '@/components/tui-components/loadmore/loadmore'
  77. import tuiNomore from '@/components/tui-components/nomore/nomore'
  78. import uniStars from '@/components/uni-stars/uni-stars.vue'
  79. import authorize from '@/common/config/authorize.js'
  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. uni.setStorageSync('pageLabel',this.listQuery.keyword)
  142. this.ShopService.GetSearchSupplierList(this.listQuery).then(response =>{
  143. let data = JSON.parse(response.data)
  144. let dataList = data.items
  145. console.log(data)
  146. this.total = data.total
  147. if(dataList && dataList.length > 0){
  148. this.isEmpty = false
  149. this.supplierList = dataList
  150. this.pullFlag = false
  151. setTimeout(()=>{this.pullFlag = true},500)
  152. if(this.total>this.supplierList.length){
  153. this.pullUpOn = false
  154. this.nomoreText = '上拉显示更多'
  155. }else{
  156. this.pullUpOn = true
  157. this.loadding = false
  158. this.nomoreText = '已至底部'
  159. }
  160. }else{
  161. this.isEmpty = true
  162. }
  163. }).catch(error =>{
  164. this.$util.msg(error.msg,2000)
  165. })
  166. },
  167. GetSearchSupplierListBottomData(){//上滑加载
  168. this.listQuery.pageNum+=1
  169. this.ShopService.GetSearchSupplierList(this.listQuery).then(response =>{
  170. let data = JSON.parse(response.data)
  171. console.log(data)
  172. this.total = data.total
  173. this.supplierList = this.supplierList.concat(data.items)
  174. if(this.total>this.supplierList.length){
  175. this.pullUpOn = false
  176. this.nomoreText = '上拉显示更多'
  177. }else{
  178. this.pullUpOn = true
  179. this.loadding = false
  180. this.nomoreText = '已至底部'
  181. }
  182. }).catch(error =>{
  183. this.$util.msg(error.msg,2000)
  184. })
  185. },
  186. onShowClose () {//输入框失去焦点时触发
  187. if(this.listQuery.keyword != ''){
  188. this.isShowClose = true
  189. }else{
  190. this.isShowClose = false
  191. this.listQuery.pageNum=1
  192. this.GetSearchSupplierList()
  193. }
  194. },
  195. delInputText(){//清除输入框内容
  196. this.listQuery.keyword = ''
  197. this.isShowClose = false
  198. this.listQuery.pageNum=1
  199. this.GetSearchSupplierList()
  200. },
  201. navToDetailPage(id) {//跳转商品详情页
  202. this.$api.navigateTo(`/pages/goods/product?id=${id}`)
  203. },
  204. SetNewBusiness(value){//回显处理主营内容
  205. let Array = []
  206. value.split('/').forEach((item,index) =>{
  207. Array.push(item)
  208. })
  209. return Array
  210. },
  211. goSupplier(shop){//跳供应商资料页
  212. if(shop.shopType === 2){
  213. return
  214. }
  215. this.$api.navigateTo('/pages/supplier/user/my-shop?shopId='+shop.shopId)
  216. },
  217. },
  218. onReachBottom() {
  219. if(this.total>this.supplierList.length){
  220. this.loadding = true
  221. this.pullUpOn = true
  222. this.GetSearchSupplierListBottomData()
  223. }
  224. },
  225. onShareAppMessage(res){//分享转发
  226. if (res.from === 'button') {
  227. // 来自页面内转发按钮
  228. }
  229. return {
  230. title: '采美正品供应商,质量有保证!',
  231. path: `pages/search/search-supplier?type=share&keyWord=${this.listQuery.keyword}`
  232. }
  233. },
  234. onShow() {
  235. }
  236. }
  237. </script>
  238. <style lang='scss'>
  239. page {
  240. height: auto;
  241. }
  242. page,.container{
  243. /* padding-bottom: 120upx; */
  244. background: #F7F7F7;
  245. }
  246. .container{
  247. position: relative;
  248. }
  249. .supplier {
  250. width: 100%;
  251. height: auto;
  252. box-sizing: border-box;
  253. }
  254. .supplier-search{
  255. height: 84rpx;
  256. width: 100%;
  257. padding:10rpx 24rpx;
  258. background: #FFFFFF;
  259. display: flex;
  260. align-items: center;
  261. position: fixed;
  262. top: 0;
  263. left: 0;
  264. z-index: 999;
  265. box-sizing: border-box;
  266. .search-from{
  267. width: 582rpx;
  268. height: 64rpx;
  269. background: #F7F7F7;
  270. border-radius: 32rpx;
  271. float: left;
  272. position: relative;
  273. .input{
  274. width: 500rpx;
  275. height: 64rpx;
  276. float: left;
  277. line-height: 64rpx;
  278. color: $text-color;
  279. font-size: $font-size-24;
  280. }
  281. .icon-sousuo{
  282. width: 64rpx;
  283. height: 64rpx;
  284. line-height: 64rpx;
  285. text-align: center;
  286. display: block;
  287. font-size: $font-size-38;
  288. float: left;
  289. color: #999999;
  290. }
  291. .icon-shanchu1{
  292. font-size: $font-size-32;
  293. color: #999999;
  294. position: absolute;
  295. width: 64rpx;
  296. height: 64rpx;
  297. line-height: 64rpx;
  298. text-align: center;
  299. top: 0;
  300. right: 0;
  301. z-index: 10;
  302. }
  303. }
  304. .search-btn{
  305. width: 120rpx;
  306. line-height: 64rpx;
  307. text-align: center;
  308. font-size: $font-size-28;
  309. color: #666666;
  310. float: left;
  311. background: #FFFFFF;
  312. }
  313. }
  314. .supplier-main{
  315. margin-top: 94rpx;
  316. }
  317. .list{
  318. box-sizing: border-box;
  319. padding: 0 24rpx;
  320. background-color:#FFFFFF ;
  321. margin-bottom: 20rpx;
  322. }
  323. .list-top{
  324. width: 100%;
  325. height: auto;
  326. }
  327. .list-top-msg{
  328. width: 100%;
  329. height: auto;
  330. box-sizing: border-box;
  331. padding-left: 115rpx;
  332. .msg-pin{
  333. width: 100%;
  334. height: auto;
  335. margin-bottom: 16rpx;
  336. .label{
  337. float: left;
  338. line-height: 37rpx;
  339. font-size: $font-size-26;
  340. color: #999999;
  341. }
  342. .label-li{
  343. width: 476rpx;
  344. float: left;
  345. line-height: 37rpx;
  346. .text{
  347. display: inline-block;
  348. padding: 0 8rpx;
  349. height: 33rpx;
  350. border-radius: 6rpx;
  351. background-color: #86b2fb;
  352. color: #FFFFFF;
  353. line-height: 33rpx;
  354. float: left;
  355. font-size: $font-size-20;
  356. text-align: center;
  357. margin: 10rpx;
  358. margin-top: 5rpx;
  359. }
  360. .none{
  361. font-size: $font-size-20;
  362. color: #999999;
  363. }
  364. }
  365. .label-text{
  366. line-height: 37rpx;
  367. font-size: $font-size-26;
  368. color: #999999;
  369. margin-left: 10rpx;
  370. float: left;
  371. }
  372. }
  373. }
  374. .list-top-supplier{
  375. width: 100%;
  376. height: 140rpx;
  377. padding: 30rpx 0 10rpx 0;
  378. box-sizing: border-box;
  379. background-color: #FFFFFF;
  380. position: relative;
  381. box-sizing: border-box;
  382. .logo{
  383. width: 90rpx;
  384. height: 72rpx;
  385. float: left;
  386. border: 1px solid #efefef;
  387. border-radius: 6rpx;
  388. image{
  389. width: 100%;
  390. height: 100%;
  391. display: block;
  392. border-radius: 6rpx;
  393. }
  394. }
  395. .main{
  396. width: 470rpx;
  397. height: 92rpx;
  398. float: left;
  399. margin-left: 20rpx;
  400. .name{
  401. width: 100%;
  402. line-height: 46rpx;
  403. float: left;
  404. font-size: $font-size-28;
  405. color: $text-color;
  406. float: right;
  407. overflow: hidden;
  408. text-overflow:ellipsis;
  409. white-space: nowrap;
  410. text-align: left;
  411. }
  412. .massgs{
  413. width: 100%;
  414. line-height: 46rpx;
  415. float: left;
  416. font-size: $font-size-24;
  417. color: #999999;
  418. .label{
  419. float: left;
  420. }
  421. .p-stars{
  422. float: left;
  423. margin-left: 20rpx;
  424. }
  425. }
  426. }
  427. .icon-xiayibu{
  428. line-height: 154rpx;
  429. display: inline-block;
  430. position: absolute;
  431. width: 48rpx;
  432. top: 0;
  433. right: 0;
  434. color: #b2b2b2;
  435. }
  436. }
  437. .list-bottom{
  438. width: 100%;
  439. height: auto;
  440. float: left;
  441. padding: 20rpx 0;
  442. .pros-item{
  443. width: 220rpx;
  444. height: auto;
  445. float: left;
  446. margin-right: 20rpx;
  447. &:last-child{
  448. margin-right: 0;
  449. }
  450. .pros-item-image{
  451. width: 218rpx;
  452. height: 218rpx;
  453. display: block;
  454. float: left;
  455. border: 1px solid #EBEBEB;
  456. border-radius: 6rpx;
  457. }
  458. .pros-name{
  459. width: 100%;
  460. height: 54rpx;
  461. line-height: 54rpx;
  462. box-sizing: border-box;
  463. padding: 0 10rpx;
  464. font-size: $font-size-24;
  465. color: #666666;
  466. white-space: normal;
  467. word-break: break-all;
  468. overflow: hidden;
  469. text-overflow: ellipsis;
  470. display: -webkit-box;
  471. -webkit-box-orient: vertical;
  472. -webkit-line-clamp: 1;
  473. }
  474. }
  475. }
  476. </style>