index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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" @click="buy(item.movieId)">购票</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" @click="buy(item.movieId)">预售</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.reLaunch({
  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. },
  237. created() {
  238. //去除
  239. //#ifndef H5 || MP-ALIPAY ||APP-PLUS
  240. //获取小程序胶囊的高度
  241. let {
  242. bottom
  243. } = uni.getMenuButtonBoundingClientRect()
  244. this.height = bottom
  245. //#endif
  246. }
  247. }
  248. </script>
  249. <style lang="scss" >
  250. .movie{
  251. background: #F9F9F9;
  252. .header{
  253. display: flex;
  254. justify-content: center;
  255. align-items: flex-end;
  256. background: #fff;
  257. padding-bottom: 8px;
  258. position: fixed;
  259. top: 0;
  260. left: 0;
  261. width: 100%;
  262. z-index: 3;
  263. .back{
  264. position: absolute;
  265. left: 32rpx;
  266. bottom: 8px;
  267. width: 40rpx;
  268. height: 40rpx;
  269. }
  270. .tab{
  271. font-size: 36rpx;
  272. color: #AAAAAA;
  273. padding: 0 20rpx;
  274. vertical-align: bottom;
  275. }
  276. .tab.active{
  277. color: #222222;
  278. font-weight: 600;
  279. }
  280. }
  281. .zs-list{
  282. padding: 20rpx 24rpx;
  283. .item{
  284. background: #FFFFFF;
  285. border-radius: 16rpx 16rpx 16rpx 16rpx;
  286. padding: 24rpx;
  287. display: flex;
  288. margin-bottom: 20rpx;
  289. position: relative;
  290. .img-box{
  291. position: relative;
  292. .tag{
  293. position: absolute;
  294. top: 8rpx;
  295. left: 12rpx;
  296. background: rgba(0, 0, 0, .8);
  297. padding: 6rpx 4rpx;
  298. border-radius: 8rpx 8rpx 8rpx 8rpx;
  299. font-size: 18rpx;
  300. color: #FFFFFF;
  301. z-index: 2;
  302. }
  303. .icon{
  304. width: 160rpx;
  305. height: 200rpx;
  306. border-radius: 16rpx;
  307. background: #F9F9F9;
  308. }
  309. }
  310. .info{
  311. font-size: 24rpx;
  312. color: #AAAAAA;
  313. display: flex;
  314. flex-direction: column;
  315. // justify-content: space-between;
  316. margin-left: 20rpx;
  317. .name{
  318. font-weight: 600;
  319. font-size: 28rpx;
  320. color: #222222;
  321. width: 400rpx;
  322. white-space: nowrap;
  323. overflow: hidden;
  324. text-overflow: ellipsis;
  325. }
  326. .score-box{
  327. display: flex;
  328. margin-top: 20rpx;
  329. .score{
  330. display: flex;
  331. align-items: center;
  332. .num{
  333. font-size: 28rpx;
  334. color: #FF4D3A;
  335. padding: 0 12rpx;
  336. }
  337. }
  338. .want-num{
  339. padding: 0 12rpx;
  340. align-self: flex-end;
  341. // font-size: 24rpx;
  342. // color: #AAAAAA;
  343. }
  344. .score+.want-num{
  345. border-left: 2rpx solid #F0F0F0;
  346. }
  347. }
  348. .actor,.releaseTime{
  349. margin-top: 20rpx;
  350. width: 350rpx;
  351. line-height: 44rpx;
  352. overflow: hidden;
  353. text-overflow: ellipsis;
  354. /* 弹性伸缩盒子模型显示 */
  355. display: -webkit-box;
  356. /* 限制在一个块元素显示的文本的行数 */
  357. -webkit-line-clamp: 2;
  358. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  359. -webkit-box-orient: vertical;
  360. // font-size: 24rpx;
  361. // color: #AAAAAA;
  362. }
  363. .play-movie-num{
  364. // font-size: 24rpx;
  365. // color: #AAAAAA;
  366. }
  367. }
  368. .buy-btn{
  369. position: absolute;
  370. top: 50%;
  371. right: 24rpx;
  372. transform: translateY(-50%);
  373. width: 120rpx;
  374. height: 52rpx;
  375. line-height: 52rpx;
  376. background: #EE4320;
  377. border-radius: 26rpx;
  378. font-size: 28rpx;
  379. color: #FFFFFF;
  380. }
  381. .presell-btn{
  382. position: absolute;
  383. top: 50%;
  384. right: 0;
  385. transform: translateY(-50%);
  386. width: 120rpx;
  387. height: 52rpx;
  388. line-height: 52rpx;
  389. background: #3879F9;
  390. border-radius: 26rpx;
  391. font-size: 28rpx;
  392. color: #FFFFFF;
  393. }
  394. }
  395. .cinema-item{
  396. background: #FFFFFF;
  397. border-radius: 16rpx 16rpx 16rpx 16rpx;
  398. padding: 24rpx;
  399. margin-bottom: 20rpx;
  400. .name-box{
  401. display: flex;
  402. justify-content: space-between;
  403. .name{
  404. font-weight: 600;
  405. font-size: 28rpx;
  406. color: #222222;
  407. width: 450rpx;
  408. white-space: nowrap;
  409. overflow: hidden;
  410. text-overflow: ellipsis;
  411. }
  412. .price{
  413. display: flex;
  414. align-items: center;
  415. font-size: 28rpx;
  416. color: #FF4D3A;
  417. .label{
  418. font-size: 24rpx;
  419. color: #AAAAAA;
  420. }
  421. }
  422. }
  423. .address-box{
  424. display: flex;
  425. justify-content: space-between;
  426. font-size: 24rpx;
  427. color: #AAAAAA;
  428. margin-top: 16rpx;
  429. .address{
  430. width: 460rpx;
  431. white-space: nowrap;
  432. overflow: hidden;
  433. text-overflow: ellipsis;
  434. }
  435. .distance{
  436. }
  437. }
  438. .movie-name{
  439. font-size: 24rpx;
  440. color: #222222;
  441. margin-top: 16rpx;
  442. width: 100%;
  443. white-space: nowrap;
  444. overflow: hidden;
  445. text-overflow: ellipsis;
  446. }
  447. }
  448. }
  449. }
  450. </style>