Yansen 11 个月前
父节点
当前提交
df3397b683

+ 2
- 2
config/dev.js 查看文件

@@ -3,8 +3,8 @@ module.exports = {
3 3
     NODE_ENV: '"development"',
4 4
   },
5 5
   defineConstants: {
6
-    // HOST: '"http://127.0.0.1:9087"',
7
-    HOST: '""',
6
+    HOST: '"http://127.0.0.1:9087"',
7
+    // HOST: '""',
8 8
     // HOST: '"https://wmcj.huoshannews.com"',
9 9
     MAPHOST: '"/api2"',
10 10
     AD_IMAGE: '"https://h5.njyunzhi.com/images/citizen_banner.png"',

+ 4
- 1
config/index.js 查看文件

@@ -30,7 +30,10 @@ export default defineConfig(async (merge, { command, mode }) => {
30 30
     plugins: [],
31 31
     defineConstants: {},
32 32
     copy: {
33
-      patterns: [{ from: "src/assets/tabbar/", to: "dist/assets/tabbar/" }],
33
+      patterns: [
34
+        { from: "src/assets/tabbar/", to: "dist/assets/tabbar/" },
35
+        { from: "src/assets/js/", to: "dist/assets/js/" },
36
+      ],
34 37
       options: {},
35 38
     },
36 39
     framework: "react",

二进制
src/assets/image/logo.png 查看文件


+ 614
- 0
src/assets/js/smartcitysdk.js 查看文件

@@ -0,0 +1,614 @@
1
+;(function(undefined) {
2
+
3
+    var _initBridge = false;
4
+
5
+    function SmartCity(){}
6
+  
7
+    function setupWebViewJavascriptBridge(callback) {
8
+        if (window.WebViewJavascriptBridge) {
9
+            return callback(WebViewJavascriptBridge);
10
+        }else{
11
+            document.addEventListener('WebViewJavascriptBridgeReady', function() {
12
+                return callback(WebViewJavascriptBridge);
13
+            }, false);
14
+        }
15
+        if (window.WVJBCallbacks) {
16
+            return window.WVJBCallbacks.push(callback);
17
+        }
18
+        window.WVJBCallbacks = [callback];
19
+        var WVJBIframe = document.createElement('iframe');
20
+        WVJBIframe.style.display = 'none';
21
+        WVJBIframe.src = 'https://__bridge_loaded__';
22
+        document.documentElement.appendChild(WVJBIframe);
23
+        setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
24
+    }
25
+    
26
+    function getMobileDevice(){
27
+        var mbldevice = navigator.userAgent.toLowerCase()
28
+        if (/iphone|ipod|ipad/gi.test(mbldevice)) {
29
+            return 'iOS'
30
+        } else if (/android/gi.test(mbldevice)) {
31
+            return 'Android'
32
+        } else {
33
+            return 'other'
34
+        }
35
+    }
36
+
37
+    function isSmartCity(){
38
+        var mbldevice = navigator.userAgent.toLowerCase();
39
+        console.log(mbldevice)
40
+        if (/m2osmartcity/gi.test(mbldevice) || /workcall/gi.test(mbldevice) || /html5plus/gi.test(mbldevice)
41
+        ) {
42
+            return true;
43
+        }else{
44
+            return false;
45
+        }
46
+    }
47
+
48
+    function callHandler(api, param, callback){
49
+        if(!isSmartCity()){
50
+            // alert('请在app中打开');
51
+            return;
52
+        }
53
+        setupWebViewJavascriptBridge(function(bridge){
54
+            if(typeof bridge.init != 'undefined' && bridge.init instanceof Function){
55
+                if(!_initBridge){
56
+                bridge.init(function(message, responseCallback) {});
57
+                _initBridge = true;
58
+                }
59
+            }
60
+            if (api == 'getLocation') {
61
+                bridge.registerHandler('getLocation', function (response, responseCallback) {
62
+                    response = typeof response === 'string' ? JSON.parse(response) : response;
63
+                    callback && callback(response);
64
+                    responseCallback('success');
65
+                });
66
+            }
67
+            bridge.callHandler(api, param , function(response) {
68
+                response = typeof response === 'string' ? JSON.parse(response) : response;
69
+                callback && callback(response);
70
+            });
71
+        });
72
+    }
73
+
74
+    SmartCity.prototype = {
75
+
76
+        constructor: this,
77
+
78
+        //判断是否在厚建客户端
79
+        isSmartCityApp : function(){
80
+            return isSmartCity();
81
+        },
82
+
83
+        //获取用户信息
84
+        getUserInfo : function(callback){
85
+            callHandler('getUserInfo', null , function(response) {
86
+                callback && callback(response);
87
+            })
88
+        },
89
+        //获取用户信息(hmas)
90
+        getHMASUserInfo : function(param,callback){
91
+            callHandler('getHMASUserInfo', param , function(response) {
92
+                callback && callback(response);
93
+            })
94
+        },
95
+        //获取设备信息
96
+        getSystemInfo : function(callback){
97
+            callHandler('getSystemInfo', null , function(response) {
98
+                callback && callback(response);
99
+            })
100
+        },
101
+
102
+        //获取位置信息
103
+        getLocation : function(callback){
104
+            callHandler('getLocation', null , function(response) {
105
+                callback && callback(response);
106
+            })
107
+        },
108
+
109
+        //去登录页
110
+        goLogin : function(){
111
+            callHandler('goLogin', null , null);
112
+        },
113
+
114
+        //回到上一页
115
+        goBack : function(){
116
+            callHandler('goBack', null , null);
117
+        },
118
+
119
+        //打电话
120
+        makeCall : function(param){
121
+            callHandler('makeCall', param , null);
122
+        },
123
+
124
+        //发邮件
125
+        sendMail : function(param){
126
+            callHandler('sendMail', param , null);
127
+        },
128
+
129
+        //发短信
130
+        makeMsm : function(param){
131
+            callHandler('makeMsm', param , null);
132
+        },
133
+
134
+        //去用户中心
135
+        goUcenter : function(){
136
+            callHandler('goUcenter', null , null);
137
+        },
138
+
139
+        //退出当前页面        
140
+        goAbort : function(){
141
+            callHandler('goAbort', null , null);
142
+        },
143
+
144
+        //返回首页
145
+        goRoot : function(){
146
+            callHandler('goRoot', null , null);
147
+        },
148
+
149
+        //分享
150
+        shareTo : function(param, callback){
151
+            callHandler('shareTo', param , function(response){
152
+                callback && callback(response); 
153
+            });
154
+        },
155
+
156
+        //分享成功
157
+        onShareSuccess : function(callback){
158
+            callHandler('onShareSuccess', null , function(response) {
159
+                callback && callback(response);
160
+            })
161
+        },
162
+
163
+        showKakuAnimations : function(callback){
164
+            callHandler('showKakuAnimations', null, function(response){
165
+                callback && callback(response)
166
+            })
167
+        },
168
+
169
+        //内链跳转
170
+        linkTo : function(param){
171
+            callHandler('linkTo', param , null);
172
+        },
173
+
174
+        //去地图
175
+        goMap : function(param){
176
+            callHandler('goMap', param , null);
177
+        },
178
+
179
+        //大图预览(单张)
180
+        clickImage : function(param){
181
+            callHandler('clickImage', param , null);
182
+        },
183
+
184
+        //大图预览(单张)
185
+        showBigImage : function(param){
186
+            callHandler('showBigImage', param , null);
187
+        },
188
+
189
+        //图片保存
190
+        saveImage : function(param){
191
+            callHandler('saveImage', param , null);
192
+        },
193
+
194
+        //显示分享按钮
195
+        showShareBtn : function(param){
196
+            callHandler('showShareBtn', param , null);
197
+        },
198
+
199
+        //隐藏导航栏
200
+        hideTopView : function(param){
201
+            callHandler('hideTopView', param , null);
202
+        },
203
+
204
+        //全屏播放
205
+        fullScreenPlay : function(param){
206
+            callHandler('fullScreenPlay', param , null);
207
+        },
208
+
209
+        //清空历史信息
210
+        clearHistory : function(){
211
+            callHandler('clearHistory', null , null);
212
+        },
213
+
214
+        //获取头加密信息
215
+        getRequestHeader: function(callback){
216
+            callHandler('getRequestHeader', null , function(response) {
217
+                callback && callback(response);
218
+            })
219
+        },
220
+
221
+        //选择图片
222
+        chooseImage : function(param,callback){
223
+            callHandler('chooseImage', param , function(response) {
224
+                callback && callback(response);
225
+            })
226
+        },
227
+
228
+        openSmartDialog : function(param, callback){
229
+            callHandler('openSmartDialog', param, function(response){
230
+                callback && callback(response);
231
+            })
232
+
233
+        },
234
+
235
+
236
+        //图片预览
237
+        previewImage : function(param){
238
+            callHandler('previewImage', param , null);
239
+        },
240
+
241
+        //扫描二维码
242
+        scanQRCode : function(callback){
243
+            callHandler('scanQRCode', null , function(response) {
244
+                callback && callback(response);
245
+            })
246
+        },
247
+
248
+        //跳转绑定手机号页面
249
+        goBind : function(){
250
+            callHandler('goBind', null , null);
251
+        },
252
+
253
+        //跳转人脸识别实名认证组件
254
+        goToAuthentication : function(callback){
255
+            callHandler('goToAuthentication', null , function(response) {
256
+                callback && callback(response);
257
+            })
258
+        },
259
+
260
+		 //跳转禾点点人脸识别
261
+        goToJXMealCardLivingStyle : function(callback){
262
+            callHandler('goToJXMealCardLivingStyle', null , function(response) {
263
+                callback && callback(response);
264
+            })
265
+        },
266
+
267
+        //跳转禾点点银行控件
268
+        goToJXMealCardSafetyKeyboard : function(callback){
269
+            callHandler('goToJXMealCardSafetyKeyboard', null , function(response) {
270
+                callback && callback(response);
271
+            })
272
+        },
273
+ 
274
+        //内蒙本地相册选取视频
275
+        chooseVideo : function(callback){
276
+            callHandler('chooseVideo', null , function(response) {
277
+                callback && callback(response);
278
+            })
279
+        },
280
+
281
+        // 跳转实人认证页面
282
+        goToRealPersionAuth : function (param,callback) {
283
+            callHandler('goToRealPersionAuth', param , function(response) {
284
+                callback && callback(response);
285
+            })
286
+        },
287
+        
288
+        // 获取每日运动量 add by Neil@20220318
289
+        getStepDayData : function(param, callback) {
290
+            callHandler('getStepDayData', param, function(response) {
291
+                callback && callback(response)
292
+            })
293
+        },
294
+
295
+        // 获取健康数据 add by Neil@20220318
296
+        getHealthDayData : function(param, callback) {
297
+            callHandler('getHealthDayData', param, function(response) {
298
+                callback && callback(response)
299
+            })
300
+        },
301
+
302
+        //跳转拍照页面
303
+        goToCamera : function(param,callback){
304
+            callHandler('goToCamera', param , function(response) {
305
+                callback && callback(response);
306
+            })
307
+        },
308
+
309
+        //跳转拍照身份证页面
310
+        optionalAreaForPhotos : function(param,callback){
311
+            callHandler('optionalAreaForPhotos', param , function(response) {
312
+                callback && callback(response);
313
+            })
314
+        },
315
+
316
+        //跳转活体认证页面
317
+        goToLivingStyle : function(callback){
318
+            callHandler('goToLivingStyle', null , function(response) {
319
+                callback && callback(response);
320
+            })
321
+        },
322
+
323
+        //请求接口数据
324
+        requestApi : function(param,callback){
325
+            callHandler('requestApi', param , function(response) {
326
+                callback && callback(response);
327
+            })
328
+        },
329
+
330
+        //是否禁止侧滑返回
331
+        interactivePopDisabled : function(param){
332
+            callHandler('interactivePopDisabled', param , null);
333
+        },
334
+
335
+        //发送云统计数据
336
+        sendAnalysisData : function(param){
337
+            callHandler('sendAnalysisData', param , null);
338
+        },
339
+
340
+        //请求跳转子app
341
+        linkToSubApp : function(param){
342
+            callHandler('linkToSubApp', param , null);
343
+        },
344
+
345
+        //播放vr视频
346
+        goVRPlayer : function(param){
347
+            callHandler('goVRPlayer', param , null);
348
+        },
349
+
350
+        //加载播放器
351
+        embedVideoPlayer : function(param){
352
+            callHandler('embedVideoPlayer', param , null);
353
+        },
354
+
355
+        //销毁播放器
356
+        destroyVideoPlayer : function(){
357
+            callHandler('destroyVideoPlayer', null , null);
358
+        },
359
+
360
+         //跳转数字人民币
361
+        goUniWallet : function(param){
362
+            callHandler('goUniWallet', param , null);
363
+        },
364
+
365
+        //加载弹幕
366
+        loadBarrageData : function(param){
367
+            callHandler('loadBarrageData', param , null);
368
+        },
369
+
370
+        //请求接口数据
371
+        getRelateNews : function(callback){
372
+            callHandler('getRelateNews', null , function(response) {
373
+                callback && callback(response);
374
+            })
375
+        },
376
+  
377
+        goSubscription : function(param,callback){
378
+            callHandler('goSubscription', param , function(response) {
379
+                callback && callback(response);
380
+            })
381
+        },
382
+  
383
+        getPraiseInfo : function(callback){
384
+            callHandler('getPraiseInfo', null , function(response) {
385
+                callback && callback(response);
386
+            })
387
+        },
388
+
389
+        goPraise : function(){
390
+            callHandler('goPraise', null , null)
391
+        },
392
+
393
+        getMyPraise : function(callback){
394
+            callHandler('getMyPraise', null , function(response) {
395
+                callback && callback(response);
396
+            })
397
+        },
398
+  
399
+        getDiggInfo : function(callback){
400
+            callHandler('getDiggInfo', null , function(response) {
401
+                callback && callback(response);
402
+            })
403
+        },
404
+  
405
+        getCommentList : function(callback){
406
+            callHandler('getCommentList', null , function(response) {
407
+                callback && callback(response);
408
+            })
409
+        },
410
+
411
+        getCommentCount : function(callback){
412
+            callHandler('getCommentCount', null , function(response) {
413
+                callback && callback(response);
414
+            })
415
+        },
416
+  
417
+        getMoreComment : function(){
418
+            callHandler('getMoreComment', null , null)
419
+        },
420
+
421
+        showCommentInput : function(param){
422
+            callHandler('showCommentInput', param , null)
423
+        },
424
+  
425
+        getSubsInfo : function(callback){
426
+            callHandler('getSubsInfo', null , function(response) {
427
+                callback && callback(response);
428
+            })
429
+        },
430
+  
431
+        newsZan : function(callback){
432
+            callHandler('newsZan', null , function(response) {
433
+                callback && callback(response);
434
+            })
435
+        },
436
+  
437
+        commentZan : function(param,callback){
438
+            callHandler('commentZan', param , function(response) {
439
+                callback && callback(response);
440
+            })
441
+        },
442
+        
443
+        commentReply : function(param){
444
+            callHandler('commentReply', param , null)
445
+        },
446
+  
447
+        digg : function(param,callback){
448
+            callHandler('digg', param , function(response) {
449
+                callback && callback(response);
450
+            })
451
+        },
452
+
453
+        //获取电讯广告
454
+        getNewsDetailCDSPAd : function(callback){
455
+            callHandler('getNewsDetailCDSPAd', null , function(response) {
456
+                callback && callback(response);
457
+            })
458
+        },
459
+
460
+        //读新闻
461
+        readNewsContent : function(param){
462
+            callHandler('readNewsContent', param , null)
463
+        },
464
+
465
+        //设置字体大小
466
+        setFontSize : function(param){
467
+            callHandler('setFontSize', param , null)
468
+        },
469
+
470
+        //获取夜间模式状态
471
+        getNightStatus : function(callback){
472
+            callHandler('getNightStatus', null , function(response) {
473
+                callback && callback(response);
474
+            })
475
+        },
476
+
477
+        //融合号跳转
478
+        getSubsInfoOfPlus : function(param){
479
+            callHandler('getSubsInfoOfPlus', param , null)
480
+        },
481
+
482
+        //订阅"订阅状态:0或者1"
483
+        goSubscriptionOfPlus : function(param,callback){
484
+            callHandler('goSubscriptionOfPlus', param , function(response) {
485
+                callback && callback(response);
486
+            })
487
+        },
488
+
489
+        //获取网易信息流点赞数量
490
+        getPraiseNum : function(callback){
491
+            callHandler('getPraiseNum', null , function(response) {
492
+                callback && callback(response);
493
+            })
494
+        },
495
+
496
+        //获取网易信息流点击量
497
+        getPraiseNum : function(callback){
498
+            callHandler('getClickNum', null , function(response) {
499
+                callback && callback(response);
500
+            })
501
+        },
502
+
503
+        //打赏
504
+        goToReward : function(){
505
+            callHandler('goToReward', null , null);
506
+        },
507
+
508
+        getViewPagerInfo : function(param){
509
+            callHandler('getViewPagerInfo', param , null);
510
+        },
511
+
512
+        //开始录音
513
+        startRecord : function(callback){
514
+            callHandler('startRecord', null , function(response) {
515
+                callback && callback(response);
516
+            })
517
+        },
518
+
519
+        //停止录音
520
+        stopRecord : function(callback){
521
+            callHandler('stopRecord', null , function(response) {
522
+                callback && callback(response);
523
+            })
524
+        },
525
+
526
+        //开始播放
527
+        playVoice : function(param){
528
+            callHandler('playVoice', param , null);
529
+        },
530
+        
531
+        //结束播放
532
+        pauseVoice : function(param){
533
+            callHandler('pauseVoice', param , null);
534
+        },
535
+
536
+        //上传文件
537
+        uploadFile : function(param,callback){
538
+            callHandler('uploadFile', param , function(response) {
539
+                callback && callback(response);
540
+            })
541
+        },
542
+
543
+        //云闪付
544
+        appTLUnifyAllinpay : function(param){
545
+            callHandler('appTLUnifyAllinpay', param , null);
546
+        },
547
+
548
+        //微信支付
549
+        appCommonPay : function(param){
550
+            callHandler('appCommonPay', param , null);
551
+        },
552
+
553
+        //浏览器返回劫持
554
+        stopUnload: function(param,callback){
555
+            callHandler('stopUnload', param , function(response) {
556
+                callback && callback(response);
557
+            })
558
+        },
559
+
560
+        //震动反馈
561
+        vibrateFeedback: function(param,callback){
562
+            callHandler('vibrateFeedback', param , function(response) {
563
+                callback && callback(response);
564
+            })
565
+        },
566
+
567
+        //状态管理
568
+        applicationState: function(callback){
569
+            callHandler('applicationState', null , function(response) {
570
+                callback && callback(response);
571
+            })
572
+        },
573
+
574
+        // 拍视频
575
+        videoRecording: function(param,callback) {
576
+            callHandler('videoRecording', param , function(response) {
577
+                callback && callback(response);
578
+            })
579
+        },
580
+
581
+        //关闭web的弹性下拉
582
+        closeWebViewBounces: function(param){
583
+            callHandler('closeWebViewBounces', param , null);
584
+        },
585
+        // 添加快捷方式到桌面
586
+        createShortCut: function (param) {
587
+            callHandler('createShortCut', param , null)
588
+        },
589
+        // 天目云服务埋点
590
+        getServicePage: function (param) {
591
+            callHandler('getServicePage', param , null)
592
+        },
593
+
594
+        //更新每日任务和积分
595
+        creditRulesUpdate : function(param){
596
+            callHandler('creditRulesUpdate', param , null);
597
+        },
598
+
599
+        //禾点点禁止截屏
600
+        canScreenshot : function(param){
601
+            callHandler('canScreenshot', param , null);
602
+        },
603
+
604
+        //建行支付
605
+        appCCBPay : function(param){
606
+            callHandler('appCCBPay', param , null);
607
+        },
608
+        // 返回上一级
609
+        webGoBack: function(param) {
610
+            callHandler('webGoBack', param , null);
611
+        }
612
+    }
613
+    window.SmartCity = new SmartCity();
614
+}());

+ 4
- 2
src/index.html 查看文件

@@ -16,11 +16,13 @@
16 16
       charset="utf-8"
17 17
       src="https://map.qq.com/api/gljs?v=1.exp&key=HTPBZ-HHJA7-XD2XD-PRS37-H3HVJ-U5BAA&libraries=service"
18 18
     ></script>
19
-    <!-- <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
19
+    <!-- <script src="./assets/js/smartcitysdk.js"></script> -->
20
+    <script src="http://wmcj.ycjcjy.com/h5/assets/js/smartcitysdk.js"></script>
21
+    <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
20 22
     <script>
21 23
       // VConsole 默认会挂载到 `window.VConsole` 上
22 24
       var vConsole = new window.VConsole();
23
-    </script> -->
25
+    </script>
24 26
 
25 27
     <title>civilized-miniapp</title>
26 28
     <script>

+ 34
- 45
src/layouts/index.jsx 查看文件

@@ -12,64 +12,52 @@ import { useEffect } from "react";
12 12
 export default (props) => {
13 13
   const { className, style, roles, tabBar = false, loading } = props;
14 14
 
15
-  const { user, duty, current: currentUser } = useModel("user");
15
+  const { person, user, duty } = useModel('user');
16
+
16 17
   const containerClass = `${laySty["page-conatiner"]} ${
17 18
     tabBar ? laySty["with-tabbar"] : ""
18 19
   } ${className}`;
19 20
 
20
-  const userRef = useRef();
21
-  // const personRef = useRef();
21
+  React.useEffect(() => {
22
+    const currentPage = Taro.getCurrentPages().slice().pop();
23
+
24
+    if (!person || !user) {
25
+      if (!currentPage.route.includes("pages/login/index")) {
26
+        Taro.navigateTo({
27
+          url: "/pages/login/index",
28
+        });
29
+
30
+        return;
31
+      }
32
+    }
33
+  }, [person, user]);
34
+
22 35
 
23 36
   // React.useEffect(() => {
24
-  //   if (!userRef.current && !personRef.current) {
25
-  //     userRef.current = person;
26
-  //     personRef.current = user;
27
-  //   }
28
-  //   if (!user) {
29
-  //     userRef.current = null;
30
-  //   }
31 37
   //   console.log("personRef******************");
32
-  //   console.log(personRef.current);
38
+  //   // console.log(person);
33 39
   //   console.log("userRef******************");
34
-  //   console.log(userRef.current);
35
-  //   console.log(personRef.current && !userRef.current);
40
+  //   console.log(user);
41
+  //   console.log(!user);
42
+  //   // if (!userRef.current&&user) {
43
+  //   //   userRef.current = user;
44
+  //   // }
36 45
 
37
-  //   if (personRef.current && !userRef.current) {
38
-  //     const currentPage = Taro.getCurrentPages().slice().pop();
39
-  //     console.log(currentPage.route);
40
-  //     if ("pages/login/index" !== currentPage.route) {
41
-  //       Taro.navigateTo({
42
-  //         url: "/pages/login/index",
43
-  //       });
44
-  //     }
46
+  //   if (!user) {
47
+  //     currentUser().catch(() => {
48
+  //       const currentPage = Taro.getCurrentPages().slice().pop();
49
+  //       if (!currentPage.route.includes("pages/login/index")) {
50
+  //         Taro.navigateTo({
51
+  //           url: "/pages/login/index",
52
+  //         });
53
+  //       }
54
+  //     });
45 55
   //   }
46
-  // }, [person, user]);
47
-
48
-  React.useEffect(() => {
49
-    console.log("personRef******************");
50
-    // console.log(person);
51
-    console.log("userRef******************");
52
-    console.log(user);
53
-    console.log(!user);
54
-    // if (!userRef.current&&user) {
55
-    //   userRef.current = user;
56
-    // }
57
-
58
-    if (!user) {
59
-      currentUser().catch(() => {
60
-        const currentPage = Taro.getCurrentPages().slice().pop();
61
-        if (!currentPage.route.includes("pages/login/index")) {
62
-          Taro.navigateTo({
63
-            url: "/pages/login/index",
64
-          });
65
-        }
66
-      });
67
-    }
68
-  }, [user]);
56
+  // }, [user]);
69 57
 
70 58
   Taro.useShareAppMessage(() => {
71 59
     return {
72
-      title: "文明霍山",
60
+      title: "文明城市",
73 61
     };
74 62
   });
75 63
 
@@ -81,6 +69,7 @@ export default (props) => {
81 69
       // 设置解码后的标题
82 70
       document.title = decodedTitle;
83 71
   }, []);
72
+
84 73
   return (
85 74
     <View className={laySty["page-wrapper"]}>
86 75
       <Notify id="vanNotify" />

+ 37
- 7
src/pages/login/components/Bottom.jsx 查看文件

@@ -1,4 +1,5 @@
1 1
 import React from 'react';
2
+import Taro from '@tarojs/taro';
2 3
 import { View, Image, Button } from '@tarojs/components';
3 4
 // import Icon from '@/assets/image/WeChat.png';
4 5
 import { useModel } from '@/store';
@@ -7,7 +8,7 @@ import style from './bottom.module.less';
7 8
 
8 9
 export default (props) => {
9 10
 
10
-  const { signinByPhone } = useModel('user');
11
+  const { signinByPhone, signup } = useModel('user');
11 12
 
12 13
   const onGetPhoneNumber = (e) => {
13 14
     console.log(e)
@@ -15,18 +16,47 @@ export default (props) => {
15 16
     signinByPhone(code).then(props.onSuccess);
16 17
   }
17 18
 
19
+  const onClick = () => {
20
+    // eslint-disable-next-line no-undef
21
+    SmartCity.getUserInfo(function(res){
22
+      console.log(res);
23
+      if( res && res.userInfo){
24
+        console.log("=========SmartCity.getUserInfo==========");
25
+        console.log(res);
26
+
27
+        const data = {
28
+          openid: res.userInfo.id,
29
+          name: res.userInfo.member_nickname,
30
+          phone: res.userInfo.member_mobile,
31
+          avatar: res.userInfo.member_avatar,
32
+        };
33
+
34
+        Taro.showLoading({ title: '登录中...' });
35
+        signup(data).then(res2 => {
36
+          Taro.hideLoading();
37
+          props.onSuccess();
38
+        }).catch(err => {
39
+          Taro.hideLoading();
40
+        })
41
+      }else{
42
+          // eslint-disable-next-line no-undef
43
+          SmartCity.goLogin();
44
+      }
45
+    })
46
+  }
47
+
18 48
   return (
19 49
     <View>
20
-      <View className={style['txt-box2']}>—— 没有账号?手机号快捷登录 ——</View>
21
-      <View className={style['img-box2']}>
50
+      {/* <View className={style['txt-box2']}>—— 没有账号?手机号快捷登录 ——</View> */}
51
+      {/* <View className={style['img-box2']}>
22 52
         <Button openType="getPhoneNumber" onGetPhoneNumber={onGetPhoneNumber}>
23
-          {/* <Image className={style['img-wechat']}
53
+          <Image className={style['img-wechat']}
24 54
             src={Icon}
25
-          /> */}
55
+          />
26 56
           <Icon name="phone" size="32px" color='green' style={{ marginTop: '10px' }} />
27 57
         </Button>
28
-      </View>
29
-      <View className={style['wechat-login']}>手机号快捷登录</View>
58
+      </View> */}
59
+      <View className={style['wechat-login']} onClick={onClick}>市民入口</View>
30 60
     </View>
31 61
   )
32 62
 }

+ 5
- 3
src/pages/login/components/bottom.module.less 查看文件

@@ -27,8 +27,10 @@
27 27
   }
28 28
 }
29 29
 .wechat-login {
30
-  font-size: 25px;
31
-  color: rgb(174, 174, 174);
30
+  // font-size: 25px;
31
+  // color: rgb(174, 174, 174);
32
+  font-size: 32px;
33
+  color: var(--main-bg-color);
32 34
   text-align: center;
33
-  margin: 12px auto;
35
+  margin: 48px auto;
34 36
 }

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

@@ -4,7 +4,7 @@ import { View } from '@tarojs/components';
4 4
 import Page from '@/layouts/index';
5 5
 import Head from "./components/Head";
6 6
 // import Form1 from "./components/Form1";
7
-// import Bottom from "./components/Bottom";
7
+import Bottom from "./components/Bottom";
8 8
 import './index.less'
9 9
 import Forms from './components/Forms';
10 10
 import Form1 from './components/Form1';
@@ -23,7 +23,7 @@ export default (props) => {
23 23
         <Head />
24 24
         <Form1 onSuccess={onSuccess} />
25 25
         {/* H5此无功能 */}
26
-        {/* <Bottom onSuccess={onSuccess} /> */}
26
+        <Bottom onSuccess={onSuccess} />
27 27
       </View>
28 28
     </Page>
29 29
   )

+ 3
- 0
src/services/wxma.js 查看文件

@@ -37,3 +37,6 @@ export const currentUser = () => request(`/api/ma/current`);
37 37
  * 修改密码
38 38
  */
39 39
 export const changePwd = (data) => request(`/api/ma/change-password`, { method: 'post', data });
40
+
41
+
42
+export const signup = (data) => request(`/api/ma/signup`, { method: 'post', data });

+ 14
- 1
src/store/user.js 查看文件

@@ -9,8 +9,10 @@ import {
9 9
   authUser,
10 10
 } from "@/services/wxma";
11 11
 import { changePassword } from "@/services/sysuser";
12
+import { signup } from '@/services/wxma';
12 13
 import { ROLE_CITIZEN } from "@/utils/user";
13 14
 import { setToken } from "@/utils/token";
15
+import { resolve } from "path";
14 16
 
15 17
 export default function useUser() {
16 18
   const [person, setPerson] = React.useState();
@@ -62,6 +64,16 @@ export default function useUser() {
62 64
     });
63 65
   };
64 66
 
67
+  const maSignup = (data) => {
68
+    return new Promise((resolve, reject) => {
69
+      signup(data).then(res => {
70
+        setPerson(res.person);
71
+        setUser(res.user);
72
+        resolve(res);
73
+      }).catch(reject);
74
+    });
75
+  }
76
+
65 77
   const current = () => {
66 78
     return new Promise((resolve, reject) => {
67 79
       currentUser()
@@ -130,6 +142,7 @@ export default function useUser() {
130 142
     authProfile,
131 143
     signOut,
132 144
     changePwd,
133
-    // setPerson,
145
+    setPerson,
146
+    signup: maSignup,
134 147
   };
135 148
 }