123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414 |
- <template>
- <scroll-view scroll-y class="cinema">
- <view class='topbar'>
- <topbar>
- <view class="topbar-box">
- <view class="left-box" @click="goPage(`/pages/cinema/citylist?cityList=${JSON.stringify(cityList)}`,null,{cityList:cityList})">
- <van-icon name="location" />
- <text>{{address}}</text>
- <van-icon name="arrow-down" />
- </view>
- <van-search class='top-search' shape="round" background="#fff" placeholder="请输入电影名称" @search="onSearch" @change='onSearchChange' />
- </view>
- </topbar>
- </view>
- <view class="tabs-box">
- <van-tabs :active='tabActive' animated sticky offset-top='87' @change='tabsChange'>
- <van-tab title="热映">
- <loadSke :loading='hotLoading' :list='hotList'>
- <view class="flex-box">
- <view @click="goPage(`/pages/cinema/cinemalist?filmId=${item.filmId}&cityId=${cityId}&location=${location}`)"
- class="film-box" v-for="(item,index) in hotList" :key='item.filmId'>
- <image :src="item.pic" mode="scaleToFill" class="img" draggable></image>
- <view class="bottom-box">
- <view class="tit">
- <text class="text-1">{{item.name}}</text>
- <text class="text-2">{{item.grade ?'评分'+item.grade : '暂无评分'}}</text>
- </view>
- <view class="des-box">
- <view class="des">{{item.filmTypes}}</view>
- <view class="des">{{item.cast}}</view>
- </view>
-
- <button type="default" class="buy">
- 购 票
- </button>
- </view>
- </view>
- </view>
- </loadSke>
- </van-tab>
- <van-tab title="影院">
- <loadSke :loading='cinemaLoading' :list='cinemaList'>
- <view class="cinema-box" v-for="(item,index) in cinemaList" :key='item.cinemaId' @click='goPage(`/pages/cinema/schedulelist?cinemaId=${item.cinemaId}&filmId=${filmId}`)'>
- <view class="tit">
- <text>{{item.cinemaName}}</text>
- <text class="text-2">{{item.distance}}km</text>
- </view>
- <text class="address">{{item.address}}</text>
- </view>
- </loadSke>
- </van-tab>
- <van-tab title="即将上映">
- <loadSke :loading='soonLoading'>
- <view class="soon-box" v-for="(ObjItem,ObjIndex) in soonList" :key='ObjIndex'>
- <view class="tit-text">
- <van-icon class='icon' name="https://t1-1305573081.cos.ap-shanghai.myqcloud.com/wxapp/static/imgs/%E6%97%A5%E6%9C%9F.png" />
- {{ObjIndex}}
- </view>
- <view class="flex-box">
- <view class="film-box" v-for="(item,index) in ObjItem" :key='item.filmId'>
- <image :src="item.pic" mode="scaleToFill" class="img" draggable></image>
- <view class="bottom-box">
- <view class="tit">
- <text class="text-1">{{item.name}}</text>
- <text class="text-2">{{item.grade ?'评分'+item.grade : '暂无评分'}}</text>
- </view>
- <view class="des-box">
- <view class="des">{{item.filmTypes}}</view>
- <view class="des">{{item.cast}}</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </loadSke>
- </van-tab>
- </van-tabs>
- </view>
-
- </scroll-view>
- </template>
- <script>
- import loadSke from '@/components/skeleton/index/index.vue'
- import {
- getPayData
- } from '@/api/pay.js'
- import {
- amapRegeo
- } from '@/api/amap.js'
- import {
- getHotList,
- getSoonList,
- getCityList,
- getInfo,
- getFilmDiscount,
- getCinemaList
- } from '@/api/cinema.js'
- export default {
- components: {
- loadSke
- },
- data: () => ({
- tabActive: 0,
- hotList: [],
- soonList: {},
- hotLoading: true,
- soonLoading: true,
- location: [119.131390, 26.150210],
- cityList: [],
- address: '定位中',
- cinemaList: {},
- cinemaLoading: true
- }),
- async mounted() {
- this.setFilmDiscount()
- await this.getLocation()
- this.address = this.$store.state.cinema.cityObj.regionName;
- this.init()
- this.cinemaListInit()
- },
- computed: {
- cityId() {
- return this.$store.state.cinema.cityId;
- }
- },
- watch: {
- cityId() {
- this.address = this.$store.state.cinema.cityObj.regionName;
- this.init()
- this.cinemaListInit()
- }
- },
- methods: {
- onSearch(e){
- console.log(e)
- },
- onSearchChange(e){
- console.log(e)
- },
- tabsChange(e) {
- this.tabActive = e.detail.index
- },
- setFilmDiscount() {
- getFilmDiscount().then(res => {
- this.$store.commit('SET_FILMDISCOUNT', res.data)
- })
- },
- async getLocation() {
- let location = await wx.getLocation()
- this.location = [location.longitude.toFixed(6), location.latitude.toFixed(6)]
- let address = await amapRegeo({
- location: this.location.toString()
- })
- let cityListRes = await getCityList()
- let cityList = cityListRes.data.data.list
- let cityObj = {}
- cityList.map((val) => {
- cityObj[val.pinYin] || (cityObj[val.pinYin] = [])
- cityObj[val.pinYin].push(val)
- if (val.regionName == address.regeocode.addressComponent.city.slice(0, -1)) {
- this.selectCity(val)
- }
- })
- this.cityList = cityObj
- },
- async init() {
- this.hotLoading = true
- this.soonLoading = true
- let hotListRes = await getHotList({
- cityId: this.cityId
- })
- this.hotList = hotListRes.data.data.list
- this.$nextTick(()=>{
- this.hotLoading = false
- })
- let soonListRes = await getSoonList({
- cityId: this.cityId
- })
- let soonListObj = {}
- soonListRes.data.data.list.forEach((val) => {
- soonListObj[val.publishDate.slice(0, 10)] || (soonListObj[val.publishDate.slice(0, 10)] = [])
- soonListObj[val.publishDate.slice(0, 10)].push(val)
- })
- this.soonList = soonListObj
- this.$store.commit('SET_FILMLIST', this.hotList.concat(soonListRes.data.data.list))
- this.$nextTick(()=>{
- this.soonLoading = false
- })
- },
- async cinemaListInit() {
- this.cinemaLoading = true
- let showListRes = await getCinemaList({
- cityId: this.cityId,
- latitude: this.location[1],
- longitude: this.location[0],
- })
- showListRes.data.data.list.map(val => {
- val.distance = (Math.sqrt((val.latitude - this.location[1]) ** 2 + (val.longitude - this.location[0]) ** 2) *
- 111).toFixed(2)
- return val
- })
- showListRes.data.data.list.sort(function(a, b) {
- return a.distance - b.distance
- })
- this.cinemaList = showListRes.data.data.list
- this.cinemaLoading = false
- },
- selectCity(obj) {
- this.$store.commit('SET_CITYOBJ', obj)
- this.$store.commit('SET_CITYID', obj.cityId)
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .cinema{
- height: 100%;
- position: relative;
- }
-
- .topbar {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- z-index: 1;
- .topbar-box {
- display: flex;
- align-items: center;
-
- .left-box {
- min-width: 150rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- margin-left: 20rpx;
- text{
- white-space: nowrap;
- }
- }
- }
- }
-
- .tabs-box{
- margin-top: 160rpx;
- }
-
- .cinema-box {
- padding: 30rpx;
- border-top: 1rpx solid #E8E8E8;
- background-color: #FFFFFF;
- display: flex;
- flex-direction: column;
- .tit {
- display: flex;
- justify-content: space-between;
- .text-1 {
- font-size: 30rpx;
- color: #0F0404;
- }
- .text-2 {
- font-size: 26rpx;
- color: #999999;
- white-space: nowrap;
- }
- }
- .address {
- margin-top: 20rpx;
- width: 600rpx;
- font-size: 26rpx;
- color: #666666;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- }
- .tab {
- display: flex;
- justify-content: space-around;
- align-items: stretch;
- background-color: #FFFFFF;
- position: sticky;
- top: 0;
- left: 0;
- z-index: 1;
- .text {
- padding: 30rpx 0;
- font-size: 30rpx;
- color: #0F0404;
- }
- .hover {
- border-bottom: 6rpx solid red;
- }
- .location-box {
- padding: 30rpx 0;
- font-size: 30rpx;
- color: #0F0404;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- }
- .flex-box {
- display: flex;
- justify-content: space-between;
- flex-wrap: wrap;
- background: #FFFFFF;
- margin-top: 1rpx;
- padding: 0rpx 20rpx;
- padding-bottom: 20rpx;
- .film-box {
- width: 334rpx;
- border-radius: 20rpx;
- overflow: hidden;
- background: #FFFFFF;
- margin: 30rpx 11rpx 0;
- box-shadow: 0px 2px 16px 0px rgba(68, 6, 6, 0.2);
- .img {
- width: 100%;
- height: 456rpx;
- }
- .bottom-box {
- padding: 30rpx 20rpx;
- .tit {
- display: flex;
- justify-content: space-between;
- .text-1 {
- width: 200rpx;
- font-size: 26rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .text-2 {
- font-size: 26rpx;
- color: #ED4F24;
- white-space: nowrap;
- }
- }
- .des-box {
- margin-top: 20rpx;
- .des {
- width: 100%;
- font-size: 22rpx;
- color: #666666;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- }
- .buy {
- margin-top: 30rpx;
- width: 126rpx;
- height: 60rpx;
- background: linear-gradient(90deg, #E31818, #ED3E24, #ED4F24);
- border-radius: 30rpx;
- font-size: 26rpx;
- font-weight: 400;
- color: #FFFFFF;
- display: flex;
- justify-content: center;
- align-items: center;
- white-space: nowrap;
- }
- }
- }
- }
- .soon-box {
- margin-top: 20rpx;
- .tit-text {
- background-color: #FFF0E5;
- padding: 28rpx 55rpx;
- font-size: 26rpx;
- font-weight: bold;
- color: #0F0404;
- display: flex;
- align-items: center;
- .icon {
- margin-right: 20rpx;
- }
- }
- }
- </style>
|