calendar.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <view class="travel_calendar bg-base">
  3. <u-navbar title="节庆日历" autoBack bgColor="transparent" />
  4. <view class="banner">
  5. <swiper class="swiper right-indicator" circular :indicator-dots="true" :autoplay="true" :interval="2000"
  6. :duration="1000">
  7. <swiper-item v-for="item in bannerData" :key="item.id">
  8. <view class="item">
  9. <image class="w-100" :src="item.image" mode="aspectFill"></image>
  10. </view>
  11. </swiper-item>
  12. </swiper>
  13. </view>
  14. <view class="main m-3 radius-l p-3 bg-light">
  15. <view class="change-year">
  16. <view class="year">
  17. <text class="iconfont icon-arrow-left" @click="changeYear(currentYear - 1)"></text>
  18. <picker mode="date" :value="currentYear" @change="(e: any) => changeYear(e.detail.value)" fields="year">
  19. <view class="current-year">{{ currentYear }} 年</view>
  20. </picker>
  21. <text class="iconfont icon-arrow-right" @click="changeYear(currentYear + 1)"></text>
  22. </view>
  23. <text class="iconfont icon-calendar"></text>
  24. </view>
  25. <u-tabs
  26. :current="activeTab"
  27. :list="tabs"
  28. lineWidth="30"
  29. lineColor="#d9492e"
  30. :activeStyle="{
  31. color: '#000',
  32. fontWeight: 'bold',
  33. transform: 'scale(1.05)'
  34. }"
  35. :inactiveStyle="{
  36. color: '#606266',
  37. transform: 'scale(1)'
  38. }"
  39. class="top-tab"
  40. @click="tabClick"
  41. />
  42. <view class="activity-wrap mt-3">
  43. <view class="month-list">
  44. <view
  45. v-for="month in monthList"
  46. :key="month.value"
  47. :class="{ active: month.value === currentMonth }"
  48. class="month"
  49. @click="goMonth(month.value)"
  50. >
  51. {{ month.label }}
  52. </view>
  53. </view>
  54. <SimplePageContentLoader
  55. :loader="listLoader"
  56. :showEmpty="!listLoader.content.value?.length"
  57. >
  58. <view
  59. v-if="listLoader.content.value && listLoader.content.value.length"
  60. class="activity-list"
  61. >
  62. <scroll-view scroll-y :scroll-into-view="'month' + currentMonth" scroll-with-animation>
  63. <view class="item" v-for="item in listLoader.content.value" :key="item.id">
  64. <view class="head" :id="'month' + item.month">
  65. <view class="year-month">{{ item.year }}年{{ item.month }}月</view>
  66. <view>本月活动 <text>{{ item.data.length }}</text></view>
  67. </view>
  68. <view class="activity" v-for="act in item.data" :key="act.id">
  69. <view class="title">{{ act.title }}</view>
  70. <view class="dot" :class="{ ing: act.status === 0 }"></view>
  71. <view class="desc ellipsis-2">{{ act.desc }}</view>
  72. <view class="place"><text class="iconfont icon-place"></text>{{ act.place }}</view>
  73. <view class="time"><text class="iconfont icon-time"></text>{{ act.time }}</view>
  74. </view>
  75. </view>
  76. </scroll-view>
  77. </view>
  78. </SimplePageContentLoader>
  79. </view>
  80. </view>
  81. </view>
  82. </template>
  83. <script setup lang="ts">
  84. import { GetContentListParams } from '@/api/CommonContent';
  85. import NewsIndexContent from '@/api/news/NewsIndexContent';
  86. import SimplePageContentLoader from '@/common/components/SimplePageContentLoader.vue';
  87. import { useSimplePageContentLoader } from '@/common/composeabe/SimplePageContentLoader';
  88. import { onLoad } from '@dcloudio/uni-app';
  89. import { ref } from 'vue';
  90. const tabs = [
  91. {
  92. id: 1,
  93. name: '全部'
  94. },
  95. {
  96. id: 2,
  97. name: '节庆民俗'
  98. },
  99. {
  100. id: 3,
  101. name: '信仰祭祀'
  102. },
  103. {
  104. id: 4,
  105. name: '游艺竞技'
  106. },
  107. {
  108. id: 5,
  109. name: '民间艺术'
  110. },
  111. {
  112. id: 7,
  113. name: '其他'
  114. }
  115. ];
  116. const activeTab = ref(0);
  117. const bannerData = [
  118. {
  119. id: 1,
  120. image: 'https://lucheng.app4lh.cn/static/tmp/static/tmp/banner_act.png',
  121. },
  122. {
  123. id: 2,
  124. image: 'https://lucheng.app4lh.cn/static/tmp/static/tmp/banner_act.png',
  125. }
  126. ]
  127. const currentMonth = ref(1);
  128. const currentYear = ref(new Date().getFullYear());
  129. const monthList = [
  130. {
  131. label: '1月',
  132. value: 1
  133. }, {
  134. label: '2月',
  135. value: 2
  136. }, {
  137. label: '3月',
  138. value: 3
  139. }, {
  140. label: '4月',
  141. value: 4
  142. }, {
  143. label: '5月',
  144. value: 5
  145. }, {
  146. label: '6月',
  147. value: 6
  148. }, {
  149. label: '7月',
  150. value: 7
  151. }, {
  152. label: '8月',
  153. value: 8
  154. }, {
  155. label: '9月',
  156. value: 9
  157. }, {
  158. label: '10月',
  159. value: 10
  160. }, {
  161. label: '11月',
  162. value: 11
  163. }, {
  164. label: '12月',
  165. value: 12
  166. }
  167. ];
  168. const listLoader = useSimplePageContentLoader<{
  169. id: number;
  170. month: number,
  171. year: number,
  172. data: {
  173. id: number,
  174. title: string,
  175. desc: string,
  176. place: string,
  177. time: string,
  178. status: number,
  179. }[]
  180. }[]>(async () => {
  181. const res = await NewsIndexContent.getContentList(new GetContentListParams()
  182. .setModelId(18)
  183. .setMainBodyColumnId(272)
  184. , 1, 50);
  185. return [
  186. {
  187. id: 1,
  188. month: 1,
  189. year: 2025,
  190. data: res.list.map(item => ({
  191. id: item.id,
  192. title: item.title,
  193. desc: item.desc,
  194. place: item.district,
  195. time: '2025-01-01',
  196. status: 1,
  197. }))
  198. }
  199. ];
  200. });
  201. function tabClick(e: { index: number }) {
  202. activeTab.value = e.index;
  203. }
  204. function goMonth(month: number) {
  205. currentMonth.value = month;
  206. }
  207. async function changeYear(year: number) {
  208. currentYear.value = year;
  209. listLoader.loadData(undefined, true);
  210. }
  211. onLoad(() => {
  212. listLoader.loadData(undefined, true);
  213. });
  214. </script>
  215. <style lang="scss">
  216. @use "sass:map";
  217. @use "@/common/scss/define/colors.scss" as *;
  218. $color-primary: map.get($colors, "primary");
  219. .travel_calendar {
  220. .banner {
  221. margin-top: 0;
  222. .swiper {
  223. height: 400rpx;
  224. border-radius: 0 0 28rpx 28rpx;
  225. .item {
  226. image {
  227. border-radius: 0 0 28rpx 28rpx;
  228. }
  229. }
  230. }
  231. }
  232. .activity-wrap {
  233. display: flex;
  234. .activity-list {
  235. .head {
  236. background: #FFFFFF;
  237. border-radius: 28rpx;
  238. margin-bottom: 18rpx;
  239. color: #111111;
  240. padding: 12rpx 42rpx 12rpx 50rpx;
  241. display: flex;
  242. align-items: center;
  243. font-size: 24rpx;
  244. .year-month {
  245. font-weight: 600;
  246. font-size: 30rpx;
  247. flex: 1;
  248. }
  249. text {
  250. font-weight: 600;
  251. display: inline-block;
  252. margin-left: 12rpx;
  253. }
  254. }
  255. .activity {
  256. padding: 36rpx 32rpx 38rpx 48rpx;
  257. background: #FFFFFF;
  258. box-shadow: 0rpx 12rpx 28rpx 0rpx rgba(215, 215, 215, 0.35);
  259. border-radius: 24rpx;
  260. position: relative;
  261. font-size: 24rpx;
  262. overflow: hidden;
  263. margin-bottom: 46rpx;
  264. .desc {
  265. text-align: justify;
  266. margin-bottom: 36rpx;
  267. }
  268. .dot {
  269. width: 12rpx;
  270. height: 12rpx;
  271. background: #E0E0E0;
  272. border-radius: 50%;
  273. position: absolute;
  274. left: 20rpx;
  275. top: 50rpx;
  276. &.ing {
  277. background: $color-primary;
  278. }
  279. }
  280. .title {
  281. font-weight: 600;
  282. font-size: 30rpx;
  283. color: #111111;
  284. margin-bottom: 25rpx;
  285. }
  286. .place {
  287. margin-bottom: 18rpx;
  288. align-items: center;
  289. display: flex;
  290. font-size: 28rpx;
  291. }
  292. .iconfont {
  293. display: inline-block;
  294. margin-right: 6rpx;
  295. font-size: 36rpx;
  296. }
  297. .time {
  298. display: flex;
  299. align-items: center;
  300. font-size: 28rpx;
  301. }
  302. .status {
  303. position: absolute;
  304. bottom: 0;
  305. right: 0;
  306. background: $color-primary;
  307. padding: 14rpx 26rpx;
  308. border-radius: 31rpx 0rpx 0rpx 0rpx;
  309. color: #fff;
  310. view {
  311. font-size: 24rpx;
  312. }
  313. &.ing {
  314. background: #24515D;
  315. }
  316. &.end {
  317. background: #C9C9C9;
  318. }
  319. }
  320. }
  321. }
  322. .month-list {
  323. text-align: center;
  324. flex-shrink: 0;
  325. margin-right: 28rpx;
  326. .month {
  327. border-radius: 10rpx;
  328. margin-bottom: 30rpx;
  329. padding: 12rpx 20rpx;
  330. &.active {
  331. border: 1px solid $color-primary;
  332. background: #FFFFFF;
  333. }
  334. }
  335. }
  336. }
  337. scroll-view {
  338. height: calc(100vh - 540rpx);
  339. padding-bottom: 50rpx;
  340. }
  341. .change-year {
  342. padding: 0 34rpx 34rpx 34rpx;
  343. text-align: center;
  344. position: relative;
  345. display: flex;
  346. align-items: center;
  347. justify-content: center;
  348. .year {
  349. display: flex;
  350. align-items: center;
  351. justify-content: center;
  352. }
  353. .current-year {
  354. font-size: 36rpx;
  355. color: #333333;
  356. }
  357. text.icon-arrow-left {
  358. display: inline-block;
  359. margin-right: 100rpx;
  360. font-size: 32rpx;
  361. }
  362. text.icon-arrow-right {
  363. display: inline-block;
  364. margin-left: 100rpx;
  365. font-size: 32rpx;
  366. }
  367. text.icon-calendar {
  368. position: absolute;
  369. right: 0;
  370. top: 8rpx;
  371. }
  372. }
  373. }
  374. </style>