cloud-web-corejs 1.0.146 → 1.0.148

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.146",
4
+ "version": "1.0.148",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "lint": "eslint --ext .js,.vue src",
package/src/lang/index.js CHANGED
@@ -1,51 +1,56 @@
1
- import Vue from 'vue'
2
- import VueI18n from 'vue-i18n'
3
-
4
- import enLocale from 'element-ui/lib/locale/lang/en'
5
- import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
6
- import zhCN_vxe from 'vxe-table/lib/locale/lang/zh-CN'
7
- import enUS_vxe from 'vxe-table/lib/locale/lang/en-US'
8
- import VXETable from 'vxe-table'
9
- import ElementLocale from 'element-ui/lib/locale'
10
- import settingConfig from "@/settings";
11
-
12
- Vue.use(VueI18n);
13
-
14
- const messages = {
15
- en: {
16
- ...enLocale,
17
- ...enUS_vxe
18
- },
19
- zh: {
20
- ...zhLocale,
21
- ...zhCN_vxe
22
- }
23
- };
24
-
25
- /*const enLocaleMine = require.context('@/lang/locale/en', false, /\w+\.js/);
26
- const zhLocaleMine = require.context('@/lang/locale/zh', false, /\w+\.js/);
27
-
28
- zhLocaleMine.keys().map(fileName => {
29
- let comp = zhLocaleMine(fileName).default;
30
- Object.assign(messages["zh"], comp);
31
- });
32
- enLocaleMine.keys().map(fileName => {
33
- let comp = enLocaleMine(fileName).default;
34
- Object.assign(messages["en"], comp);
35
- });*/
36
-
37
- // Create VueI18n instance with options
38
- let i18nLang = localStorage.getItem("i18n-lang");
39
- const i18n = new VueI18n({
40
- locale: i18nLang || settingConfig.languageCode || 'zh', // set locale
41
- messages, // set locale messages
42
- });
43
-
44
- ElementLocale.i18n((key, value) => i18n.t(key, value));
45
-
46
- VXETable.setup({
47
- // 对组件内置的提示语进行国际化翻译
48
- i18n: (key, args) => i18n.t(key, args)
49
- });
50
-
51
- export default i18n;
1
+ import Vue from 'vue'
2
+ import VueI18n from 'vue-i18n'
3
+
4
+ import enLocale from 'element-ui/lib/locale/lang/en'
5
+ import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
6
+ import zhCN_vxe from 'vxe-table/lib/locale/lang/zh-CN'
7
+ import enUS_vxe from 'vxe-table/lib/locale/lang/en-US'
8
+ import VXETable from 'vxe-table'
9
+ import ElementLocale from 'element-ui/lib/locale'
10
+ import settingConfig from "@/settings";
11
+
12
+ import enLogin from "./locale/en/login.js"
13
+ import zhLogin from "./locale/zh/login.js"
14
+
15
+ Vue.use(VueI18n);
16
+
17
+ const messages = {
18
+ en: {
19
+ ...enLocale,
20
+ ...enUS_vxe,
21
+ ...enLogin
22
+ },
23
+ zh: {
24
+ ...zhLocale,
25
+ ...zhCN_vxe,
26
+ ...zhLogin
27
+ }
28
+ };
29
+
30
+ /*const enLocaleMine = require.context('@/lang/locale/en', false, /\w+\.js/);
31
+ const zhLocaleMine = require.context('@/lang/locale/zh', false, /\w+\.js/);
32
+
33
+ zhLocaleMine.keys().map(fileName => {
34
+ let comp = zhLocaleMine(fileName).default;
35
+ Object.assign(messages["zh"], comp);
36
+ });
37
+ enLocaleMine.keys().map(fileName => {
38
+ let comp = enLocaleMine(fileName).default;
39
+ Object.assign(messages["en"], comp);
40
+ });*/
41
+
42
+ // Create VueI18n instance with options
43
+ let i18nLang = localStorage.getItem("i18n-lang");
44
+ const i18n = new VueI18n({
45
+ locale: i18nLang || settingConfig.languageCode || 'zh', // set locale
46
+ messages, // set locale messages
47
+ });
48
+
49
+ ElementLocale.i18n((key, value) => i18n.t(key, value));
50
+
51
+ VXETable.setup({
52
+ // 对组件内置的提示语进行国际化翻译
53
+ i18n: (key, args) => i18n.t(key, args)
54
+ });
55
+
56
+ export default i18n;
@@ -1,24 +1,49 @@
1
1
  <template>
