allActivity.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  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://oss.familydaf.cn/sxsnfile/20251218/c41452a8b9ae40629c6505b0c4fdcf64.png" class="top_bg_img" mode="widthFix"></image>
  5. <view class="top-search">
  6. <cus-search ref="searchRef" @handleSearch="doSearch"></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://oss.familydaf.cn/sxsnfile/20251218/5023dfb59c414a09808d86d5771e6c2c.png"></image>
  24. </view>
  25. <view class="filter-pre adfac" @click="showPlace">
  26. <text>{{place}}</text>
  27. <image src="https://oss.familydaf.cn/sxsnfile/20251218/5023dfb59c414a09808d86d5771e6c2c.png"></image>
  28. </view>
  29. <view class="filter-pre adfac" @click="showStatus">
  30. <text>{{status}}</text>
  31. <image src="https://oss.familydaf.cn/sxsnfile/20251218/5023dfb59c414a09808d86d5771e6c2c.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" :index="index"></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" @reset="areaReset"></ActivityArea>
  64. </view>
  65. </view>
  66. <view class="window nbg" :style="{'top':topAll+'px','height':'calc(100vh - '+topAll+'px)'}" v-if="allShow">
  67. <view class="window-bg" @click="handleAll"></view>
  68. <view class="window-all">
  69. <view class="wabox">
  70. <view class="pre" v-for="(t,i) in typeList2" :key="i" @click="changeType2(t,t.name,i)">{{t.name}}</view>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="window nbg" :style="{'top':topAll+'px','height':'calc(100vh - '+topAll+'px)'}" v-if="statusShow">
  75. <view class="window-bg" @click="statusShow=false"></view>
  76. <view class="window-status">
  77. <view
  78. class="status-option"
  79. :class="{'active': statusValue === item.value}"
  80. v-for="item in statusOptions"
  81. :key="item.value || 'all'"
  82. @click="changeStatus(item)"
  83. >{{item.name}}</view>
  84. </view>
  85. </view>
  86. <login-register></login-register>
  87. </view>
  88. </template>
  89. <script setup name="">
  90. import CusHeader from '@/components/CusHeader/index.vue'
  91. import CusSearch from '@/components/CusSearch/index.vue'
  92. import NonprofitActivety from '@/components/pages/nonprofitActivety/index.vue'
  93. import ActivityCalendar from '@/components/pages/activityCalendar/index.vue'
  94. import ActivityArea from '@/components/pages/activityArea/index.vue'
  95. import PageEmpty from '@/components/pageEmpty/index.vue'
  96. import { ref, onMounted, nextTick, getCurrentInstance, watch } from 'vue'
  97. import { onLoad } from '@dcloudio/uni-app'
  98. const { proxy } = getCurrentInstance()
  99. const loadedByKeyword = ref(false)
  100. onLoad(options => {
  101. if (options?.keyword) {
  102. loadedByKeyword.value = true
  103. const kw = decodeURIComponent(options.keyword)
  104. queryParams.value.activityName = kw
  105. nextTick(() => { if(proxy.$refs.searchRef) proxy.$refs.searchRef.keyword = kw })
  106. getActivityList()
  107. }
  108. })
  109. import { useUserStore } from '@/common/stores/user';
  110. const userStore = useUserStore();
  111. const typeIndex = ref('')
  112. const typeList = ref([])
  113. const typeList2 = ref([])
  114. const scrollLeft = ref(0)
  115. const time = ref('全部时间')
  116. const timeText = ref('全部时间')
  117. const place = ref('全部地区')
  118. const status = ref('活动状态')
  119. const statusValue = ref('')
  120. const statusOptions = [
  121. { name: '全部', value: '' },
  122. { name: '报名中', value: 1 },
  123. { name: '报名已截止', value: 2 },
  124. { name: '已结束', value: 3 }
  125. ]
  126. const queryParams = ref({
  127. page:1,
  128. limit:10,
  129. userId:'',
  130. activityName:'',
  131. beginTime:'',
  132. endTime:'',
  133. categoryId:'',
  134. districtId:'',
  135. activeState:''
  136. })
  137. const isOver = ref(false)
  138. const list = ref([])
  139. const top = ref(0)
  140. const topAll = ref(0)
  141. const timeShow = ref(false)
  142. const placeShow = ref(false)
  143. const allShow = ref(false)
  144. const statusShow = ref(false)
  145. const wtIndex = ref(0)
  146. const acRef = ref(null)
  147. watch(()=>userStore.token,(newVal,oldVal)=>{
  148. if(oldVal!=newVal&&newVal){
  149. setTimeout(()=>{
  150. uni.showToast({
  151. title: '登录成功',
  152. icon: 'success'
  153. });
  154. },200)
  155. nextTick(()=>{
  156. queryParams.value.userId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
  157. getTypeList()
  158. initList();
  159. getActivityList()
  160. nextTick(()=>{
  161. getTop();
  162. })
  163. })
  164. }
  165. })
  166. const doSearch = (keyword) => {
  167. if (!keyword) return
  168. initList()
  169. queryParams.value.activityName = keyword
  170. getActivityList()
  171. }
  172. const initList = () => {
  173. queryParams.value.page = 1;
  174. list.value = [];
  175. isOver.value = false;
  176. }
  177. const changeType = (item,index) => {
  178. initList();
  179. queryParams.value.categoryId = item.id;
  180. typeIndex.value = index;
  181. if(typeList.value.length>4){
  182. if(index<3) scrollLeft.value = 0
  183. else{
  184. scrollLeft.value = (index-2)*154/2;
  185. }
  186. }
  187. allShow.value = false;
  188. getActivityList()
  189. }
  190. const changeType2 = (item,name,index) => {
  191. initList();
  192. queryParams.value.categoryId = item.id;
  193. if(name==='全部'){
  194. typeIndex.value = '';
  195. // scrollLeft.value = 0;
  196. }else{
  197. index--;
  198. typeIndex.value = index;
  199. // if(typeList.value.length>4){
  200. // if(index<3) scrollLeft.value = 0
  201. // else{
  202. // scrollLeft.value = (index-2)*154/2;
  203. // }
  204. // }
  205. }
  206. allShow.value = false;
  207. getActivityList()
  208. }
  209. const handleAll = () => {
  210. // typeIndex.value = '';
  211. // scrollLeft.value = 0;
  212. timeShow.value = false;
  213. placeShow.value = false;
  214. statusShow.value = false;
  215. allShow.value = !allShow.value;
  216. }
  217. const showPlace = () => {
  218. timeShow.value = false
  219. allShow.value = false
  220. statusShow.value = false
  221. placeShow.value = !placeShow.value
  222. }
  223. const showStatus = () => {
  224. timeShow.value = false
  225. placeShow.value = false
  226. allShow.value = false
  227. statusShow.value = !statusShow.value
  228. }
  229. const changeStatus = (item) => {
  230. status.value = item.name
  231. statusValue.value = item.value
  232. queryParams.value.activeState = item.value
  233. statusShow.value = false
  234. initList()
  235. getActivityList()
  236. }
  237. const changeWindowTime = (wtindex,text) => {
  238. wtIndex.value = wtindex;
  239. timeText.value = text;
  240. acRef.value.setStartEndDay(wtindex);
  241. }
  242. const showTime = () => {
  243. placeShow.value = false;
  244. allShow.value = false;
  245. statusShow.value = false;
  246. timeShow.value = !timeShow.value;
  247. setTimeout(()=>{
  248. acRef.value.setStartEndDay(wtIndex.value);
  249. },100)
  250. }
  251. const timeConfirm = () => {
  252. time.value = timeText.value;
  253. timeShow.value = false;
  254. queryParams.value.beginTime = proxy.$refs.acRef.startDay;
  255. queryParams.value.endTime = proxy.$refs.acRef.endDay;
  256. initList()
  257. getActivityList()
  258. }
  259. const areaConfirm = (data) => {
  260. initList()
  261. place.value = data.city+'-'+data.area;
  262. queryParams.value.districtId = data.areaId;
  263. placeShow.value = false;
  264. getActivityList()
  265. }
  266. const areaReset = () => {
  267. initList()
  268. place.value = '全部地区'
  269. queryParams.value.districtId = ''
  270. placeShow.value = false
  271. getActivityList()
  272. }
  273. const scrolltolower = () => {
  274. if(isOver.value) return
  275. getActivityList()
  276. }
  277. const getTop = () => {
  278. let query = uni.createSelectorQuery();
  279. query.select('#list').boundingClientRect(rect=>{
  280. if(rect){
  281. top.value = (rect?.top+20)||0;//20是上间距
  282. }
  283. }).exec()
  284. query.select('#filter').boundingClientRect(rect=>{
  285. if(rect){
  286. topAll.value = rect?.top||0;
  287. }
  288. }).exec()
  289. }
  290. const getTypeList = () => {
  291. proxy.$api.get('/core/activity/category/list').then(({data:res})=>{
  292. if(res.code!==0) return proxy.$showToast(res.msg)
  293. typeList.value = [...res.data.map(d=>({id:d.id,name:d.categoryName}))];
  294. typeList2.value = [{id:'',name:'全部'},...res.data.map(d=>({id:d.id,name:d.categoryName}))];
  295. })
  296. }
  297. const getActivityList = () => {
  298. proxy.$api.get('/core/activity/page',queryParams.value).then(({data:res})=>{
  299. if(res.code!==0) return proxy.$showToast(res.msg)
  300. list.value = [...list.value,...res.data.list];
  301. list.value.forEach(a=>{
  302. a.signupEndTime = a.signupEndTime?new Date(a.signupEndTime).Format('yyyy.MM.dd hh:mm'):''
  303. })
  304. queryParams.value.page++;
  305. if(res.data.list.length===0) isOver.value = true
  306. })
  307. }
  308. const getActivityTickets = () => {
  309. }
  310. onMounted(()=>{
  311. if(uni.getStorageSync('userInfo')){
  312. queryParams.value.userId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
  313. }
  314. getTypeList()
  315. if (!loadedByKeyword.value) getActivityList()
  316. nextTick(()=>{
  317. getTop();
  318. })
  319. })
  320. </script>
  321. <style scoped lang="scss">
  322. .scroll-view_H {
  323. white-space: nowrap;
  324. width: 100%;
  325. }
  326. .scroll-view-item_H {
  327. display: inline-block;
  328. height: 50rpx;
  329. margin-left: 42rpx;
  330. &:first-child{
  331. margin-left: 0;
  332. }
  333. }
  334. .common_page{
  335. .top-search{
  336. position: relative;
  337. margin-top: 20rpx;
  338. }
  339. .type{
  340. margin-top: 40rpx;
  341. width: 100%;
  342. height: 50rpx;
  343. position: relative;
  344. &-list{
  345. width: calc(100% - 72rpx);
  346. padding-right: 40rpx;
  347. box-sizing: border-box;
  348. .cl_item{
  349. // width: 112rpx;
  350. line-height: 50rpx;
  351. font-family: PingFangSC, PingFang SC;
  352. font-weight: 400;
  353. font-size: 30rpx;
  354. color: #676775;
  355. &.active{
  356. font-weight: bold;
  357. font-size: 36rpx;
  358. color: #252525;
  359. line-height: 50rpx;
  360. }
  361. }
  362. }
  363. &-all{
  364. width: 72rpx;
  365. font-family: PingFangSC, PingFang SC;
  366. font-weight: 400;
  367. font-size: 28rpx;
  368. color: #676775;
  369. line-height: 40rpx;
  370. position: relative;
  371. &.active{
  372. font-weight: bold;
  373. font-size: 36rpx;
  374. color: #252525;
  375. line-height: 50rpx;
  376. &::after{
  377. content: '';
  378. width: 40rpx;
  379. height: 8rpx;
  380. background: linear-gradient( 270deg, #B7F358 0%, #00AE57 100%);
  381. border-radius: 4rpx;
  382. position: absolute;
  383. left: 50%;
  384. margin-left: -20rpx;
  385. bottom: -10rpx;
  386. }
  387. }
  388. }
  389. }
  390. .filter{
  391. margin-top: 33rpx;
  392. position: relative;
  393. &-pre{
  394. width: 186rpx;
  395. text{
  396. font-family: PingFang-SC, PingFang-SC;
  397. font-weight: bold;
  398. font-size: 24rpx;
  399. color: #252525;
  400. line-height: 33rpx;
  401. }
  402. image{
  403. width: 24rpx;
  404. height: 24rpx;
  405. margin-left: 6rpx;
  406. }
  407. }
  408. }
  409. .list{
  410. flex: 1;
  411. padding: 20rpx 0;
  412. box-sizing: border-box;
  413. overflow-y: auto;
  414. }
  415. }
  416. .window{
  417. width: 100%;
  418. position: fixed;
  419. left: 0;
  420. right: 0;
  421. background: rgba(0, 0, 0, .4);
  422. &-time{
  423. background: #FFFFFF;
  424. border-radius: 0 0 24rpx 24rpx;
  425. .top{
  426. padding: 32rpx 30rpx;
  427. &-pre{
  428. padding: 10rpx 24rpx;
  429. background: #F5F6F8;
  430. border-radius: 27rpx;
  431. font-family: PingFangSC, PingFang SC;
  432. font-weight: 400;
  433. font-size: 24rpx;
  434. color: #252525;
  435. line-height: 33rpx;
  436. margin-left: 20rpx;
  437. &:first-child{
  438. margin-left: 0;
  439. }
  440. &.active{
  441. background: #B7F358;
  442. font-weight: bold;
  443. }
  444. }
  445. }
  446. .middle{
  447. height: 594rpx;
  448. background: #F7F7F7;
  449. }
  450. .bottom{
  451. padding: 24rpx 24rpx 36rpx;
  452. .reset{
  453. width: 222rpx;
  454. height: 80rpx;
  455. border-radius: 45rpx;
  456. border: 1rpx solid #252525;
  457. font-family: PingFang-SC, PingFang-SC;
  458. font-weight: bold;
  459. font-size: 28rpx;
  460. color: #252525;
  461. line-height: 80rpx;
  462. text-align: center;
  463. letter-spacing: 2rpx;
  464. }
  465. .confirm{
  466. width: calc(100% - 252rpx);
  467. height: 80rpx;
  468. background: #B7F358;
  469. border-radius: 45rpx;
  470. font-family: PingFang-SC, PingFang-SC;
  471. font-weight: bold;
  472. font-size: 28rpx;
  473. color: #252525;
  474. line-height: 80rpx;
  475. text-align: center;
  476. }
  477. }
  478. }
  479. &-all{
  480. padding: 26rpx 30rpx 103rpx;
  481. background: #FFFFFF;
  482. border-radius: 0 0 24rpx 24rpx;
  483. .wabox{
  484. margin-left: -18rpx;
  485. overflow: hidden;
  486. }
  487. .pre{
  488. width: calc(100% / 3 - 18rpx);
  489. height: 59rpx;
  490. background: #F7F7F7;
  491. border-radius: 30rpx;
  492. font-family: PingFangSC, PingFang SC;
  493. font-weight: 400;
  494. font-size: 24rpx;
  495. color: #252525;
  496. line-height: 59rpx;
  497. text-align: center;
  498. margin-top: 24rpx;
  499. margin-left: 18rpx;
  500. float: left;
  501. }
  502. }
  503. &-status{
  504. padding: 26rpx 30rpx 40rpx;
  505. background: #FFFFFF;
  506. border-radius: 0 0 24rpx 24rpx;
  507. .status-option{
  508. display: inline-block;
  509. padding: 10rpx 24rpx;
  510. margin: 0 18rpx 18rpx 0;
  511. background: #F7F7F7;
  512. border-radius: 30rpx;
  513. font-family: PingFangSC, PingFang SC;
  514. font-size: 24rpx;
  515. color: #252525;
  516. line-height: 33rpx;
  517. &.active{
  518. background: #B7F358;
  519. font-weight: bold;
  520. }
  521. }
  522. }
  523. &.nbg{
  524. background: none;
  525. }
  526. &-bg{
  527. width: 100%;
  528. height: 100%;
  529. background: rgba(0, 0, 0, .4);
  530. position: absolute;
  531. z-index: -1;
  532. }
  533. }
  534. </style>