瀏覽代碼

Merge branch 'main' of http://git.ycjcjy.com/marketing/miniapp into main

张延森 3 年之前
父節點
當前提交
3762bd0e36

+ 1
- 1
src/pages/index/activityDetail/index.jsx 查看文件

@@ -42,7 +42,7 @@ const activityStatusDict = {
42 42
 };
43 43
 
44 44
 export default withLayout((props) => {
45
-  console.log(props, "props");
45
+  
46 46
   const { id } = props.router.params;
47 47
   const [detail, setDetail] = useState({});
48 48
   const [canChoose, setCanChoose] = useState("none");

+ 26
- 10
src/pages/index/components/HotRecommend/index.jsx 查看文件

@@ -3,15 +3,17 @@ import { useSelector } from 'react-redux'
3 3
 import Taro from '@tarojs/taro'
4 4
 import { fetch } from '@/utils/request'
5 5
 import { API_ACTIVITY_LIST } from '@/constants/api'
6
+import { queryActivityList, getActNewList } from '@/services/activity'
6 7
 import './index.scss'
7 8
 import '../../../../assets/css/iconfont.css'
8 9
 
9 10
 export default function HotRecommend () {
10 11
 
11 12
   const city = useSelector(state => state.city)
12
-  const [MenuList] = useState([{ name: '热门活动', id: 1 }, { name: '热门团房', id: 2 }])
13
-  const [CurrentId, setCurrentId] = useState(1)
14
-  const [CurrentContentInfo, setCurrentContentInfo] = useState({ name: '#大运河孔雀城时代', desc: '5月30日六一儿童节表演赛案场展开!' })
13
+  const [MenuList] = useState([{ name: '热门活动', id: 'dymic' }, { name: '热门团房', id: 'house' }])
14
+  const [CurrentId, setCurrentId] = useState('dymic')
15
+  const [list,setList]=useState([])
16
+  const [CurrentContentInfo, setCurrentContentInfo] = useState({ title: '#大运河孔雀城时代', desc: '5月30日六一儿童节表演赛案场展开!' })
15 17
 
16 18
   useEffect(() => {
17 19
     if(city.curCity.name) {
@@ -20,21 +22,34 @@ export default function HotRecommend () {
20 22
   }, [city])
21 23
 
22 24
   const GetRecommendActivity = () => {
23
-    fetch({url: API_ACTIVITY_LIST, method: 'get', payload: {pageNum: 1, pageSize: 1, cityId: city.curCity.id}}).then((res) => {
24
-      
25
-    })
25
+    
26
+      queryActivityList({home:1}).then((res)=>{
27
+        console.log(res,'-----------------')
28
+        setList(res.list)
29
+      })
26 30
   }
27 31
 
32
+  useEffect(() => {
33
+    if(list.length>0) {
34
+      setCurrentContentInfo(list.filter(x=>x.type==CurrentId)[0])
35
+    }
36
+  }, [CurrentId,list])
37
+
28 38
   const CutMenu = (id) => {
29 39
     return () => {
30 40
       setCurrentId(id)
31 41
     }
32 42
   }
33
-
43
+// x?type=dymic' },
44
+//     { name: '团房信息', id: 8, icon: require('../../../../assets/index-icon12.png'), router: '/pages/index/activityList/index?type=house'
34 45
   const ToMore = () => {
35 46
     Taro.navigateTo({url: `/pages/index/activityList/index?type=${CurrentId}`})
36 47
   }
37 48
 
49
+  const toDetail = () => {
50
+    Taro.navigateTo({url: `/pages/index/activityDetail/index?id=${CurrentContentInfo.dynamicId}`})
51
+  }
52
+  // url: `/pages/index/activityDetail/index?id=${data.dynamicId}`
38 53
   return (
39 54
     <view className='components HotRecommend'>
40 55
       <view>
@@ -45,10 +60,11 @@ export default function HotRecommend () {
45 60
             ))
46 61
           }
47 62
         </view>
48
-        <view className='Content'>
63
+        {console.log(CurrentContentInfo,'CurrentContentInfo')}
64
+        <view className='Content' onClick={toDetail}>
49 65
           <view className='flex-h'>
50
-            <text className='flex-item'>{CurrentContentInfo.name}</text>
51
-            <text onClick={ToMore}>{CurrentId === 1 ? '更多活动' : '更多团房'}</text>
66
+            <text className='flex-item'>{CurrentContentInfo.title}</text>
67
+            <text onClick={ToMore}>{CurrentId === 'dymic' ? '更多活动' : '更多团房'}</text>
52 68
           </view>
53 69
           <text>{CurrentContentInfo.desc}</text>
54 70
         </view>

+ 1
- 1
src/pages/index/components/LiveSale/index.jsx 查看文件

@@ -47,7 +47,7 @@ export default function LiveSale () {
47 47
             {
48 48
               PageList.map((item, index) => (
49 49
                 <view className='ListItem' key={`List-${index}`} style={{display: CurrentId === 1 || (CurrentId === 2 && item.kind === 'notice') || (CurrentId === 3 && item.kind === 'live')  || (CurrentId === 4 && item.kind !== 'notice') ? 'inline-block' : 'none'}}>
50
-                  <Image mode='aspectFill' className='centerLabel' src={`${getImgURL(item.images)}`} />
50
+                  <Image mode='aspectFill' className='centerLabel' onClick={()=>{}} src={`${getImgURL(item.images)}`} />
51 51
                 </view>
52 52
               ))
53 53
             }

+ 8
- 5
src/pages/index/components/NewsListItem/index.jsx 查看文件

@@ -2,17 +2,20 @@ import React, { useState, useEffect } from 'react'
2 2
 import './index.scss'
3 3
 import { Image } from '@tarojs/components'
4 4
 import Taro from '@tarojs/taro'
5
+import { getImgURL } from "@/utils/image";
6
+import getDateFormat from "@/utils/chatDate";
5 7
 
6 8
 export default function NewsListItem (props) {
7
-  const { Data = {} } = props
9
+  const { data = {} } = props
10
+  console.log(data,'data')
8 11
   return (
9
-    <view className='components NewsListItem flex-h' onClick={() => { Taro.navigateTo({ url: `/pages/index/newsDetail/index?id=${Data.id}` }) }}>
12
+    <view className='components NewsListItem flex-h' onClick={() => { Taro.navigateTo({ url: `/pages/index/newsDetail/index?id=${data.newsId}` }) }}>
10 13
       <view className='Img'>
11
-        <Image mode='aspectFill' src={null} className='centerLabel'></Image>
14
+        <Image mode='aspectFill' src={getImgURL(data.newsImg)} className='centerLabel'></Image>
12 15
       </view>
13 16
       <view className='flex-item'>
14
-        <text>破晓·内容生态下半场的版权之道2019企业版权</text>
15
-        <text>于2019-12-12 14:20:30发布</text>
17
+        <text>{data.newsName}</text>
18
+        <text>于{getDateFormat(new Date(data.createDate).valueOf(), true,"yyyy-M-d")}发布</text>
16 19
       </view>
17 20
     </view>
18 21
   )

+ 94
- 51
src/pages/index/newsDetail/index.jsx 查看文件

@@ -1,68 +1,111 @@
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 { Image, RichText } from '@tarojs/components'
1
+import React, { useState, useEffect } from "react";
2
+import Taro from "@tarojs/taro";
3
+import withLayout from "@/layout";
4
+import "./index.scss";
5
+import { ScrollView, Image, RichText,WebView } from "@tarojs/components";
6
+import "../../../assets/css/iconfont.css";
7
+import {
8
+  addNewsUv,
9
+  favorNews,
10
+  // addNewsShareNum,
11
+  queryNewsDetail,
12
+  cancelFavorNews,
13
+} from "@/services/news";
14
+import getDateFormat from "@/utils/chatDate";
7 15
 
8 16
 export default withLayout((props) => {
17
+  const { id } = props.router.params;
9 18
 
10
-  // const [PageProps] = useState(props)
11
-  const [PageList, setPageList] = useState(['', '', '', '', '', '', '', '', '', '', '', '', ''])
12
-  const [IsPull, setPull] = useState(false)
13
-  const [PullTimer, setPullTimer] = useState(null)
19
+  const [data, setData] = useState(null);
20
+  const [IsPull, setPull] = useState(false);
21
+  const [PullTimer, setPullTimer] = useState(null);
14 22
 
15
-  const PageRefresh = () => { // 页面下拉刷新回调
16
-    setPull(true)
17
-  }
23
+  const PageRefresh = () => {
24
+    // 页面下拉刷新回调
25
+    setPull(true);
26
+  };
18 27
 
19
-  useEffect(() => { // 下拉刷新触发
28
+  useEffect(() => {
29
+    // 下拉刷新触发
20 30
     if (IsPull) {
21
-      clearTimeout(PullTimer)
22
-      setPullTimer(setTimeout(() => {
23
-        setPull(false)
24
-      }, 2000))
31
+      clearTimeout(PullTimer);
32
+      setPullTimer(
33
+        setTimeout(() => {
34
+          setPull(false);
35
+        }, 2000)
36
+      );
25 37
     }
26
-  }, [IsPull])
38
+  }, [IsPull]);
27 39
 
28
-  return (
29
-    <view className='Page newsDetail flex-v'>
30
-      <view className='flex-item'>
31
-        <view>
32
-          <ScrollView scroll-y={true} refresher-enabled={true} refresher-triggered={IsPull} onrefresherrefresh={PageRefresh} refresher-background='#fff'>
33
-            <view className='PageContent'>
40
+  const getData = (params) => {
41
+    Taro.showLoading();
42
+    queryNewsDetail(params).then((res) => {
43
+  
44
+      setData(res);
45
+      Taro.hideLoading();
46
+    });
47
+  };
48
+
49
+  useEffect(() => {
50
+    if (id) {
51
+      getData(id);
52
+    }
53
+  }, [id]);
34 54
 
35
-              <view className='Info'>
36
-                <view>
37
-                  <text className='Title'>公积金又有新变化,附最新南京公积金贷款和提取方法。</text>
55
+  return (
56
+    <view className="Page newsDetail flex-v">
57
+      {data&& (data.newsDetailType === '0' ? <WebView src={data.newsDetail} /> :<>
58
+        <view className="flex-item">
59
+          <view>
60
+            <ScrollView
61
+              scroll-y={true}
62
+              refresher-enabled={true}
63
+              refresher-triggered={IsPull}
64
+              onrefresherrefresh={PageRefresh}
65
+              refresher-background="#fff"
66
+            >
67
+              <view className="PageContent">
68
+                <view className="Info">
38 69
                   <view>
39
-                    <text>阅读:28</text>
40
-                    <text>点赞15</text>
41
-                    <text>收藏22</text>
70
+                    <text className="Title">{data.newsName}</text>
71
+                    <view>
72
+                      <text>阅读:{data.pvNum || 0}</text>
73
+                      <text>点赞{data.favorNum || 0}</text>
74
+                      <text>收藏{data.saveNum || 0}</text>
75
+                    </view>
76
+                    <text className="Time">
77
+                      时间:
78
+                      {getDateFormat(
79
+                        new Date(data.createDate).valueOf(),
80
+                        true,
81
+                        "yyyy-M-d"
82
+                      )}{" "}
83
+                    </text>
84
+                    <text className="Share">分享好友</text>
42 85
                   </view>
43
-                  <text className='Time'>时间:2019-10-20 10:00 </text>
44
-                  <text className='Share'>分享好友</text>
45 86
                 </view>
46
-              </view>
47 87
 
48
-              <view className='Content'>
49
-                <RichText nodes={'<p>这是内容</p>'}></RichText>
88
+                <view className="Content">
89
+                  <RichText nodes={data.newsDetail}></RichText>
90
+                </view>
50 91
               </view>
51
-
52
-            </view>
53
-          </ScrollView>
54
-        </view>
55
-      </view>
56
-      <view className='Bottom'>
57
-        <view>
58
-          <Image mode='heightFix' src={require('../../../assets/buildingDetail-icon3.png')}></Image>
59
-          <text>生成海报</text>
92
+            </ScrollView>
93
+          </view>
60 94
         </view>
61
-        <view>
62
-          <text className='iconfont icon-shoucang'></text>
63
-          <text>收藏</text>
95
+        <view className="Bottom">
96
+          <view>
97
+            <Image
98
+              mode="heightFix"
99
+              src={require("../../../assets/buildingDetail-icon3.png")}
100
+            ></Image>
101
+            <text>生成海报</text>
102
+          </view>
103
+          <view>
104
+            <text className="iconfont icon-shoucang"></text>
105
+            <text>收藏</text>
106
+          </view>
64 107
         </view>
65
-      </view>
108
+      </>)}
66 109
     </view>
67
-  )
68
-})
110
+  );
111
+});

+ 62
- 2
src/pages/index/newsList/index.jsx 查看文件

@@ -4,11 +4,13 @@ import './index.scss'
4 4
 import { ScrollView } from '@tarojs/components'
5 5
 import '../../../assets/css/iconfont.css'
6 6
 import NewsListItem from '../components/NewsListItem/index'
7
+import { useDidShow } from '@tarojs/taro'
8
+import { queryNewsList } from '@/services/news'
7 9
 
8 10
 export default withLayout((props) => {
9 11
 
10 12
   // const [PageProps] = useState(props)
11
-  const [PageList, setPageList] = useState(['', '', '', '', '', '', '', '', '', '', '', '', ''])
13
+  const [PageList, setPageList] = useState([])
12 14
   const [IsPull, setPull] = useState(false)
13 15
   const [PullTimer, setPullTimer] = useState(null)
14 16
 
@@ -25,6 +27,64 @@ export default withLayout((props) => {
25 27
     }
26 28
   }, [IsPull])
27 29
 
30
+ 
31
+  // componentDidShow() {
32
+  //   // // this.onPullDownRefresh()
33
+  //   // console.log('----', this)
34
+  //   const pageSize = (Taro.getStorageSync('newsPageIndex') || 1) * 10
35
+  //   loadData(1, pageSize)
36
+  // }
37
+
38
+  // loadList(pageNumber, pageSize = 10) {
39
+  //   const { curCity: { id: cityId } } = this.props
40
+  //   const payload = { pageSize, pageNumber }
41
+
42
+  //   const { params: { buildingId, from } } = this.$router
43
+  //   if (cityId) {
44
+  //     payload.cityId = cityId
45
+  //   }
46
+  //   // 从个人中心过来
47
+  //   console.log(this.router, "from")
48
+  //   if (from === 'mine') {
49
+  //     payload.mine = true
50
+  //   }
51
+  //   // // 从项目详情过来
52
+  //   if (buildingId) {
53
+  //     payload.buildingId = buildingId
54
+  //   }
55
+  //   // return queryActivityList(payload)
56
+  //   return queryNewsList(payload)
57
+  // }
58
+
59
+  const loadData = (params) => {
60
+    // const currentPage = page || this.state.pageIndex
61
+
62
+    queryNewsList(params).then(res=>{
63
+      console.log(res,'queryNewsList')
64
+      const { records, list, total, current, pages, size } = res || {}
65
+      setPageList([...PageList, ...records])
66
+    })
67
+
68
+    // this.loadList(currentPage, pageSize).then(res => {
69
+    //   const { records, list, total, current, pages, size } = res || {}
70
+    //   const _list = records || list || []
71
+    //   const newList = current <= 1 ? _list : this.state.list.concat(_list)
72
+    //   console.log(res, '---res-------')
73
+    //   const pageNum = Math.max(Taro.getStorageSync('newsPageIndex'), current)
74
+    //   setPageList
75
+    //   this.setState({
76
+    //     list: newList,
77
+    //     isEmpty: total == 0,
78
+    //     hasMore: current * size < total,
79
+    //     pageIndex: pageNum,
80
+    //     // pageIndex: current >= pages ? pages : current,
81
+    //   })
82
+    // })
83
+  }
84
+  useEffect(()=>{
85
+    loadData({page : 0, pageSize : 10})
86
+  },[])
87
+
28 88
   return (
29 89
     <view className='Page newsList'>
30 90
 
@@ -33,7 +93,7 @@ export default withLayout((props) => {
33 93
 
34 94
           {
35 95
             PageList.map((item, index) => (
36
-              <NewsListItem></NewsListItem>
96
+              <NewsListItem data={item}></NewsListItem>
37 97
             ))
38 98
           }
39 99