search.vue 13 KB

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