Ver código fonte

feat: 增加默认H5处理

Yansen 11 meses atrás
pai
commit
3bccc67087

+ 1
- 1
config/dev.js Ver arquivo

9
     MAPHOST: '"/api2"',
9
     MAPHOST: '"/api2"',
10
     QMAP_WEBSERVICE_KEY: '"HTPBZ-HHJA7-XD2XD-PRS37-H3HVJ-U5BAA"',
10
     QMAP_WEBSERVICE_KEY: '"HTPBZ-HHJA7-XD2XD-PRS37-H3HVJ-U5BAA"',
11
     AD_IMAGE: '"https://h5.njyunzhi.com/images/citizen_banner.png"',
11
     AD_IMAGE: '"https://h5.njyunzhi.com/images/citizen_banner.png"',
12
-    DEFAULT_POS: '"116.34761502876347,31.40974743425614"', // 霍山县人民政府 gcj02
12
+    DEFAULT_POS: '"101.718514,26.582455"', // 攀枝花市人民政府 gcj02
13
     VERSION: '"1.1.13-20230325"',
13
     VERSION: '"1.1.13-20230325"',
14
   },
14
   },
15
   // isWatch:true,
15
   // isWatch:true,

+ 1
- 1
config/prod.js Ver arquivo

9
     MAPHOST: '"http://api.wmcj.ycjcjy.com/api2"',
9
     MAPHOST: '"http://api.wmcj.ycjcjy.com/api2"',
10
     QMAP_WEBSERVICE_KEY: '"HTPBZ-HHJA7-XD2XD-PRS37-H3HVJ-U5BAA"',
10
     QMAP_WEBSERVICE_KEY: '"HTPBZ-HHJA7-XD2XD-PRS37-H3HVJ-U5BAA"',
11
     AD_IMAGE: '"https://h5.njyunzhi.com/images/citizen_banner.png"',
11
     AD_IMAGE: '"https://h5.njyunzhi.com/images/citizen_banner.png"',
12
-    DEFAULT_POS: '"116.34761502876347,31.40974743425614"', // 霍山县人民政府 gcj02
12
+    DEFAULT_POS: '"101.718514,26.582455"', // 攀枝花市人民政府 gcj02
13
     VERSION: '"1.1.29-20240224"',
13
     VERSION: '"1.1.29-20240224"',
14
   },
14
   },
15
   mini: {},
15
   mini: {},

+ 39
- 36
src/components/Uploader/index.jsx Ver arquivo

18
     e.stopPropagation();
18
     e.stopPropagation();
19
 
19
 
20
     if (disabled) return;
20
     if (disabled) return;
21
-
21
+    
22
     setLoading(true);
22
     setLoading(true);
23
 
23
 
24
     // eslint-disable-next-line no-undef
24
     // eslint-disable-next-line no-undef
25
-    SmartCity.chooseImage({
26
-      count : 1 // 图片张数
27
-    },function(res){
28
-        console.log("--------上传图片---------", res);
29
-        const base64 = res[0].imageData;
30
-        const fileName = res[0].name;
31
-        const fileType = res[0].type;
32
-
33
-        uploadFileBase64(base64, fileName, fileType).then(resp => {
34
-          setLoading(false);
35
-          onChange((value || []).concat(resp));
36
-        }).catch((err) => {
25
+    if (IS_APP_CLIENT) {  
26
+      // eslint-disable-next-line no-undef
27
+      SmartCity.chooseImage({
28
+        count : 1 // 图片张数
29
+      },function(res){
30
+          console.log("--------上传图片---------", res);
31
+          const base64 = res[0].imageData;
32
+          const fileName = res[0].name;
33
+          const fileType = res[0].type;
34
+  
35
+          uploadFileBase64(base64, fileName, fileType).then(resp => {
36
+            setLoading(false);
37
+            onChange((value || []).concat(resp));
38
+          }).catch((err) => {
39
+            console.error(err);
40
+            setLoading(false);
41
+          });
42
+      });
43
+    } else {
44
+      Taro.chooseMedia({
45
+        maxDuration: 60,
46
+        // sizeType: "compressed",
47
+        success: (res) => {
48
+          const { tempFiles } = res;
49
+          uploadFiles(tempFiles)
50
+            .then((resp) => {
51
+              setLoading(false);
52
+              onChange((value || []).concat(resp));
53
+            })
54
+            .catch((err) => {
55
+              console.error(err);
56
+              setLoading(false);
57
+            });
58
+        },
59
+        fail: (err) => {
37
           console.error(err);
60
           console.error(err);
38
           setLoading(false);
61
           setLoading(false);
39
-        });
40
-    });
41
-
42
-    // Taro.chooseMedia({
43
-    //   maxDuration: 60,
44
-    //   // sizeType: "compressed",
45
-    //   success: (res) => {
46
-    //     const { tempFiles } = res;
47
-    //     uploadFiles(tempFiles)
48
-    //       .then((resp) => {
49
-    //         setLoading(false);
50
-    //         onChange((value || []).concat(resp));
51
-    //       })
52
-    //       .catch((err) => {
53
-    //         console.error(err);
54
-    //         setLoading(false);
55
-    //       });
56
-    //   },
57
-    //   fail: (err) => {
58
-    //     console.error(err);
59
-    //     setLoading(false);
60
-    //   },
61
-    // });
62
+        },
63
+      });
64
+    }
62
   };
