allActivity.vue 12 KB

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