Yansen 1 year ago
parent
commit
1761c654e5

+ 6
- 1
src/pages/index/components/order/index.jsx View File

34
   const handleDetail = (val) => {
34
   const handleDetail = (val) => {
35
     Taro.navigateTo({ url: `/pages/orderDetail/index?id=${val}&job=1` });
35
     Taro.navigateTo({ url: `/pages/orderDetail/index?id=${val}&job=1` });
36
   }
36
   }
37
+
38
+  const goToNews = () => {
39
+    Taro.navigateTo({ url: `/pages/news/index` });
40
+  }
41
+
37
   // 上拉加载
42
   // 上拉加载
38
   const handleScrollToLower = () => {
43
   const handleScrollToLower = () => {
39
     setCurrentPage(currentPage + 1)
44
     setCurrentPage(currentPage + 1)
156
           className='swiper'
161
           className='swiper'
157
         >
162
         >
158
           {imgList.map((item, inx) => (
163
           {imgList.map((item, inx) => (
159
-            <SwiperItem key={inx}>
164
+            <SwiperItem key={inx} onClick={goToNews}>
160
               <Image src={item.thumb} mode='widthFix' className='storeImage' />
165
               <Image src={item.thumb} mode='widthFix' className='storeImage' />
161
             </SwiperItem>
166
             </SwiperItem>
162
           ))}
167
           ))}

+ 7
- 0
src/pages/news/index.config.js View File

1
+export default {
2
+  navigationBarTitleText: '农业资讯',
3
+  // navigationStyle: 'custom',
4
+  styleIsolation: 'shared',
5
+  enableShareAppMessage: true,
6
+  disableScroll: true,
7
+}

+ 37
- 0
src/pages/news/index.jsx View File

1
+import React from 'react';
2
+import Taro from '@tarojs/taro';
3
+import { View, Image, ScrollView } from '@tarojs/components';
4
+
5
+export default function (props) {
6
+
7
+  const [imgStyle, setStyle] = React.useState({ height: '100%' });
8
+
9
+  const onLoad = e => {
10
+    const { width, height } = e.detail;
11
+
12
+    if (width > 0 && height > 0) {
13
+      Taro.getSystemInfo({
14
+        success: res => {
15
+          const windowWidth = res.windowWidth;
16
+
17
+
18
+          setStyle({
19
+            height: `${windowWidth * height / width}px`,
20
+          });
21
+        }
22
+      })
23
+    }
24
+  }
25
+  
26
+  return (
27
+    <View className='page-index'>
28
+      <ScrollView scrollY style={{ height: '100%'  }}>
29
+        <Image
30
+          src='https://dz-machinery.oss-cn-nanjing.aliyuncs.com/images/news-demo1.png'
31
+          style={{ display: 'block', width: '100%', ...imgStyle }}
32
+          onLoad={onLoad}
33
+        />
34
+      </ScrollView>
35
+    </View>
36
+  );
37
+}

+ 4
- 0
src/routes.js View File

74
     title: '我的考勤',
74
     title: '我的考勤',
75
     page: 'pages/WorkInShifts/index',
75
     page: 'pages/WorkInShifts/index',
76
   }, 
76
   }, 
77
+  {
78
+    title: '农业资讯',
79
+    page: 'pages/news/index',
80
+  }, 
77
 ];
81
 ];
78
 
82
 
79
 // 所有的页面
83
 // 所有的页面