index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <page-layout class="exhibitor-index">
  3. <nav-bar title="展商信息" @init="onInitNavbar"></nav-bar>
  4. <u-scroll-view :tabbar-conflict="true">
  5. <view class="main-container">
  6. <view class="search-box">
  7. <view class="search-title item-title">
  8. 搜索
  9. </view>
  10. <u-search v-model="searchKeyword" placeholder="搜索关键词" @search="onSearch"/>
  11. </view>
  12. <view class="select-box">
  13. <view class="select-head">
  14. <view class="select-title item-title">
  15. 筛选
  16. </view>
  17. <view class="select-search-btn" @click="searchExhibitorsList()">搜索</view>
  18. </view>
  19. <view class="select-body">
  20. <view class="select-list">
  21. <view class="select-module">
  22. <view class="select-input" @click="()=>{activeName1 = !activeName1;activeName2=false;activeName3=false;}">展馆号</view>
  23. <view class="select-option-module" :class="{'active': activeName1}">
  24. <u-scroll-view :tabbar-conflict="true">
  25. <u-select title="展馆号" v-model="searchHall" :data="halls" uId="dropdown1"
  26. @change-event="searchExhibitorsList()" :special="true"></u-select>
  27. </u-scroll-view>
  28. </view>
  29. </view>
  30. <view class="select-module">
  31. <view class="select-input" @click="()=>{activeName2 = !activeName2;activeName1=false;activeName3=false;}">展品分类</view>
  32. <view class="select-option-module second-module" :class="{'active': activeName2}">
  33. <u-scroll-view :tabbar-conflict="true">
  34. <u-select title="展品分类" v-model="searchCategoryId" :data="categories" uId="dropdown2"
  35. :children="true"
  36. @change-event="searchExhibitorsList()"></u-select>
  37. </u-scroll-view>
  38. </view>
  39. </view>
  40. <view class="select-module">
  41. <view class="select-input" @click="()=>{activeName3 = !activeName3;activeName1=false;activeName2=false;}">应用领域</view>
  42. <view class="select-option-module third-module" :class="{'active': activeName3}">
  43. <u-scroll-view :tabbar-conflict="true">
  44. <u-select title="应用领域" v-model="searchApplicationAreas" :data="applicationAreass"
  45. uId="dropdown3"
  46. @change-event="searchExhibitorsList()"></u-select>
  47. </u-scroll-view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="ad-space" v-if="adInfo && adInfo.ad_file" @tap="navigateToAdLink(adInfo.ad_link)">
  54. <image :src="adInfo.ad_file" mode="widthFix"/>
  55. </view>
  56. <van-empty v-if="exhibitorList.length === 0" description="暂无数据"/>
  57. <view v-else class="exhibitor-list">
  58. <template v-for="(item, index) in exhibitorList">
  59. <exhibitor-item :item="item" :key="index" :pollShow="pollShow.exhibitors_poll_show"
  60. @share="onShare()" @updateItemValue="updateItemValue()"/>
  61. </template>
  62. </view>
  63. <u-pagination :pageSize="exhibitorsParams.page_size" :total="total" @page-change="handlePageChange()"
  64. v-if="total>0"></u-pagination>
  65. <disclaimer-text></disclaimer-text>
  66. </view>
  67. </u-scroll-view>
  68. <float-button></float-button>
  69. <u-share-action-sheet :show.sync="showShare" :show-info="shareInfo" />
  70. </page-layout>
  71. </template>
  72. <script>
  73. import NavBar from '@/components/layout/nav-bar'
  74. import USelect from '@/components/common/u-select/index.vue'
  75. import UScrollView from '@/components/common/u-scroll-view'
  76. import USearch from '@/components/common/u-search'
  77. import UPagination from '@/components/common/u-pagination/index.vue'
  78. import UDropdownSelect from '@/components/common/u-dropdown-select'
  79. import ExhibitorItem from '@/pages/exhibitor/components/exhibitor-item.vue'
  80. import floatButton from "@/components/layout/float-button"
  81. import UShareActionSheet from '@/components/common/u-share-action-sheet'
  82. import {
  83. exhibitorsList,
  84. productCategoryList,
  85. exhibitorsHallList,
  86. applicationAreasList,
  87. globalPollShow
  88. } from '@/api/exhibitor'
  89. import {
  90. getAdInfo
  91. } from '@/api'
  92. import DisclaimerText from '@/components/disclaimer-text/index.vue'
  93. import PageLayout from "@/components/layout/page-layout";
  94. import vanCollapse from '@/wxcomponents/vant/collapse/index'
  95. import vanCollapseItem from '@/wxcomponents/vant/collapse-item/index'
  96. import dropdownItem from '@/wxcomponents/vant/dropdown-item/index'
  97. import dropdownMenu from '@/wxcomponents/vant/dropdown-menu/index'
  98. export default {
  99. options: {
  100. styleIsolation: 'shared'
  101. },
  102. onShow(val) {
  103. console.log('onBackPress',val)
  104. },
  105. components: {
  106. PageLayout,
  107. NavBar,
  108. USearch,
  109. UScrollView,
  110. UDropdownSelect,
  111. ExhibitorItem,
  112. DisclaimerText,
  113. UPagination,
  114. USelect,
  115. floatButton,
  116. vanCollapse,
  117. vanCollapseItem,
  118. dropdownItem,
  119. dropdownMenu,
  120. UShareActionSheet
  121. },
  122. data() {
  123. return {
  124. activeName1: false,
  125. activeName2: false,
  126. activeName3: false,
  127. showShare: false,
  128. shareInfo: null,
  129. searchCategoryId: '',
  130. searchHall: '',
  131. searchApplicationAreas: '',
  132. searchKeyword: '',
  133. exhibitorsParams: {
  134. page: 1,
  135. page_size: 20,
  136. keyword: '',
  137. country: '',
  138. hall_id: '',
  139. product_cate_id: '',
  140. application_areas_id: ''
  141. },
  142. exhibitorList: [],
  143. exhibitorListLoading: false,
  144. exhibitorListLastPage: 1,
  145. categories: [],
  146. halls: [],
  147. applicationAreass: [],
  148. pollShow: {
  149. exhibitors_poll_show: 0,
  150. product_poll_show: 0
  151. },
  152. total: 0,
  153. baseUrl: this.$store.getters.baseApi,
  154. adInfo: {
  155. ad_file: ''
  156. }
  157. }
  158. },
  159. created() {
  160. this.getProductCategoryList()
  161. this.getExhibitorsHallList()
  162. this.getApplicationAreasList()
  163. this.getGlobalPollShow()
  164. this.getAdData()
  165. this.getExhibitorsList()
  166. uni.$on('refreshData', (val) => {
  167. if (val === 'exhibitor') {
  168. this.searchExhibitorsList()
  169. }
  170. })
  171. },
  172. methods: {
  173. onShare(e) {
  174. this.shareInfo = e.detail
  175. this.showShare = true
  176. },
  177. onChange(event) {
  178. this.activeName = event
  179. },
  180. getApplicationAreasList() {
  181. applicationAreasList().then(res => {
  182. let areas = []
  183. res.data.forEach(item => {
  184. areas.push({
  185. label: item.name,
  186. value: item.id,
  187. })
  188. })
  189. this.applicationAreass = areas
  190. })
  191. },
  192. getExhibitorsHallList() {
  193. exhibitorsHallList().then(res => {
  194. let halls = []
  195. res.data.forEach(item => {
  196. halls.push({
  197. label: item.name,
  198. value: item.id,
  199. })
  200. })
  201. this.halls = halls
  202. })
  203. },
  204. getProductCategoryList() {
  205. productCategoryList().then(res => {
  206. let cate = []
  207. res.data.forEach(item => {
  208. let child = []
  209. item.children.forEach(itemC => {
  210. child.push({
  211. label: itemC.name,
  212. value: itemC.id
  213. })
  214. })
  215. cate.push({
  216. label: item.name,
  217. value: item.id,
  218. children: child
  219. })
  220. })
  221. this.categories = cate
  222. })
  223. },
  224. searchExhibitorsList() {
  225. this.showLoading()
  226. let hall_ids = ''
  227. let product_cate_ids = ''
  228. let application_areas_ids = ''
  229. if (this.searchHall.length === 0) {
  230. hall_ids = 'hall='
  231. } else {
  232. for (let i = 0; i < this.searchHall.length; i++) {
  233. if (i === this.searchHall.length - 1) {
  234. hall_ids = hall_ids + 'hall[]=' + this.searchHall[i]
  235. } else {
  236. hall_ids = hall_ids + 'hall[]=' + this.searchHall[i] + '&'
  237. }
  238. }
  239. }
  240. if (this.searchCategoryId.length === 0) {
  241. product_cate_ids = 'product_cate_id='
  242. } else {
  243. for (let i = 0; i < this.searchCategoryId.length; i++) {
  244. if (i === this.searchCategoryId.length - 1) {
  245. product_cate_ids = product_cate_ids + 'product_cate_id[]=' + this.searchCategoryId[i]
  246. } else {
  247. product_cate_ids = product_cate_ids + 'product_cate_id[]=' + this.searchCategoryId[i] + '&'
  248. }
  249. }
  250. }
  251. if (this.searchApplicationAreas.length === 0) {
  252. application_areas_ids = 'application_areas_id='
  253. } else {
  254. for (let i = 0; i < this.searchApplicationAreas.length; i++) {
  255. if (i === this.searchApplicationAreas.length - 1) {
  256. application_areas_ids = application_areas_ids + 'application_areas_id[]=' + this.searchApplicationAreas[i]
  257. } else {
  258. application_areas_ids = application_areas_ids + 'application_areas_id[]=' + this.searchApplicationAreas[
  259. i] + '&'
  260. }
  261. }
  262. }
  263. let url = this.baseUrl + '/api/exhibitors/list?page=1&page_size=20&keyword=&country=&' + hall_ids + '&' +
  264. product_cate_ids + '&' + application_areas_ids
  265. uni.request({
  266. url: url,
  267. method: 'GET',
  268. success: (res) => {
  269. // 处理返回的数据
  270. this.exhibitorList = res.data.data
  271. this.total = res.data.total
  272. this.exhibitorListLastPage = res.data.last_page
  273. this.hideLoading()
  274. },
  275. fail: (err) => {
  276. console.error('请求失败', err);
  277. }
  278. });
  279. },
  280. getExhibitorsList() {
  281. this.showLoading()
  282. exhibitorsList(this.exhibitorsParams).then(res => {
  283. if (res.data.data) {
  284. this.exhibitorList = res.data.data
  285. this.total = res.data.total
  286. this.exhibitorListLastPage = res.data.last_page
  287. } else {
  288. this.showToast('系统繁忙,稍候再试')
  289. }
  290. this.exhibitorListLoading = false
  291. this.hideLoading()
  292. })
  293. },
  294. // onScrollToLower(e) {
  295. // if (this.exhibitorListLastPage === this.exhibitorsParams.page) {
  296. // return
  297. // }
  298. // if (this.exhibitorListLoading === true) {
  299. // return
  300. // }
  301. // this.exhibitorListLoading = true
  302. // this.exhibitorsParams.page = this.exhibitorsParams.page + 1
  303. // this.getExhibitorsList()
  304. // },
  305. onSelectDropdown(index) {
  306. ['select1', 'select2', 'select3'].forEach(v => {
  307. if (v !== 'select' + index) {
  308. this.$refs[v].hideDropdown()
  309. }
  310. })
  311. },
  312. onSearch() {
  313. this.navigateTo('/pages/index/search?query=' + this.searchKeyword)
  314. },
  315. getGlobalPollShow() {
  316. globalPollShow().then(res => {
  317. this.pollShow = res.data
  318. })
  319. },
  320. updateItemValue(e) {
  321. this.exhibitorList.forEach((item) => {
  322. if (item.id === e.id) {
  323. item[e.key] = e.value
  324. }
  325. })
  326. },
  327. handlePageChange(page) {
  328. this.exhibitorsParams.page = page
  329. exhibitorsList(this.exhibitorsParams).then(res => {
  330. if (res.data.data) {
  331. this.exhibitorList = res.data.data
  332. } else {
  333. this.showToast('系统繁忙,稍候再试')
  334. }
  335. this.exhibitorListLoading = false
  336. })
  337. },
  338. navigateToAdLink(href) {
  339. this.navigateTo(href)
  340. },
  341. getAdData() {
  342. getAdInfo({
  343. number: "ExhibitorListTop001"
  344. }).then(res => {
  345. this.adInfo = res.data[0]
  346. })
  347. }
  348. }
  349. }
  350. </script>
  351. <style lang="scss">
  352. </style>