exhibit.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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', (val) => {
  151. if (val === 'product') {
  152. this.searchList()
  153. }
  154. })
  155. },
  156. methods: {
  157. onChange(event) {
  158. this.activeName = event
  159. },
  160. handlePageChange(page) {
  161. this.exhibitParams.page = page
  162. this.searchList()
  163. /*exhibitorsProductList(this.exhibitParams).then(res => {
  164. if (res.data.data) {
  165. this.exhibitList = res.data.data
  166. } else {
  167. this.showToast('系统繁忙,稍候再试')
  168. }
  169. })*/
  170. },
  171. getApplicationAreasList() {
  172. applicationAreasList().then(res => {
  173. let areas = []
  174. res.data.forEach(item => {
  175. areas.push({
  176. label: item.name,
  177. value: item.id,
  178. })
  179. })
  180. this.applicationAreass = areas
  181. })
  182. },
  183. getProductCategoryList() {
  184. productCategoryList().then(res => {
  185. let cate = []
  186. res.data.forEach(item => {
  187. let child = []
  188. item.children.forEach(itemC => {
  189. child.push({
  190. label: itemC.name,
  191. value: itemC.id
  192. })
  193. })
  194. cate.push({
  195. label: item.name,
  196. value: item.id,
  197. children: child
  198. })
  199. })
  200. this.categories = cate
  201. })
  202. },
  203. searchList() {
  204. this.showLoading()
  205. let product_cate_ids = ''
  206. let application_areas_ids = ''
  207. if (this.searchCategoryId.length === 0) {
  208. product_cate_ids = 'product_cate_id='
  209. } else {
  210. for (let i = 0; i < this.searchCategoryId.length; i++) {
  211. if (i === this.searchCategoryId.length - 1) {
  212. product_cate_ids = product_cate_ids + 'product_cate_id[]=' + this.searchCategoryId[i]
  213. } else {
  214. product_cate_ids = product_cate_ids + 'product_cate_id[]=' + this.searchCategoryId[i] + '&'
  215. }
  216. }
  217. }
  218. if (this.searchApplicationAreas.length === 0) {
  219. application_areas_ids = 'application_areas_id='
  220. } else {
  221. for (let i = 0; i < this.searchApplicationAreas.length; i++) {
  222. if (i === this.searchApplicationAreas.length - 1) {
  223. application_areas_ids = application_areas_ids + 'application_areas_id[]=' + this.searchApplicationAreas[i]
  224. } else {
  225. application_areas_ids = application_areas_ids + 'application_areas_id[]=' + this.searchApplicationAreas[
  226. i] + '&'
  227. }
  228. }
  229. }
  230. let url = this.baseUrl + '/api/exhibitors/product/list?page='+this.exhibitParams.page+'&page_size='+ this.exhibitParams.page_size+'&keyword=&' + product_cate_ids + '&' +
  231. application_areas_ids
  232. uni.request({
  233. url: url,
  234. method: 'GET',
  235. header: {
  236. 'token': getToken()
  237. },
  238. success: (res) => {
  239. // 处理返回的数据
  240. this.exhibitList = res.data.data
  241. this.total = res.data.total
  242. this.exhibitListLastPage = res.data.last_page
  243. this.hideLoading()
  244. },
  245. fail: (err) => {
  246. console.error('请求失败', err);
  247. }
  248. });
  249. },
  250. getList() {
  251. this.showLoading()
  252. exhibitorsProductList(this.exhibitParams).then(res => {
  253. if (res.data.data) {
  254. this.exhibitList = res.data.data
  255. this.total = res.data.total
  256. this.exhibitListLastPage = res.data.last_page
  257. } else {
  258. this.showToast('系统繁忙,稍候再试')
  259. }
  260. this.exhibitListLoading = false
  261. this.hideLoading()
  262. })
  263. },
  264. // onScrollToLower(e) {
  265. // if (this.exhibitListLastPage === this.exhibitParams.page) {
  266. // return
  267. // }
  268. // if (this.exhibitListLoading === true) {
  269. // return
  270. // }
  271. // this.exhibitListLoading = true
  272. // this.exhibitParams.page = this.exhibitParams.page+1
  273. // this.getList()
  274. // },
  275. onShare(e) {
  276. this.$emit('share',e)
  277. },
  278. onSelectDropdown(index) {
  279. ['select1', 'select2', 'select3'].forEach(v => {
  280. if (v !== 'select' + index) {
  281. this.$refs[v].hideDropdown()
  282. }
  283. })
  284. },
  285. onClickExhibit(item) {
  286. this.navigateTo('/pages/exhibitor/exhibit-detail')
  287. },
  288. onSearch() {
  289. this.navigateTo('/pages/index/search?query=' + this.searchKeyword)
  290. },
  291. getGlobalPollShow() {
  292. globalPollShow().then(res => {
  293. this.pollShow = res.data
  294. })
  295. },
  296. updateItemValue(e) {
  297. this.exhibitList.forEach((item) => {
  298. if (item.id === e.id) {
  299. item[e.key] = e.value
  300. }
  301. })
  302. },
  303. navigateToAdLink(href) {
  304. this.navigateTo(href)
  305. },
  306. getAdData() {
  307. getAdInfo({
  308. number: "ExhibitorProductTop001"
  309. }).then(res => {
  310. this.adInfo = res.data[0]
  311. })
  312. }
  313. }
  314. }
  315. </script>
  316. <style lang="scss">
  317. </style>