home.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <view class="container">
  3. <!-- <page-top-bar /> -->
  4. <view class="top-bar">
  5. <view class="row">
  6. <view class="column column1" @click="navTo(1,'/pages/theater/index/index')">
  7. <image src="@/static/images/backhome.png" style="width: 24px; height: 24px;"></image>
  8. </view>
  9. <view class="column column2"><input @input="KeyName" class="input-box" type="text" placeholder="搜索内容"
  10. style="width: 100%;" /></view>
  11. <view class="column column3">
  12. <image src="@/static/images/fangdajing.png" style="width: 21px; height: 21px;" @click="seachText">
  13. </image>
  14. </view>
  15. <view class="column column4"></view>
  16. </view>
  17. </view>
  18. <view class="banner">
  19. <swiper style="height: 240px;" indicator-dots="true" autoplay="true" interval="2000" duration="500">
  20. <swiper-item v-for="hot in eventshot" @click="onView(hot.id)">
  21. <image :src=hot.imgList[0] class="slide-image"></image>
  22. </swiper-item>
  23. </swiper>
  24. </view>
  25. <view class="section1">
  26. <view class="serow">
  27. <view class="column">
  28. <view class="cell" :class="active == 6?'active':''" @click="selActive('',6)">
  29. <view class="cl">
  30. <image :src="'/static/images/chart_alt6.png'" style="width: 24px; height: 24px;">
  31. </image>
  32. </view>
  33. <view class="cl">全部</view>
  34. </view>
  35. </view>
  36. <view class="column" v-for="(tag,index) in eventstag">
  37. <view class="cell" :class="active == index?'active':''" @click="selActive(tag,index)">
  38. <view class="cl">
  39. <image :src="'/static/images/chart_alt'+index+'.png'" style="width: 24px; height: 24px;">
  40. </image>
  41. </view>
  42. <view class="cl">{{tag.name}}</view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="full-row">
  47. <view class="rows" @click="showCity">
  48. <view class="column" style="min-width: 40px;">
  49. {{activeCity}}
  50. </view>
  51. <view class="column2">
  52. <image src="/static/images/arr.png" style="width: 10px; height: 10px;"></image>
  53. </view>
  54. </view>
  55. <view class="rows" @click="showType">
  56. <view class="column">类型</view>
  57. <view class="column2">
  58. <image src="/static/images/arr.png" style="width: 10px; height: 10px;"></image>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="selected" v-if="cityShow">
  63. <view class="textInfo" @click="selCity('全国')">
  64. 全国
  65. </view>
  66. <view class="textInfo" v-for="(item,index) in cityLists" :key='index' @click="selCity(item)">
  67. {{item.name}}
  68. </view>
  69. </view>
  70. <view class="selected" style="left: 16%;width: 80px;" v-if="typeShow">
  71. <view class="textInfo" :class="active == 6?'active':''" @click="selActive('',6)">
  72. 全部
  73. </view>
  74. <view class="textInfo" :class="active == index?'active':''" v-for="(item,index) in eventList"
  75. :key='index' @click="selActive(item,index)">
  76. {{item.name}}
  77. </view>
  78. </view>
  79. </view>
  80. <view class="section3" style="padding-bottom: 110px;">
  81. <view class="item" @click="onView(event.id)" v-for="event in events" :key="event.id">
  82. <view class="item_img">
  83. <img :src="event.imgList[0]"></img>
  84. </view>
  85. <view class="item_info">
  86. <view class="title"> {{ event.title }}</view>
  87. <view class="time_yuyue">
  88. <view class="ico">
  89. <image src="/static/images/time.png" style="width: 12px; height: 12px;"></image>
  90. </view>
  91. <!-- - {{ event.closeTime }} -->
  92. <view class="time">{{ event.openTime }} </view>
  93. <view class="adres_yuyue">
  94. <view class="ico">
  95. <image src="/static/images/daohang.png" style="width: 12px; height: 12px;"></image>
  96. </view>
  97. <view class="didian">{{ event.address }}</view>
  98. </view>
  99. <view class="yuyue_btn" @click="onView(event.id)" >
  100. <button type="default" style="background-color: white; font-size: 14px; height: 30px; line-height: 30px; color: #666; font-weight: bold;border: 1px solid #666; border-radius: 8px; padding: 0px 4px;">立即预约</button>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. <page-btm-bar :active="1" />
  107. </view>
  108. </template>
  109. <script>
  110. import {
  111. mapState,
  112. mapGetters,
  113. mapMutations
  114. } from 'vuex'
  115. const app = getApp();
  116. const data = require('@/static/city.json')
  117. export default {
  118. computed: {
  119. ...mapState(['store_id', 'systemInfo'])
  120. },
  121. data() {
  122. return {
  123. events: [], // 用于存储事件数据
  124. eventshot: [],
  125. eventstag: [],
  126. active: 6,
  127. tagId: '',
  128. keyword: '',
  129. cityShow: false,
  130. cityLists: [],
  131. cities: data,
  132. activeCity: '全国',
  133. city: '',
  134. typeShow: false,
  135. eventList: [],
  136. total: null, //总共多少条数据
  137. formData: {
  138. pageSize: 10, //每页10条数据
  139. page: 1, //第几页
  140. }
  141. };
  142. },
  143. mounted() {
  144. this.fetchEventsData();
  145. this.fetchEventsHotData();
  146. this.fetchEventsTag();
  147. },
  148. onReachBottom() {
  149. let allTotal = this.formData.page * this.formData.pageSize
  150. if (allTotal < this.total) {
  151. //当前条数小于总条数 则增加请求页数
  152. this.formData.page++;
  153. this.fetchEventsData() //调用加载数据方法
  154. } else {
  155. // console.log('已加载全部数据')
  156. }
  157. },
  158. onPullDownRefresh() {
  159. this.events = []
  160. //调用获取数据方法
  161. this.getData()
  162. setTimeout(() => {
  163. //结束下拉刷新
  164. uni.stopPullDownRefresh();
  165. }, 1000);
  166. },
  167. methods: {
  168. showType() {
  169. let _this = this
  170. this.cityShow=false
  171. _this.$http.request('events/searchTags', {
  172. page: 1,
  173. pageSize: 50,
  174. }).then(response => {
  175. console.log(response); // 先打印整个响应对象查看结构
  176. this.eventList = response.data;
  177. this.typeShow = !this.typeShow
  178. }).catch(error => {
  179. console.error('数据获取失败:', error);
  180. });
  181. },
  182. selCity(item) {
  183. if(item=='全国'){
  184. this.activeCity=item
  185. this.city = ""
  186. this.cityShow = false
  187. this.fetchEventsData()
  188. }else{
  189. console.log(item);
  190. this.activeCity = item.name
  191. this.city = item.city
  192. this.cityShow = false
  193. this.fetchEventsData()
  194. }
  195. },
  196. showCity() {
  197. this.typeShow=false
  198. this.cityShow = !this.cityShow
  199. },
  200. navTo(index, url) {
  201. if (index != this.active) {
  202. uni.switchTab({
  203. url: url
  204. })
  205. }
  206. },
  207. //搜索内容
  208. seachText() {
  209. this.$http.request('events/searchEvents', {
  210. page: 1,
  211. pageSize: 10,
  212. keyword: this.keyword
  213. }).then(response => {
  214. this.events = response.data;
  215. }).catch(error => {
  216. console.error('数据获取失败:', error);
  217. });
  218. },
  219. KeyName(t) {
  220. this.keyword = t.detail.value;
  221. },
  222. //切换筛选条件
  223. selActive(item, index) {
  224. if(item==''){
  225. this.city=''
  226. }
  227. this.tagId = item.id
  228. this.active = index
  229. this.fetchEventsData()
  230. this.typeShow = false
  231. },
  232. fetchEventsData() {
  233. let _this = this;
  234. _this.formData.tagId = _this.tagId;
  235. _this.formData.city = _this.city;
  236. _this.$http.request('events/searchEvents', _this.formData).then(response => {
  237. if (_this.cityLists.length === 0) {
  238. response.data.forEach(item => {
  239. _this.cities.forEach(el => {
  240. if (item.province === el.code) {
  241. let obj = {
  242. name: el.name,
  243. city: item.city
  244. };
  245. // 检查是否已经存在相同的城市对象
  246. if (!_this.cityLists.some(city => city.city === obj.city)) {
  247. _this.cityLists.push(obj);
  248. }
  249. }
  250. });
  251. });
  252. }
  253. console.log(_this.cityLists); // 先打印整个响应对象查看结构
  254. _this.total = response.data.length;
  255. _this.events = response.data;
  256. }).catch(error => {
  257. console.error('数据获取失败:', error);
  258. });
  259. },
  260. fetchEventsHotData() {
  261. let _this = this;
  262. _this.$http.request('events/searchEvents', {
  263. page: 1,
  264. pageSize: 5,
  265. hot: 1,
  266. }).then(response => {
  267. console.log(response); // 先打印整个响应对象查看结构
  268. this.eventshot = response.data;
  269. console.log(response.data)
  270. }).catch(error => {
  271. console.error('数据获取失败:', error);
  272. });
  273. },
  274. fetchEventsTag() {
  275. let _this = this;
  276. _this.$http.request('events/searchTags', {
  277. page: 1,
  278. pageSize: 4,
  279. }).then(response => {
  280. console.log(response); // 先打印整个响应对象查看结构
  281. this.eventstag = response.data;
  282. console.log(response.data)
  283. }).catch(error => {
  284. console.error('数据获取失败:', error);
  285. });
  286. },
  287. onView(e) {
  288. console.log('传递的ID:', e);
  289. uni.navigateTo({
  290. url: '/pages/home/detail/detail?id=' + e,
  291. })
  292. },
  293. },
  294. }
  295. </script>
  296. <style lang="scss">
  297. @import "./index.scss"
  298. </style>