张涛 hace 1 año
padre
commit
3b4b66a849

+ 2
- 2
config/dev.js Ver fichero

@@ -4,10 +4,10 @@ module.exports = {
4 4
   },
5 5
   defineConstants: {
6 6
     // HOST: '"http://127.0.0.1:9087"',
7
-    HOST: '"http://192.168.89.13:9087"',
7
+    HOST: '""',
8 8
     // HOST: '"https://wmcj.huoshannews.com"',
9 9
     AD_IMAGE: '"https://h5.njyunzhi.com/images/citizen_banner.png"',
10
-    DEFAULT_POS: '"116.3476917447715,31.409912844296578"', // 霍山县人民政府 gcj02
10
+    DEFAULT_POS: '"116.34761502876347,31.40974743425614"', // 霍山县人民政府 gcj02
11 11
     VERSION: '"1.1.13-20230325"',
12 12
   },
13 13
   // isWatch:true,

+ 15
- 17
config/index.js Ver fichero

@@ -4,18 +4,19 @@ const path = require("path");
4 4
 
5 5
 import devConfig from "./dev";
6 6
 import prodConfig from "./prod";
7
-const url = "http://127.0.0.1:9087";
7
+const url = "http://localhost:9087";
8
+const url2 = "https://apis.map.qq.com";
8 9
 