2
- <div class="login-container" :class="backgroundClass" ref="login-container" v-show="showContent">
3
- <div class="login-main" style="height: auto;">
4
- <el-tabs v-model="activeName">
5
- <el-tab-pane label="账号登录" name="first">
6
- <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="box-form login" autocomplete="on"
7
- label-position="left">
2
+ <div
3
+ class="login-container"
4
+ :class="backgroundClass"
5
+ ref="login-container"
6
+ v-show="showContent"
7
+ >
8
+ <div class="login-main" style="height: auto">
9
+ <el-tabs v-model="activeName" @tab-click="changeTab">
10
+ <el-tab-pane :label="$t1('账号登录')" name="first">
11
+ <el-form
12
+ ref="loginForm"
13
+ :model="loginForm"
14
+ :rules="loginRules"
15
+ class="box-form login"
16
+ autocomplete="on"
17
+ label-position="left"
18
+ >
8
19
  <el-form-item prop="username" class="txt">
9
- <span class="svg-container"><i class="el-icon-user"/></span>
10
- <el-input ref="username" v-model="loginForm.username" placeholder="请输入用户名" name="" type="text"
11
- tabindex="1" autocomplete="on" @keyup.enter.native="handleLogin"/>
20
+ <span class="svg-container"><i class="el-icon-user" /></span>
21
+ <el-input
22
+ ref="username"
23
+ v-model="loginForm.username"
24
+ :placeholder="$t1('请输入用户名')"
25
+ name=""
26
+ type="text"
27
+ tabindex="1"
28
+ autocomplete="on"
29
+ @keyup.enter.native="handleLogin"
30
+ />
12
31
  </el-form-item>
13
- <el-tooltip :enterable="false" v-model="capsTooltip" content="Caps lock is On" placement="right" manual>
32
+ <el-tooltip
33
+ :enterable="false"
34
+ v-model="capsTooltip"
35
+ content="Caps lock is On"
36
+ placement="right"
37
+ manual
38
+ >
14
39
  <el-form-item prop="password" class="txt">
15
- <span class="svg-container"><i class="el-icon-lock"/></span>
40
+ <span class="svg-container"><i class="el-icon-lock" /></span>
16
41
  <el-input
17
42
  :key="passwordType"
18
43
  ref="password"
19
44
  v-model="loginForm.password"
20
45
  :type="passwordType"
21
- placeholder="请输入密码"
46
+ :placeholder="$t1('请输入密码')"
22
47
  name=""
23
48
  tabindex="2"
24
49
  autocomplete="on"
@@ -27,41 +52,101 @@
27
52
  @blur="capsTooltip = false"
28
53
  @keyup.enter.native="handleLogin"
29
54
  />
30
- <span class="show-pwd" @click="showPwd"><svg-icon
31
- :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"/></span>
55
+ <span class="show-pwd" @click="showPwd"
56
+ ><svg-icon
57
+ :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"
58
+ /></span>
32
59
  </el-form-item>
33
60
  </el-tooltip>
34
61
  <div class="">
35
- <el-checkbox v-model="isRememberPassword">记住密码</el-checkbox>
62
+ <el-checkbox v-model="isRememberPassword">{{
63
+ $t1("记住密码")
64
+ }}</el-checkbox>
36
65
  </div>
37
- <el-button :loading="loading" type="primary" @click.prevent.stop="handleLogin" class="btn">登录</el-button>
66
+ <el-button
67
+ :loading="loading"
68
+ type="primary"
69
+ @click.prevent.stop="handleLogin"
70
+ class="btn"
71
+ >{{ $t1("登录") }}</el-button
72
+ >
38
73
  </el-form>
39
74
  </el-tab-pane>
40
- <el-tab-pane label="手机验证码登录" name="second">
41
- <el-form ref="loginForm" :model="loginForm2" :rules="loginRules" class="box-form login" autocomplete="on"
42
- label-position="left">
43
- <el-form-item prop="username" class="txt" style="width:66%">
44
- <span class="svg-container"><i class="el-icon-mobile-phone"/></span>
45
- <el-input ref="mobile" v-model="loginForm2.username" placeholder="请输入手机号" name="" type="text"
46
- tabindex="1" autocomplete="on" @keyup.enter.native="handleLogin"/>
75
+ <el-tab-pane
76
+ :label="$t1('手机登录')"
77
+ name="second"
78
+ v-if="settingConfig.mobileLoginEnabled"
79
+ >
80
+ <el-form
81
+ ref="loginForm"
82
+ :model="loginForm2"
83
+ :rules="loginRules"
84
+ class="box-form login"
85
+ autocomplete="on"
86
+ label-position="left"
87
+ >
88
+ <el-form-item prop="username" class="txt" style="width: 66%">
89
+ <span class="svg-container"><i class="el-icon-mobile-phone" /></span>
90
+ <el-input
91
+ ref="mobile"
92
+ v-model="loginForm2.username"
93
+ :placeholder="$t1('请输入手机号')"
94
+ name=""
95
+ type="text"
96
+ tabindex="1"
97
+ autocomplete="on"
98
+ @keyup.enter.native="handleLogin"
99
+ />
47
100
  </el-form-item>
