index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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="()=>{exhibitorsParams.page=1; 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="()=>{exhibitorsParams.page=1; 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="()=>{exhibitorsParams.page=1; 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 :page="exhibitorsParams.page" :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. </page-layout>
  70. </template>
  71. <script>
  72. import NavBar from '@/components/layout/nav-bar'
  73. import USelect from '@/components/common/u-select/index.vue'
  74. import UScrollView from '@/components/common/u-scroll-view'
  75. import USearch from '@/components/common/u-search'
  76. import UPagination from '@/components/common/u-pagination/index.vue'
  77. import UDropdownSelect from '@/components/common/u-dropdown-select'
  78. import ExhibitorItem from '@/pages/exhibitor/components/exhibitor-item.vue'
  79. import floatButton from "@/components/layout/float-button"
  80. import {
  81. exhibitorsList,
  82. productCategoryList,
  83. exhibitorsHallList,
  84. applicationAreasList,
  85. globalPollShow
  86. } from '@/api/exhibitor'
  87. import {
  88. getAdInfo
  89. } from '@/api'
  90. import DisclaimerText from '@/components/disclaimer-text/index.vue'
  91. import PageLayout from "@/components/layout/page-layout";
  92. import vanCollapse from '@/wxcomponents/vant/collapse/index'
  93. import vanCollapseItem from '@/wxcomponents/vant/collapse-item/index'
  94. import dropdownItem from '@/wxcomponents/vant/dropdown-item/index'
  95. import dropdownMenu from '@/wxcomponents/vant/dropdown-menu/index'
  96. import {getToken} from "@/utils/auth";
  97. export default {
  98. options: {
  99. styleIsolation: 'shared'
  100. },
  101. onShow(val) {
  102. console.log('onBackPress',val)
  103. },
  104. components: {
  105. PageLayout,
  106. NavBar,
  107. USearch,
  108. UScrollView,
  109. UDropdownSelect,
  110. ExhibitorItem,
  111. DisclaimerText,
  112. UPagination,
  113. USelect,
  114. floatButton,
  115. vanCollapse,
  116. vanCollapseItem,
  117. dropdownItem,
  118. dropdownMenu
  119. },
  120. data() {
  121. return {
  122. activeName1: false,
  123. activeName2: false,
  124. activeName3: false,
  125. searchCategoryId: '',
  126. searchHall: '',
  127. searchApplicationAreas: '',
  128. searchKeyword: '',
  129. exhibitorsParams: {
  130. page: 1,
  131. page_size: 20,
  132. keyword: '',
  133. country: '',
  134. hall_id: '',
  135. product_cate_id: '',
  136. application_areas_id: ''
  137. },
  138. exhibitorList: [],
  139. exhibitorListLoading: false,
  140. exhibitorListLastPage: 1,
  141. categories: [],
  142. halls: [],
  143. applicationAreass: [],
  144. pollShow: {
  145. exhibitors_poll_show: 0,
  146. product_poll_show: 0
  147. },
  148. total: 0,
  149. baseUrl: this.$store.getters.baseApi,
  150. adInfo: {
  151. ad_file: ''
  152. },
  153. }
  154. },
  155. created() {
  156. this.getProductCategoryList()
  157. this.getExhibitorsHallList()
  158. this.getApplicationAreasList()
  159. this.getGlobalPollShow()
  160. this.getAdData()
  161. this.getExhibitorsList()
  162. uni.$on('refreshData', (val) => {
  163. if (val === 'exhibitor') {
  164. this.getProductCategoryList()
  165. this.getExhibitorsHallList()
  166. this.getApplicationAreasList()
  167. this.getGlobalPollShow()
  168. this.getAdData()
  169. this.getExhibitorsList()
  170. }
  171. })
  172. },
  173. methods: {
  174. onShare(e) {
  175. this.$emit('share',e)
  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='+this.exhibitorsParams.page+'&page_size='+this.exhibitorsParams.page_size+'&keyword=&country=&' + hall_ids + '&' +
  264. product_cate_ids + '&' + application_areas_ids
  265. uni.request({
  266. url: url,
  267. method: 'GET',
  268. header: {
  269. 'token': getToken()
  270. },
  271. success: (res) => {
  272. // 处理返回的数据
  273. this.exhibitorList = res.data.data
  274. this.total = res.data.total
  275. this.exhibitorListLastPage = res.data.last_page
  276. this.hideLoading()
  277. },
  278. fail: (err) => {
  279. console.error('请求失败', err);
  280. }
  281. });
  282. },
  283. getExhibitorsList() {
  284. this.showLoading()
  285. exhibitorsList(this.exhibitorsParams).then(res => {
  286. if (res.data.data) {
  287. this.exhibitorList = res.data.data
  288. this.total = res.data.total
  289. this.exhibitorListLastPage = res.data.last_page
  290. } else {
  291. this.showToast('系统繁忙,稍候再试')
  292. }
  293. this.exhibitorListLoading = false
  294. this.hideLoading()
  295. })
  296. },
  297. // onScrollToLower(e) {
  298. // if (this.exhibitorListLastPage === this.exhibitorsParams.page) {
  299. // return
  300. // }
  301. // if (this.exhibitorListLoading === true) {
  302. // return
  303. // }
  304. // this.exhibitorListLoading = true
  305. // this.exhibitorsParams.page = this.exhibitorsParams.page + 1
  306. // this.getExhibitorsList()
  307. // },
  308. onSelectDropdown(index) {
  309. ['select1', 'select2', 'select3'].forEach(v => {
  310. if (v !== 'select' + index) {
  311. this.$refs[v].hideDropdown()
  312. }
  313. })
  314. },
  315. onSearch() {
  316. this.navigateTo('/pages/index/search?query=' + this.searchKeyword)
  317. },
  318. getGlobalPollShow() {
  319. globalPollShow().then(res => {
  320. this.pollShow = res.data
  321. })
  322. },
  323. updateItemValue(e) {
  324. this.exhibitorList.forEach((item) => {
  325. if (item.id === e.id) {
  326. item[e.key] = e.value
  327. }
  328. })
  329. },
  330. handlePageChange(page) {
  331. this.exhibitorsParams.page = page
  332. this.searchExhibitorsList()
  333. },
  334. navigateToAdLink(href) {
  335. this.navigateTo(href)
  336. },
  337. getAdData() {
  338. getAdInfo({
  339. number: "ExhibitorListTop001"
  340. }).then(res => {
  341. this.adInfo = res.data[0]
  342. })
  343. }
  344. }
  345. }
  346. </script>
  347. <style lang="scss">
  348. </style>