index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. <template>
  2. <view class="movie">
  3. <view class="header" :style="{height:height +'px'}">
  4. <image class="back" src="@/static/back-btn.png" @click="back" mode=""></image>
  5. <view class="tab" :class="[tab == 1?'active':'']" @click="handleTab(1)">
  6. 热映
  7. </view>
  8. <view class="tab" :class="[tab == 2?'active':'']" @click="handleTab(2)">
  9. 影院
  10. </view>
  11. <view class="tab" :class="[tab == 3?'active':'']" @click="handleTab(3)">
  12. 待映
  13. </view>
  14. </view>
  15. <!-- 列表 -->
  16. <zs-list :mt="(height+8) +'px'" @load="loadMore" :status="status">
  17. <template v-if="tab == 1">
  18. <view class="item" v-for="(item,index) in list1" :key="index" @click="buy(item.movieId)">
  19. <view class="img-box">
  20. <view class="tag" v-if="item.version">
  21. {{item.version}}
  22. </view>
  23. <zs-img class="icon" :src="item.posterUrl" radius="full" width="160rpx" height="150rpx" mode="widthFix" ></zs-img>
  24. </view>
  25. <view class="info">
  26. <view class="name">
  27. {{item.name}}
  28. </view>
  29. <view class="score-box">
  30. <view class="score">
  31. 评分 <view class="num">
  32. {{item.score}}
  33. </view>
  34. </view>
  35. <view class="want-num">
  36. {{item.wish | filterNum}}人想看
  37. </view>
  38. </view>
  39. <view class="actor">
  40. {{item.star}}
  41. </view>
  42. <!-- <view class="play-movie-num">
  43. 今天 269家影院放映2507场
  44. </view> -->
  45. </view>
  46. <button class="buy-btn" type="default">购票</button>
  47. </view>
  48. </template>
  49. <template v-else-if="tab == 2">
  50. <view class="cinema-item" v-for="(item,index) in list2" :key="index" @click="goCinema(item.cinemaId)">
  51. <view class="name-box">
  52. <view class="name">
  53. {{item.name}}
  54. </view>
  55. <view class="price">
  56. ¥{{item.sellPrice}} <view class="label">起</view>
  57. </view>
  58. </view>
  59. <view class="address-box">
  60. <view class="address">
  61. {{item.address}}
  62. </view>
  63. <view class="distance">
  64. {{item.dis}}
  65. </view>
  66. </view>
  67. <view class="movie-name">
  68. 近期场次:{{item.showInfo}}
  69. </view>
  70. </view>
  71. </template>
  72. <template v-else-if="tab == 3">
  73. <view class="item" v-for="(item,index) in list3" :key="index" @click="buy(item.movieId)">
  74. <view class="img-box">
  75. <view class="tag" v-if="item.version">
  76. {{item.version}}
  77. </view>
  78. <zs-img class="icon" :src="item.posterUrl" radius="full" width="160rpx" height="150rpx" mode="widthFix" ></zs-img>
  79. </view>
  80. <view class="info">
  81. <view class="name">
  82. {{item.name}}
  83. </view>
  84. <view class="score-box">
  85. <view class="score" v-if="item.score">
  86. 评分 <view class="num">
  87. {{item.score}}
  88. </view>
  89. </view>
  90. <view class="want-num">
  91. {{item.wish | filterNum}}人想看
  92. </view>
  93. </view>
  94. <view class="actor">
  95. {{item.star}}
  96. </view>
  97. <view class="releaseTime">
  98. {{ $u.timeFormat(new Date(item.releaseTime).getTime(), 'yyyy年mm月dd日')}}
  99. </view>
  100. </view>
  101. <button class="presell-btn" type="default">预售</button>
  102. </view>
  103. </template>
  104. </zs-list>
  105. </view>
  106. </template>
  107. <script>
  108. import {hotList,comingList,cinemas,cityList,cinema_filter} from '@/api/movie.js'
  109. export default {
  110. data() {
  111. return {
  112. status: "more",
  113. tab:1,
  114. height:0,
  115. list1:[],
  116. list2:[],
  117. list3:[],
  118. cityId:0,
  119. hotQuery:{
  120. cityId:0,
  121. pageIndex:0,
  122. pageSize:20,
  123. },
  124. cinemasQuery:{
  125. cityId:0,
  126. lat:JSON.parse(uni.getStorageSync('location')).latitude,
  127. lng:JSON.parse(uni.getStorageSync('location')).longitude,
  128. },
  129. }
  130. },
  131. filters: {
  132. filterNum: function(value) {
  133. if(value>10000){
  134. return (value/10000).toFixed(1)+'万';
  135. }else{
  136. return value;
  137. }
  138. }
  139. },
  140. methods: {
  141. back(){
  142. uni.switchTab({
  143. url:'/pages/index/index'
  144. })
  145. },
  146. goCinema(id){
  147. uni.navigateTo({
  148. url:'/movie/movieList?id='+id
  149. })
  150. },
  151. handleTab(val){
  152. this.tab = val
  153. this.list1 = []
  154. this.list2 = []
  155. this.list3 = []
  156. if(val == 1){
  157. this.status = 'more'
  158. this.hotQuery.pageIndex = 0
  159. this.hotList()
  160. }else if(val == 2){
  161. this.status = 'noMore'
  162. this.cinemas()
  163. }else if(val == 3){
  164. this.status = 'noMore'
  165. this.comingList()
  166. }
  167. },
  168. buy(id){
  169. uni.navigateTo({
  170. url:'/movie/movieDetail?id='+id
  171. })
  172. },
  173. loadMore() {
  174. if(this.cityId != 0 && this.tab == 1){
  175. this.hotQuery.cityId = this.cityId
  176. this.hotList()
  177. }
  178. },
  179. cityList(){
  180. return new Promise((resolve,reject)=>{
  181. cityList().then(res=>{
  182. if(res.state == 'Success'){
  183. let city = uni.getStorageSync('city').replace('市','')
  184. this.cityId = res.content.data.filter(item=>item.name == city)[0].cityId
  185. uni.setStorageSync('movieCityId',this.cityId)
  186. resolve()
  187. }
  188. })
  189. })
  190. },
  191. hotList(){
  192. if(this.status == 'loading') return
  193. this.status = 'loading'
  194. this.hotQuery.cityId = this.cityId
  195. hotList(this.hotQuery).then(res=>{
  196. if(res.state == 'Success'){
  197. this.list1 = this.list1.concat(res.content.data.movies)
  198. if(this.list1.length>=res.content.data.count){
  199. this.status = 'noMore'
  200. }else{
  201. this.status = 'more'
  202. this.hotQuery.pageIndex++
  203. }
  204. }
  205. })
  206. },
  207. comingList(){
  208. comingList({cityId:this.cityId}).then(res=>{
  209. if(res.state == 'Success'){
  210. this.list3 = this.list3.concat(res.content.data.movies)
  211. }
  212. })
  213. },
  214. cinema_filter(){
  215. cinema_filter({cityId:this.cityId}).then(res=>{
  216. if(res.state == 'Success'){
  217. }
  218. })
  219. },
  220. cinemas(){
  221. this.status = 'loading'
  222. this.cinemasQuery.cityId = this.cityId
  223. cinemas(this.cinemasQuery).then(res=>{
  224. if(res.state == 'Success'){
  225. this.list2 = res.content.data
  226. this.status = 'noMore'
  227. }
  228. })
  229. },
  230. },
  231. onLoad() {
  232. // this.cityList().then(()=>{
  233. // // this.cinema_filter()
  234. // this.hotList()
  235. // })
  236. this.cityId = uni.getStorageSync('movieCityId')
  237. this.hotList()
  238. },
  239. created() {
  240. //去除
  241. //#ifndef H5 || MP-ALIPAY ||APP-PLUS
  242. //获取小程序胶囊的高度
  243. let {
  244. bottom
  245. } = uni.getMenuButtonBoundingClientRect()
  246. this.height = bottom
  247. //#endif
  248. }
  249. }
  250. </script>
  251. <style lang="scss" >
  252. .movie{
  253. background: #F9F9F9;
  254. .header{
  255. display: flex;
  256. justify-content: center;
  257. align-items: flex-end;
  258. background: #fff;
  259. padding-bottom: 8px;
  260. position: fixed;
  261. top: 0;
  262. left: 0;
  263. width: 100%;
  264. z-index: 3;
  265. .back{
  266. position: absolute;
  267. left: 32rpx;
  268. bottom: 8px;
  269. width: 40rpx;
  270. height: 40rpx;
  271. }
  272. .tab{
  273. font-size: 36rpx;
  274. color: #AAAAAA;
  275. padding: 0 20rpx;
  276. vertical-align: bottom;
  277. }
  278. .tab.active{
  279. color: #222222;
  280. font-weight: 600;
  281. }
  282. }
  283. .zs-list{
  284. padding: 20rpx 24rpx;
  285. .item{
  286. background: #FFFFFF;
  287. border-radius: 16rpx 16rpx 16rpx 16rpx;
  288. padding: 24rpx;
  289. display: flex;
  290. margin-bottom: 20rpx;
  291. position: relative;
  292. .img-box{
  293. position: relative;
  294. .tag{
  295. position: absolute;
  296. top: 8rpx;
  297. left: 12rpx;
  298. background: rgba(0, 0, 0, .8);
  299. padding: 6rpx 4rpx;
  300. border-radius: 8rpx 8rpx 8rpx 8rpx;
  301. font-size: 18rpx;
  302. color: #FFFFFF;
  303. z-index: 2;
  304. }
  305. .icon{
  306. width: 160rpx;
  307. height: 200rpx;
  308. border-radius: 16rpx;
  309. background: #F9F9F9;
  310. }
  311. }
  312. .info{
  313. font-size: 24rpx;
  314. color: #AAAAAA;
  315. display: flex;
  316. flex-direction: column;
  317. // justify-content: space-between;
  318. margin-left: 20rpx;
  319. .name{
  320. font-weight: 600;
  321. font-size: 28rpx;
  322. color: #222222;
  323. width: 400rpx;
  324. white-space: nowrap;
  325. overflow: hidden;
  326. text-overflow: ellipsis;
  327. }
  328. .score-box{
  329. display: flex;
  330. margin-top: 20rpx;
  331. .score{
  332. display: flex;
  333. align-items: center;
  334. .num{
  335. font-size: 28rpx;
  336. color: #FF4D3A;
  337. padding: 0 12rpx;
  338. }
  339. }
  340. .want-num{
  341. padding: 0 12rpx;
  342. align-self: flex-end;
  343. // font-size: 24rpx;
  344. // color: #AAAAAA;
  345. }
  346. .score+.want-num{
  347. border-left: 2rpx solid #F0F0F0;
  348. }
  349. }
  350. .actor,.releaseTime{
  351. margin-top: 20rpx;
  352. width: 350rpx;
  353. line-height: 44rpx;
  354. overflow: hidden;
  355. text-overflow: ellipsis;
  356. /* 弹性伸缩盒子模型显示 */
  357. display: -webkit-box;
  358. /* 限制在一个块元素显示的文本的行数 */
  359. -webkit-line-clamp: 2;
  360. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  361. -webkit-box-orient: vertical;
  362. // font-size: 24rpx;
  363. // color: #AAAAAA;
  364. }
  365. .play-movie-num{
  366. // font-size: 24rpx;
  367. // color: #AAAAAA;
  368. }
  369. }
  370. .buy-btn{
  371. position: absolute;
  372. top: 50%;
  373. right: 24rpx;
  374. transform: translateY(-50%);
  375. width: 120rpx;
  376. height: 52rpx;
  377. line-height: 52rpx;
  378. background: #EE4320;
  379. border-radius: 26rpx;
  380. font-size: 28rpx;
  381. color: #FFFFFF;
  382. }
  383. .presell-btn{
  384. position: absolute;
  385. top: 50%;
  386. right: 0;
  387. transform: translateY(-50%);
  388. width: 120rpx;
  389. height: 52rpx;
  390. line-height: 52rpx;
  391. background: #3879F9;
  392. border-radius: 26rpx;
  393. font-size: 28rpx;
  394. color: #FFFFFF;
  395. }
  396. }
  397. .cinema-item{
  398. background: #FFFFFF;
  399. border-radius: 16rpx 16rpx 16rpx 16rpx;
  400. padding: 24rpx;
  401. margin-bottom: 20rpx;
  402. .name-box{
  403. display: flex;
  404. justify-content: space-between;
  405. .name{
  406. font-weight: 600;
  407. font-size: 28rpx;
  408. color: #222222;
  409. width: 450rpx;
  410. white-space: nowrap;
  411. overflow: hidden;
  412. text-overflow: ellipsis;
  413. }
  414. .price{
  415. display: flex;
  416. align-items: center;
  417. font-size: 28rpx;
  418. color: #FF4D3A;
  419. .label{
  420. font-size: 24rpx;
  421. color: #AAAAAA;
  422. }
  423. }
  424. }
  425. .address-box{
  426. display: flex;
  427. justify-content: space-between;
  428. font-size: 24rpx;
  429. color: #AAAAAA;
  430. margin-top: 16rpx;
  431. .address{
  432. width: 460rpx;
  433. white-space: nowrap;
  434. overflow: hidden;
  435. text-overflow: ellipsis;
  436. }
  437. .distance{
  438. }
  439. }
  440. .movie-name{
  441. font-size: 24rpx;
  442. color: #222222;
  443. margin-top: 16rpx;
  444. width: 100%;
  445. white-space: nowrap;
  446. overflow: hidden;
  447. text-overflow: ellipsis;
  448. }
  449. }
  450. }
  451. }
  452. </style>