zlisen преди 3 години
родител
ревизия
0e0788290b
променени са 3 файла, в които са добавени 78 реда и са изтрити 54 реда
  1. 2
    2
      config/dev.js
  2. 12
    6
      src/pages/index/activityList/index.jsx
  3. 64
    46
      src/pages/index/newsList/index.jsx

+ 2
- 2
config/dev.js Целия файл

@@ -3,8 +3,8 @@ module.exports = {
3 3
     NODE_ENV: '"development"'
4 4
   },
5 5
   defineConstants: {
6
-    // HOST: '"https://xlk.njyz.tech"',
7
-    HOST: '"http://127.0.0.1:8081"',
6
+    HOST: '"https://xlk.njyz.tech"',
7
+    // HOST: '"http://127.0.0.1:8081"',
8 8
     WSS_HOST: '"wss://xlk.njyz.tech"',
9 9
     OSS_PATH: '"https://zhiyun-image.oss-accelerate.aliyuncs.com/"',
10 10
     OSS_FAST_PATH: '"https://zhiyun-image.oss-accelerate.aliyuncs.com/"',

+ 12
- 6
src/pages/index/activityList/index.jsx Целия файл

@@ -10,9 +10,9 @@ import ActivityListItem from '../components/ActivityListItem/index'
10 10
 import './index.scss'
11 11
 
12 12
 export default function MyCollectForActivity (props) {
13
- const router=useRouter()
14 13
 
15
-   const { type } = router.params;
14
+ const router=useRouter()
15
+   const { type,buildingId } = router.params;
16 16
   const city = useSelector(state => state.city)
17 17
  
18 18
   const [PageList, setPageList] = useState([])
@@ -35,16 +35,22 @@ export default function MyCollectForActivity (props) {
35 35
   
36 36
 
37 37
  const getList = (params) => {
38
-  queryActivityList({...params,type,cityId: city.curCity.id}).then((res)=>{
38
+  params.cityId = city.curCity.id;
39
+  if(buildingId){
40
+    params.buildingId = buildingId;
41
+  }else{
42
+    params.cityId = city?.curCity?.id;
43
+  }
44
+  queryActivityList({...params,type}).then((res)=>{
39 45
     setPageList(res.list)
40 46
   })
41 47
   }
42 48
   useEffect(()=>{
43
-    if(city?.curCity?.id){
49
+ 
44 50
       getList({page :0, pageSize : 10})
45
-    }
51
+
46 52
    
47
-  },[city])
53
+  },[])
48 54
   // useDidShow(() => {
49 55
   //   getList({page :0, pageSize : 10})
50 56
   // })

+ 64
- 46
src/pages/index/newsList/index.jsx Целия файл

@@ -1,33 +1,40 @@
1
-import React, { useState, useEffect } from 'react'
2
-import withLayout from '@/layout'
3
-import './index.scss'
4
-import { ScrollView } from '@tarojs/components'
5
-import '@/assets/css/iconfont.css'
6
-import NewsListItem from '../components/NewsListItem/index'
7
-import { useDidShow } from '@tarojs/taro'
8
-import { queryNewsList } from '@/services/news'
1
+import React, { useState, useEffect } from "react";
2
+import { useRouter } from "@tarojs/taro";
3
+import { useSelector } from "react-redux";
4
+import withLayout from "@/layout";
5
+import "./index.scss";
6
+import { ScrollView } from "@tarojs/components";
7
+import "@/assets/css/iconfont.css";
8
+import NewsListItem from "../components/NewsListItem/index";
9
+import { useDidShow } from "@tarojs/taro";
10
+import { queryNewsList } from "@/services/news";
9 11
 
10 12
 export default withLayout((props) => {
11
-
13
+  const router = useRouter();
14
+  const { buildingId, from } = router.params;
15
+  const city = useSelector((state) => state.city);
12 16
   // const [PageProps] = useState(props)
13
-  const [PageList, setPageList] = useState([])
14
-  const [IsPull, setPull] = useState(false)
15
-  const [PullTimer, setPullTimer] = useState(null)
17
+  const [PageList, setPageList] = useState([]);
18
+  const [IsPull, setPull] = useState(false);
19
+  const [PullTimer, setPullTimer] = useState(null);
16 20
 
17
-  const PageRefresh = () => { // 页面下拉刷新回调
18
-    setPull(true)
19
-  }
21
+  const PageRefresh = () => {
22
+    // 页面下拉刷新回调
23
+    setPull(true);
24
+  };
20 25
 
21
-  useEffect(() => { // 下拉刷新触发
26
+  useEffect(() => {
27
+    // 下拉刷新触发
22 28
     if (IsPull) {
23
-      clearTimeout(PullTimer)
24
-      setPullTimer(setTimeout(() => {
25
-        setPull(false)
26
-      }, 2000))
29
+      clearTimeout(PullTimer);
30
+      setPullTimer(
31
+        setTimeout(() => {
32
+          setPull(false);
33
+        }, 2000)
34
+      );
27 35
     }
28
-  }, [IsPull])
36
+  }, [IsPull]);
29 37
 
30
- 
31 38
   // componentDidShow() {
32 39
   //   // // this.onPullDownRefresh()
33 40
   //   // console.log('----', this)
@@ -58,12 +65,23 @@ export default withLayout((props) => {
58 65
 
59 66
   const loadData = (params) => {
60 67
     // const currentPage = page || this.state.pageIndex
68
+    // const { curCity: { id: cityId } } = this.props
69
+
70
+ 
71
+    // if (from === "mine") {
72
+    //   params.mine = true;
73
+    // }
74
+    // // 从项目详情过来
75
+    if (buildingId) {
76
+      params.buildingId = buildingId;
77
+    }else if(city?.curCity?.id){
78
+      params.cityId = city.curCity.id;
79
+    }
61 80
 
62
-    queryNewsList(params).then(res=>{
63
-      console.log(res,'queryNewsList')
64
-      const { records, list, total, current, pages, size } = res || {}
65
-      setPageList([...PageList, ...records])
66
-    })
81
+    queryNewsList(params).then((res) => {
82
+      const { records, list, total, current, pages, size } = res || {};
83
+      setPageList([...PageList, ...records]);
84
+    });
67 85
 
68 86
     // this.loadList(currentPage, pageSize).then(res => {
69 87
     //   const { records, list, total, current, pages, size } = res || {}
@@ -80,31 +98,31 @@ export default withLayout((props) => {
80 98
     //     // pageIndex: current >= pages ? pages : current,
81 99
     //   })
82 100
     // })
83
-  }
84
-  useEffect(()=>{
85
-    loadData({page : 0, pageSize : 10})
86
-  },[])
101
+  };
102
+  useEffect(() => {
103
+    loadData({ page: 0, pageSize: 10 });
104
+  }, []);
87 105
 
88 106
   return (
89
-    <view className='Page newsList'>
90
-
91
-      <ScrollView scroll-y={true} refresher-enabled={true} refresher-triggered={IsPull} onrefresherrefresh={PageRefresh} refresher-background='#fff'>
92
-        <view className='PageContent'>
93
-
94
-          {
95
-            PageList.map((item, index) => (
96
-              <NewsListItem data={item}></NewsListItem>
97
-            ))
98
-          }
107
+    <view className="Page newsList">
108
+      <ScrollView
109
+        scroll-y={true}
110
+        refresher-enabled={true}
111
+        refresher-triggered={IsPull}
112
+        onrefresherrefresh={PageRefresh}
113
+        refresher-background="#fff"
114
+      >
115
+        <view className="PageContent">
116
+          {PageList.map((item, index) => (
117
+            <NewsListItem data={item}></NewsListItem>
118
+          ))}
99 119
 
100 120
           {/* bottom */}
101
-          <view className='PageBottom'>
121
+          <view className="PageBottom">
102 122
             <text>已经到底了~</text>
103 123
           </view>
104
-
105 124
         </view>
106 125
       </ScrollView>
107
-
108 126
     </view>
109
-  )
110
-})
127
+  );
128
+});