48
- <el-button class="btn-send" type="success" :class="{'gray-btn':isCounting}" @click="sendCode">
101
+ <el-button
102
+ class="btn-send"
103
+ type="success"
104
+ :class="{ 'gray-btn': isCounting }"
105
+ @click="sendCode"
106
+ >
49
107
  {{ buttonText }}
50
108
  </el-button>
51
109
  <el-form-item prop="smsCode" class="txt">
52
- <span class="svg-container"><i class="el-icon-message"/></span>
53
- <el-input ref="smsCode" v-model="loginForm2.smsCode" placeholder="请输入验证码" name="" type="text"
54
- tabindex="1" autocomplete="on" @keyup.enter.native="handleLogin"/>
110
+ <span class="svg-container"><i class="el-icon-message" /></span>
111
+ <el-input
112
+ ref="smsCode"
113
+ v-model="loginForm2.smsCode"
114
+ :placeholder="$t1('请输入验证码')"
115
+ name=""
116
+ type="text"
117
+ tabindex="1"
118
+ autocomplete="on"
119
+ @keyup.enter.native="handleLogin"
120
+ />
55
121
  </el-form-item>
56
- <el-button :loading="loading" type="primary" @click.prevent.stop="handleLogin" class="btn">登录</el-button>
122
+ <el-button
123
+ :loading="loading"
124
+ type="primary"
125
+ @click.prevent.stop="handleLogin"
126
+ class="btn"
127
+ >{{ $t1("登录") }}</el-button
128
+ >
57
129
  </el-form>
58
130
  </el-tab-pane>
131
+ <el-tab-pane
132
+ :label="$t1('扫码登录')"
133
+ name="third"
134
+ v-if="settingConfig.qrLoginEnabled"
135
+ >
136
+ <div class="login-qr">
137
+ <img class="qr__img" :src="qrBase64" v-if="activeName === 'third'" />
138
+ <span class="qr__txt">{{ $t1("扫一扫,登录系统") }}</span>
139
+ <div v-if="qrExpired" @click="initQR" class="qr__lose">
140
+ <span><i class="el-icon-refresh"></i>{{ $t1("二维码失效") }}</span>
141
+ </div>
142
+ </div>
143
+ </el-tab-pane>
59
144
  </el-tabs>
60
145
  </div>
61
146
  <div class="tc copyright">
62
147
  <slot name="footer">
63
- © 广州同望科技发展有限公司
64
- <span style="margin-left:50px;">4000646100</span>
148
+ © {{ $t1("广州同望科技发展有限公司") }}
149
+ <span style="margin-left: 50px">4000646100</span>
65
150
  </slot>
66
151
  </div>
67
152
  </div>
@@ -71,12 +156,12 @@
71
156
  import mixin from "./indexMixin";
72
157
 
73
158
  export default {
74
- name: 'Login',
75
- mixins: [mixin]
76
- }
159
+ name: "Login",
160
+ mixins: [mixin],
161
+ };
77
162
  </script>
78
163
  <style lang="scss" scoped>
79
- @import '@/resources/css/login.scss';
164
+ @import "@/resources/css/login.scss";
80
165
 
