Przeglądaj źródła

微信登录统一

seimin 3 lat temu
rodzic
commit
250a868f20
6 zmienionych plików z 129 dodań i 90 usunięć
  1. 26 7
      package-lock.json
  2. 1 0
      package.json
  3. 3 2
      public/index.html
  4. 20 9
      src/App.vue
  5. 72 72
      src/cube-ui.js
  6. 7 0
      src/main.js

+ 26 - 7
package-lock.json

@@ -9,6 +9,7 @@
9
       "version": "0.1.0",
9
       "version": "0.1.0",
10
       "dependencies": {
10
       "dependencies": {
11
         "amfe-flexible": "^2.2.1",
11
         "amfe-flexible": "^2.2.1",
12
+        "axios": "^0.24.0",
12
         "core-js": "^3.6.5",
13
         "core-js": "^3.6.5",
13
         "cube-ui": "~1.12.15",
14
         "cube-ui": "~1.12.15",
14
         "vue": "^2.6.11"
15
         "vue": "^2.6.11"
@@ -3078,6 +3079,14 @@
3078
       "integrity": "sha1-1h9G2DslGSUOJ4Ta9bCUeai0HFk=",
3079
       "integrity": "sha1-1h9G2DslGSUOJ4Ta9bCUeai0HFk=",
3079
       "dev": true
3080
       "dev": true
3080
     },
3081
     },