9 10
 export default defineConfig(async (merge, { command, mode }) => {
10 11
   const config = {
11 12
     projectName: "civilized-miniapp",
12 13
     date: "2024-03-21",
13 14
     designWidth(input) {
14
-      console.log('---->', input?.file)
15
+      console.log("---->", input?.file);
15 16
       // if (input?.file.replace(/\\+/g, '/').indexOf('@antmjs/vantui') > -1) {
16 17
       //   return 750
17 18
       // }
18
-      return 750
19
+      return 750;
19 20
     },
20 21
     deviceRatio: {
21 22
       640: 2.34 / 2,
@@ -60,27 +61,19 @@ export default defineConfig(async (merge, { command, mode }) => {
60 61
     //   },
61 62
     // },
62 63
     h5: {
63
-      esnextModules: ["@antmjs"],
64 64
       publicPath: "/",
65 65
       staticDirectory: "static",
66 66
       outputDir: "dist",
67 67
       router: {
68 68
         mode: "hash",
69 69
       },
70
-      esnextModules: ['@antmjs'],
71
-      // miniCssExtractPluginOption: {
72
-      //   ignoreOrder: true,
73
-      //   filename: "css/[name].[hash].css",
74
-      //   chunkFilename: "css/[id].css",
75
-      // },
76
-
70
+      esnextModules: ["@antmjs"],
77 71
       postcss: {
78 72
         autoprefixer: {
79 73
           enable: true,
80
-          config: {
81
-          }
74
+          config: {},
82 75
         },
83
-     
76
+
84 77
         pxtransform: {
85 78
           enable: true,
86 79
           config: {
@@ -108,13 +101,18 @@ export default defineConfig(async (merge, { command, mode }) => {
108 101
       },
109 102
       devServer: {
110 103
         proxy: {
111
-          "/api": {
112
-            target: url, // 服务端地址
104
+          "/api2": {
105
+            target: url2, // 服务端地址
106
+            changeOrigin: true,
113 107
             pathRewrite: {
114
-              "^/api": "",
108
+              "^/api2": "",
115 109
             },
110
+          },
111
+          "/api": {
112
+            target: url, // 服务端地址
116 113
             changeOrigin: true,
117 114
           },
115
+         
118 116
         },
119 117
       },
120 118
     },

+ 1
- 1
config/prod.js Ver fichero

@@ -6,7 +6,7 @@ module.exports = {
6 6
     // HOST: '"http://192.168.89.147:9087"',
7 7
     HOST: '"https://wmcj.ycjcjy.com"',
8 8
     AD_IMAGE: '"https://h5.njyunzhi.com/images/citizen_banner.png"',
9
-    DEFAULT_POS: '"118.91,32.07"', // gcj02
9
+    DEFAULT_POS: '"31.416373,116.373904"', // gcj02
10 10
     VERSION: '"1.1.29-20240224"',
11 11
   },
12 12
   mini: {},

+ 5
- 11
src/app.js Ver fichero

@@ -3,25 +3,19 @@ import store, { Provider, getState } from "@/store";
3 3
 import "./app.less";
4 4
 import { useEffect, useMemo } from "react";
5 5
 // import wxsdk from "./utils/wx";
6
-import '@antmjs/vantui/lib/index.less'
6
+import "@antmjs/vantui/lib/index.less";
7 7
 // import '@antmjs/vantui/lib/index.css'
8 8
 
9 9
 const App = (props) => {
10
-
11
-  const init = async () => {
12
-    console.log(11111111111)
10
+  const init = () => {
13 11
     const userState = store.getState("user");
14
-    // 等待组件挂载完成
15
-    await Promise.resolve();
16 12
 
17
-    // 然后执行异步操作
18
-    await userState.login(123);
19
-    await userState.current();
13
+    userState.login(123);
14
+    userState.current();
20 15
   };
21
- 
22 16
 
23 17
   useEffect(() => {
24
-    init()
18
+    init();
25 19
   }, []);
26 20
 
27 21
   return <Provider>{props.children}</Provider>;

+ 6
- 3
src/app.less Ver fichero

@@ -22,14 +22,17 @@
22 22
   }
23 23
 
24 24
   .van-cell {
25
-    font-size: var(--cell-font-size, 32rpx) !important;
25
+    // font-size: var(--cell-font-size, 16px) !important;
26 26
   }
27 27
 
28 28
   .van-field__control {
29
-    font-size: var(--field-font-size, 30rpx) !important;
29
+    font-size: var(--field-font-size, 16px) !important;
30 30
 
31 31
   }
32
-
32
+  // .van-icon--image{
33
+  //   // width: 100%;
34
+  //   // height: 100%;
35
+  // }
33 36
 
34 37
 }
35 38
 

+ 52
- 0
src/components/H5Map/index.jsx Ver fichero

@@ -0,0 +1,52 @@
1
+import Taro from "@tarojs/taro";
2
+import { getLocation, h5GetLocation } from "@/utils/authorize";
3
+import React from "react";
4
+import { useEffect } from "react";
5
+export default (props) => {
6
+  const { location, onChange } = props;
7
+  useEffect(() => {
8
+    if (location) {
9
+      console.log(location)
10
+      const [lat, lng] = (location || DEFAULT_POS).split(",");
11
+   
12
+      const center = new TMap.LatLng(parseFloat(lat), parseFloat(lng));
13
+      new TMap.Map("container", {
14
+        rotation: 20, //设置地图旋转角度
15
+        pitch: 30, //设置俯仰角度(0~45)
16
+        zoom: 20, //设置地图缩放级别
17
+        center: center, //设置地图中心点坐标
18
+      });
19
+    }
20
+  }, [location]);
21
+
22
+  useEffect(() => {
23
+    fixedLocation().then((res) => {
24
+      console.log(res);
25
+      const {lat,lng   } = res.location;
26
+      onChange([lat,lng].join(","));
27
+    });
28
+  }, []);
29
+
30
+  const fixedLocation = () => {
31
+    return new Promise((resolve) => {
32
+      Taro.showLoading({
33
+        title: "加载中",
34
+      });
35
+      return h5GetLocation()
36
+        .then((res) => {
37
+          Taro.hideLoading();
38
+          resolve(res.data.result);
39
+        })
40
+        .catch((err) => {
41
+          console.error(err);
42
+          Taro.hideLoading();
43
+          Taro.showToast({
44
+            title: "定位失败",
45
+            icon: "none",
46
+          });
47
+        });
48
+    });
49
+  };
50
+
51
+  return <div id="container"></div>;
52
+};

+ 4
- 4
src/components/MenuIcon.jsx Ver fichero

@@ -12,16 +12,16 @@ const wrapperStyle = {
12 12
 }
13 13
 
14 14
 const iconStyle = {
15
-  width: '100rpx',
16
-  height: '100rpx',
15
+  width: '50px',
16
+  height: '50px',
17 17
   margin: 'auto',
18 18
   display: 'block',
19 19
 }
20 20
 
21 21
 const txtStyle = {
22
-  marginTop: '20rpx',
22
+  marginTop: '10px',
23 23
   textAlign: 'center',
24
-  fontSize: '30rpx',
24
+  fontSize: '15px',
25 25
   color: '#202020',
26 26
 }
27 27
 

+ 1
- 1
src/components/PowerList/index.jsx Ver fichero

@@ -128,7 +128,7 @@ export default React.forwardRef((props, ref) => {
128 128
       finished={finished}
129 129
       onScrollToLower={onScrollToLower}
130 130
       style={{ height: "100%", overflowY: "auto" }}
131
-      renderLoading={loading ? <view>加载中...</view> : <view></view>}
131
+      renderLoading={loading ? <View>加载中...</View> : <View></View>}
132 132
     >
133 133
       {list.map(renderItem)}
134 134
     </PowerScrollView>

+ 67
- 62
src/components/Uploader/index.jsx Ver fichero

@@ -1,11 +1,11 @@
1
-import React from 'react';
2
-import Taro from '@tarojs/taro';
3
-import { View, Image, Video } from '@tarojs/components';
4
-import { Loading } from '@antmjs/vantui';
5
-import { uploadFiles } from '@/utils/request';
6
-import icon from '@/assets/icons/uploader.png';
7
-import closeIcon from '@/assets/icons/close.png';
8
-import style from './style.modules.less';
1
+import React from "react";
2
+import Taro from "@tarojs/taro";
3
+import { View, Image, Video } from "@tarojs/components";
4
+import { Loading } from "@antmjs/vantui";
5
+import { uploadFiles } from "@/utils/request";
6
+import icon from "@/assets/icons/uploader.png";
7
+import closeIcon from "@/assets/icons/close.png";
8
+import style from "./style.modules.less";
9 9
 
10 10
 export default (props) => {
11 11
   // value 为数组
@@ -22,72 +22,77 @@ export default (props) => {
22 22
     setLoading(true);
23 23
     Taro.chooseMedia({
24 24
       maxDuration: 60,
25
-      sizeType: 'compressed',
25
+      // sizeType: "compressed",
26 26
       success: (res) => {
27 27
         const { tempFiles } = res;
28
-        uploadFiles(tempFiles).then(resp => {
29
-          setLoading(false);          
30
-          onChange((value || []).concat(resp));
31
-        }).catch((err) => {
32
-          console.error(err);
33
-          setLoading(false);
34
-        })
28
+        uploadFiles(tempFiles)
29
+          .then((resp) => {
30
+            setLoading(false);
31
+            onChange((value || []).concat(resp));
32
+          })
33
+          .catch((err) => {
34
+            console.error(err);
35
+            setLoading(false);
36
+          });
35 37
       },
36 38
       fail: (err) => {
37 39
         console.error(err);
38 40
         setLoading(false);
39
-      }
40
-    })
41
-  }
41
+      },
42
+    });
43
+  };
42 44
 
43 45
   const onDelete = (item) => {
44
-    const newVal = value.filter(x => x.url != item.url);
46
+    const newVal = value.filter((x) => x.url != item.url);
45 47
     onChange(newVal);
46
-  }
48
+  };
47 49
 
48 50
   const onPreview = (inx) => {
49
-    Taro.previewMedia({
50
-      sources: value.map(x => ({ url: x.url, type: x.fileType })),
51
-      current: inx,
52
-    })
53
-  }
51
+    const url = value.map((x) => x.url);
52
+    // Taro.previewMedia({
53
+    //   sources: value.map(x => ({ url: x.url, type: x.fileType })),
54
+    //   current: inx,
55
+    // })
56
+
57
+    //H5
58
+    Taro.previewImage({
59
+      current: inx, // 当前显示图片的http链接
60
+      urls: url,
61
+    });
62
+  };
54 63
 
55 64
   return (
56
-    <View className={style['uploader-wrapper']}>
57
-      <View className={style['uploader-box']}>
58
-        {
59
-          !disabled && (
60
-            <View className={style['uploader-add']}>
61
-              <Image src={icon} onClick={onAdd} />
62
-              {
63
-                loading && (
64
-                  <View>
65
-                    <Loading color="#fff" />
66
-                  </View>
67
-                )
68
-              }
69
-            </View>
70
-          )
71
-        }
72
-        {
73
-          (value || []).map((item, inx) => (
74
-            <View key={item.url} className={style['uploader-item']}>
75
-              {
76
-                item.fileType == 'image' ?
77
-                  <Image src={item.url} onClick={() => onPreview(inx)} /> :
78
-                  <Video src={item.url} controls={false} onClick={() => onPreview(inx)} />
79
-              }
80
-              {
81
-                !disabled && (
82
-                  <View onClick={() => onDelete(item)}>
83
-                    <Image src={closeIcon} />
84
-                  </View>
85
-                )
86
-              }
87
-            </View>
88
-          ))
89
-        }
65
+    <View className={style["uploader-wrapper"]}>
66
+      <View className={style["uploader-box"]}>
67
+        {!disabled && (
68
+          <View className={style["uploader-add"]}>
69
+            <Image src={icon} onClick={onAdd} />
70
+            {loading && (
71
+              <View>
72
+                <Loading color="#fff" />
73
+              </View>
74
+            )}
75
+          </View>
76
+        )}
77
+        {(value || []).map((item, inx) => (
78
+          <View key={item.url} className={style["uploader-item"]}>
79
+            {item.fileType.indexOf("image") == 0 ? (
80
+              <Image src={item.url} onClick={() => onPreview(inx)} />
81
+            ) : (
82
+              <Video
83
+                src={item.url}
84
+                controls={false}
85
+                onClick={() => onPreview(inx)}
86
+              />
87
+            )}
88
+            {!disabled && (
89
+              <View onClick={() => onDelete(item)}>
90
+                <Image src={closeIcon} />
91
+              </View>
92
+            )}
93
+          </View>
94
+        ))}
90 95
       </View>
91 96
     </View>
92
-  )
93
-}
97
+  );
98
+};

+ 148
- 0
src/components/map/index copy.jsx Ver fichero

@@ -0,0 +1,148 @@
1
+import React, { useEffect } from "react";
2
+import Taro from "@tarojs/taro";
3
+import { View, Map } from "@tarojs/components";
4
+import { Icon, Loading } from "@antmjs/vantui";
5
+import { getLocation } from "@/utils/authorize";
6
+import iconPath from "@/assets/icons/marker.png";
7
+import style from "./style.module.less";
8
+
9
+/**
10
+ * 这里使用2个map, 每个 map 负责不同的场景
11
+ * 如果使用 1 个map, 通过属性去控制, 微信暂时有 bug 比如 showLocation 就有bug
12
+ */
13
+export default (props) => {
14
+  const { readOnly, location, onChange } = props;
15
+
16
+  console.log("-----map---readOnly---", readOnly, location);
17
+
18
+  const id = React.useMemo(
19
+    () => `map-${Math.random().toString(36).substring(2, 10)}`,
20
+    []
21
+  );
22
+  const idReadOnly = React.useMemo(
23
+    () => `map-${Math.random().toString(36).substring(2, 10)}`,
24
+    []
25
+  );
26
+  const mapCtxRef = React.useRef();
27
+
28
+  const [markers, center] = React.useMemo(() => {
29
+    // eslint-disable-next-line no-undef
30
+    const loc = location || DEFAULT_POS;
31
+    const [longitude, latitude] = loc.split(",");
32
+
33
+    const mks = readOnly
34
+      ? [
35
+          {
36
+            id: 1,
37
+            longitude,
38
+            latitude,
39
+            iconPath,
40
+            width: 17,
41
+            height: 20,
42
+          },
43
+        ]
44
+      : [];
45
+
46
+    return [mks, { longitude, latitude }];
47
+  }, [location, readOnly]);
48
+
49
+  console.log("------center-------", center, location);
50
+
51
+  const moveTo = (ctx, point) => {
52
+    ctx.moveToLocation({
53
+      ...point,
54
+      fail: console.error,
55
+    });
56
+  };
57
+
58
+  const getContext = React.useCallback(() => {
59
+    const query = Taro.createSelectorQuery();
60
+    query
61
+      .select(`#${id}`)
62
+      .boundingClientRect((res) => {
63
+        console.log(res);
64
+        mapCtxRef.current = res.context;
65
+
66
+        // 修改中心图标 - 暂时不起作用, wx bug
67
+        mapCtxRef.current.setLocMarkerIcon({
68
+          iconPath,
69
+          fail: console.error,
70
+        });
71
+      })
72
+      .exec();
73
+  }, [id]);
74
+
75
+  const fixedLocation = () => {
76
+    return new Promise((resolve) => {
77
+      Taro.showLoading({
78
+        title: "加载中",
79
+      });
80
+      getLocation({ type: "wgs84" })
81
+        .then((res) => {
82
+          Taro.hideLoading();
83
+          resolve(res);
84
+        })
85
+        .catch((err) => {
86
+          console.error(err);
87
+          Taro.hideLoading();
88
+          Taro.showToast({
89
+            title: "定位失败",
90
+            icon: "none",
91
+          });
92
+        });
93
+    });
94
+  };
95
+
96
+  const onRefresh = () => {
97
+    if (mapCtxRef.current) {
98
+      fixedLocation().then((res) => {
99
+        const { longitude, latitude } = res;
100
+        // console.log('longitude', longitude);
101
+        // console.log('latitude', latitude);
102
+        onChange([res.longitude, res.latitude].join(","));
103
+        moveTo(mapCtxRef.current, { longitude, latitude });
104
+      });
105
+    }
106
+  };
107
+
108
+  React.useEffect(() => {
109
+    if (!readOnly) {
110
+      getContext();
111
+
112
+      // 获取定位
113
+      fixedLocation().then((res) => {
114
+        const { longitude, latitude } = res;
115
+        onChange([longitude, latitude].join(","));
116
+      });
117
+    }
118
+    // eslint-disable-next-line react-hooks/exhaustive-deps
119
+  }, [readOnly, getContext]);
120
+
121
+  return (
122
+    <View className={style["map-wrapper"]}>
123
+
124
+      {/* {
125
+        !readOnly && (
126
+          <Map
127
+            id={id}
128
+            showLocation
129
+            longitude={center.longitude}
130
+            latitude={center.latitude}
131
+          >
132
+            <Icon name="aim" size="24px" onClick={onRefresh} color="#1A7565" className={style['icon']} />
133
+          </Map>
134
+        )
135
+      }
136
+      {
137
+        readOnly && (
138
+          <Map
139
+            id={idReadOnly}
140
+            longitude={center.longitude}
141
+            latitude={center.latitude}
142
+            markers={markers}
143
+          />
144
+        )
145
+      } */}
146
+    </View>
147
+  );
148
+};

+ 95
- 110
src/components/map/index.jsx Ver fichero

@@ -1,10 +1,10 @@
1
-import React from 'react';
2
-import Taro from '@tarojs/taro';
3
-import { View, Map } from '@tarojs/components';
4
-import { Icon, Loading } from '@antmjs/vantui';
5
-import { getLocation } from '@/utils/authorize';
6
-import iconPath from '@/assets/icons/marker.png';
7
-import style from './style.module.less';
1
+import React, { useEffect, useMemo } from "react";
2
+import Taro from "@tarojs/taro";
3
+import { View, Map } from "@tarojs/components";
4
+import { Icon, Loading } from "@antmjs/vantui";
5
+import { getLocation, h5GetLocation } from "@/utils/authorize";
6
+import iconPath from "@/assets/icons/marker.png";
7
+import style from "./style.module.less";
8 8
 
9 9
 /**
10 10
  * 这里使用2个map, 每个 map 负责不同的场景
@@ -13,126 +13,111 @@ import style from './style.module.less';
13 13
 export default (props) => {
14 14
   const { readOnly, location, onChange } = props;
15 15
 
16
-  console.log('-----map---readOnly---', readOnly, location);
16
+  console.log("-----map---readOnly---", readOnly, location);
17 17
 
18
-  const id = React.useMemo(() => `map-${Math.random().toString(36).substring(2, 10)}`, []);
19
-  const idReadOnly = React.useMemo(() => `map-${Math.random().toString(36).substring(2, 10)}`, []);
18
+  const id = React.useMemo(
19
+    () => `map-${Math.random().toString(36).substring(2, 10)}`,
20
+    []
21
+  );
22
+  const idReadOnly = React.useMemo(
23
+    () => `map-${Math.random().toString(36).substring(2, 10)}`,
24
+    []
25
+  );
20 26
   const mapCtxRef = React.useRef();
21 27
 
22
-  const [
23
-    markers,
24
-    center,
25
-  ] = React.useMemo(() => {
26
-    // eslint-disable-next-line no-undef
27
-    const loc = location || DEFAULT_POS;
28
-    const [longitude, latitude] = loc.split(',');
29
-
30
-    const mks = readOnly ? [{
31
-      id: 1,
32
-      longitude,
33
-      latitude,
34
-      iconPath,
35
-      width: 17,
36
-      height: 20
37
-    }] : [];
38
-
39
-    return [
40
-      mks,
41
-      { longitude, latitude }
42
-    ]
43
-  }, [location, readOnly]);
44
-
45
-  console.log('------center-------', center, location)
46
-
47
-  const moveTo = (ctx, point) => {
48
-    ctx.moveToLocation({
49
-      ...point,
50
-      fail: console.error,
51
-    })
52
-  }
28
+  useEffect(() => {
29
+    let map, marker;
30
+    if (!mapCtxRef.current) {
31
+      if (location) {
32
+        console.log(location);
33
+        console.log(DEFAULT_POS);
34
+        const [lng, lat] = (location || DEFAULT_POS).split(",");
35
+        console.log(lng, lat)
36
+        const center = new TMap.LatLng(parseFloat(lat), parseFloat(lng));
37
+        map = new TMap.Map("container", {
38
+          rotation: 20, //设置地图旋转角度
39
+          pitch: 30, //设置俯仰角度(0~45)
40
+          zoom: 20, //设置地图缩放级别
41
+          center: center, //设置地图中心点坐标
42
+        });
43
+
44
+        const isRemove = [
45
+          {
46
+            id: "demo",
47
+            styleId: "marker",
48
+            position: center,
49
+            properties: {
50
+              title: "marker",
51
+            },
52
+          },
53
+        ];
54
+        marker = new TMap.MultiMarker({
55
+          id: "marker-layer",
56
+          map: map,
57
+          geometries: isRemove,
58
+        });
59
+      }
53 60
 
54
-  const getContext = React.useCallback(() => {
55
-    const query = Taro.createSelectorQuery();
56
-    query.select(`#${id}`).context(res => {
57
-      mapCtxRef.current = res.context;
61
+      mapCtxRef.current = map;
62
+    } else {
63
+      map = mapCtxRef.current;
64
+    }
58 65
 
59
-      // 修改中心图标 - 暂时不起作用, wx bug
60
-      mapCtxRef.current.setLocMarkerIcon({
61
-        iconPath,
62
-        fail: console.error,
63
-      })
64
-    }).exec();
65
-  }, [id]);
66
+    if (map && marker) {
67
+      console.log("-------------------------");
68
+      console.log(marker);
69
+      console.log(map);
70
+      getMarker(map, marker);
71
+    }
72
+  }, [location]);
73
+
74
+  const getMarker = (map, marker) => {
75
+    if (readOnly) return;
76
+
77
+    map.on("click", (evt) => {
78
+      marker.setGeometries([
79
+        {
80
+          position: evt.latLng,
81
+        },
82
+      ]);
83
+      const { lng, lat } = evt.latLng;
84
+      onChange([lng, lat].join(","));
85
+    });
86
+  };
66 87
 
67 88
   const fixedLocation = () => {
68 89
     return new Promise((resolve) => {
69 90
       Taro.showLoading({
70
-        title: '加载中',
71
-      })
72
-      getLocation({ type: 'gcj02' }).then((res) => {
73
-        Taro.hideLoading()
74
-        resolve(res);
75
-      }).catch((err) => {
76
-        console.error(err);
77
-        Taro.hideLoading();
78
-        Taro.showToast({
79
-          title: '定位失败',
80
-          icon: 'none',
81
-        })
91
+        title: "加载中",
82 92
       });
93
+      return h5GetLocation()
94
+        .then((res) => {
95
+          Taro.hideLoading();
96
+          resolve(res.data.result);
97
+        })
98
+        .catch((err) => {
99
+          console.error(err);
100
+          Taro.hideLoading();
101
+          Taro.showToast({
102
+            title: "定位失败",
103
+            icon: "none",
104
+          });
105
+        });
83 106
     });
84
-  }
85
-
86
-  const onRefresh = () => {
87
-    if (mapCtxRef.current) {
88
-      fixedLocation().then((res) => {
89
-        const { longitude, latitude } = res;
90
-        // console.log('longitude', longitude);
91
-        // console.log('latitude', latitude);
92
-        onChange([res.longitude, res.latitude].join(','));
93
-        moveTo(mapCtxRef.current, { longitude, latitude });
94
-      })
95
-
96
-    }
97
-  }
107
+  };
98 108
 
99 109
   React.useEffect(() => {
100 110
     if (!readOnly) {
101
-      getContext();
111
+      // getContext();
102 112
 
103 113
       // 获取定位
104 114
       fixedLocation().then((res) => {
105
-        const { longitude, latitude } = res;
106
-        onChange([longitude, latitude].join(','));
107
-      })
115
+        const { lng, lat } = res.location;
116
+        onChange([lng, lat].join(","));
117
+      });
108 118
     }
109 119
     // eslint-disable-next-line react-hooks/exhaustive-deps
110
-  }, [readOnly, getContext]);
120
+  }, [readOnly]); //getContext
111 121
 
112
-  return (
113
-    <View className={style['map-wrapper']}>
114
-      {
115
-        !readOnly && (
116
-          <Map
117
-            id={id}
118
-            showLocation
119
-            longitude={center.longitude}
120
-            latitude={center.latitude}
121
-          >
122
-            <Icon name="aim" size="24px" onClick={onRefresh} color="#1A7565" className={style['icon']} />
123
-          </Map>
124
-        )
125
-      }
126
-      {
127
-        readOnly && (
128
-          <Map
129
-            id={idReadOnly}
130
-            longitude={center.longitude}
131
-            latitude={center.latitude}
132
-            markers={markers}
133
-          />
134
-        )
135
-      }
136
-    </View >
137
-  )
138
-}
122
+  return <div id="container"></div>;
123
+};

+ 1
- 0
src/index.html Ver fichero

@@ -9,6 +9,7 @@
9 9
   <meta name="apple-mobile-web-app-status-bar-style" content="white">
10 10
   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
11 11
   <script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
12
+  <script charset="utf-8" src="https://map.qq.com/api/gljs?v=1.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"></script>
12 13
   <title>civilized-miniapp</title>
13 14
   <script><%= htmlWebpackPlugin.options.script %></script>
14 15
 </head>

+ 23
- 23
src/layouts/TabBar.jsx Ver fichero

@@ -104,29 +104,29 @@ export default (props) => {
104 104
       className={className}
105 105
       active={active}
106 106
       onChange={onChange}
107
-    >
108
-      {tabItems.map((item) => (
109
-        <TabbarItem
110
-          key={item.name}
111
-          name={item.name}
112
-          renderIcon={
113
-            <Image
114
-              src={item.icon}
115
-              mode="aspectFit"
116
-              style="width: 30px; height: 20px;"
117
-            ></Image>
118
-          }
119
-          renderIconActive={
120
-            <Image
121
-              src={item.activeIcon}
122
-              mode="aspectFit"
123
-              style="width: 30px; height: 20px;"
124
-            ></Image>
125
-          }
126
-        >
127
-          <View style={{ fontSize: "14px" }}>{item.label}</View>
128
-        </TabbarItem>
129
-      ))}
107
+      >
108
+        {tabItems.map((item) => (
109
+          <TabbarItem
110
+            key={item.name}
111
+            name={item.name}
112
+            renderIcon={
113
+              <Image
114
+                src={item.icon}
115
+                mode="aspectFit"
116
+                style="width: 20px; height: 20px;"
117
+              ></Image>
118
+            }
119
+            renderIconActive={
120
+              <Image
121
+                src={item.activeIcon}
122
+                mode="aspectFit"
123
+                style="width: 20px; height: 20px;"
124
+              ></Image>
125
+            }
126
+          >
127
+            <View style={{ fontSize: "14px" }}>{item.label}</View>
128
+          </TabbarItem>
129
+        ))}
130 130
     </Tabbar>
131 131
   );
132 132
 };

+ 38
- 17
src/layouts/index.jsx Ver fichero

@@ -1,4 +1,4 @@
1
-import React from "react";
1
+import React, { useRef } from "react";
2 2
 import Taro from "@tarojs/taro";
3 3
 import { View, Image } from "@tarojs/components";
4 4
 import { useModel } from "@/store";
@@ -16,33 +16,54 @@ export default (props) => {
16 16
     tabBar ? laySty["with-tabbar"] : ""
17 17
   } ${className}`;
18 18
 
19
-  // React.useEffect(() => {
20
-  //   if (person && !user) {
21
-  //     const currentPage = Taro.getCurrentPages().slice().pop();
22
-  //     if ('pages/login/index' !== currentPage.route) {
23
-  //       Taro.navigateTo({
24
-  //         url: '/pages/login/index',
25
-  //       })
26
-  //     }
27
-  //   }
28
-  // }, [person, user]);
19
+  const userRef = useRef();
20
+  const personRef = useRef();
21
+
22
+  React.useEffect(() => {
23
+    if (!userRef.current && !personRef.current) {
24
+      userRef.current = person;
25
+      personRef.current = user;
26
+    }
27
+    if (!user) {
28
+      userRef.current = null;
29
+    }
30
+    console.log("personRef******************");
31
+    console.log(personRef.current);
32
+    console.log("userRef******************");
33
+    console.log(userRef.current);
34
+    console.log(personRef.current && !userRef.current);
29 35
 
30
-  console.log(person)
31
-  console.log(user)
32
-  React.useMemo(() => {
33
-    if (person && !user) {
36
+    if (personRef.current && !userRef.current) {
34 37
       const currentPage = Taro.getCurrentPages().slice().pop();
38
+      console.log(currentPage.route);
35 39
       if ("pages/login/index" !== currentPage.route) {
36 40
         Taro.navigateTo({
37 41
           url: "/pages/login/index",
38 42
         });
39 43
       }
40 44
     }
41
-  }, []);
45
+  }, [person, user]);
46
+
47
+  // React.useEffect(() => {
48
+  //   console.log("personRef******************");
49
+  //   console.log(person);
50
+  //   console.log("userRef******************");
51
+  //   console.log(user);
52
+  //   console.log(person && !user);
53
+
54
+  //   if (person && !user) {
55
+  //     const currentPage = Taro.getCurrentPages().slice().pop();
56
+  //     if ("pages/login/index" !== currentPage.route) {
57
+  //       Taro.navigateTo({
58
+  //         url: "/pages/login/index",
59
+  //       });
60
+  //     }
61
+  //   }
62
+  // }, [person, user]);
42 63
 
43 64
   Taro.useShareAppMessage(() => {
44 65
     return {
45
-      title: '文明城市'
66
+      title: "文明霍山",
46 67
     };
47 68
   });
48 69
 

+ 1
- 1
src/layouts/layout.module.less Ver fichero

@@ -13,7 +13,7 @@
13 13
     &.with-tabbar {
14 14
       overflow-y: scroll;
15 15
       // height: calc(100% - var(--tabbar-height, 100rpx));
16
-      padding-bottom: var(--tabbar-height, 100rpx);
16
+      padding-bottom: var(--tabbar-height, 50px);
17 17
     }
18 18
 
19 19
     .pdm-space {

+ 114
- 133
src/pages/issue/components/Issue/index.jsx Ver fichero

@@ -1,22 +1,21 @@
1
-import React from 'react';
2
-import Taro from '@tarojs/taro';
3
-import { View } from '@tarojs/components';
4
-import { Field, Cell, CellGroup } from '@antmjs/vantui';
5
-import LocType from '@/components/LocType';
6
-import IssueType from '@/components/IssueType';
7
-import OrgPicker from '@/components/OrgPicker';
8
-import DatePicker from '@/components/DatePicker';
9
-import Map from '@/components/map';
10
-import Uploader from '@/components/Uploader/index';
11
-import { getDateStr } from '@/utils/date';
12
-import mapIcon from '@/assets/icons/marker.png';
13
-import { getTaOrgIssueByIssueId } from '@/services/taorgissue';
14
-import { PROCESS_END } from '@/utils/biz';
15
-import { geocoder } from '@/utils/map';
16
-import {
17
-  ROLE_ORG_USER,
18
-} from "@/utils/user";
19
-import IssueStatus from './IssueStatus';
1
+import React, { useEffect } from "react";
2
+import Taro from "@tarojs/taro";
3
+import { View } from "@tarojs/components";
4
+import { Field, Cell, CellGroup } from "@antmjs/vantui";
5
+import LocType from "@/components/LocType";
6
+import IssueType from "@/components/IssueType";
7
+import OrgPicker from "@/components/OrgPicker";
8
+import DatePicker from "@/components/DatePicker";
9
+import Map from "@/components/map";
10
+import Uploader from "@/components/Uploader/index";
11
+import { getDateStr } from "@/utils/date";
12
+import mapIcon from "@/assets/icons/marker.png";
13
+import { getTaOrgIssueByIssueId } from "@/services/taorgissue";
14
+import { PROCESS_END } from "@/utils/biz";
15
+import { geocoder } from "@/utils/map";
16
+import H5Map from "@/components/H5Map";
17
+import { ROLE_ORG_USER } from "@/utils/user";
18
+import IssueStatus from "./IssueStatus";
20 19
 
21 20
 const today = new Date();
22 21
 
@@ -28,7 +27,7 @@ export default (props) => {
28 27
     showOrg,
29 28
     showExpireDate,
30 29
     renderFields,
31
-    renderAction
30
+    renderAction,
32 31
   } = props;
33 32
 
34 33
   const fmRef = React.useRef({
@@ -54,7 +53,9 @@ export default (props) => {
54 53
 
55 54
     // 如果单子办结了就是实际办结时间
56 55
     // 否则就是预计办结时间
57
-    return formData.processNode == PROCESS_END ? formData.endDate : formData.expireDate;
56
+    return formData.processNode == PROCESS_END
57
+      ? formData.endDate
58
+      : formData.expireDate;
58 59
   }, [formData]);
59 60
 
60 61
   const onLocTypeChange = (_, it) => {
@@ -62,80 +63,89 @@ export default (props) => {
62 63
       ...fmRef.current,
63 64
       locId: it.typeId,
64 65
       locName: it.name,
65
-    }
66
+    };
66 67
     fmRef.current = data;
67 68
     setFormData(data);
68 69
     setShowLocType(false);
69
-  }
70
+  };
70 71
 
71 72
   const onIssueTypeChange = (_, it) => {
72 73
     const data = {
73 74
       ...fmRef.current,
74 75
       typeId: it.typeId,
75 76
       typeName: it.name,
76
-    }
77
+    };
77 78
     fmRef.current = data;
78 79
     setFormData(data);
79 80
     setShowIssueType(false);
80
-  }
81
+  };
81 82
 
82 83
   const onOrgChange = (_, it) => {
83 84
     const data = {
84 85
       ...fmRef.current,
85 86
       orgId: it.orgId,
86 87
       orgName: it.name,
87
-    }
88
+    };
88 89
     fmRef.current = data;
89 90
     setFormData(data);
90 91
     setShowOrgPicker(false);
91
-  }
92
+  };
92 93
 
93 94
   const onDateChange = (dt) => {
94 95
     const date = getDateStr(dt);
95 96
     const data = {
96 97
       ...fmRef.current,
97 98
       expireDate: date,
98
-    }
99
+    };
99 100
     fmRef.current = data;
100 101
     setFormData(data);
101 102
     setShowDatePicker(false);
102
-  }
103
+  };
103 104
 
104 105
   const setFieldChange = (field, value) => {
105 106
     const data = {
106 107
       ...fmRef.current,
107 108
       [field]: value,
108
-    }
109
+    };
109 110
     fmRef.current = data;
111
+    console.log(data)
110 112
     setFormData(data);
111
-  }
113
+  };
112 114
 
113
-  
114 115
   const onLocationChange = (loc) => {
115
-    setFieldChange('location', loc);
116
-
116
+    setFieldChange("location", loc);
117
+    console.log(loc);
117 118
     if (loc) {
118 119
       // 交换经纬度位置
119
-      const [x, y] = loc.split(',');
120
-      const location = [y, x].join(',');
121
-      geocoder(location).then(e => setFieldChange('addr', e?.address_component?.street_number || e?.address)).catch(console.error)
120
+      const [x, y] = loc.split(",");
121
+      const location = [y,x].join(",");
122
+      geocoder(location)
123
+        .then((e) => {
124
+          console.log(e?.address_component?.street_number || e?.address);
125
+
126
+          setFieldChange(
127
+            "addr",
128
+            e?.address_component?.street_number || e?.address
129
+          );
130
+        })
131
+        .catch(console.error);
122 132
     }
123
-  }
133
+  };
124 134
 
125 135
   React.useEffect(() => {
126 136
     if (issue) {
127 137
       fmRef.current = issue;
128 138
       setFormData(issue);
129 139
       // console.log('---------issue-------->', issue)
130
-      getTaOrgIssueByIssueId(issue.issueId, issue.orgId).then(r => {
140
+      getTaOrgIssueByIssueId(issue.issueId, issue.orgId).then((r) => {
131 141
         setOrgIssue(r);
132 142
       });
133
-
134 143
     }
135 144
   }, [issue]);
136 145
 
137
-  // console.log('showIssueType', showIssueType)
138
-  // console.log('readOnly', readOnly)
146
+  useEffect(() => {
147
+    container;
148
+  }, []);
139 149
   return (
140 150
     <View>
141 151
       <LocType
@@ -175,15 +185,10 @@ export default (props) => {
175 185
         onChange={onLocationChange}
176 186
       />
177 187
 
188
+      {/* <H5Map location={formData.location} onChange={onLocationChange} /> */}
189
+
178 190
       <CellGroup>
179
-        {
180
-          issue?.issueId && (
181
-            <Cell
182
-              title="ID"
183
-              value={issue.issueId}
184
-            />
185
-          )
186
-        }
191
+        {issue?.issueId && <Cell title="ID" value={issue.issueId} />}
187 192
         <Cell
188 193
           title="点位"
189 194
           isLink={!readOnly}
@@ -195,24 +200,21 @@ export default (props) => {
195 200
           value={formData.addr}
196 201
           leftIcon={mapIcon}
197 202
           readonly={readOnly}
198
-          onChange={e => setFieldChange('addr', e.detail)}
203
+          onChange={(e) => setFieldChange("addr", e.detail)}
199 204
         />
200 205
       </CellGroup>
201 206
 
202
-      {
203
-        readOnly && (
204
-          <CellGroup style={{ marginTop: '20px' }}>
205
-            <IssueStatus issue={issue} />
206
-          </CellGroup>
207
-        )
208
-      }
207
+      {readOnly && (
208
+        <CellGroup style={{ marginTop: "20px" }}>
209
+          <IssueStatus issue={issue} />
210
+        </CellGroup>
211
+      )}
209 212
 
210
-
211
-      <CellGroup style={{ marginTop: '20px' }}>
213
+      <CellGroup style={{ marginTop: "20px" }}>
212 214
         <Cell
213 215
           title="问题分类"
214 216
           isLink={!readOnly}
215
-          style={{ marginTop: '20px' }}
217
+          style={{ marginTop: "20px" }}
216 218
           value={formData.typeName}
217 219
           onClick={() => !readOnly && setShowIssueType(true)}
218 220
         />
@@ -222,13 +224,13 @@ export default (props) => {
222 224
           type="textarea"
223 225
           placeholder="请输入问题描述"
224 226
           readonly={readOnly}
225
-          autosize={{ minHeight: '120px' }}
227
+          autosize={{ minHeight: "120px" }}
226 228
           value={formData.content}
227
-          onChange={e => setFieldChange('content', e.detail)}
229
+          onChange={(e) => setFieldChange("content", e.detail)}
228 230
         />
229 231
       </CellGroup>
230 232
 
231
-      <CellGroup style={{ marginTop: '20px' }}>
233
+      <CellGroup style={{ marginTop: "20px" }}>
232 234
         <Cell title="拍照或视频" border={false} />
233 235
 
234 236
         <Cell
@@ -236,83 +238,62 @@ export default (props) => {
236 238
             <Uploader
237 239
               value={formData.attachList}
238 240
               disabled={readOnly}
239
-              onChange={e => setFieldChange('attachList', e)}
241
+              onChange={(e) => setFieldChange("attachList", e)}
240 242
             />
241 243
           }
242 244
         />
243 245
       </CellGroup>
244 246
 
245
-      {
246
-        (showOrg ) && (
247
-          <CellGroup style={{ marginTop: '20px' }}>
248
-            {
249
-              showOrg && (
250
-                <Cell
251
-                  title="交办单位"
252
-                  isLink={!readOnly}
253
-                  value={formData.orgName}
254
-                  onClick={() => !readOnly && setShowOrgPicker(true)}
255
-                />
256
-              )
257
-            }
258
-            {
259
-              (showExpireDate)  && (
260
-                <Cell
261
-                  title="办结时间"
262
-                  isLink={!readOnly}
263
-                  value={endDate}
264
-                  onClick={() => !readOnly && setShowDatePicker(true)}
265
-                />
266
-              )
267
-            }
268
-          </CellGroup>
269
-        )
270
-      }
271
-
272
-      {
273
-        orgIssue && issue?.processNode == PROCESS_END && (
274
-          <CellGroup style={{ marginTop: '20px' }}>
275
-            <Cell title="整改结果" />
276
-            <Field
277
-              readonly
278
-              type="textarea"
279
-              autosize={{ minHeight: '120px' }}
280
-              value={orgIssue?.result}
247
+      {showOrg && (
248
+        <CellGroup style={{ marginTop: "20px" }}>
249
+          {showOrg && (
250
+            <Cell
251
+              title="交办单位"
252
+              isLink={!readOnly}
253
+              value={formData.orgName}
254
+              onClick={() => !readOnly && setShowOrgPicker(true)}
281 255
             />
282
-
283
-            <Cell title="整改照片" border={false} />
256
+          )}
257
+          {showExpireDate && (
284 258
             <Cell
285
-              renderTitle={
286
-                <Uploader
287
-                  disabled
288
-                  value={orgIssue?.attachList}
289
-                />
290
-              }
259
+              title="办结时间"
260
+              isLink={!readOnly}
261
+              value={endDate}
262
+              onClick={() => !readOnly && setShowDatePicker(true)}
291 263
             />
292
-          </CellGroup>
293
-        )
294
-      }
264
+          )}
265
+        </CellGroup>
266
+      )}
267
+
268
+      {orgIssue && issue?.processNode == PROCESS_END && (
269
+        <CellGroup style={{ marginTop: "20px" }}>
270
+          <Cell title="整改结果" />
271
+          <Field
272
+            readonly
273
+            type="textarea"
274
+            autosize={{ minHeight: "120px" }}
275
+            value={orgIssue?.result}
276
+          />
277
+
278
+          <Cell title="整改照片" border={false} />
279
+          <Cell
280
+            renderTitle={<Uploader disabled value={orgIssue?.attachList} />}
281
+          />
282
+        </CellGroup>
283
+      )}
295 284
 
296
-      {
297
-        renderFields ?
298
-          renderFields(
299
-            formData,
300
-            {
301
-              setFieldChange,
302
-              setFormData,
303
-              showOrgPicker,
304
-              setShowOrgPicker,
305
-            }
306
-          ) : null
307
-      }
285
+      {renderFields
286
+        ? renderFields(formData, {
287
+            setFieldChange,
288
+            setFormData,
289
+            showOrgPicker,
290
+            setShowOrgPicker,
291
+          })
292
+        : null}
308 293
 
309
-      {
310
-        renderAction ? (
311
-          <View style={{ margin: '20px auto' }}>
312
-            {renderAction(formData)}
313
-          </View>
314
-        ) : null
315
-      }
294
+      {renderAction ? (
295
+        <View style={{ margin: "20px auto" }}>{renderAction(formData)}</View>
296
+      ) : null}
316 297
     </View>
317
-  )
318
-}
298
+  );
299
+};

+ 60
- 33
src/pages/login/components/Form.jsx Ver fichero

@@ -1,59 +1,87 @@
1
-import React from 'react';
2
-import Taro from '@tarojs/taro';
3
-import { View } from '@tarojs/components';
4
-import { Form, FormItem, Field, Button } from '@antmjs/vantui'
5
-import { useModel } from '@/store';
6
-import user from '@/assets/image/user.png';
7
-import password from '@/assets/image/password.png';
8
-import { warn } from '@/utils/message';
9
-import './form.less';
1
+import React from "react";
2
+import Taro from "@tarojs/taro";
3
+import { View } from "@tarojs/components";
4
+import { Form, FormItem, Field, Button } from "@antmjs/vantui";
5
+import { useModel } from "@/store";
6
+import user from "@/assets/image/user.png";
7
+import password from "@/assets/image/password.png";
8
+import { warn } from "@/utils/message";
9
+import "./form.less";
10 10
 
11 11
 export default (props) => {
12 12
   const { onSuccess } = props;
13 13
 
14
-  const { signin } = useModel('user');
14
+  const { signin } = useModel("user");
15 15
   const form = Form.useForm();
16 16
   const [accErr, setAccErr] = React.useState();
17 17
   const [pwdErr, setPwdErr] = React.useState();
18 18
   const [loading, setLoading] = React.useState(false);
19 19
 
20 20
   const onFinish = (errs, res) => {
21
+    console.log(11111111);
21 22
     if (!res.account) {
22
-      setAccErr('账户不能为空');
23
+      setAccErr("账户不能为空");
23 24
       return;
24 25
     } else {
25 26
       setAccErr();
26 27
     }
27 28
     if (!res.password) {
28
-      setPwdErr('密码不能为空');
29
+      setPwdErr("密码不能为空");
29 30
       return;
30 31
     } else {
31 32
       setPwdErr();
32 33
     }
33 34
 
34 35
     setLoading(true);
35
-    signin(res).then(() => {
36
-      onSuccess();
37
-      setLoading(false);
38
-    }).catch(err => {
39
-      setLoading(false);
40
-    })
41
-  }
36
+    signin(res)
37
+      .then(() => {
38
+        onSuccess();
39
+        setLoading(false);
40
+      })
41
+      .catch((err) => {
42
+        setLoading(false);
43
+      });
44
+  };
42 45
 
43 46
   const onForgetPwd = () => {
44 47
     // Taro.navigateTo({
45 48
     //   url: '/pages/reset-password/index'
46 49
     // });
47
-    warn(true, '请联系管理人员')
48
-  }
50
+    warn(true, "请联系管理人员");
51
+  };
49 52
 
53
+  const handleClick = () => {
54
+    form.validateFields((err, res) => {
55
+      if (!res.account) {
56
+        setAccErr("账户不能为空");
57
+        return;
58
+      } else {
59
+        setAccErr();
60
+      }
61
+      if (!res.password) {
62
+        setPwdErr("密码不能为空");
63
+        return;
64
+      } else {
65
+        setPwdErr();
66
+      }
67
+  
68
+      setLoading(true);
69
+      signin(res)
70
+        .then(() => {
71
+          onSuccess();
72
+          setLoading(false);
73
+        })
74
+        .catch((err) => {
75
+          setLoading(false);
76
+        });
77
+    });
78
+    console.log(11111);
79
+  };
50 80
   return (
51 81
     <View className="login-form">
52
-      <Form form={form} onFinish={onFinish}>
53
-        <FormItem
54
-          name="account"
55
-          valueFormat={(e) => e.detail}
56
-        >
82
+      {/* onFinish={onFinish} */}
83
+      <Form form={form} >
84
+        <FormItem name="account" valueFormat={(e) => e.detail}>
57 85
           <Field
58 86
             border
59 87
             label="账号"
@@ -62,10 +90,7 @@ export default (props) => {
62 90
             placeholder="请输入您的登录账号"
63 91
           ></Field>
64 92
         </FormItem>
65
-        <FormItem
66
-          name="password"
67
-          valueFormat={(e) => e.detail}
68
-        >
93
+        <FormItem name="password" valueFormat={(e) => e.detail}>
69 94
           <Field
70 95
             password
71 96
             label="密码"
@@ -81,13 +106,15 @@ export default (props) => {
81 106
           <Button
82 107
             block
83 108
             type="primary"
84
-            formType="submit"
109
+            // formType="submit"
85 110
             loading={loading}
111
+            disabled={loading}
112
+            onClick={handleClick}
86 113
           >
87 114
             登录
88 115
           </Button>
89 116
         </View>
90 117
       </Form>
91 118
     </View>
92
-  )
93
-}
119
+  );
120
+};

