search.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <page-layout class="search-index">
  3. <nav-bar title="搜索" @init="onInitNavbar"></nav-bar>
  4. <u-scroll-view :tabbar-conflict="false" @scroll-near-lower="onScrollToLower">
  5. <view class="main-container">
  6. <u-search v-model="searchKeyword" placeholder="搜索展商 / 展品名称 / 会议" @search="onClickSearch"/>
  7. <view class="search-result-text">搜索结果</view>
  8. <template v-if="isEmpty">
  9. <van-empty description="暂无数据" />
  10. </template>
  11. <template v-else>
  12. <u-tabs :active.sync="tabActive" :tabs="tabs" tab-style="default" @change="tabChange"/>
  13. <view v-if="tabActive === 1" class="search-result-list exhibit-list">
  14. <template v-for="(item, index) in exhibitorList">
  15. <exhibitor-item :item="item" :key="index" :pollShow="pollShow.exhibitors_poll_show" @share="onShare()" @updateItemValue="updateItemValue()"/>
  16. </template>
  17. </view>
  18. <view v-else-if="tabActive === 2" class="search-result-list exhibit-list">
  19. <template v-for="(item, index) in exhibitList">
  20. <exhibit-item :item="item" :key="index" :pollShow="pollShow.product_poll_show" @share="onShare()" @updateItemValue="updateItemValue()"/>
  21. </template>
  22. </view>
  23. <view v-else-if="tabActive === 3" class="search-result-list exhibit-list">
  24. <template v-for="(item, index) in newsList">
  25. <news-item :item="item" :key="index" type="exhibitor" />
  26. </template>
  27. </view>
  28. <view v-else-if="tabActive === 4" class="search-result-list exhibit-list">
  29. <template v-for="(item, index) in activityList">
  30. <activity-item type="exhibitor" :item="item" :key="index" @updateItemValue="updateItemValue()"/>
  31. </template>
  32. </view>
  33. <view v-else-if="tabActive === 5" class="search-result-list exhibit-list">
  34. <template v-for="(item, index) in mettingList">
  35. <activity-item :item="item" :key="index" platform="metting" @updateItemValue="updateItemValue()"/>
  36. </template>
  37. </view>
  38. </template>
  39. <disclaimer-text></disclaimer-text>
  40. </view>
  41. </u-scroll-view>
  42. <u-share-action-sheet :show.sync="showShare" :show-info="shareInfo" />
  43. </page-layout>
  44. </template>
  45. <script>
  46. import NavBar from '@/components/layout/nav-bar'
  47. import UTabs from '@/components/common/u-tabs'
  48. import UScrollView from '@/components/common/u-scroll-view'
  49. import UShareActionSheet from '@/components/common/u-share-action-sheet'
  50. import USearch from '@/components/common/u-search'
  51. import ExhibitItem from '@/pages/exhibitor/components/exhibit-item.vue'
  52. import ExhibitorItem from '@/pages/exhibitor/components/exhibitor-item.vue'
  53. import NewsItem from '@/pages/news/components/news-item.vue'
  54. import ActivityItem from '@/pages/activity/components/activity-item.vue'
  55. import { globalSearch, mettingList, exhibitorsList, exhibitorsProductList, exhibitorsNewsList, exhibitorsBoothActivityList, globalPollShow } from '@/api/exhibitor'
  56. import DisclaimerText from '@/components/disclaimer-text/index.vue'
  57. import PageLayout from "@/components/layout/page-layout";
  58. export default {
  59. options: {
  60. styleIsolation: 'shared'
  61. },
  62. components: {
  63. PageLayout,
  64. NavBar,
  65. UScrollView,
  66. UTabs,
  67. USearch,
  68. ExhibitItem,
  69. ExhibitorItem,
  70. NewsItem,
  71. ActivityItem,
  72. DisclaimerText,
  73. UShareActionSheet
  74. },
  75. data() {
  76. return {
  77. searchKeyword: '',
  78. tabActive: 1,
  79. isEmpty: false,
  80. defaultTabs: [{
  81. label: '展商',
  82. value: 1
  83. }, {
  84. label: '展品',
  85. value: 2
  86. }, {
  87. label: '展商新闻',
  88. value: 3
  89. }, {
  90. label: '展商活动',
  91. value: 4
  92. }, {
  93. label: '同期活动',
  94. value: 5
  95. }],
  96. tabs: [],
  97. exhibitorList: [],
  98. exhibitorListLoading: false,
  99. exhibitorListLastPage: 1,
  100. exhibitorListParams: {
  101. page: 1,
  102. page_size: 10,
  103. keyword: ''
  104. },
  105. exhibitList: [],
  106. exhibitListLoading: false,
  107. exhibitListLastPage: 1,
  108. exhibitListParams: {
  109. page: 1,
  110. page_size: 10,
  111. keyword: ''
  112. },
  113. newsList: [],
  114. newsListLoading: false,
  115. newsListLastPage: 1,
  116. newsListParams: {
  117. page: 1,
  118. page_size: 10,
  119. keyword: ''
  120. },
  121. activityList: [],
  122. activityListLoading: false,
  123. activityListLastPage: 1,
  124. activityListParams: {
  125. page: 1,
  126. page_size: 10,
  127. keyword: ''
  128. },
  129. mettingList: [],
  130. mettingListLoading: false,
  131. mettingListLastPage: 1,
  132. mettingListParams: {
  133. page: 1,
  134. page_size: 10,
  135. keyword: ''
  136. },
  137. listParams: {
  138. page: 1,
  139. page_size: 10,
  140. keyword: ''
  141. },
  142. pollShow: {
  143. exhibitors_poll_show: 0,
  144. product_poll_show: 0
  145. },
  146. showShare: false,
  147. shareInfo: null,
  148. }
  149. },
  150. onLoad(options) {
  151. console.log('options')
  152. console.log(options.query)
  153. this.searchKeyword = options.query
  154. this.onClickSearch()
  155. },
  156. created() {
  157. this.getGlobalPollShow()
  158. },
  159. methods: {
  160. tabChange() {
  161. },
  162. onClickSearch() {
  163. this.listParams.page = 1
  164. this.listParams.keyword = this.searchKeyword
  165. this.exhibitorListParams = {...this.listParams}
  166. this.exhibitListParams = {...this.listParams}
  167. this.newsListParams = {...this.listParams}
  168. this.activityListParams = {...this.listParams}
  169. this.mettingListParams = {...this.listParams}
  170. this.tabs = [...this.defaultTabs]
  171. this.getGlobalSearch()
  172. this.getMettingList()
  173. },
  174. getGlobalSearch() { // 全局搜索
  175. globalSearch(this.listParams).then(res => {
  176. if (res.code === 0) {
  177. this.exhibitorList = res.data.exhibitors_list.data ?? []
  178. this.exhibitorListLastPage = res.data.exhibitors_list.last_page ?? 1
  179. this.exhibitList = res.data.product_list.data ?? []
  180. this.exhibitListLastPage = res.data.product_list.last_page ?? 0
  181. this.newsList = res.data.news_list.data ?? []
  182. this.newsListLastPage = res.data.news_list.last_page ?? 0
  183. this.activityList = res.data.booth_activity_list.data ?? []
  184. this.activityListLastPage = res.data.booth_activity_list.last_page ?? 0
  185. if (this.exhibitorList.length === 0) {
  186. this.tabs = this.tabs.filter(item => item.value !== 1);
  187. }
  188. if (this.exhibitList.length === 0) {
  189. this.tabs = this.tabs.filter(item => item.value !== 2);
  190. }
  191. if (this.newsList.length === 0) {
  192. this.tabs = this.tabs.filter(item => item.value !== 3);
  193. }
  194. if (this.activityList.length === 0) {
  195. this.tabs = this.tabs.filter(item => item.value !== 4);
  196. }
  197. }
  198. })
  199. },
  200. getExhibitorsList() { // 展商
  201. this.exhibitorListLoading = true
  202. exhibitorsList(this.exhibitorListParams).then(res => {
  203. if (res.data.data) {
  204. if (this.exhibitorListParams.page > 1) {
  205. this.exhibitorList = [...this.exhibitorList, ...res.data.data]
  206. } else {
  207. this.exhibitorList = res.data.data
  208. this.exhibitorListLastPage = res.data.last_page
  209. }
  210. } else {
  211. this.showToast('系统繁忙,稍候再试')
  212. }
  213. this.exhibitorListLoading = false
  214. })
  215. },
  216. getExhibitList() { // 展品
  217. this.exhibitListLoading = true
  218. exhibitorsProductList(this.exhibitListParams).then(res => {
  219. if (res.data.data) {
  220. if (this.exhibitListParams.page > 1) {
  221. this.exhibitList = [...this.exhibitList, ...res.data.data]
  222. } else {
  223. this.exhibitList = res.data.data
  224. this.exhibitListLastPage = res.data.last_page
  225. }
  226. } else {
  227. this.showToast('系统繁忙,稍候再试')
  228. }
  229. this.exhibitListLoading = false
  230. })
  231. },
  232. getExhibitorsNewsList() { // 展商新闻
  233. this.newsListLoading = true
  234. exhibitorsNewsList(this.newsListParams).then(res => {
  235. if (res.data.data) {
  236. if (this.newsListParams.page > 1) {
  237. this.newsList = [...this.newsList, ...res.data.data]
  238. } else {
  239. this.newsList = res.data.data
  240. this.newsListLastPage = res.data.last_page
  241. }
  242. } else {
  243. this.showToast('系统繁忙,稍候再试')
  244. }
  245. this.newsListLoading = false
  246. })
  247. },
  248. getActivityList() { // 展台活动
  249. this.activityListLoading = true
  250. exhibitorsBoothActivityList(this.activityListParams).then(res => {
  251. if (res.data.data) {
  252. if (this.activityListParams.page > 1) {
  253. this.activityList = [...this.activityList, ...res.data.data]
  254. } else {
  255. this.activityList = res.data.data
  256. this.activityListLastPage = res.data.last_page
  257. }
  258. } else {
  259. this.showToast('系统繁忙,稍候再试')
  260. }
  261. this.activityListLoading = false
  262. })
  263. },
  264. getMettingList() { // 同期活动
  265. this.mettingListLoading = true
  266. mettingList(this.mettingListParams).then(res => {
  267. if (res.data.data) {
  268. if (this.mettingListParams.page > 1) {
  269. this.mettingList = [...this.mettingList, ...res.data.data]
  270. } else {
  271. this.mettingList = res.data.data
  272. this.mettingListLastPage = res.data.last_page
  273. }
  274. if (this.mettingListParams.page === 1 && this.mettingList.length === 0) {
  275. this.tabs = this.tabs.filter(item => item.value !== 5);
  276. }
  277. } else {
  278. this.showToast('系统繁忙,稍候再试')
  279. }
  280. this.mettingListLoading = false
  281. })
  282. },
  283. onScrollToLower(e) {
  284. if (this.tabActive === 1) {
  285. if (this.exhibitorListLastPage === this.exhibitorListParams.page) return
  286. if (this.exhibitorListLoading === true) return
  287. this.exhibitorListLoading = true
  288. this.exhibitorListParams.page = this.exhibitorListParams.page+1
  289. this.getExhibitorsList()
  290. } else if (this.tabActive === 2) {
  291. if (this.exhibitListLastPage === this.exhibitListParams.page) return
  292. if (this.exhibitListLoading === true) return
  293. this.exhibitListLoading = true
  294. this.exhibitListParams.page = this.exhibitListParams.page+1
  295. this.getExhibitList()
  296. } else if (this.tabActive === 3) {
  297. if (this.newsListLastPage === this.newsListParams.page) return
  298. if (this.newsListLoading === true) return
  299. this.newsListLoading = true
  300. this.newsListParams.page = this.newsListParams.page+1
  301. this.getExhibitorsNewsList()
  302. } else if (this.tabActive === 4) {
  303. if (this.activityListLastPage === this.activityListParams.page) return
  304. if (this.activityListLoading === true) return
  305. this.activityListLoading = true
  306. this.activityListParams.page = this.activityListParams.page+1
  307. this.getActivityList()
  308. } else if (this.tabActive === 5) {
  309. if (this.mettingListLastPage === this.mettingListParams.page) return
  310. if (this.mettingListLoading === true) return
  311. this.mettingListLoading = true
  312. this.mettingListParams.page = this.mettingListParams.page+1
  313. this.getMettingList()
  314. }
  315. },
  316. updateItemValue(e) {
  317. if (this.tabActive === 1) {
  318. this.exhibitorList.forEach((item) => {
  319. if (item.id === e.id) {
  320. item[e.key] = e.value
  321. }
  322. })
  323. } else if (this.tabActive === 2) {
  324. this.exhibitList.forEach((item) => {
  325. if (item.id === e.id) {
  326. item[e.key] = e.value
  327. }
  328. })
  329. } else if (this.tabActive === 4) {
  330. this.activityList.forEach((item) => {
  331. if (item.id === e.id) {
  332. item[e.key] = e.value
  333. }
  334. })
  335. } else if (this.tabActive === 5) {
  336. this.mettingList.forEach((item) => {
  337. if (item.id === e.id) {
  338. item[e.key] = e.value
  339. }
  340. })
  341. }
  342. },
  343. getGlobalPollShow() {
  344. globalPollShow().then(res => {
  345. this.pollShow = res.data
  346. })
  347. },
  348. onShare(e) {
  349. this.shareInfo = e.detail
  350. this.showShare = true
  351. },
  352. onShareAppMessage: function (res) {
  353. if (res.from === 'button') {
  354. if (this.shareInfo) {
  355. return this.shareInfo
  356. }
  357. }
  358. this.shareInfo = null
  359. this.showShare = false
  360. return {
  361. title: '慕尼黑上海电子生产设备展',
  362. path: '/pages/index/index',
  363. imageUrl: 'https://oss.starify.cn/prod/starify/up/0001018678/20241108/672da5a7dd374.png?x-oss-process=image/resize,w_600,h_600,limit_0,m_pad'
  364. }
  365. }
  366. }
  367. }
  368. </script>
  369. <style lang="scss">
  370. .search-result-text{
  371. margin: 33rpx 0;
  372. display: block;
  373. font-size: $fontSize3;
  374. color: #000000;
  375. }
  376. .search-result-list{
  377. display: grid;
  378. grid-template-columns: 1fr;
  379. grid-row-gap: 28rpx;
  380. margin-top: 32rpx;
  381. }
  382. </style>