index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view class="exhibitor-index">
  3. <nav-bar title="展商信息" @init="onInitNavbar"></nav-bar>
  4. <u-scroll-view :tabbar-conflict="true" @scroll-near-lower="onScrollToLower">
  5. <view class="main-container">
  6. <view class="exhibitor-filter">
  7. <view>
  8. <view class="exhibitor-filter-label">展馆号</view>
  9. <u-dropdown-select ref="select1" v-model="searchHall" placeholder="选择展馆号" :options="halls" @dropdown="onSelectDropdown(1)" @change="searchExhibitorsList()"/>
  10. </view>
  11. <view>
  12. <view class="exhibitor-filter-label">产品类别</view>
  13. <u-dropdown-select ref="select2" v-model="searchCategoryId" placeholder="选择产品类别" :options="categories" @dropdown="onSelectDropdown(2)" @change="searchExhibitorsList()"/>
  14. </view>
  15. <view>
  16. <view class="exhibitor-filter-label">应用领域</view>
  17. <u-dropdown-select ref="select3" v-model="searchApplicationAreas" placeholder="选择应用领域" :options="applicationAreass" @dropdown="onSelectDropdown(3)" @change="searchExhibitorsList()"/>
  18. </view>
  19. </view>
  20. <u-search v-model="searchKeyword" placeholder="搜索展商 / 展品名称 / 会议" @search="onSearch" />
  21. <view class="ad-space">
  22. <image src="https://oss.starify.cn/prod/starify/up/0001018678/20241108/672da70a6c76a.png?x-oss-process=image/resize,w_200" mode="aspectFill"/>
  23. </view>
  24. <van-empty v-if="exhibitorList.length === 0" description="暂无数据" />
  25. <view v-else class="exhibitor-list">
  26. <template v-for="(item, index) in exhibitorList">
  27. <exhibitor-item :item="item" :key="index" @share="(e) => $emit('share', e)" />
  28. </template>
  29. </view>
  30. </view>
  31. </u-scroll-view>
  32. </view>
  33. </template>
  34. <script>
  35. import NavBar from '@/components/layout/nav-bar'
  36. import UScrollView from '@/components/common/u-scroll-view'
  37. import USearch from '@/components/common/u-search'
  38. import UDropdownSelect from '@/components/common/u-dropdown-select'
  39. import ExhibitorItem from '@/pages/exhibitor/components/exhibitor-item.vue'
  40. import { exhibitorsList, productCategoryList, exhibitorsHallList, applicationAreasList } from '@/api/exhibitor'
  41. export default {
  42. options: {
  43. styleIsolation: 'shared'
  44. },
  45. components: {
  46. NavBar,
  47. USearch,
  48. UScrollView,
  49. UDropdownSelect,
  50. ExhibitorItem
  51. },
  52. data() {
  53. return {
  54. searchCategoryId: '',
  55. searchHall: '',
  56. searchApplicationAreas: '',
  57. searchKeyword: '',
  58. exhibitorsParams: {
  59. page: 1,
  60. page_size: 10,
  61. keyword: '',
  62. country: '',
  63. hall: '',
  64. product_cate_id: '',
  65. application_areas_id: ''
  66. },
  67. exhibitorList: [],
  68. exhibitorListLoading: false,
  69. exhibitorListLastPage: 1,
  70. categories: [],
  71. halls: [],
  72. applicationAreass: []
  73. }
  74. },
  75. created() {
  76. this.loadFontFace('Poppins')
  77. this.getProductCategoryList()
  78. this.getExhibitorsHallList()
  79. this.getApplicationAreasList()
  80. this.getExhibitorsList()
  81. },
  82. methods: {
  83. getApplicationAreasList() {
  84. applicationAreasList().then(res => {
  85. let areas = []
  86. res.data.forEach(item => {
  87. areas.push({
  88. label: item.name,
  89. value: item.id,
  90. })
  91. })
  92. this.applicationAreass = areas
  93. })
  94. },
  95. getExhibitorsHallList() {
  96. exhibitorsHallList().then(res => {
  97. let halls = []
  98. res.data.forEach(item => {
  99. halls.push({
  100. label: item.name,
  101. value: item.id,
  102. })
  103. })
  104. console.log(halls)
  105. this.halls = halls
  106. })
  107. },
  108. getProductCategoryList() {
  109. productCategoryList().then(res => {
  110. let cate = []
  111. res.data.forEach(item => {
  112. let child = []
  113. item.children.forEach(itemC => {
  114. child.push({
  115. label: itemC.name,
  116. value: itemC.id
  117. })
  118. })
  119. cate.push({
  120. label: item.name,
  121. value: item.id,
  122. children: child
  123. })
  124. })
  125. this.categories = cate
  126. })
  127. },
  128. searchExhibitorsList() {
  129. console.log(this.searchCategoryId)
  130. this.exhibitorsParams.application_areas_id = this.searchApplicationAreas || ''
  131. this.exhibitorsParams.product_cate_id = this.searchCategoryId || ''
  132. this.exhibitorsParams.hall = this.searchHall || ''
  133. this.exhibitorsParams.page = 1
  134. this.getExhibitorsList()
  135. },
  136. getExhibitorsList() {
  137. if (this.exhibitorListLoading === true) {
  138. return
  139. }
  140. this.exhibitorListLoading = true
  141. exhibitorsList(this.exhibitorsParams).then(res => {
  142. if (res.data.data) {
  143. if (this.exhibitorsParams.page > 1) {
  144. this.exhibitorList = [...this.exhibitorList, ...res.data.data]
  145. } else {
  146. this.exhibitorList = res.data.data
  147. this.exhibitorListLastPage = res.data.last_page
  148. }
  149. } else {
  150. this.showToast('系统繁忙,稍候再试')
  151. }
  152. this.exhibitorListLoading = false
  153. })
  154. },
  155. onScrollToLower(e) {
  156. if (this.exhibitorListLastPage === this.exhibitorsParams.page) {
  157. return
  158. }
  159. this.exhibitorsParams.page = this.exhibitorsParams.page+1
  160. this.getExhibitorsList()
  161. },
  162. onSelectDropdown(index) {
  163. ['select1', 'select2', 'select3'].forEach(v => {
  164. if (v !== 'select' + index) {
  165. this.$refs[v].hideDropdown()
  166. }
  167. })
  168. },
  169. onSearch() {
  170. this.navigateTo('/pages/index/search?query=' + this.searchKeyword)
  171. }
  172. }
  173. }
  174. </script>
  175. <style lang="scss">
  176. </style>