+ 2
- 1
src/pages/login/index.jsx Ver fichero

@@ -20,7 +20,8 @@ export default (props) => {
20 20
       <View className="login-box">
21 21
         <Head />
22 22
         <Form onSuccess={onSuccess} />
23
-        <Bottom onSuccess={onSuccess} />
23
+        {/* H5此无功能 */}
24
+        {/* <Bottom onSuccess={onSuccess} /> */}
24 25
       </View>
25 26
     </Page>
26 27
   )

+ 45
- 38
src/pages/notice/detail/index.jsx Ver fichero

@@ -1,65 +1,72 @@
1
-import React from 'react';
2
-import Taro from '@tarojs/taro';
3
-import { View, Image, RichText } from '@tarojs/components';
4
-import Page from '@/layouts/index';
5
-import { getTaNoticeById } from '@/services/tanotice';
6
-import { getDtStr } from '@/utils/date';
7
-import style from './style.module.less';
1
+import React from "react";
2
+import Taro from "@tarojs/taro";
3
+import { View, Image, RichText } from "@tarojs/components";
4
+import Page from "@/layouts/index";
5
+import { getTaNoticeById } from "@/services/tanotice";
6
+import { getDtStr } from "@/utils/date";
7
+import style from "./style.module.less";
8 8
 
