allActivity.vue 13 KB

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