allActivity.vue 12 KB

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