9 9
 export default (props) => {
10
-
11 10
   const [loading, setLoading] = React.useState(false);
12 11
   const [detail, setDetail] = React.useState();
13
-  const dateStr = React.useMemo(() => detail?.createDate ? getDtStr(detail.createDate) : '-', [detail]);
12
+  const dateStr = React.useMemo(
13
+    () => (detail?.createDate ? getDtStr(detail.createDate) : "-"),
14
+    [detail]
15
+  );
14 16
 
15 17
   const router = Taro.useRouter();
16 18
   const { id } = router.params;
17 19
 
18 20
   const onPreview = () => {
19 21
     if (!detail?.thumb) return;
20
-
21
-    Taro.previewMedia({
22
-      sources: [
23
-        {
24
-          url: detail.thumb,
25
-        },        
26
-      ],
27
-      current: 0,
28
-    })
29
-  }
22
+      //Weapp
23
+    // Taro.previewMedia({
24
+    //   sources: [
25
+    //     {
26
+    //       url: detail.thumb,
27
+    //     },
28
+    //   ],
29
+    //   current: 0,
30
+    // })
31
+    
32
+    //H5
33
+    Taro.previewImage({
34
+      current: 0, // 当前显示图片的http链接
35
+      urls: [detail.thumb],
36
+    });
37
+  };
30 38
 
