allActivity.vue 13 KB

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