allActivity.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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" @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. <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 areaReset = () => {
  224. initList()
  225. place.value = '全部地区'
  226. queryParams.value.districtId = ''
  227. placeShow.value = false
  228. getActivityList()
  229. }
  230. const scrolltolower = () => {
  231. if(isOver.value) return
  232. getActivityList()
  233. }
  234. const getTop = () => {
  235. let query = uni.createSelectorQuery();
  236. query.select('#list').boundingClientRect(rect=>{
  237. if(rect){
  238. top.value = (rect?.top+20)||0;//20是上间距
  239. }
  240. }).exec()
  241. query.select('#filter').boundingClientRect(rect=>{
  242. if(rect){
  243. topAll.value = rect?.top||0;
  244. }
  245. }).exec()
  246. }
  247. const getTypeList = () => {
  248. proxy.$api.get('/core/activity/category/list').then(({data:res})=>{
  249. if(res.code!==0) return proxy.$showToast(res.msg)
  250. typeList.value = [...res.data.map(d=>({id:d.id,name:d.categoryName}))];
  251. typeList2.value = [{id:'',name:'全部'},...res.data.map(d=>({id:d.id,name:d.categoryName}))];
  252. })
  253. }
  254. const getActivityList = () => {
  255. proxy.$api.get('/core/activity/page',queryParams.value).then(({data:res})=>{
  256. if(res.code!==0) return proxy.$showToast(res.msg)
  257. list.value = [...list.value,...res.data.list];
  258. list.value.forEach(a=>{
  259. a.signupEndTime = a.signupEndTime?new Date(a.signupEndTime).Format('yyyy.MM.dd hh:mm'):''
  260. })
  261. queryParams.value.page++;
  262. if(res.data.list.length===0) isOver.value = true
  263. })
  264. }
  265. const getActivityTickets = () => {
  266. }
  267. onMounted(()=>{
  268. if(uni.getStorageSync('userInfo')){
  269. queryParams.value.userId = JSON.parse(uni.getStorageSync('userInfo'))?.id;
  270. }
  271. getTypeList()
  272. if (!loadedByKeyword.value) getActivityList()
  273. nextTick(()=>{
  274. getTop();
  275. })
  276. })
  277. </script>
  278. <style scoped lang="scss">
  279. .scroll-view_H {
  280. white-space: nowrap;
  281. width: 100%;
  282. }
  283. .scroll-view-item_H {
  284. display: inline-block;
  285. height: 50rpx;
  286. margin-left: 42rpx;
  287. &:first-child{
  288. margin-left: 0;
  289. }
  290. }
  291. .common_page{
  292. .top-search{
  293. position: relative;
  294. margin-top: 20rpx;
  295. }
  296. .type{
  297. margin-top: 40rpx;
  298. width: 100%;
  299. height: 50rpx;
  300. position: relative;
  301. &-list{
  302. width: calc(100% - 72rpx);
  303. padding-right: 40rpx;
  304. box-sizing: border-box;
  305. .cl_item{
  306. // width: 112rpx;
  307. line-height: 50rpx;
  308. font-family: PingFangSC, PingFang SC;
  309. font-weight: 400;
  310. font-size: 30rpx;
  311. color: #676775;
  312. &.active{
  313. font-weight: bold;
  314. font-size: 36rpx;
  315. color: #252525;
  316. line-height: 50rpx;
  317. }
  318. }
  319. }
  320. &-all{
  321. width: 72rpx;
  322. font-family: PingFangSC, PingFang SC;
  323. font-weight: 400;
  324. font-size: 28rpx;
  325. color: #676775;
  326. line-height: 40rpx;
  327. position: relative;
  328. &.active{
  329. font-weight: bold;
  330. font-size: 36rpx;
  331. color: #252525;
  332. line-height: 50rpx;
  333. &::after{
  334. content: '';
  335. width: 40rpx;
  336. height: 8rpx;
  337. background: linear-gradient( 270deg, #B7F358 0%, #00AE57 100%);
  338. border-radius: 4rpx;
  339. position: absolute;
  340. left: 50%;
  341. margin-left: -20rpx;
  342. bottom: -10rpx;
  343. }
  344. }
  345. }
  346. }
  347. .filter{
  348. margin-top: 33rpx;
  349. position: relative;
  350. &-pre{
  351. width: 186rpx;
  352. text{
  353. font-family: PingFang-SC, PingFang-SC;
  354. font-weight: bold;
  355. font-size: 24rpx;
  356. color: #252525;
  357. line-height: 33rpx;
  358. }
  359. image{
  360. width: 24rpx;
  361. height: 24rpx;
  362. margin-left: 6rpx;
  363. }
  364. }
  365. }
  366. .list{
  367. flex: 1;
  368. padding: 20rpx 0;
  369. box-sizing: border-box;
  370. overflow-y: auto;
  371. }
  372. }
  373. .window{
  374. width: 100%;
  375. position: fixed;
  376. left: 0;
  377. right: 0;
  378. background: rgba(0, 0, 0, .4);
  379. &-time{
  380. background: #FFFFFF;
  381. border-radius: 0 0 24rpx 24rpx;
  382. .top{
  383. padding: 32rpx 30rpx;
  384. &-pre{
  385. padding: 10rpx 24rpx;
  386. background: #F5F6F8;
  387. border-radius: 27rpx;
  388. font-family: PingFangSC, PingFang SC;
  389. font-weight: 400;
  390. font-size: 24rpx;
  391. color: #252525;
  392. line-height: 33rpx;
  393. margin-left: 20rpx;
  394. &:first-child{
  395. margin-left: 0;
  396. }
  397. &.active{
  398. background: #B7F358;
  399. font-weight: bold;
  400. }
  401. }
  402. }
  403. .middle{
  404. height: 594rpx;
  405. background: #F7F7F7;
  406. }
  407. .bottom{
  408. padding: 24rpx 24rpx 36rpx;
  409. .reset{
  410. width: 222rpx;
  411. height: 80rpx;
  412. border-radius: 45rpx;
  413. border: 1rpx solid #252525;
  414. font-family: PingFang-SC, PingFang-SC;
  415. font-weight: bold;
  416. font-size: 28rpx;
  417. color: #252525;
  418. line-height: 80rpx;
  419. text-align: center;
  420. letter-spacing: 2rpx;
  421. }
  422. .confirm{
  423. width: calc(100% - 252rpx);
  424. height: 80rpx;
  425. background: #B7F358;
  426. border-radius: 45rpx;
  427. font-family: PingFang-SC, PingFang-SC;
  428. font-weight: bold;
  429. font-size: 28rpx;
  430. color: #252525;
  431. line-height: 80rpx;
  432. text-align: center;
  433. }
  434. }
  435. }
  436. &-all{
  437. padding: 26rpx 30rpx 103rpx;
  438. background: #FFFFFF;
  439. border-radius: 0 0 24rpx 24rpx;
  440. .wabox{
  441. margin-left: -18rpx;
  442. overflow: hidden;
  443. }
  444. .pre{
  445. width: calc(100% / 3 - 18rpx);
  446. height: 59rpx;
  447. background: #F7F7F7;
  448. border-radius: 30rpx;
  449. font-family: PingFangSC, PingFang SC;
  450. font-weight: 400;
  451. font-size: 24rpx;
  452. color: #252525;
  453. line-height: 59rpx;
  454. text-align: center;
  455. margin-top: 24rpx;
  456. margin-left: 18rpx;
  457. float: left;
  458. }
  459. }
  460. &.nbg{
  461. background: none;
  462. }
  463. &-bg{
  464. width: 100%;
  465. height: 100%;
  466. background: rgba(0, 0, 0, .4);
  467. position: absolute;
  468. z-index: -1;
  469. }
  470. }
  471. </style>