31 39
   React.useEffect(() => {
32 40
     if (id) {
33 41
       setLoading(true);
34
-      getTaNoticeById(id).then((res) => {
35
-        setDetail(res);
36
-        Taro.setNavigationBarTitle({
37
-          title: res.title,
42
+      getTaNoticeById(id)
43
+        .then((res) => {
44
+          setDetail(res);
45
+          Taro.setNavigationBarTitle({
46
+            title: res.title,
47
+          });
48
+          setLoading(false);
38 49
         })
39
-        setLoading(false);
40
-      }).catch(er => {
41
-        console.error(er);
42
-        setLoading(false);
43
-      });
50
+        .catch((er) => {
51
+          console.error(er);
52
+          setLoading(false);
53
+        });
44 54
     }
45 55
   }, [id]);
46 56
 
47
-  
48 57
   return (
49 58
     <Page loading={loading}>
50
-      <View className={style['notice-wrapper']} style={style}>
51
-        <View className={style['notice-hd']}>
59
+      <View className={style["notice-wrapper"]} style={style}>
60
+        <View className={style["notice-hd"]}>
52 61
           {detail?.title}
53
-          <View className={style['notice-hd2']}>{dateStr}</View>
62
+          <View className={style["notice-hd2"]}>{dateStr}</View>
54 63
         </View>
55
-        <View className={style['notice-bd']}>
64
+        <View className={style["notice-bd"]}>
56 65
           <Image src={detail?.thumb} onClick={onPreview}></Image>
57 66
           <RichText nodes={detail?.content} />
58 67
         </View>
59
-        <View className={style['notice-ft']}>
60
-
61
-        </View>
68
+        <View className={style["notice-ft"]}></View>
62 69
       </View>
63 70
     </Page>
64
-  )
65
-}
71
+  );
72
+};

