index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. <script setup lang="ts">
  2. import Tabbar from '../components/tabbar.vue'
  3. import { filterDay, timeFormat } from '../utils'
  4. import { StaticUrl } from '@/config'
  5. const route = useRoute()
  6. const router = useRouter()
  7. const addressStore = useAddressStore()
  8. const { Location } = storeToRefs(addressStore)
  9. definePage({
  10. name: 'film-movie',
  11. islogin: false,
  12. style: {
  13. navigationStyle: 'custom',
  14. navigationBarTitleText: '电影演出',
  15. backgroundColorBottom: '#fff',
  16. },
  17. })
  18. const active = ref(route.query?.active || 0)
  19. const tabList = reactive([
  20. { title: '热映', path: 'film-index' },
  21. { title: '影院', path: 'film-movie' },
  22. { title: '待映', path: 'film-order' },
  23. ])
  24. const { data: hotList, isLastPage, page, reload, error, refresh } = usePagination((pageNum, pageSize) =>
  25. Apis.film.getMovieList({ data: { showSt: 1, pageNum, pageSize } }), {
  26. data: resp => resp.data?.records,
  27. initialData: [],
  28. initialPage: 1,
  29. initialPageSize: 10,
  30. append: true,
  31. immediate: false,
  32. })
  33. const { data: filmList, isLastPage: isLastPage1, page: page1, reload: reload1, error: error1, refresh: refresh1 } = usePagination(() =>
  34. Apis.film.getFilmList({ data: { movieId: '2062', lat: Location.value.latitude, lng: Location.value.longitude } }), {
  35. data: resp => resp.data,
  36. initialData: [],
  37. initialPage: 1,
  38. initialPageSize: 10,
  39. append: true,
  40. immediate: false,
  41. })
  42. const { data: comingSoonList, isLastPage: isLastPage2, page: page2, reload: reload2, error: error2, refresh: refresh2 } = usePagination((pageNum, pageSize) =>
  43. Apis.film.getMovieList({ data: { showSt: 2, pageNum, pageSize } }), {
  44. data: resp => resp.data?.records,
  45. initialData: [],
  46. initialPage: 1,
  47. initialPageSize: 10,
  48. append: true,
  49. immediate: false,
  50. })
  51. const state = computed(() => {
  52. if (active.value === 0) {
  53. return error.value ? 'error' : !isLastPage.value ? 'loading' : 'finished'
  54. }
  55. else if (active.value === 1) {
  56. return error1.value ? 'error' : !isLastPage2.value ? 'loading' : 'finished'
  57. }
  58. else {
  59. return error2.value ? 'error' : !isLastPage2.value ? 'loading' : 'finished'
  60. }
  61. })
  62. function loadData() {
  63. console.log('loadData')
  64. if (active.value === 0) {
  65. reload()
  66. }
  67. else if (active.value === 1) {
  68. reload1()
  69. }
  70. else if (active.value === 2) {
  71. reload2()
  72. }
  73. uni.pageScrollTo({
  74. scrollTop: 0, // 滚动目标位置(0 = 页面最顶部,核心参数)
  75. duration: 0, // 滚动动画时长,单位ms(可选,默认300,设0为无动画瞬间滚动)
  76. })
  77. }
  78. function refreshData() {
  79. if (Number(active.value) === 0) {
  80. refresh()
  81. }
  82. else if (Number(active.value) === 1) {
  83. refresh1()
  84. }
  85. else if (Number(active.value) === 2) {
  86. refresh2()
  87. }
  88. }
  89. function addPageNum() {
  90. if (active.value === 0) {
  91. if (!isLastPage.value) {
  92. page.value++
  93. }
  94. }
  95. else if (active.value === 1) {
  96. if (!isLastPage1.value) {
  97. page1.value++
  98. }
  99. }
  100. else if (active.value === 2) {
  101. if (!isLastPage2.value) {
  102. page2.value++
  103. }
  104. }
  105. }
  106. onLoad((options) => {
  107. console.log('onload', options)
  108. active.value = Number(options?.active || 0)
  109. refreshData()
  110. })
  111. onReachBottom(() => {
  112. console.log('onReachBottom', state.value)
  113. addPageNum()
  114. })
  115. function handleItem(index: number) {
  116. active.value = index
  117. loadData()
  118. console.log('handle', state.value)
  119. }
  120. function handleFilm(title: string, movieId: string, cinemaId: string) {
  121. router.push({
  122. name: 'film-select-time',
  123. params: {
  124. id: '2221',
  125. title,
  126. movieId,
  127. cinemaId,
  128. },
  129. })
  130. }
  131. function handleBuy(item: Api.filmMovieList) {
  132. router.push({ name: 'film-movie-detail', params: { id: item.id as string, movieId: item.movieId as string } })
  133. }
  134. function handleWant(item: Api.filmMovieList) {
  135. router.push({ name: 'film-movie-detail', params: { id: item.id as string, movieId: item.movieId as string } })
  136. // useGlobalToast().show('敬请期待')
  137. }
  138. onMounted(() => {
  139. if (!Location.value.latitude) {
  140. useAddressStore().getLocation()
  141. }
  142. })
  143. </script>
  144. <template>
  145. <view class="movies">
  146. <wd-navbar
  147. title="" :bordered="false" :z-index="99" safe-area-inset-top left-arrow placeholder fixed
  148. @click-left="router.back()"
  149. >
  150. <template #left>
  151. <view class="flex items-center">
  152. <wd-icon name="arrow-left" size="22px" color="#000" />
  153. </view>
  154. </template>
  155. <template #title>
  156. <view class="tabbar">
  157. <view v-for="(item, index) in tabList" :key="index" class="item" @click="handleItem(index)">
  158. <view class="title" :class="[active == index ? 'active' : '']">
  159. {{ item.title }}
  160. </view>
  161. </view>
  162. </view>
  163. </template>
  164. </wd-navbar>
  165. <!-- 热映 列表 -->
  166. <view v-if="active == 0" class="list">
  167. <view v-for="(item, index) in hotList" :key="index" class="item">
  168. <view class="img-box">
  169. <image class="img" :src="item.posterUrl" />
  170. <view class="tag">
  171. {{ item.version }}
  172. </view>
  173. </view>
  174. <view class="info">
  175. <view class="title">
  176. {{ item.name }}
  177. </view>
  178. <view class="num-box">
  179. <view class="score-box">
  180. <view class="label">
  181. 评分
  182. </view>
  183. <view class="score">
  184. {{ item.score }}
  185. </view>
  186. </view>
  187. <view class="num">
  188. {{ item.wish }}人想看
  189. </view>
  190. </view>
  191. <view class="type-box">
  192. <view class="type">
  193. {{ item.category }} |
  194. </view>
  195. <view class="time">
  196. {{ item.duration }}分钟
  197. </view>
  198. </view>
  199. <view class="director">
  200. 导演:{{ item.director }}
  201. </view>
  202. <view class="actor">
  203. 演员:{{ item.star }}
  204. </view>
  205. </view>
  206. <view class="btn-box">
  207. <image class="img" :src="`${StaticUrl}/film-movie-icon.png`" mode="scaleToFill" />
  208. <view class="btn" @click="handleBuy(item)">
  209. 购票
  210. </view>
  211. </view>
  212. </view>
  213. </view>
  214. <!-- 影院 列表 -->
  215. <view v-else-if="active == 1" class="film-list">
  216. <view
  217. v-for="(item, index) in filmList" :key="index" class="film-item"
  218. @click="handleFilm(item.name, '', item.cinemaId)"
  219. >
  220. <view class="name-box">
  221. <view class="name w-450rpx overflow-hidden text-ellipsis whitespace-nowrap">
  222. {{ item.name }}
  223. </view>
  224. <view class="price-box">
  225. <view class="num">
  226. ¥{{ item.sellPrice }}
  227. </view>
  228. <div class="label">
  229. </div>
  230. </view>
  231. </view>
  232. <view class="address-box">
  233. <view class="address overflow-hidden text-ellipsis whitespace-nowrap">
  234. {{ item.address }}
  235. </view>
  236. <view class="distance">
  237. {{ item.distance }}km
  238. </view>
  239. </view>
  240. <div class="cantact">
  241. {{ item.phone || '暂无联系方式' }}
  242. </div>
  243. <div class="movie-box">
  244. <!-- 今日热映:《疯狂动物城2》《阿凡达3》《匿杀》《惊天魔... -->
  245. </div>
  246. </view>
  247. </view>
  248. <!-- 待映映 列表 -->
  249. <view v-else-if="active == 2" class="list soon-list">
  250. <view v-for="(item, index) in comingSoonList" :key="index" class="item">
  251. <view class="img-box">
  252. <image class="img" :src="item.posterUrl" />
  253. <view class="tag">
  254. {{ item.version }}
  255. </view>
  256. </view>
  257. <view class="info">
  258. <view class="title">
  259. {{ item.name }}
  260. </view>
  261. <view class="num-box">
  262. <view class="score-box">
  263. <view class="label">
  264. 想看:
  265. </view>
  266. <view class="score">
  267. {{ item.wish }}人
  268. </view>
  269. </view>
  270. <!-- <view class="num">
  271. {{ item.wish }}人想看
  272. </view> -->
  273. </view>
  274. <view class="type-box">
  275. <view class="type">
  276. 上映时间: {{ `${timeFormat(item.releaseTime, 'MM-dd')} (${filterDay(timeFormat(item.releaseTime, 'yyyy-MM-dd'))})` }}
  277. </view>
  278. </view>
  279. <view class="director">
  280. 导演:{{ item.director }}
  281. </view>
  282. <view class="actor">
  283. 演员:{{ item.star }}
  284. </view>
  285. </view>
  286. <view class="btn-box">
  287. <image class="img" :src="`${StaticUrl}/film-movie-icon.png`" mode="scaleToFill" />
  288. <view class="btn" @click="handleWant(item)">
  289. 想看
  290. </view>
  291. </view>
  292. </view>
  293. </view>
  294. <wd-loadmore :state="state" :loading-props="{ color: '#9ED605', size: 20 }" @reload="reload" />
  295. <Tabbar :active="1" />
  296. </view>
  297. </template>
  298. <style lang="scss" scoped>
  299. .movies{
  300. padding: 16rpx 24rpx 350rpx;
  301. background: #F9F9F9;
  302. .tabbar {
  303. display: flex;
  304. justify-content: space-between;
  305. padding: 0 60rpx;
  306. .item {
  307. flex: 1;
  308. text-align: center;
  309. .title {
  310. font-weight: bold;
  311. font-size: 36rpx;
  312. color: #AAAAAA;
  313. &.active {
  314. color: #222222;
  315. }
  316. }
  317. }
  318. }
  319. .list{
  320. .item{
  321. background: #FFFFFF;
  322. border-radius: 16rpx 16rpx 16rpx 16rpx;
  323. display: flex;
  324. padding: 28rpx 24rpx;
  325. position: relative;
  326. margin-bottom: 20rpx;
  327. .img-box{
  328. position: relative;
  329. margin-right: 24rpx;
  330. .img{
  331. width: 152rpx;
  332. height: 208rpx;
  333. border-radius: 16rpx;
  334. vertical-align: top;
  335. }
  336. .tag{
  337. line-height: 26rpx;
  338. background: rgba(34, 34, 34, 0.7);
  339. border-radius: 8rpx 8rpx 8rpx 8rpx;
  340. font-size: 18rpx;
  341. color: #FFFFFF;
  342. padding: 0 10rpx;
  343. position: absolute;
  344. top: 4rpx;
  345. right: 4rpx;
  346. }
  347. }
  348. .info{
  349. .title{
  350. font-weight: bold;
  351. font-size: 32rpx;
  352. color: #222222;
  353. width: 330rpx;
  354. white-space: nowrap;
  355. text-overflow: ellipsis;
  356. overflow: hidden;
  357. }
  358. .num-box{
  359. display: flex;
  360. align-items: flex-end;
  361. margin-top: 8rpx;
  362. line-height: 28rpx;
  363. .score-box{
  364. display: flex;
  365. align-items: flex-end;
  366. .label{
  367. font-size: 24rpx;
  368. color: #AAAAAA;
  369. }
  370. .score{
  371. font-weight: bold;
  372. font-size: 28rpx;
  373. color: #FF4D3A;
  374. margin-left: 6rpx;
  375. }
  376. }
  377. .num{
  378. font-size: 24rpx;
  379. color: #AAAAAA;
  380. margin-left: 8rpx;
  381. }
  382. }
  383. .type-box{
  384. display: flex;
  385. margin-top: 8rpx;
  386. .type {
  387. font-size: 24rpx;
  388. color: #AAAAAA;
  389. }
  390. .time{
  391. font-size: 24rpx;
  392. color: #AAAAAA;
  393. }
  394. }
  395. .director{
  396. font-size: 24rpx;
  397. color: #AAAAAA;
  398. margin-top: 8rpx;
  399. }
  400. .actor{
  401. font-size: 24rpx;
  402. color: #AAAAAA;
  403. margin-top: 8rpx;
  404. width: 470rpx;
  405. white-space: nowrap;
  406. text-overflow: ellipsis;
  407. overflow: hidden;
  408. }
  409. }
  410. .btn-box{
  411. position: absolute;
  412. top: 0;
  413. right: 0;
  414. .img{
  415. width: 172rpx;
  416. height: 150rpx;
  417. }
  418. .btn{
  419. position: absolute;
  420. bottom: 0;
  421. left: calc(50% - 60rpx);
  422. width: 120rpx;
  423. height: 52rpx;
  424. line-height: 52rpx;
  425. text-align: center;
  426. background: #9ED605;
  427. border-radius: 26rpx 26rpx 26rpx 26rpx;
  428. font-size: 28rpx;
  429. color: #FFFFFF;
  430. }
  431. }
  432. }
  433. }
  434. .list.soon-list .btn-box .btn{
  435. background: #FFB639;
  436. }
  437. .film-list {
  438. .film-item {
  439. background: #FFF;
  440. border-radius: 16rpx 16rpx 16rpx 16rpx;
  441. padding: 24rpx;
  442. margin-bottom: 20rpx;
  443. .name-box {
  444. display: flex;
  445. justify-content: space-between;
  446. margin-bottom: 16rpx;
  447. .name {
  448. font-weight: bold;
  449. font-size: 28rpx;
  450. color: #222222;
  451. }
  452. .price-box {
  453. display: flex;
  454. align-items: center;
  455. .num {
  456. font-weight: bold;
  457. font-size: 36rpx;
  458. color: #FF4D3A;
  459. }
  460. .label {
  461. font-size: 24rpx;
  462. color: #AAAAAA;
  463. }
  464. }
  465. }
  466. .address-box {
  467. display: flex;
  468. justify-content: space-between;
  469. font-size: 24rpx;
  470. color: #AAAAAA;
  471. margin-bottom: 16rpx;
  472. .address {
  473. font-size: 24rpx;
  474. color: #AAAAAA;
  475. }
  476. .distance {}
  477. }
  478. .cantact {
  479. font-size: 24rpx;
  480. color: #AAAAAA;
  481. margin-bottom: 16rpx;
  482. }
  483. .movie-box {
  484. font-size: 24rpx;
  485. color: #222222;
  486. width: 100%;
  487. white-space: nowrap;
  488. text-overflow: ellipsis;
  489. overflow: hidden;
  490. }
  491. }
  492. }
  493. }
  494. </style>