exhibit.vue 10 KB

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