+ 0
- 1
src/pages/reset-password/components/ResetPwd.jsx Ver fichero

@@ -43,7 +43,6 @@ export default (props) => {
43 43
     setLoading(true)
44 44
     onSubmit({ password: md5(pwd1) }).then(() => {
45 45
       setLoading(false);
46
-
47 46
       Taro.navigateBack({
48 47
         delta: 1,
49 48
         fail: () => {

+ 4
- 4
src/pages/user/list/index.jsx Ver fichero

@@ -57,8 +57,8 @@ export default (props) => {
57 57
   return (
58 58
     <Page loading={loading} onShow={onShow}>
59 59
       <Dialog id={dialogId} />
60
-      <view className={styles["user-warpper"]}>
61
-        <view className={styles["user-warpper-list"]}>
60
+      <View className={styles["user-warpper"]}>
61
+        <View className={styles["user-warpper-list"]}>
62 62
           <PowerList
63 63
             sid={sid1}
64 64
             ref={listRef}
@@ -91,7 +91,7 @@ export default (props) => {
91 91
               </Cell>
92 92
             )}
93 93
           />
94
-        </view>
94
+        </View>
95 95
 
96 96
         <Button
97 97
           type="primary"
@@ -104,7 +104,7 @@ export default (props) => {
104 104
         >
105 105
           添加
106 106
         </Button>
107
-      </view>
107
+      </View>
108 108
     </Page>
109 109
   );
110 110
 };

+ 28
- 18
src/store/user.js Ver fichero

@@ -17,14 +17,15 @@ export default function useUser() {
17 17
   const [duty, setDuty] = React.useState();
18 18
 
19 19
   const maLogin = (code) => {
20
-    console.log(code)
21
-    login(code).then((res) => {
22
-      setPerson(res.person);
23
-      Taro.setStorage({ key: "personId", data: res.person.personId });
24
-      Taro.setStorage({ key: "sessionKey", data: res.sessionKey });
25
-    }).catch(e => {
26
-      console.log(e)
27
-    });
20
+    login(code)
21
+      .then((res) => {
22
+        setPerson(res.person);
23
+        Taro.setStorage({ key: "personId", data: res.person.personId });
24
+        Taro.setStorage({ key: "sessionKey", data: res.sessionKey });
25
+      })
26
+      .catch((e) => {
27
+        console.error(e);
28
+      });
28 29
   };
29 30
 
30 31
   const updateDuty = (d = ROLE_CITIZEN) => {
@@ -33,9 +34,9 @@ export default function useUser() {
33 34
   };
34 35
 
35 36
   const initDuty = (u) => {
36
-    console.log(u)
37
+    console.log(u);
37 38
     const d = Taro.getStorageSync("duty");
38
-    console.log(d)
39
+    console.log(d);
39 40
     const dutyList = u?.dutyList || [];
40 41
     if (d) {
41 42
       if (dutyList.indexOf(d) < 0) {
@@ -61,12 +62,14 @@ export default function useUser() {
61 62
   };
62 63
 
63 64
   const current = () => {
64
-    currentUser().then((res) => {
65
-      setUser(res.user);
66
-      initDuty(res.user);
67
-    }).catch(e => {
68
-      console.log(e)
69
-    });
65
+    currentUser()
66
+      .then((res) => {
67
+        setUser(res.user);
68
+        initDuty(res.user);
69
+      })
70
+      .catch((e) => {
71
+        console.log(e);
72
+      });
70 73
   };
71 74
 
72 75
   const signinByPhone = (code) => {
@@ -86,7 +89,7 @@ export default function useUser() {
86 89
 
87 90
   const signOut = () => {
88 91
     setUser(null);
89
-    initDuty([]);
92
+    initDuty(null);
90 93
   };
91 94
 
92 95
   const changePwd = (params) => {
@@ -95,7 +98,14 @@ export default function useUser() {
95 98
       newPassword: md5(params.newPassword),
96 99
     };
97 100
 
98
-    changePassword(data);
101
+    changePassword(data)
102
+      .then((res) => {
103
+        signOut()
104
+
105
+      })
106
+      .catch((e) => {
107
+        console.error(e);
108
+      });
99 109
   };
100 110
 
101 111
   return {

+ 2
- 2
src/subpkg1/components/chart/index.jsx Ver fichero

@@ -37,9 +37,9 @@ const Chart = (props) => {
37 37
   }, [option, inited]);
38 38
 
39 39
   return (
40
-    <view className={className} style={style}>
40
+    <View className={className} style={style}>
41 41
       <ec-canvas canvasId={canvasId} ec={ec}></ec-canvas>
42
-    </view>
42
+    </View>
43 43
   )
44 44
 }
45 45
 

+ 42
- 19
src/utils/authorize.js Ver fichero

@@ -1,4 +1,4 @@
1
-import Taro from '@tarojs/taro';
1
+import Taro from "@tarojs/taro";
2 2
 
3 3
 export default function getAuthorize(scope) {
4 4
   return new Promise((resolve, reject) => {
@@ -12,7 +12,7 @@ export default function getAuthorize(scope) {
12 12
               console.error(err);
13 13
               reject(err);
14 14
             },
15
-          })
15
+          });
16 16
         } else {
17 17
           resolve();
18 18
         }
@@ -20,27 +20,50 @@ export default function getAuthorize(scope) {
20 20
       fail(err) {
21 21
         console.error(err);
22 22
         reject(err);
23
-      }
23
+      },
24 24
     });
25 25
   });
26 26
 }
27 27
 
28
-export const getLocation = (options) => {
28
+export const getLocation = async (options) => {
29
+  // try {
30
+  return await new Promise((resolve, reject) => {
31
+    wx.getLocation({
32
+      ...(options || {}),
33
+      success(res) {
34
+        resolve(res);
35
+      },
36
+      fail(err) {
37
+        console.error(err);
38
+        reject(err);
39
+      },
40
+    });
41
+  });
42
+  // } catch (err_1) {
43
+  //   console.error(err_1);
44
+  //   reject(err_1);
45
+  // }
46
+};
47
+const key = "6WQBZ-5VIC4-BZTUI-DIG64-R4XO3-PWBH3";
48
+export const h5GetLocation = () => {
29 49
   return new Promise((resolve, reject) => {
30
-    getAuthorize('scope.userLocation').then(() => {
31
-      Taro.getLocation({
32
-        ...options || {},
33
-        success(res) {
34
-          resolve(res);
35
-        },
36
-        fail(err) {
37
-          console.error(err);
38
-          reject(err);
39
-        }
40
-      });
41
-    }).catch((err) => {
42
-      console.error(err);
43
-      reject(err);
50
+    const url = `/api2/ws/location/v1/ip?key=${key}`;
51
+    const res = Taro.request({
52
+      url: url,
53
+      method: "GET",
54
+      dataType: "json",
55
+      header: {
56
+        "content-type": "application/json",
57
+      },
44 58
     });
59
+    resolve(res);
60
+    reject(res);
61
+    // .then((res) => {
62
+    //   resolve(res.result);
63
+    // })
64
+    // .catch((error) => {
65
+    //   reject(error);
66
+    //   console.error("请求失败", error);
67
+    // });
45 68
   });
46
-}
69
+};

+ 1
- 1
src/utils/map.js Ver fichero

@@ -11,7 +11,7 @@ export function geocoder(location, getPoi = 0) {
11 11
   }
12 12
 
13 13
   return new Promise((resolve, reject) => {
14
-    const url = `https://apis.map.qq.com/ws/geocoder/v1/?location=${location}&key=${QMAP_WEBSERVICE_KEY}&get_poi=${getPoi}`
14
+    const url = `/api2/ws/geocoder/v1/?location=${location}&key=${QMAP_WEBSERVICE_KEY}&get_poi=${getPoi}`
15 15
 
16 16
     Taro.request({ url }).then(({ data }) => {
17 17
       const { status, message, result } = data || {};

+ 2
- 1
src/utils/message.js Ver fichero

@@ -7,6 +7,7 @@ export function warn(predicate, message) {
7 7
       message,
8 8
       type: 'warning',
9 9
     })
10
-    throw new Error(message);
10
+    //Weapp
11
+    // throw new Error(message);
11 12
   }
12 13
 }

+ 9
- 9
src/utils/request.js Ver fichero

@@ -32,13 +32,13 @@ export default function request(api, options = {}) {
32 32
     const duty = Taro.getStorageSync("duty");
33 33
 
34 34
     const onError = (err) => {
35
-      console.error(err);
36
-      if (!H5) {
37
-        console.log(1)
38
-        logger.error(`接口 [${method}]: ${url}`);
39
-        logger.error("参数: ", data);
40
-        logger.error(err);
41
-      }
35
+      // console.error(err);
36
+      // if (!H5) {
37
+      //   console.log(1)
38
+      //   logger.error(`接口 [${method}]: ${url}`);
39
+      //   logger.error("参数: ", data);
40
+      //   logger.error(err);
41
+      // }
42 42
 
43 43
       if (!silent && "GET" !== method.toUpperCase()) {
44 44
         Taro.showModal({
@@ -54,7 +54,6 @@ export default function request(api, options = {}) {
54 54
       url,
55 55
       data,
56 56
       method,
57
-      // mode: "no-cors",
58 57
       header: {
59 58
         "x-client": "miniapp",
60 59
         "x-personId": personId,
@@ -104,12 +103,13 @@ export const uploadFiles = async (files, url) => {
104 103
       Taro.uploadFile({
105 104
         // eslint-disable-next-line no-undef
106 105
         url: url || `${HOST}/api/ma/file`,
107
-        filePath: files[i].tempFilePath,
106
+        filePath: files[i].tempFilePath,//
108 107
         header: {
109 108
           authorization: token,
110 109
         },
111 110
         name: "file",
112 111
         formData: {
112
+          file: files[i].originalFileObj,
113 113
           fileType: files[i].fileType,
114 114
         },
115 115
         success: function (res) {