3082
+    "node_modules/axios": {
3083
+      "version": "0.24.0",
3084
+      "resolved": "https://registry.npmmirror.com/axios/download/axios-0.24.0.tgz",
3085
+      "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==",
3086
+      "dependencies": {
3087
+        "follow-redirects": "^1.14.4"
3088
+      }
3089
+    },
3081
     "node_modules/babel-loader": {
3090
     "node_modules/babel-loader": {
3082
       "version": "8.2.3",
3091
       "version": "8.2.3",
3083
       "resolved": "https://registry.npmmirror.com/babel-loader/download/babel-loader-8.2.3.tgz",
3092
       "resolved": "https://registry.npmmirror.com/babel-loader/download/babel-loader-8.2.3.tgz",
@@ -6446,7 +6455,6 @@
6446
       "version": "1.14.6",
6455
       "version": "1.14.6",
6447
       "resolved": "https://registry.npmmirror.com/follow-redirects/download/follow-redirects-1.14.6.tgz",
6456
       "resolved": "https://registry.npmmirror.com/follow-redirects/download/follow-redirects-1.14.6.tgz",
6448
       "integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==",
6457
       "integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==",
6449
-      "dev": true,
6450
       "funding": [
6458
       "funding": [
6451
         {
6459
         {
6452
           "type": "individual",
6460
           "type": "individual",
@@ -16304,7 +16312,8 @@
16304
       "version": "4.5.15",
16312
       "version": "4.5.15",
16305
       "resolved": "https://registry.npmmirror.com/@vue/cli-plugin-vuex/download/@vue/cli-plugin-vuex-4.5.15.tgz",
16313
       "resolved": "https://registry.npmmirror.com/@vue/cli-plugin-vuex/download/@vue/cli-plugin-vuex-4.5.15.tgz",
16306
       "integrity": "sha1-RmwfAnd9Av71Opu0mjbMOjvP7E4=",
16314
       "integrity": "sha1-RmwfAnd9Av71Opu0mjbMOjvP7E4=",
16307
-      "dev": true
16315
+      "dev": true,
16316
+      "requires": {}
16308
     },
16317
     },
16309
     "@vue/cli-service": {
16318
     "@vue/cli-service": {
16310
       "version": "4.5.15",
16319
       "version": "4.5.15",
@@ -16441,7 +16450,8 @@
16441
       "version": "1.1.2",
16450
       "version": "1.1.2",
16442
       "resolved": "https://registry.nlark.com/@vue/preload-webpack-plugin/download/@vue/preload-webpack-plugin-1.1.2.tgz",
16451
       "resolved": "https://registry.nlark.com/@vue/preload-webpack-plugin/download/@vue/preload-webpack-plugin-1.1.2.tgz",
16443
       "integrity": "sha1-zrkktOyzucQ4ccekKaAvhCPmIas=",
16452
       "integrity": "sha1-zrkktOyzucQ4ccekKaAvhCPmIas=",
16444
-      "dev": true
16453
+      "dev": true,
16454
+      "requires": {}
16445
     },
16455
     },
16446
     "@vue/web-component-wrapper": {
16456
     "@vue/web-component-wrapper": {
16447
       "version": "1.3.0",
16457
       "version": "1.3.0",
@@ -16680,13 +16690,15 @@
16680
       "version": "1.0.1",
16690
       "version": "1.0.1",
16681
       "resolved": "https://registry.nlark.com/ajv-errors/download/ajv-errors-1.0.1.tgz",
16691
       "resolved": "https://registry.nlark.com/ajv-errors/download/ajv-errors-1.0.1.tgz",
16682
       "integrity": "sha1-81mGrOuRr63sQQL72FAUlQzvpk0=",
16692
       "integrity": "sha1-81mGrOuRr63sQQL72FAUlQzvpk0=",
16683
-      "dev": true
16693
+      "dev": true,
16694
+      "requires": {}
16684
     },
16695
     },
16685
     "ajv-keywords": {
16696
     "ajv-keywords": {
16686
       "version": "3.5.2",
16697
       "version": "3.5.2",
16687
       "resolved": "https://registry.npmmirror.com/ajv-keywords/download/ajv-keywords-3.5.2.tgz",
16698
       "resolved": "https://registry.npmmirror.com/ajv-keywords/download/ajv-keywords-3.5.2.tgz",
16688
       "integrity": "sha1-MfKdpatuANHC0yms97WSlhTVAU0=",
16699
       "integrity": "sha1-MfKdpatuANHC0yms97WSlhTVAU0=",
16689
-      "dev": true
16700
+      "dev": true,
16701
+      "requires": {}
16690
     },
16702
     },
16691
     "alphanum-sort": {
16703
     "alphanum-sort": {
16692
       "version": "1.0.2",
16704
       "version": "1.0.2",
@@ -16936,6 +16948,14 @@
16936
       "integrity": "sha1-1h9G2DslGSUOJ4Ta9bCUeai0HFk=",
16948
       "integrity": "sha1-1h9G2DslGSUOJ4Ta9bCUeai0HFk=",
16937
       "dev": true
16949
       "dev": true
16938
     },
16950
     },
16951
+    "axios": {
16952
+      "version": "0.24.0",
16953
+      "resolved": "https://registry.npmmirror.com/axios/download/axios-0.24.0.tgz",
16954
+      "integrity": "sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA==",
16955
+      "requires": {
16956
+        "follow-redirects": "^1.14.4"
16957
+      }
16958
+    },
16939
     "babel-loader": {
16959
     "babel-loader": {
16940
       "version": "8.2.3",
16960
       "version": "8.2.3",
16941
       "resolved": "https://registry.npmmirror.com/babel-loader/download/babel-loader-8.2.3.tgz",
16961
       "resolved": "https://registry.npmmirror.com/babel-loader/download/babel-loader-8.2.3.tgz",
@@ -19745,8 +19765,7 @@
19745
     "follow-redirects": {
19765
     "follow-redirects": {
19746
       "version": "1.14.6",
19766
       "version": "1.14.6",
19747
       "resolved": "https://registry.npmmirror.com/follow-redirects/download/follow-redirects-1.14.6.tgz",
19767
       "resolved": "https://registry.npmmirror.com/follow-redirects/download/follow-redirects-1.14.6.tgz",
19748
-      "integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A==",
19749
-      "dev": true
19768
+      "integrity": "sha512-fhUl5EwSJbbl8AR+uYL2KQDxLkdSjZGR36xy46AO7cOMTrCMON6Sa28FmAnC2tRTDbd/Uuzz3aJBv7EBN7JH8A=="
19750
     },
19769
     },
19751
     "for-in": {
19770
     "for-in": {
19752
       "version": "1.0.2",
19771
       "version": "1.0.2",

+ 1 - 0
package.json

@@ -8,6 +8,7 @@
8
   },
8
   },
9
   "dependencies": {
9
   "dependencies": {
10
     "amfe-flexible": "^2.2.1",
10
     "amfe-flexible": "^2.2.1",
11
+    "axios": "^0.24.0",
11
     "core-js": "^3.6.5",
12
     "core-js": "^3.6.5",
12
     "cube-ui": "~1.12.15",
13
     "cube-ui": "~1.12.15",
13
     "vue": "^2.6.11"
14
     "vue": "^2.6.11"

+ 3 - 2
public/index.html

@@ -4,8 +4,9 @@
4
     <meta charset="utf-8">
4
     <meta charset="utf-8">
5
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
5
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
6
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
7
-    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
8
-    <title><%= htmlWebpackPlugin.options.title %></title>
7
+    <!-- <link rel="icon" href="<%= BASE_URL %>favicon.ico"> -->
8
+    <!-- <title><%= htmlWebpackPlugin.options.title %></title> -->
9
+    <title>首页</title>
9
   </head>
10
   </head>
10
   <body>
11
   <body>
11
     <noscript>
12
     <noscript>

+ 20 - 9
src/App.vue

@@ -1,8 +1,8 @@
1
 <template>
1
 <template>
2
   <div id="app">
2
   <div id="app">
3
-    <cube-button @click="goTo('service')">进入微信服务台</cube-button>
4
-    <cube-button @click="goTo('user')">进入微信运维端</cube-button>
5
-    <cube-button @click="goTo('req')">进入微信报修端</cube-button>
3
+    <cube-button @click="goTo('service')" v-show="isService">进入微信服务台</cube-button>
4
+    <cube-button @click="goTo('user')" v-show="isUser">进入微信运维端</cube-button>
5
+    <cube-button @click="goTo('req')" v-show="isReq">进入微信报修端</cube-button>
6
   </div>
6
   </div>
7
 </template>
7
 </template>
8
 
8
 
@@ -12,12 +12,23 @@ export default {
12
   data() {
12
   data() {
13
     return {
13
     return {
14
       baseUrl: document.location.protocol + "//" + document.domain,
14
       baseUrl: document.location.protocol + "//" + document.domain,
15
+      isService:false,//服务台
16
+      isUser:false,//运维端
17
+      isReq:false,//报修端
15
     };
18
     };
16
   },
19
   },
17
   methods: {
20
   methods: {
18
     // 判断角色
21
     // 判断角色
19
-    roleHandler(user){
20
-
22
+    roleHandler(user,requester){
23
+      let userRoles = user.role.map(v=>({id:v.id,rolecode:v.rolecode}));
24
+      if(userRoles.length){
25
+        this.isService = userRoles.some(v=>(v.rolecode === 'call center' || v.rolecode === 'call center admin'))
26
+        this.isUser = userRoles.some(v=>(v.rolecode === 'first-line support' || v.rolecode === 'second-line support' || v.rolecode === 'incident manager' || v.rolecode === 'inspectman' || v.rolecode === 'incident-category-manager'))
27
+      }else{
28
+        this.isService = false;
29
+        this.isUser = false;
30
+      }
31
+      this.isReq = requester ? true : false;
21
     },
32
     },
22
     // 跳转应用
33
     // 跳转应用
23
     goTo(type) {
34
     goTo(type) {
@@ -35,12 +46,12 @@ export default {
35
     },
46
     },
36
     // 登陆
47
     // 登陆
37
     login() {
48
     login() {
38
-      this.$http.post("service/auth/wechatlogin", {}).then(function(res) {
49
+      this.$http.post("service/auth/wechatAuth", {}).then(function(res) {
39
         if (res.data.url) {
50
         if (res.data.url) {
40
           window.location.href = res.data.url;
51
           window.location.href = res.data.url;
41
         } else {
52
         } else {
42
           if (res.data.user) {
53
           if (res.data.user) {
43
-            this.roleHandler(res.data.user.user);
54
+            this.roleHandler(res.data.user.user,res.data.user.requester);
44
           }
55
           }
45
         }
56
         }
46
       });
57
       });
@@ -54,10 +65,10 @@ export default {
54
         var code = {
65
         var code = {
55
           code: url[1],
66
           code: url[1],
56
         };
67
         };
57
-        this.$http.post("service/auth/wechatlogin2", code).then(res => {
68
+        this.$http.post("service/auth/wechatLoginEncrypt", code).then(res => {
58
           if (res.data.state == 200) {
69
           if (res.data.state == 200) {
59
             if (res.data.user) {
70
             if (res.data.user) {
60
-              this.roleHandler(res.data.user.user);
71
+              this.roleHandler(res.data.user.user,res.data.user.requester);
61
             }
72
             }
62
           } else if (res.data.state == 501) {
73
           } else if (res.data.state == 501) {
63
             this
74
             this

+ 72 - 72
src/cube-ui.js

@@ -8,81 +8,81 @@ import {
8
   Style,
8
   Style,
9
   // basic
9
   // basic
10
   Button,
10
   Button,
11
-  Loading,
12
-  Tip,
13
-  Toolbar,
14
-  TabBar,
15
-  TabPanels,
11
+  // Loading,
12
+  // Tip,
13
+  // Toolbar,
14
+  // TabBar,
15
+  // TabPanels,
16
   // form
16
   // form
17
-  Checkbox,
18
-  CheckboxGroup,
19
-  Checker,
20
-  Radio,
21
-  RadioGroup,
22
-  Input,
23
-  Textarea,
24
-  Select,
25
-  Switch,
26
-  Rate,
27
-  Validator,
28
-  Upload,
29
-  Form,
17
+  // Checkbox,
18
+  // CheckboxGroup,
19
+  // Checker,
20
+  // Radio,
21
+  // RadioGroup,
22
+  // Input,
23
+  // Textarea,
24
+  // Select,
25
+  // Switch,
26
+  // Rate,
27
+  // Validator,
28
+  // Upload,
29
+  // Form,
30
   // popup
30
   // popup
31
-  Popup,
32
-  Toast,
33
-  Picker,
34
-  CascadePicker,
35
-  DatePicker,
36
-  TimePicker,
37
-  SegmentPicker,
38
-  Dialog,
39
-  ActionSheet,
40
-  Drawer,
41
-  ImagePreview,
31
+  // Popup,
32
+  // Toast,
33
+  // Picker,
34
+  // CascadePicker,
35
+  // DatePicker,
36
+  // TimePicker,
37
+  // SegmentPicker,
38
+  // Dialog,
39
+  // ActionSheet,
40
+  // Drawer,
41
+  // ImagePreview,
42
   // scroll
42
   // scroll
43
-  Scroll,
44
-  Slide,
45
-  IndexList,
46
-  Swipe,
47
-  Sticky,
48
-  ScrollNav,
49
-  ScrollNavBar
43
+  // Scroll,
44
+  // Slide,
45
+  // IndexList,
46
+  // Swipe,
47
+  // Sticky,
48
+  // ScrollNav,
49
+  // ScrollNavBar
50
 } from 'cube-ui'
50
 } from 'cube-ui'
51
 
51
 
52
 Vue.use(Button)
52
 Vue.use(Button)
53
-Vue.use(Loading)
54
-Vue.use(Tip)
55
-Vue.use(Toolbar)
56
-Vue.use(TabBar)
57
-Vue.use(TabPanels)
58
-Vue.use(Checkbox)
59
-Vue.use(CheckboxGroup)
60
-Vue.use(Checker)
61
-Vue.use(Radio)
62
-Vue.use(RadioGroup)
63
-Vue.use(Input)
64
-Vue.use(Textarea)
65
-Vue.use(Select)
66
-Vue.use(Switch)
67
-Vue.use(Rate)
68
-Vue.use(Validator)
69
-Vue.use(Upload)
70
-Vue.use(Form)
71
-Vue.use(Popup)
72
-Vue.use(Toast)
73
-Vue.use(Picker)
74
-Vue.use(CascadePicker)
75
-Vue.use(DatePicker)
76
-Vue.use(TimePicker)
77
-Vue.use(SegmentPicker)
78
-Vue.use(Dialog)
79
-Vue.use(ActionSheet)
80
-Vue.use(Drawer)
81
-Vue.use(ImagePreview)
82
-Vue.use(Scroll)
83
-Vue.use(Slide)
84
-Vue.use(IndexList)
85
-Vue.use(Swipe)
86
-Vue.use(Sticky)
87
-Vue.use(ScrollNav)
88
-Vue.use(ScrollNavBar)
53
+// Vue.use(Loading)
54
+// Vue.use(Tip)
55
+// Vue.use(Toolbar)
56
+// Vue.use(TabBar)
57
+// Vue.use(TabPanels)
58
+// Vue.use(Checkbox)
59
+// Vue.use(CheckboxGroup)
60
+// Vue.use(Checker)
61
+// Vue.use(Radio)
62
+// Vue.use(RadioGroup)
63
+// Vue.use(Input)
64
+// Vue.use(Textarea)
65
+// Vue.use(Select)
66
+// Vue.use(Switch)
67
+// Vue.use(Rate)
68
+// Vue.use(Validator)
69
+// Vue.use(Upload)
70
+// Vue.use(Form)
71
+// Vue.use(Popup)
72
+// Vue.use(Toast)
73
+// Vue.use(Picker)
74
+// Vue.use(CascadePicker)
75
+// Vue.use(DatePicker)
76
+// Vue.use(TimePicker)
77
+// Vue.use(SegmentPicker)
78
+// Vue.use(Dialog)
79
+// Vue.use(ActionSheet)
80
+// Vue.use(Drawer)
81
+// Vue.use(ImagePreview)
82
+// Vue.use(Scroll)
83
+// Vue.use(Slide)
84
+// Vue.use(IndexList)
85
+// Vue.use(Swipe)
86
+// Vue.use(Sticky)
87
+// Vue.use(ScrollNav)
88
+// Vue.use(ScrollNavBar)

+ 7 - 0
src/main.js

@@ -2,9 +2,16 @@ import Vue from 'vue'
2
 import './cube-ui'
2
 import './cube-ui'
3
 import App from './App.vue'
3
 import App from './App.vue'
4
 import 'amfe-flexible'
4
 import 'amfe-flexible'
5
+import axios from 'axios'
5
 
6
 
6
 Vue.config.productionTip = false
7
 Vue.config.productionTip = false
7
 
8
 
9
+let domainName = document.domain; //域名
10
+let protocolName = document.location.protocol; //http协议
11
+axios.defaults.baseURL = protocolName + "//" + domainName;
12
+Vue.prototype.$http = axios;
13
+// Vue.prototype.$host = protocolName + "//" + domainName;
14
+
8
 new Vue({
15
 new Vue({
9
   render: h => h(App),
16
   render: h => h(App),
10
 }).$mount('#app')
17
 }).$mount('#app')