65
   };
63
 
66
 
64
   const onDelete = (item) => {
67
   const onDelete = (item) => {

+ 5
- 0
src/index.html Ver arquivo

24
       // var vConsole = new window.VConsole();
24
       // var vConsole = new window.VConsole();
25
     </script>
25
     </script>
26
 
26
 
27
+    <script>
28
+      // 是否 app 端打开
29
+      var IS_APP_CLIENT = SmartCity.isSmartCityApp();
30
+    </script>
31
+
27
     <title>文明城市</title>
32
     <title>文明城市</title>
28
     <script>
33
     <script>
29
       <%= htmlWebpackPlugin.options.script %>
34
       <%= htmlWebpackPlugin.options.script %>

+ 4
- 4
src/pages/login/index.jsx Ver arquivo

3
 import { View } from '@tarojs/components';
3
 import { View } from '@tarojs/components';
4
 import Page from '@/layouts/index';
4
 import Page from '@/layouts/index';
5
 import Head from "./components/Head";
5
 import Head from "./components/Head";
6
-// import Form1 from "./components/Form1";
7
 import Bottom from "./components/Bottom";
6
 import Bottom from "./components/Bottom";
8
-import './index.less'
9
-import Forms from './components/Forms';
10
 import Form1 from './components/Form1';
7
 import Form1 from './components/Form1';
8
+import './index.less'
11
 
9
 
12
 export default (props) => {
10
 export default (props) => {
11
+  // eslint-disable-next-line no-undef
12
+  const isApp = IS_APP_CLIENT;
13
 
13
 
14
   const onSuccess = () => {
14
   const onSuccess = () => {
15
     Taro.reLaunch({
15
     Taro.reLaunch({
23
         <Head />
23
         <Head />
24
         <Form1 onSuccess={onSuccess} />
24
         <Form1 onSuccess={onSuccess} />
25
         {/* H5此无功能 */}
25
         {/* H5此无功能 */}
26
-        <Bottom onSuccess={onSuccess} />
26
+        {isApp && <Bottom onSuccess={onSuccess} />}
27
       </View>
27
       </View>
28
     </Page>
28
     </Page>
29
   )
29
   )

+ 13
- 0
src/utils/authorize.js Ver arquivo

27
 }
27
 }
28
 
28
 
29
 export const getLocation = () => {
29
 export const getLocation = () => {
30
+  // eslint-disable-next-line no-undef
31
+  if (!IS_APP_CLIENT) {
32
+    // 非 app 端, 直接使用默认位置
33
+    // eslint-disable-next-line no-undef
34
+    const parts = DEFAULT_POS.split(',')
35
+    return Promise.resolve({
36
+      location: {
37
+        lat: parts[1],
38
+        lng: parts[0],
39
+      },
40
+    });
41
+  }
42
+
30
   return new Promise((resolve, reject) => {
43
   return new Promise((resolve, reject) => {
31
     // eslint-disable-next-line no-undef
44
     // eslint-disable-next-line no-undef
32
     SmartCity.getLocation(function(res){
45
     SmartCity.getLocation(function(res){