club-list.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <view class="container club clearfix">
  3. <view class="club-search clearfix">
  4. <view class="search-from name">
  5. <text class="iconfont icon-sousuo"></text>
  6. <input
  7. class="input"
  8. type="text"
  9. confirm-type="search"
  10. v-model="searchInputVal"
  11. @input="onShowClose"
  12. @confirm="getClubList()"
  13. placeholder="请输入机构名称/机构联系人"
  14. maxlength="12"
  15. @focus="searchInputFoucs"
  16. @blur="hideSearchModalHandle"
  17. />
  18. <text
  19. class="iconfont icon-guanbi"
  20. v-if="isShowClose"
  21. @click="delInputText()"
  22. ></text>
  23. </view>
  24. <view class="search-btn">
  25. <button class="search-btn" type="default" @click.stop="searchClubList">搜索</button>
  26. </view>
  27. </view>
  28. <view class="club-main">
  29. <view v-if="isEmpty" class="empty-container">
  30. <image
  31. class="club-empty-image"
  32. src="/static/ws/empty_club.png"
  33. mode="aspectFit"
  34. lazy-load
  35. ></image>
  36. <view class="txt">机构列表空空如也~</view>
  37. </view>
  38. <!-- :style="{ height: scrollHeight }" -->
  39. <view v-else class="club-list">
  40. <scroll-view
  41. class="club-scroll"
  42. scroll-y="true"
  43. @scrolltolower="getOnReachBottomData"
  44. :style="{height: scrollHeight}"
  45. >
  46. <!-- 机构数据 -->
  47. <view class="list" v-for="item in clubList" :key="item.userId">
  48. <view class="list-left">
  49. <view class="list-head"
  50. ><image
  51. src="https://static.caimei365.com/app/img/icon/icon-club@3x.png"
  52. mode=""
  53. ></image
  54. ></view>
  55. </view>
  56. <view class="list-item">
  57. <view class="list-title">
  58. <text class="list-name">{{ item.clubName }}</text>
  59. </view>
  60. <view class="list-contact">
  61. <view class="list-row">
  62. <text class="iconfont icon-lianxiren"></text>
  63. <text>{{ item.userName }}</text>
  64. </view>
  65. <view class="list-row">
  66. <text class="iconfont icon-dianhua"></text>
  67. <text>{{ item.bindMobile }}</text>
  68. </view>
  69. </view>
  70. <view class="list-opea">
  71. <view class="btn border-btn" @click.stop="goOrderList(item)">
  72. <text>订单列表</text>
  73. </view>
  74. <view class="btn border-btn" @click.stop="goGoodsList(item)">
  75. <text>立即下单</text>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <!--加载loadding-->
  81. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  82. <tui-nomore
  83. :visible="!pullUpOn"
  84. :backgroundColor="'#ffffff'"
  85. :text="nomoreText"
  86. ></tui-nomore>
  87. <!--加载loadding-->
  88. </scroll-view>
  89. </view>
  90. </view>
  91. <view class="over-bg" @click="hideSearchModalHandle" v-if="showSearchModal"></view>
  92. </view>
  93. </template>
  94. <script>
  95. import authorize from '@/common/config/authorize.js'
  96. import tuiLoadmore from '@/components/tui-components/loadmore/loadmore'
  97. import tuiNomore from '@/components/tui-components/nomore/nomore'
  98. export default {
  99. components: {
  100. tuiLoadmore,
  101. tuiNomore
  102. },
  103. data() {
  104. return {
  105. isShowClose: false, //是否显示搜索框关闭按钮
  106. searchInputVal: '', //搜索框数据
  107. isEmpty: true, //机构列表是否为空
  108. nomoreText: '上拉显示更多',
  109. pageNum: 1, //当前页码
  110. pageSize: 10, //每页获取条数
  111. hasNextPage: false, //是否还有下一页
  112. loadding: false,
  113. pullUpOn: true,
  114. pullFlag: true,
  115. scrollHeight: '', //scoll-view高度
  116. clubList: [],
  117. showSearchModal: false, //模糊搜索框是否显示
  118. organizeId: ''
  119. }
  120. },
  121. onLoad(data) {
  122. this.setScrollHeight()
  123. // 获取传过来的organizeId
  124. this.organizeId = data.id
  125. // 初始化列表
  126. this.init()
  127. console.log(this.clubList)
  128. },
  129. methods: {
  130. // 初始化机构列表
  131. async init() {
  132. this.pageNum = 1
  133. this.clubList = await this.getClubList()
  134. if (this.clubList.length > 0) {
  135. this.isEmpty = false
  136. }
  137. },
  138. // 设置scroll高度
  139. setScrollHeight() {
  140. console.log(this.$store.state.isIphoneX);
  141. // 如果是苹果手机
  142. if(this.$store.state.isIphoneX){
  143. this.scrollHeight = this.$store.state.windowHeight - 100 - 44 + 'px'
  144. }else{
  145. this.scrollHeight = this.$store.state.windowHeight - 100 + 'px'
  146. }
  147. console.log(this.scrollHeight)
  148. },
  149. async searchClubList() {
  150. // 如果搜索框为空
  151. if (this.searchInputVal.trim().length <= 0) {
  152. this.searchInputVal = ''
  153. return
  154. }
  155. this.searchKeyWords()
  156. },
  157. async searchKeyWords() {
  158. console.log(this.searchInputVal);
  159. this.pageNum = 1
  160. this.clubList = await this.getClubList()
  161. if (this.clubList.length <= 0) {
  162. this.isEmpty = true
  163. }else{
  164. this.isEmpty = false
  165. }
  166. },
  167. // 初始化机构列表
  168. async getClubList() {
  169. let params = {
  170. organizeId: this.organizeId,
  171. name: this.searchInputVal,
  172. pageNum: this.pageNum,
  173. pageSize: this.pageSize
  174. }
  175. const { data: res } = await this.SellerService.GetSellerClubList(params).catch(
  176. error => {
  177. this.$util.msg(error.msg, 1500)
  178. setTimeout(() => {
  179. uni.navigateBack({
  180. delta: 1
  181. })
  182. }, 1500)
  183. }
  184. )
  185. this.pageNum = res.pageNum
  186. this.hasNextPage = res.hasNextPage
  187. return res.list
  188. },
  189. // 加载下一页数据
  190. async getOnReachBottomData() {
  191. if (!this.hasNextPage && this.pullFlag) {
  192. this.loadding = false
  193. this.pullUpOn = false
  194. this.nomoreText = '已至底部'
  195. return
  196. }
  197. this.nomoreText = '上拉显示更多'
  198. this.loadding = true
  199. this.pullUpOn = true
  200. this.pageNum += 1
  201. const list = await this.getClubList()
  202. this.clubList = [...this.clubList, ...list]
  203. setTimeout(() => {
  204. this.pullFlag = true
  205. }, 2000)
  206. },
  207. //输入框失去焦点时触发
  208. onShowClose() {
  209. if (this.searchInputVal != '') {
  210. this.isShowClose = true
  211. } else {
  212. this.isShowClose = false
  213. }
  214. },
  215. async delInputText() {
  216. //清除输入框内容
  217. this.searchInputVal = ''
  218. this.isShowClose = false
  219. this.searchKeyWords()
  220. },
  221. // 跳转下单产品列表
  222. goGoodsList(item) {
  223. uni.setStorageSync('clubInfo', item)
  224. this.$api.navigateTo(`/pages/goods/list`)
  225. },
  226. // 跳转订单列表
  227. goOrderList(item) {
  228. console.log(item)
  229. this.$api.setStorage('clubInfo', item)
  230. this.$api.navigateTo('pages/user/order/order-list')
  231. this.$api.navigateTo(`/pages/user/order/order-historylist`)
  232. },
  233. async hideSearchModalHandle() {
  234. this.showSearchModal = false
  235. this.searchKeyWords()
  236. },
  237. searchInputFoucs() {
  238. this.showSearchModal = true
  239. }
  240. }
  241. }
  242. </script>
  243. <style lang="scss">
  244. page {
  245. height: auto;
  246. }
  247. page,
  248. .container {
  249. /* padding-bottom: 120upx; */
  250. background: #fff;
  251. width: 100%;
  252. height: 100vh;
  253. overflow: hidden;
  254. }
  255. .container {
  256. position: relative;
  257. }
  258. .over-bg {
  259. top: 0;
  260. position: fixed;
  261. width: 100vw;
  262. height: 100vh;
  263. z-index: 888;
  264. background: rgba(0, 0, 0, 0.4);
  265. }
  266. .club-search {
  267. display: flex;
  268. justify-content: space-between;
  269. align-items: center;
  270. height: 74rpx;
  271. width: 702rpx;
  272. padding: 20rpx 24rpx;
  273. background: #ffffff;
  274. position: fixed;
  275. top: 0;
  276. left: 0;
  277. z-index: 999;
  278. .search-from {
  279. display: flex;
  280. justify-content: space-between;
  281. align-items: center;
  282. flex: 1;
  283. height: 64rpx;
  284. background: #f7f7f7;
  285. border-radius: 32rpx;
  286. position: relative;
  287. .icon-sousuo {
  288. width: 64rpx;
  289. height: 64rpx;
  290. line-height: 64rpx;
  291. text-align: center;
  292. display: block;
  293. font-size: $font-size-28;
  294. color: #999999;
  295. }
  296. .icon-guanbi {
  297. font-size: $font-size-28;
  298. color: #999999;
  299. position: absolute;
  300. width: 64rpx;
  301. height: 64rpx;
  302. line-height: 64rpx;
  303. text-align: center;
  304. top: 0;
  305. right: 0;
  306. z-index: 10;
  307. }
  308. .input {
  309. width: 570rpx;
  310. height: 64rpx;
  311. line-height: 64rpx;
  312. color: $text-color;
  313. font-size: $font-size-24;
  314. }
  315. }
  316. .search-btn {
  317. width: 100rpx;
  318. line-height: 64rpx;
  319. text-align: center;
  320. font-size: $font-size-28;
  321. color: $color-system;
  322. background: #ffffff;
  323. }
  324. }
  325. .empty-container{
  326. background: #f7f7f7;
  327. justify-content: flex-start;
  328. .club-empty-image{
  329. margin-top: 400rpx;
  330. margin-bottom: 36rpx;
  331. }
  332. }
  333. .club-main {
  334. position: relative;
  335. padding-top: 57px;
  336. .club-scroll {
  337. // height: 100vh;
  338. // box-sizing: border-box;
  339. // padding-top: 122rpx;
  340. }
  341. .list {
  342. align-items: flex-start;
  343. width: 702rpx;
  344. height: auto;
  345. margin: 0 auto;
  346. padding: 24rpx 0;
  347. background: #ffffff;
  348. position: relative;
  349. border-bottom: 1px solid #ebebeb;
  350. display: flex;
  351. .list-left {
  352. height: 140rpx;
  353. flex: 2;
  354. margin-right: 24rpx;
  355. .list-head {
  356. width: 180rpx;
  357. height: 180rpx;
  358. image {
  359. width: 180rpx;
  360. height: 180rpx;
  361. border-radius: 8rpx;
  362. }
  363. }
  364. }
  365. .list-item {
  366. flex: 8;
  367. display: flex;
  368. flex-direction: column;
  369. align-items: flex-start;
  370. .list-title {
  371. flex: 2;
  372. width: 100%;
  373. color: $text-color;
  374. flex-direction: row;
  375. justify-content: flex-start;
  376. .list-name {
  377. font-size: $font-size-30;
  378. width: 100%;
  379. display: block;
  380. float: left;
  381. text-align: left;
  382. -o-text-overflow: ellipsis;
  383. text-overflow: ellipsis;
  384. display: -webkit-box;
  385. word-break: break-all;
  386. -webkit-box-orient: vertical;
  387. -webkit-line-clamp: 1;
  388. overflow: hidden;
  389. }
  390. }
  391. .list-contact {
  392. padding: 20rpx 0;
  393. .list-row {
  394. margin: 10rpx 0;
  395. display: flex;
  396. justify-content: flex-start;
  397. align-items: center;
  398. color: #666;
  399. text {
  400. font-size: $font-size-26;
  401. }
  402. .iconfont {
  403. font-size: $font-size-26;
  404. margin-right: 10rpx;
  405. }
  406. }
  407. }
  408. .list-opea {
  409. width: 100%;
  410. display: flex;
  411. justify-content: flex-end;
  412. flex: 4;
  413. color: #166ce1;
  414. flex-direction: row;
  415. align-items: center;
  416. .btn {
  417. width: 160rpx;
  418. height: 56rpx;
  419. line-height: 54rpx;
  420. border-radius: 30rpx;
  421. font-size: $font-size-24;
  422. color: $text-color;
  423. text-align: center;
  424. margin: 0 17rpx;
  425. border: 1px solid #333333;
  426. box-sizing: border-box;
  427. &.border-btn {
  428. color: #333;
  429. }
  430. &:last-child{
  431. background: rgb(25,25,25);
  432. color: #fff;
  433. }
  434. }
  435. }
  436. }
  437. }
  438. }
  439. </style>