81
166
  .login-container.tc {
82
167
  background: url(~@/resources/images/bg-login5.jpg) center center/cover no-repeat;
@@ -94,7 +179,9 @@ export default {
94
179
  right: 5px;
95
180
  top: 25px;
96
181
  }
97
-
182
+ .box-form {
183
+ height: 330px;
184
+ }
98
185
  ::v-deep .login-main .el-tabs__header {
99
186
  margin-bottom: 0;
100
187
 
@@ -128,4 +215,44 @@ export default {
128
215
  color: #8a8686;
129
216
  }
130
217
  }
218
+
219
+ ::v-deep .login-main .el-tabs__header .el-tabs__nav .el-tabs__item {
220
+ width: 33%;
221
+ }
222
+ .login-qr {
223
+ height: 330px;
224
+ text-align: center;
225
+ position: relative;
226
+ .qr__img {
227
+ width: 220px;
228
+ margin-top: 40px;
229
+ }
230
+ .qr__txt {
231
+ color: #666;
232
+ font-size: 15px;
233
+ display: block;
234
+ }
235
+ .qr__lose {
236
+ position: absolute;
237
+ cursor: pointer;
238
+ width: 192px;
239
+ height: 192px;
240
+ background: rgb(255 255 255 / 76%);
241
+ top: 60px;
242
+ left: 136px;
243
+ color: #000;
244
+ line-height: 64px;
245
+ font-weight: 600;
246
+ font-size: 26px;
247
+ span {
248
+ line-height: 1;
249
+ margin-top: 30px;
250
+ }
251
+ i {
252
+ display: block;
253
+ font-size: 42px;
254
+ margin-top: 46px;
255
+ }
256
+ }
257
+ }
131
258
  </style>
@@ -1,5 +1,6 @@
1
1
  import {encode} from "js-base64";
2
2
  import settingConfig from "@/settings";
3
+ import QRcode from "qrcode";
3
4
 
4
5
  function getUrlParams(url) {
5
6
  let result = {};
@@ -13,12 +14,16 @@ function getUrlParams(url) {
13
14
 
14
15
  export default {
15
16
  name: 'Login',
17
+ props:{
18
+ lang: [String,Function]
19
+ },
16
20
  components: {},
17
21
  data() {
18
22
  return {
19
23
  isCounting: false,
20
24
  countdown: 0,
21
- buttonText: '获取验证码',
25
+ buttonText: this.$t1('获取验证码'),
26
+ smsTimer: null,
22
27
  isRememberPassword: false,
23
28
  loginForm: {
24
29
  username: '',
@@ -54,7 +59,15 @@ export default {
54
59
  },
55
60
  activeName: "first",
56
61
  searchParam: {},
57
- showContent: true
62
+ showContent: true,
63
+
64
+ qrTimer1: null,
65
+ qrTimer2: null,
66
+ qrContent: null,
67
+ qrCodeFlag: 0,
68
+ qrBase64: "",
69
+ settingConfig: settingConfig,
70
+ qrExpired: false
58
71
  };
59
72
  },
60
73
  watch: {
@@ -69,6 +82,10 @@ export default {
69
82
  immediate: true
70
83
  }
71
84
  },
85
+ beforeDestroy() {
86
+ this.clearQrLoginTimer();
87
+ this.clearSmsTimer();
88
+ },
72
89
  created() {
73
90
  this.init();
74
91
  },
@@ -84,7 +101,22 @@ export default {
84
101
  window.removeEventListener('keydown', this.keyDown, false);
85
102
  },
86
103
  methods: {
104
+ initLang(){
105
+ let lang = this.$route.query.lang;
106
+ if(!lang && !!this.lang){
107
+ if(typeof this.lang === "function"){
108
+ lang = this.lang();
109
+ }else{
110
+ lang = this.lang;
111
+ }
112
+ }
113
+ if(lang){
114
+ this.$i18n.locale = lang;
115
+ localStorage.setItem("i18n-lang", lang);
116
+ }
117
+ },
87
118
  init() {
119
+ this.initLang();
88
120
  let searchParam = getUrlParams(location.search);
89
121
  this.searchParam = searchParam;
90
122
  //小熊SSO返回判断--目前因为小熊单点返回ticket有问题要特殊处理
@@ -110,6 +142,7 @@ export default {
110
142
  if (e.keyCode == 13 && e.target.nodeName != 'INPUT') {
111
143
  let closeBtn = document.querySelector('.el-dialog__close');
112
144
  closeBtn && closeBtn.click();
145
+ if (this.activeName == "third") return
113
146
  this.handleLogin();
114
147
  }
115
148
  },
@@ -140,7 +173,7 @@ export default {
140
173
  let username = this.loginForm2.username;
141
174
  let smsCode = this.loginForm2.smsCode;
142
175
  if (!username || !smsCode) {
143
- this.$baseAlert("请输入手机号和验证码");
176
+ this.$baseAlert(this.$t1('请输入手机号和验证码'));
144
177
  return;
145
178
  }
146
179
  loadingObj = this.$baseLoading();
@@ -325,6 +358,7 @@ export default {
325
358
  this.$baseAlert("请输入手机号");
326
359
  return
327
360
  }
361
+
328
362
  this.$http({
329
363
  url: USER_PREFIX + '/auth/sendSmsCode',
330
364
  method: `post`,
@@ -338,20 +372,27 @@ export default {
338
372
  });
339
373
  this.isCounting = true
340
374
  this.countdown = 60
341
- this.buttonText = '60秒后重新获取'
342
- const times = setInterval(() => {
375
+ this.buttonText = this.$t1('60秒后重新获取')
376
+ this.clearSmsTimer();
377
+ this.smsTimer = setInterval(() => {
343
378
  this.countdown--;
344
- this.buttonText = this.countdown + '秒后重新获取'
379
+ this.buttonText = this.$t1('{time}秒后重新获取',{time:this.countdown})
345
380
  if (this.countdown == 0) {
346
- clearInterval(times);
381
+ this.clearSmsTimer();
347
382
  this.isCounting = false
348
- this.buttonText = '获取验证码'
383
+ this.buttonText = this.$t1('获取验证码')
349
384
  }
350
385
  }, 1000)
351
386
  }
352
387
  });
353
388
 
354
389
  },
390
+ clearSmsTimer() {
391
+ if (this.smsTimer) {
392
+ clearInterval(this.smsTimer);
393
+ this.smsTimer = null;
394
+ }
395
+ },
355
396
  mobileLogin() {
356
397
 
357
398
  },
@@ -420,6 +461,97 @@ export default {
420
461
  });
421
462
  }
422
463
  });
464
+ },
465
+
466
+ /**二维码登录begin*/
467
+ guid() {
468
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (t) {
469
+ var e = 16 * Math.random() | 0;
470
+ return ("x" == t ? e : 3 & e | 8).toString(16);
471
+ });
472
+ },
473
+ initQR() {
474
+ this.clearQrLoginTimer();
475
+ this.qrExpired = true;
476
+ let option = {width: 300, height: 300};
477
+ this.qrContent = this.guid();
478
+ this.createQR(this.qrContent, option).then(url => {
479
+ this.qrExpired = false;
480
+ this.qrBase64 = url
481
+ this.createQrLoginTimer();
482
+ })
483
+ },
484
+ // 生成二维码
485
+ createQR(content, options) {
486
+ return new Promise((resolve, reject) => {
487
+ QRcode.toDataURL(content, options).then(url => {
488
+ resolve(url)
489
+ })
490
+ })
491
+ },
492
+ changeTab() {
493
+ // this.initQR();
494
+ // return
495
+ if (this.activeName == "third") {
496
+ this.initQR();
497
+ } else {
498
+ this.clearQrLoginTimer();
499
+ }
500
+ },
501
+ clearQrLoginTimer() {
502
+ if (this.qrTimer1) {
503
+ clearTimeout(this.qrTimer1)
504
+ this.qrTimer1 = null;
505
+ }
506
+ if (this.qrTimer2) {
507
+ clearTimeout(this.qrTimer2)
508
+ this.qrTimer2 = null;
509
+ }
510
+ },
511
+ createQrLoginTimer() {
512
+ this.checkQrLoginTimerHanlde()
513
+ this.qrTimer2 = setTimeout(() => {
514
+ this.qrExpired = true;
515
+ this.clearQrLoginTimer();
516
+ }, 60000)
517
+ },
518
+ checkQrLoginTimerHanlde() {
519
+ this.qrTimer1 = setTimeout(() => {
520
+ this.checkQrLoginStatusHanlde();
521
+ }, 3000)
522
+ },
523
+ checkQrLoginStatusHanlde() {
524
+ if (this.qrExpired) {
525
+ return
526
+ }
527
+ this.$http({
528
+ url: USER_PREFIX + '/auth/login',
529
+ method: `post`,
530
+ data: {as: this.qrContent},
531
+ // isLoading: true,
532
+ failMsg: false,
533
+ success: res => {
534
+ let token = res.objx;
535
+ if (token) {
536
+ this.$message({
537
+ message: this.$t1('登录成功'),
538
+ type: 'success'
539
+ });
540
+ this.clearQrLoginTimer();
541
+ this.$store.dispatch('user/addToken', {token}).then(res => {
542
+ localStorage.removeItem('currentMenuId');
543
+ this.rememberPassword();
544
+ this.loading = false;
545
+ window.removeEventListener('keydown', this.keyDown, false);
546
+ this.handleRedirectUrl();
547
+ });
548
+ } else {
549
+ this.checkQrLoginTimerHanlde();
550
+ }
551
+ }
552
+ });
423
553
  }
554
+ /**二维码登录end*/
555
+
424
556
  }
425
557
  }