cinema.vue 7.0 KB

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