index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. this.halls = halls
  105. })
  106. },
  107. getProductCategoryList() {
  108. productCategoryList().then(res => {
  109. let cate = []
  110. res.data.forEach(item => {
  111. let child = []
  112. item.children.forEach(itemC => {
  113. child.push({
  114. label: itemC.name,
  115. value: itemC.id
  116. })
  117. })
  118. cate.push({
  119. label: item.name,
  120. value: item.id,
  121. children: child
  122. })
  123. })
  124. this.categories = cate
  125. })
  126. },
  127. searchExhibitorsList() {
  128. this.exhibitorsParams.application_areas_id = this.searchApplicationAreas || ''
  129. this.exhibitorsParams.product_cate_id = this.searchCategoryId || ''
  130. this.exhibitorsParams.hall = this.searchHall || ''
  131. this.exhibitorsParams.page = 1
  132. this.getExhibitorsList()
  133. },
  134. getExhibitorsList() {
  135. if (this.exhibitorListLoading === true) {
  136. return
  137. }
  138. this.exhibitorListLoading = true
  139. exhibitorsList(this.exhibitorsParams).then(res => {
  140. if (res.data.data) {
  141. if (this.exhibitorsParams.page > 1) {
  142. this.exhibitorList = [...this.exhibitorList, ...res.data.data]
  143. } else {
  144. this.exhibitorList = res.data.data
  145. this.exhibitorListLastPage = res.data.last_page
  146. }
  147. } else {
  148. this.showToast('系统繁忙,稍候再试')
  149. }
  150. this.exhibitorListLoading = false
  151. })
  152. },
  153. onScrollToLower(e) {
  154. if (this.exhibitorListLastPage === this.exhibitorsParams.page) {
  155. return
  156. }
  157. this.exhibitorsParams.page = this.exhibitorsParams.page+1
  158. this.getExhibitorsList()
  159. },
  160. onSelectDropdown(index) {
  161. ['select1', 'select2', 'select3'].forEach(v => {
  162. if (v !== 'select' + index) {
  163. this.$refs[v].hideDropdown()
  164. }
  165. })
  166. },
  167. onSearch() {
  168. this.navigateTo('/pages/index/search?query=' + this.searchKeyword)
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="scss">
  174. </style>