allActivity.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <view class="common_page adffc" :style="{'height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title="全部活动" bgColor="transparent"></cus-header>
  4. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/19/54b75bc8-d926-449b-95a5-1126f700b481.png" class="top_bg_img" mode="widthFix"></image>
  5. <view class="top-search" @click="toSearch">
  6. <cus-search ref="searchRef"></cus-search>
  7. </view>
  8. <view class="type adfacjb">
  9. <view class="type-list">
  10. <scroll-view class="scroll-view_H" scroll-x="true" scroll-with-animation="true" :scroll-left="scrollLeft">
  11. <view class="scroll-view-item_H" :id="'svih_'+index" v-for="(item,index) in typeList" :key="index" @click="changeType(item,index)">
  12. <view class="cl_item" :class="{'active':typeIndex===index}">
  13. <text>{{item.name}}</text>
  14. </view>
  15. </view>
  16. </scroll-view>
  17. </view>
  18. <view class="type-all" :class="{'active':typeIndex===''}" @click="handleAll">全部</view>
  19. </view>
  20. <view class="filter adfac" id="filter">
  21. <view class="filter-pre adfac" @click="showTime">
  22. <text>{{time}}</text>
  23. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/19/1813f2d7-42e9-4c5d-9d05-924e30568f9e.png"></image>
  24. </view>
  25. <view class="filter-pre adfac" @click="timeShow=false;allShow=false;placeShow=!placeShow">
  26. <text>{{place}}</text>
  27. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/19/1813f2d7-42e9-4c5d-9d05-924e30568f9e.png"></image>
  28. </view>
  29. <!-- <view class="filter-pre adfac">
  30. <text>{{status}}</text>
  31. <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/19/1813f2d7-42e9-4c5d-9d05-924e30568f9e.png"></image>
  32. </view> -->
  33. </view>
  34. <view class="list" id="list" :class="{'adffcacjc':list.length===0}">
  35. <template v-if="list.length">
  36. <up-list @scrolltolower="scrolltolower" style="height: 100%;">
  37. <up-list-item v-for="(item, index) in list" :key="item.id">
  38. <NonprofitActivety :item="item"></NonprofitActivety>
  39. </up-list-item>
  40. </up-list>
  41. </template>
  42. <page-empty text="暂无活动" v-else></page-empty>
  43. </view>
  44. <view class="window" :style="{'top':top+'px','height':'calc(100vh - '+top+'px)'}" v-if="timeShow">
  45. <view class="window-time">
  46. <view class="top adfac">
  47. <view class="top-pre" :class="{'active':wtIndex===0}" @click="changeWindowTime(0,'全部时间')">全部时间</view>
  48. <view class="top-pre" :class="{'active':wtIndex===1}" @click="changeWindowTime(1,'一周内')">一周内</view>
  49. <view class="top-pre" :class="{'active':wtIndex===2}" @click="changeWindowTime(2,'一月内')">一月内</view>
  50. <view class="top-pre" :class="{'active':wtIndex===3}" @click="changeWindowTime(3,'本周末')">本周末</view>
  51. </view>
  52. <view class="middle">
  53. <ActivityCalendar ref="acRef"></ActivityCalendar>
  54. </view>
  55. <view class="bottom adfacjb">
  56. <view class="reset" @click="changeWindowTime(0,'全部时间')">重置</view>
  57. <view class="confirm" @click="timeConfirm">确定</view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="window" :style="{'top':top+'px','height':'calc(100vh - '+top+'px)'}" v-if="placeShow">
  62. <view class="window-place">
  63. <ActivityArea @confirm="areaConfirm"></ActivityArea>
  64. </view>
  65. </view>
  66. <view class="window" :style="{'top':topAll+'px','height':'calc(100vh - '+topAll+'px)'}" v-if="allShow">
  67. <view class="window-all">
  68. <view class="pre" v-for="(t,i) in typeList2" :key="i" @click="changeType2(t,t.name,i)">{{t.name}}</view>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script setup name="">
  74. import CusHeader from '@/components/CusHeader/index.vue'
  75. import CusSearch from '@/components/CusSearch/index.vue'
  76. import NonprofitActivety from '@/components/pages/nonprofitActivety/index.vue'
  77. import ActivityCalendar from '@/components/pages/activityCalendar/index.vue'
  78. import ActivityArea from '@/components/pages/activityArea/index.vue'
  79. import PageEmpty from '@/components/pageEmpty/index.vue'
  80. import { ref, onMounted, nextTick, getCurrentInstance } from 'vue'
  81. const { proxy } = getCurrentInstance()
  82. const typeIndex = ref('')
  83. const typeList = ref([])
  84. const typeList2 = ref([])
  85. const scrollLeft = ref(0)
  86. const time = ref('全部时间')
  87. const timeText = ref('全部时间')
  88. const place = ref('全部地区')
  89. const status = ref('活动状态')
  90. const queryParams = ref({
  91. page:1,
  92. limit:10,
  93. activityName:'',
  94. categoryId:'',
  95. districtId:''
  96. })
  97. const isOver = ref(false)
  98. const list = ref([])
  99. const top = ref(0)
  100. const topAll = ref(0)
  101. const timeShow = ref(false)
  102. const placeShow = ref(false)
  103. const allShow = ref(false)
  104. const wtIndex = ref(0)
  105. const acRef = ref(null)
  106. const toSearch = () => {
  107. uni.navigateTo({
  108. url:'/pagesHome/searchActivity',
  109. events:{
  110. confirmSearch: data => {
  111. initList();
  112. proxy.$refs.searchRef.keyword = data;
  113. queryParams.value.activityName = data;
  114. getActivityList()
  115. }
  116. }
  117. })
  118. }
  119. const initList = () => {
  120. queryParams.value.page = 1;
  121. list.value = [];
  122. isOver.value = false;
  123. }
  124. const changeType = (item,index) => {
  125. initList();
  126. queryParams.value.categoryId = item.id;
  127. typeIndex.value = index;
  128. if(typeList.value.length>4){
  129. if(index<3) scrollLeft.value = 0
  130. else{
  131. scrollLeft.value = (index-2)*154/2;
  132. }
  133. }
  134. allShow.value = false;
  135. getActivityList()
  136. }
  137. const changeType2 = (item,name,index) => {
  138. initList();
  139. queryParams.value.categoryId = item.id;
  140. if(name==='全部'){
  141. typeIndex.value = '';
  142. scrollLeft.value = 0;
  143. }else{
  144. index--;
  145. typeIndex.value = index;
  146. if(typeList.value.length>4){
  147. if(index<3) scrollLeft.value = 0
  148. else{
  149. scrollLeft.value = (index-2)*154/2;
  150. }
  151. }
  152. }
  153. allShow.value = false;
  154. getActivityList()
  155. }
  156. const handleAll = () => {
  157. // typeIndex.value = '';
  158. // scrollLeft.value = 0;
  159. timeShow.value = false;
  160. placeShow.value = false;
  161. allShow.value = true;
  162. }
  163. const changeWindowTime = (wtindex,text) => {
  164. wtIndex.value = wtindex;
  165. timeText.value = text;
  166. acRef.value.setStartEndDay(wtindex);
  167. }
  168. const showTime = () => {
  169. placeShow.value = false;
  170. allShow.value = false;
  171. timeShow.value = !timeShow.value;
  172. setTimeout(()=>{
  173. acRef.value.setStartEndDay(wtIndex.value);
  174. },100)
  175. }
  176. const timeConfirm = () => {
  177. time.value = timeText.value;
  178. timeShow.value = false;
  179. }
  180. const areaConfirm = (data) => {
  181. initList()
  182. place.value = data.city+'-'+data.area;
  183. queryParams.value.districtId = data.areaId;
  184. placeShow.value = false;
  185. getActivityList()
  186. }
  187. const scrolltolower = () => {
  188. if(isOver.value) return
  189. getActivityList()
  190. }
  191. const getTop = () => {
  192. let query = uni.createSelectorQuery();
  193. query.select('#list').boundingClientRect(rect=>{
  194. if(rect){
  195. top.value = (rect?.top+20)||0;//20是上间距
  196. }
  197. }).exec()
  198. query.select('#filter').boundingClientRect(rect=>{
  199. if(rect){
  200. topAll.value = rect?.top||0;
  201. }
  202. }).exec()
  203. }
  204. const getTypeList = () => {
  205. proxy.$api.get('/core/activity/category/list').then(({data:res})=>{
  206. if(res.code!==0) return proxy.$showToast(res.msg)
  207. typeList.value = [...res.data.map(d=>({id:d.id,name:d.categoryName}))];
  208. typeList2.value = [{id:'',name:'全部'},...res.data.map(d=>({id:d.id,name:d.categoryName}))];
  209. })
  210. }
  211. const getActivityList = () => {
  212. proxy.$api.get('/core/activity/page',queryParams.value).then(({data:res})=>{
  213. if(res.code!==0) return proxy.$showToast(res.msg)
  214. list.value = [...list.value,...res.data.list];
  215. queryParams.value.page++;
  216. if(list.value>=res.data.total) isOver.value = true
  217. })
  218. }
  219. onMounted(()=>{
  220. getTypeList()
  221. getActivityList()
  222. nextTick(()=>{
  223. getTop();
  224. })
  225. })
  226. </script>
  227. <style scoped lang="scss">
  228. .scroll-view_H {
  229. white-space: nowrap;
  230. width: 100%;
  231. }
  232. .scroll-view-item_H {
  233. display: inline-block;
  234. height: 50rpx;
  235. margin-left: 42rpx;
  236. &:first-child{
  237. margin-left: 0;
  238. }
  239. }
  240. .common_page{
  241. .top-search{
  242. position: relative;
  243. margin-top: 20rpx;
  244. }
  245. .type{
  246. margin-top: 40rpx;
  247. width: 100%;
  248. height: 50rpx;
  249. position: relative;
  250. &-list{
  251. width: calc(100% - 72rpx);
  252. padding-right: 40rpx;
  253. box-sizing: border-box;
  254. .cl_item{
  255. width: 112rpx;
  256. line-height: 50rpx;
  257. font-family: PingFangSC, PingFang SC;
  258. font-weight: 400;
  259. font-size: 30rpx;
  260. color: #676775;
  261. &.active{
  262. font-weight: bold;
  263. font-size: 36rpx;
  264. color: #252525;
  265. line-height: 50rpx;
  266. }
  267. }
  268. }
  269. &-all{
  270. width: 72rpx;
  271. font-family: PingFangSC, PingFang SC;
  272. font-weight: 400;
  273. font-size: 28rpx;
  274. color: #676775;
  275. line-height: 40rpx;
  276. position: relative;
  277. &.active{
  278. font-weight: bold;
  279. font-size: 36rpx;
  280. color: #252525;
  281. line-height: 50rpx;
  282. &::after{
  283. content: '';
  284. width: 40rpx;
  285. height: 8rpx;
  286. background: linear-gradient( 270deg, #B7F358 0%, #00AE57 100%);
  287. border-radius: 4rpx;
  288. position: absolute;
  289. left: 50%;
  290. margin-left: -20rpx;
  291. bottom: -10rpx;
  292. }
  293. }
  294. }
  295. }
  296. .filter{
  297. margin-top: 33rpx;
  298. position: relative;
  299. &-pre{
  300. width: 186rpx;
  301. text{
  302. font-family: PingFang-SC, PingFang-SC;
  303. font-weight: bold;
  304. font-size: 24rpx;
  305. color: #252525;
  306. line-height: 33rpx;
  307. }
  308. image{
  309. width: 24rpx;
  310. height: 24rpx;
  311. margin-left: 6rpx;
  312. }
  313. }
  314. }
  315. .list{
  316. flex: 1;
  317. padding: 20rpx 0;
  318. box-sizing: border-box;
  319. overflow-y: auto;
  320. }
  321. }
  322. .window{
  323. width: 100%;
  324. position: fixed;
  325. left: 0;
  326. right: 0;
  327. background: rgba(0, 0, 0, .4);
  328. &-time{
  329. background: #FFFFFF;
  330. border-radius: 0 0 24rpx 24rpx;
  331. .top{
  332. padding: 32rpx 30rpx;
  333. &-pre{
  334. padding: 10rpx 24rpx;
  335. background: #F5F6F8;
  336. border-radius: 27rpx;
  337. font-family: PingFangSC, PingFang SC;
  338. font-weight: 400;
  339. font-size: 24rpx;
  340. color: #252525;
  341. line-height: 33rpx;
  342. margin-left: 20rpx;
  343. &:first-child{
  344. margin-left: 0;
  345. }
  346. &.active{
  347. background: #B7F358;
  348. font-weight: bold;
  349. }
  350. }
  351. }
  352. .middle{
  353. height: 594rpx;
  354. background: #F7F7F7;
  355. }
  356. .bottom{
  357. padding: 24rpx 24rpx 36rpx;
  358. .reset{
  359. width: 222rpx;
  360. height: 80rpx;
  361. border-radius: 45rpx;
  362. border: 1rpx solid #252525;
  363. font-family: PingFang-SC, PingFang-SC;
  364. font-weight: bold;
  365. font-size: 28rpx;
  366. color: #252525;
  367. line-height: 80rpx;
  368. text-align: center;
  369. letter-spacing: 2rpx;
  370. }
  371. .confirm{
  372. width: calc(100% - 252rpx);
  373. height: 80rpx;
  374. background: #B7F358;
  375. border-radius: 45rpx;
  376. font-family: PingFang-SC, PingFang-SC;
  377. font-weight: bold;
  378. font-size: 28rpx;
  379. color: #252525;
  380. line-height: 80rpx;
  381. text-align: center;
  382. }
  383. }
  384. }
  385. &-all{
  386. padding: 26rpx 30rpx 103rpx;
  387. background: #FFFFFF;
  388. display: flex;
  389. flex-wrap: wrap;
  390. justify-content: space-between;
  391. .pre{
  392. width: calc(100% / 3 - 12rpx);
  393. height: 59rpx;
  394. background: #F7F7F7;
  395. border-radius: 30rpx;
  396. font-family: PingFangSC, PingFang SC;
  397. font-weight: 400;
  398. font-size: 24rpx;
  399. color: #252525;
  400. line-height: 59rpx;
  401. text-align: center;
  402. margin-top: 24rpx;
  403. }
  404. }
  405. }
  406. </style>