allActivity.vue 13 KB

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