Yansen 1 vuosi sitten
vanhempi
commit
1761c654e5

+ 6
- 1
src/pages/index/components/order/index.jsx Näytä tiedosto

@@ -34,6 +34,11 @@ export default (props) => {
34 34
   const handleDetail = (val) => {
35 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 43
   const handleScrollToLower = () => {
39 44
     setCurrentPage(currentPage + 1)
@@ -156,7 +161,7 @@ export default (props) => {
156 161
           className='swiper'
157 162
         >
158 163
           {imgList.map((item, inx) => (
159
-            <SwiperItem key={inx}>
164
+            <SwiperItem key={inx} onClick={goToNews}>
160 165
               <Image src={item.thumb} mode='widthFix' className='storeImage' />
161 166
             </SwiperItem>
162 167
           ))}

+ 7
- 0
src/pages/news/index.config.js Näytä tiedosto

@@ -0,0 +1,7 @@
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 Näytä tiedosto

@@ -0,0 +1,37 @@
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 Näytä tiedosto

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