allActivity.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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. userId:'',
  94. activityName:'',
  95. categoryId:'',
  96. districtId:''
  97. })
  98. const isOver = ref(false)
  99. const list = ref([])
  100. const top = ref(0)
  101. const topAll = ref(0)
  102. const timeShow = ref(false)
  103. const placeShow = ref(false)
  104. const allShow = ref(false)
  105. const wtIndex = ref(0)
  106. const acRef = ref(null)
  107. const toSearch = () => {
  108. uni.navigateTo({
  109. url:'/pagesHome/searchActivity',
  110. events:{
  111. confirmSearch: data => {
  112. initList();
  113. proxy.$refs.searchRef.keyword = data;
  114. queryParams.value.activityName = data;
  115. getActivityList()
  116. }
  117. }
  118. })
  119. }
  120. const initList = () => {
  121. queryParams.value.page = 1;
  122. list.value = [];
  123. isOver.value = false;
  124. }
  125. const changeType = (item,index) => {
  126. initList();
  127. queryParams.value.categoryId = item.id;
  128. typeIndex.value = index;
  129. if(typeList.value.length>4){
  130. if(index<3) scrollLeft.value = 0
  131. else{
  132. scrollLeft.value = (index-2)*154/2;
  133. }
  134. }
  135. allShow.value = false;
  136. getActivityList()
  137. }
  138. const changeType2 = (item,name,index) => {
  139. initList();
  140. queryParams.value.categoryId = item.id;
  141. if(name==='全部'){
  142. typeIndex.value = '';
  143. scrollLeft.value = 0;
  144. }else{
  145. index--;
  146. typeIndex.value = index;
  147. if(typeList.value.length>4){
  148. if(index<3) scrollLeft.value = 0
  149. else{
  150. scrollLeft.value = (index-2)*154/2;
  151. }
  152. }
  153. }
  154. allShow.value = false;
  155. getActivityList()
  156. }
  157. const handleAll = () => {
  158. // typeIndex.value = '';
  159. // scrollLeft.value = 0;
  160. timeShow.value = false;
  161. placeShow.value = false;
  162. allShow.value = true;
  163. }
  164. const changeWindowTime = (wtindex,text) => {
  165. wtIndex.value = wtindex;
  166. timeText.value = text;
  167. acRef.value.setStartEndDay(wtindex);
  168. }
  169. const showTime = () => {
  170. placeShow.value = false;
  171. allShow.value = false;
  172. timeShow.value = !timeShow.value;
  173. setTimeout(()=>{
  174. acRef.value.setStartEndDay(wtIndex.value);
  175. },100)
  176. }
  177. const timeConfirm = () => {
  178. time.value = timeText.value;
  179. timeShow.value = false;
  180. }
  181. const areaConfirm = (data) => {
  182. initList()
  183. place.value = data.city+'-'+data.area;
  184. queryParams.value.districtId = data.areaId;
  185. placeShow.value = false;
  186. getActivityList()
  187. }
  188. const scrolltolower = () => {
  189. if(isOver.value) return
  190. getActivityList()
  191. }
  192. const getTop = () => {
  193. let query = uni.createSelectorQuery();
  194. query.select('#list').boundingClientRect(rect=>{
  195. if(rect){
  196. top.value = (rect?.top+20)||0;//20是上间距
  197. }
  198. }).exec()
  199. query.select('#filter').boundingClientRect(rect=>{
  200. if(rect){
  201. topAll.value = rect?.top||0;
  202. }
  203. }).exec()
  204. }
  205. const getTypeList = () => {
  206. proxy.$api.get('/core/activity/category/list').then(({data:res})=>{
  207. if(res.code!==0) return proxy.$showToast(res.msg)
  208. typeList.value = [...res.data.map(d=>({id:d.id,name:d.categoryName}))];
  209. typeList2.value = [{id:'',name:'全部'},...res.data.map(d=>({id:d.id,name:d.categoryName}))];
  210. })
  211. }
  212. const getActivityList = () => {
  213. proxy.$api.get('/core/activity/page',queryParams.value).then(({data:res})=>{
  214. if(res.code!==0) return proxy.$showToast(res.msg)
  215. list.value = [...list.value,...res.data.list];
  216. queryParams.value.page++;
  217. if(list.value>=res.data.total) isOver.value = true
  218. })
  219. }
  220. onMounted(()=>{
  221. if(uni.getStorageSync('userInfo')){
  222. queryParams.value.userId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
  223. }
  224. getTypeList()
  225. getActivityList()
  226. nextTick(()=>{
  227. getTop();
  228. })
  229. })
  230. </script>
  231. <style scoped lang="scss">
  232. .scroll-view_H {
  233. white-space: nowrap;
  234. width: 100%;
  235. }
  236. .scroll-view-item_H {
  237. display: inline-block;
  238. height: 50rpx;
  239. margin-left: 42rpx;
  240. &:first-child{
  241. margin-left: 0;
  242. }
  243. }
  244. .common_page{
  245. .top-search{
  246. position: relative;
  247. margin-top: 20rpx;
  248. }
  249. .type{
  250. margin-top: 40rpx;
  251. width: 100%;
  252. height: 50rpx;
  253. position: relative;
  254. &-list{
  255. width: calc(100% - 72rpx);
  256. padding-right: 40rpx;
  257. box-sizing: border-box;
  258. .cl_item{
  259. width: 112rpx;
  260. line-height: 50rpx;
  261. font-family: PingFangSC, PingFang SC;
  262. font-weight: 400;
  263. font-size: 30rpx;
  264. color: #676775;
  265. &.active{
  266. font-weight: bold;
  267. font-size: 36rpx;
  268. color: #252525;
  269. line-height: 50rpx;
  270. }
  271. }
  272. }
  273. &-all{
  274. width: 72rpx;
  275. font-family: PingFangSC, PingFang SC;
  276. font-weight: 400;
  277. font-size: 28rpx;
  278. color: #676775;
  279. line-height: 40rpx;
  280. position: relative;
  281. &.active{
  282. font-weight: bold;
  283. font-size: 36rpx;
  284. color: #252525;
  285. line-height: 50rpx;
  286. &::after{
  287. content: '';
  288. width: 40rpx;
  289. height: 8rpx;
  290. background: linear-gradient( 270deg, #B7F358 0%, #00AE57 100%);
  291. border-radius: 4rpx;
  292. position: absolute;
  293. left: 50%;
  294. margin-left: -20rpx;
  295. bottom: -10rpx;
  296. }
  297. }
  298. }
  299. }
  300. .filter{
  301. margin-top: 33rpx;
  302. position: relative;
  303. &-pre{
  304. width: 186rpx;
  305. text{
  306. font-family: PingFang-SC, PingFang-SC;
  307. font-weight: bold;
  308. font-size: 24rpx;
  309. color: #252525;
  310. line-height: 33rpx;
  311. }
  312. image{
  313. width: 24rpx;
  314. height: 24rpx;
  315. margin-left: 6rpx;
  316. }
  317. }
  318. }
  319. .list{
  320. flex: 1;
  321. padding: 20rpx 0;
  322. box-sizing: border-box;
  323. overflow-y: auto;
  324. }
  325. }
  326. .window{
  327. width: 100%;
  328. position: fixed;
  329. left: 0;
  330. right: 0;
  331. background: rgba(0, 0, 0, .4);
  332. &-time{
  333. background: #FFFFFF;
  334. border-radius: 0 0 24rpx 24rpx;
  335. .top{
  336. padding: 32rpx 30rpx;
  337. &-pre{
  338. padding: 10rpx 24rpx;
  339. background: #F5F6F8;
  340. border-radius: 27rpx;
  341. font-family: PingFangSC, PingFang SC;
  342. font-weight: 400;
  343. font-size: 24rpx;
  344. color: #252525;
  345. line-height: 33rpx;
  346. margin-left: 20rpx;
  347. &:first-child{
  348. margin-left: 0;
  349. }
  350. &.active{
  351. background: #B7F358;
  352. font-weight: bold;
  353. }
  354. }
  355. }
  356. .middle{
  357. height: 594rpx;
  358. background: #F7F7F7;
  359. }
  360. .bottom{
  361. padding: 24rpx 24rpx 36rpx;
  362. .reset{
  363. width: 222rpx;
  364. height: 80rpx;
  365. border-radius: 45rpx;
  366. border: 1rpx solid #252525;
  367. font-family: PingFang-SC, PingFang-SC;
  368. font-weight: bold;
  369. font-size: 28rpx;
  370. color: #252525;
  371. line-height: 80rpx;
  372. text-align: center;
  373. letter-spacing: 2rpx;
  374. }
  375. .confirm{
  376. width: calc(100% - 252rpx);
  377. height: 80rpx;
  378. background: #B7F358;
  379. border-radius: 45rpx;
  380. font-family: PingFang-SC, PingFang-SC;
  381. font-weight: bold;
  382. font-size: 28rpx;
  383. color: #252525;
  384. line-height: 80rpx;
  385. text-align: center;
  386. }
  387. }
  388. }
  389. &-all{
  390. padding: 26rpx 30rpx 103rpx;
  391. background: #FFFFFF;
  392. display: flex;
  393. flex-wrap: wrap;
  394. justify-content: space-between;
  395. .pre{
  396. width: calc(100% / 3 - 12rpx);
  397. height: 59rpx;
  398. background: #F7F7F7;
  399. border-radius: 30rpx;
  400. font-family: PingFangSC, PingFang SC;
  401. font-weight: 400;
  402. font-size: 24rpx;
  403. color: #252525;
  404. line-height: 59rpx;
  405. text-align: center;
  406. margin-top: 24rpx;
  407. }
  408. }
  409. }
  410. </style>