cinema.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <view class="cinema">
  3. <topbar>
  4. <view class="topbar-box">
  5. <view class="left-box">
  6. <van-icon name="location" />
  7. <text>{{address}}</text>
  8. <van-icon name="arrow-down" />
  9. </view>
  10. <van-search class='top-search' shape="round" background="#fff" placeholder="请输入搜索关键词" @search="onSearch" @change='onSearchChange' />
  11. </view>
  12. </topbar>
  13. <!-- <van-index-bar :sticky='false' sticky-offset-top='100'>
  14. <view v-for="(item,index) in cityList" :key='index'>
  15. <van-index-anchor :index="index" />
  16. <van-cell @click='selectCity(sonitem)' :title="sonitem.regionName" v-for="(sonitem,sonindex) in item" :key='sonindex' />
  17. </view>
  18. </van-index-bar> -->
  19. <van-tabs :active='tabActive' animated sticky>
  20. <van-tab title="热映">
  21. <loadSke :loading='hotLoading' :list='hotList'>
  22. <view class="flex-box">
  23. <view @click="goPage(`/pages/cinema/cinemalist?filmId=${item.filmId}&cityId=${cityId}&location=${location}`)"
  24. class="film-box" v-for="(item,index) in hotList" :key='index'>
  25. <image :src="item.pic" mode="scaleToFill" class="img" draggable></image>
  26. <view class="bottom-box">
  27. <view class="tit">
  28. <text class="text-1">{{item.name}}</text>
  29. <text class="text-2">{{item.grade ?'评分'+item.grade : '暂无评分'}}</text>
  30. </view>
  31. <view class="des-box">
  32. <view class="des">{{item.filmTypes}}</view>
  33. <view class="des">{{item.cast}}</view>
  34. </view>
  35. <button type="default" class="buy">
  36. 购 票
  37. </button>
  38. </view>
  39. </view>
  40. </view>
  41. </loadSke>
  42. </van-tab>
  43. <van-tab title="影院">
  44. <loadSke :loading='cinemaLoading' :list='cinemaList'>
  45. <view class="cinema-box" v-for="(item,index) in cinemaList" :key='index' @click='goPage(`/pages/cinema/schedulelist?cinemaId=${item.cinemaId}&filmId=${filmId}`)'>
  46. <view class="tit">
  47. <text>{{item.cinemaName}}</text>
  48. <text class="text-2">{{item.distance}}km</text>
  49. </view>
  50. <text class="address">{{item.address}}</text>
  51. </view>
  52. </loadSke>
  53. </van-tab>
  54. <van-tab title="即将上映">
  55. <loadSke :loading='soonLoading'>
  56. <view class="soon-box" v-for="(ObjItem,ObjIndex) in soonList" :key='ObjIndex'>
  57. <view class="tit-text">
  58. <van-icon class='icon' name="https://t1-1305573081.cos.ap-shanghai.myqcloud.com/wxapp/static/imgs/%E6%97%A5%E6%9C%9F.png" />
  59. {{ObjIndex}}
  60. </view>
  61. <view class="flex-box">
  62. <view class="film-box" v-for="(item,index) in ObjItem" :key='index'>
  63. <image :src="item.pic" mode="scaleToFill" class="img" draggable></image>
  64. <view class="bottom-box">
  65. <view class="tit">
  66. <text class="text-1">{{item.name}}</text>
  67. <text class="text-2">{{item.grade ?'评分'+item.grade : '暂无评分'}}</text>
  68. </view>
  69. <view class="des-box">
  70. <view class="des">{{item.filmTypes}}</view>
  71. <view class="des">{{item.cast}}</view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </loadSke>
  78. </van-tab>
  79. </van-tabs>
  80. </view>
  81. </template>
  82. <script>
  83. import loadSke from '@/components/skeleton/index/index.vue'
  84. import {
  85. getPayData
  86. } from '@/api/pay.js'
  87. import {
  88. amapRegeo
  89. } from '@/api/amap.js'
  90. import {
  91. getHotList,
  92. getSoonList,
  93. getCityList,
  94. getInfo,
  95. getFilmDiscount,
  96. getCinemaList
  97. } from '@/api/cinema.js'
  98. export default {
  99. components: {
  100. loadSke
  101. },
  102. data: () => ({
  103. tabActive: 0,
  104. hotList: [],
  105. soonList: {},
  106. hotLoading: true,
  107. soonLoading: true,
  108. location: [119.131390, 26.150210],
  109. cityList: [],
  110. cityId: 188,
  111. address: '定位中',
  112. cinemaList:{},
  113. cinemaLoading:true
  114. }),
  115. async mounted() {
  116. this.setFilmDiscount()
  117. await this.getLocation()
  118. },
  119. watch: {
  120. cityId() {
  121. this.init()
  122. this.cinemaListInit()
  123. }
  124. },
  125. methods: {
  126. setFilmDiscount() {
  127. getFilmDiscount().then(res => {
  128. this.$store.commit('SET_FILMDISCOUNT', res.data)
  129. })
  130. },
  131. async getLocation() {
  132. let location = await wx.getLocation()
  133. this.location = [location.longitude.toFixed(6), location.latitude.toFixed(6)]
  134. let address = await amapRegeo({
  135. location: this.location
  136. })
  137. let cityListRes = await getCityList()
  138. let cityList = cityListRes.data.data.list
  139. let cityObj = {}
  140. cityList.map((val) => {
  141. cityObj[val.pinYin] || (cityObj[val.pinYin] = [])
  142. cityObj[val.pinYin].push(val)
  143. if (val.regionName == address.regeocode.addressComponent.city.slice(0, -1)) {
  144. this.selectCity(val)
  145. }
  146. })
  147. this.cityList = cityObj
  148. },
  149. async init() {
  150. this.hotLoading = true
  151. this.soonLoading = true
  152. this.tabActive = null
  153. this.$nextTick(() => {
  154. this.tabActive = 0
  155. })
  156. let hotListRes = await getHotList({
  157. cityId: this.cityId
  158. })
  159. this.hotList = hotListRes.data.data.list
  160. this.hotLoading = false
  161. let soonListRes = await getSoonList({
  162. cityId: this.cityId
  163. })
  164. let soonListObj = {}
  165. soonListRes.data.data.list.forEach((val) => {
  166. soonListObj[val.publishDate.slice(0, 10)] || (soonListObj[val.publishDate.slice(0, 10)] = [])
  167. soonListObj[val.publishDate.slice(0, 10)].push(val)
  168. })
  169. this.soonList = soonListObj
  170. this.$store.commit('SET_FILMLIST', this.hotList.concat(soonListRes.data.data.list))
  171. this.soonLoading = false
  172. },
  173. async cinemaListInit() {
  174. let showListRes = await getCinemaList({
  175. cityId: this.cityId,
  176. latitude: this.location[1],
  177. longitude: this.location[0],
  178. })
  179. showListRes.data.data.list.map(val=>{
  180. val.distance = (Math.sqrt((val.latitude-this.location[1])**2+(val.longitude-this.location[0])**2)*111).toFixed(2)
  181. return val
  182. })
  183. showListRes.data.data.list.sort(function(a, b){return a.distance - b.distance})
  184. this.cinemaList = showListRes.data.data.list
  185. this.cinemaLoading = false
  186. },
  187. selectCity(obj) {
  188. this.address = obj.regionName
  189. this.cityId = obj.cityId
  190. }
  191. }
  192. }
  193. </script>
  194. <style scoped lang="scss">
  195. .topbar-box {
  196. display: flex;
  197. align-items: center;
  198. .left-box {
  199. width: 200rpx;
  200. display: flex;
  201. justify-content: center;
  202. align-items: center;
  203. margin-left: 20rpx;
  204. }
  205. }
  206. .cinema-box {
  207. padding: 30rpx;
  208. border-top: 1rpx solid #E8E8E8;
  209. background-color: #FFFFFF;
  210. display: flex;
  211. flex-direction: column;
  212. .tit {
  213. display: flex;
  214. justify-content: space-between;
  215. .text-1 {
  216. font-size: 30rpx;
  217. color: #0F0404;
  218. }
  219. .text-2 {
  220. font-size: 26rpx;
  221. color: #999999;
  222. white-space: nowrap;
  223. }
  224. }
  225. .address {
  226. margin-top: 20rpx;
  227. width: 600rpx;
  228. font-size: 26rpx;
  229. color: #666666;
  230. white-space: nowrap;
  231. overflow: hidden;
  232. text-overflow: ellipsis;
  233. }
  234. }
  235. .tab {
  236. display: flex;
  237. justify-content: space-around;
  238. align-items: stretch;
  239. background-color: #FFFFFF;
  240. position: sticky;
  241. top: 0;
  242. left: 0;
  243. z-index: 1;
  244. .text {
  245. padding: 30rpx 0;
  246. font-size: 30rpx;
  247. color: #0F0404;
  248. }
  249. .hover {
  250. border-bottom: 6rpx solid red;
  251. }
  252. .location-box {
  253. padding: 30rpx 0;
  254. font-size: 30rpx;
  255. color: #0F0404;
  256. display: flex;
  257. justify-content: center;
  258. align-items: center;
  259. }
  260. }
  261. .flex-box {
  262. display: flex;
  263. justify-content: space-between;
  264. flex-wrap: wrap;
  265. background: #FFFFFF;
  266. margin-top: 1rpx;
  267. padding: 0rpx 20rpx;
  268. padding-bottom: 20rpx;
  269. .film-box {
  270. width: 334rpx;
  271. border-radius: 20rpx;
  272. overflow: hidden;
  273. background: #FFFFFF;
  274. margin: 30rpx 11rpx 0;
  275. box-shadow: 0px 2px 16px 0px rgba(68, 6, 6, 0.2);
  276. .img {
  277. width: 100%;
  278. height: 456rpx;
  279. }
  280. .bottom-box {
  281. padding: 30rpx 20rpx;
  282. .tit {
  283. display: flex;
  284. justify-content: space-between;
  285. .text-1 {
  286. width: 200rpx;
  287. font-size: 26rpx;
  288. overflow: hidden;
  289. text-overflow: ellipsis;
  290. white-space: nowrap;
  291. }
  292. .text-2 {
  293. font-size: 26rpx;
  294. color: #ED4F24;
  295. white-space: nowrap;
  296. }
  297. }
  298. .des-box {
  299. margin-top: 20rpx;
  300. .des {
  301. width: 100%;
  302. font-size: 22rpx;
  303. color: #666666;
  304. overflow: hidden;
  305. text-overflow: ellipsis;
  306. white-space: nowrap;
  307. }
  308. }
  309. .buy {
  310. margin-top: 30rpx;
  311. width: 126rpx;
  312. height: 60rpx;
  313. background: linear-gradient(90deg, #E31818, #ED3E24, #ED4F24);
  314. border-radius: 30rpx;
  315. font-size: 26rpx;
  316. font-weight: 400;
  317. color: #FFFFFF;
  318. display: flex;
  319. justify-content: center;
  320. align-items: center;
  321. white-space: nowrap;
  322. }
  323. }
  324. }
  325. }
  326. .soon-box {
  327. margin-top: 20rpx;
  328. .tit-text {
  329. background-color: #FFF0E5;
  330. padding: 28rpx 55rpx;
  331. font-size: 26rpx;
  332. font-weight: bold;
  333. color: #0F0404;
  334. display: flex;
  335. align-items: center;
  336. .icon {
  337. margin-right: 20rpx;
  338. }
  339. }
  340. }
  341. </style>