allActivity.vue 13 KB

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