jufubao-base 1.0.119-beta2 → 1.0.119-beta3

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.
@@ -16,51 +16,110 @@
16
16
  <view class="jfb-base-saas-login__body" :style="{
17
17
  minHeight: layoutInfo.bodyMinHeightPx + 'px'
18
18
  }">
19
- <view class="login_form_wrap">
20
- <xd-form
21
- label-width="130"
22
- label-align="right"
23
- content-align="left"
24
- :border="true"
25
- paddingBetween="40"
26
- >
27
- <xd-form-item class="form-item"
28
- label="手机号"
29
- content-align="left"
30
- >
31
- <xd-form-input
32
- v-model="accountForm.phone_number"
33
- placeholder="请输入11位手机号"
34
- />
35
- </xd-form-item>
36
- <xd-form-item
37
- label="验证码"
19
+ <view v-if="showStep === 1" class="panel-login-auth">
20
+ <view class="logo-wrap">
21
+ <image mode="aspectFit" :src="logo" />
22
+ <view :style="{ color: logoTextColor, }" >{{ partnerName }}</view>
23
+ </view>
24
+ <view class="login_types">
25
+ <xd-button
26
+ v-if="hasAuthLogin"
27
+ :disabled="!panelIsChecked"
28
+ type="primary"
29
+ radius="20rpx"
30
+ @click="doLoginAuth"
31
+ >快捷登录</xd-button>
32
+ <view class="login-pub">
33
+ <xd-button
34
+ v-if="hasAccountLogin"
35
+ :disabled="!panelIsChecked"
36
+ type="primary"
37
+ radius="20rpx"
38
+ @click="doLoginAccount"
39
+ >账号登录</xd-button>
40
+ </view>
41
+
42
+ <view class="protocol">
43
+ <xd-form-checkbox
44
+ class="xd-form-checkbox"
45
+ v-model="panel_1_checked"
46
+ mode="default"
47
+ multiple
48
+ :localdata="[{ value: 1, text: '请阅读并同意《隐私政策》《用户服务协议》' },]"
49
+ >
50
+ <template slot="a1">
51
+ <view>
52
+ <text>请阅读并同意</text>
53
+ <text @click.stop="handlePrivacy('privacy_privacy')" :style="{color: mainColor}">《隐私政策》</text>
54
+ <text @click.stop="handlePrivacy('privacy_service')" :style="{color: mainColor}">《用户服务协议》</text>
55
+ </view>
56
+ </template>
57
+ </xd-form-checkbox>
58
+ </view>
59
+ </view>
60
+ </view>
61
+ <view v-if="showStep === 2" class="panel-login-password">
62
+ <!-- <view class="phone-login-type">
63
+ <view
64
+ v-if="phoneLogin"
65
+ class="_item"
66
+ :class="{ active: accountLoginType === 'phone' }"
67
+ @click="setAccountLoginType('phone')"
68
+ >验证码登录<text :style="{ background: mainColor }"></text
69
+ ></view>
70
+ <view
71
+ v-if="pwdLogin"
72
+ class="_item"
73
+ :class="{ active: accountLoginType === 'pwd' }"
74
+ @click="setAccountLoginType('pwd')"
75
+ >密码登录<text :style="{ background: mainColor }"></text
76
+ ></view>
77
+ </view> -->
78
+ <view style="margin-top: 40rpx">
79
+ <xd-form
80
+ label-width="130"
81
+ label-align="right"
38
82
  content-align="left"
83
+ :border="true"
84
+ paddingBetween="40"
39
85
  >
40
- <view class="flex align-center">
86
+ <xd-form-item class="form-item" label="手机号" content-align="left">
41
87
  <xd-form-input
42
- v-model="accountForm.verification_code"
43
- placeholder="请输入验证码"
88
+ v-model="accountForm.phone_number"
89
+ placeholder="请输入11位手机号"
44
90
  />
45
- <view
46
- class="get_code"
47
- @click="reGetCode"
48
- :style="{ color: mainColor }"
49
- >{{ time ? time + "秒后获取" : "获取验证码" }}
91
+ </xd-form-item>
92
+ <xd-form-item
93
+ v-if="accountLoginType === 'phone'"
94
+ label="验证码"
95
+ content-align="left"
96
+ >
97
+ <view class="flex align-center">
98
+ <xd-form-input
99
+ v-model="accountForm.verification_code"
100
+ placeholder="请输入验证码"
101
+ />
102
+ <view
103
+ class="get_code"
104
+ @click="reGetCode"
105
+ :style="{ color: mainColor }"
106
+ >{{ time ? time + "秒后获取" : "获取验证码" }}
107
+ </view>
50
108
  </view>
51
- </view>
52
- </xd-form-item>
53
- <!-- <xd-form-item
54
- label="密码"
55
- content-align="left"
56
- >
57
- <xd-form-input
58
- type="password"
59
- v-model="accountForm.password"
60
- placeholder="请输入密码"
61
- />
62
- </xd-form-item> -->
63
- </xd-form>
109
+ </xd-form-item>
110
+ <xd-form-item
111
+ v-if="accountLoginType === 'pwd'"
112
+ label="密码"
113
+ content-align="left"
114
+ >
115
+ <xd-form-input
116
+ type="password"
117
+ v-model="accountForm.password"
118
+ placeholder="请输入密码"
119
+ />
120
+ </xd-form-item>
121
+ </xd-form>
122
+ </view>
64
123
 
65
124
  <view class="form-group" style="padding-bottom:0">
66
125
  <xd-form-checkbox
@@ -88,22 +147,12 @@
88
147
  @click="doLoginForm"
89
148
  >登录</xd-button>
90
149
  </view>
91
- <!-- <view
150
+ <view
151
+ v-if="accountLoginType === 'pwd'"
92
152
  class="forget_password"
93
153
  @click="toValidPhone"
94
- >忘记密码</view> -->
154
+ >忘记密码</view>
95
155
  </view>
96
- <view class="not_login">暂不登录,去逛逛</view>
97
- <xd-dailog :show.sync="dialogShow" title="">
98
- <view class="dia_title">您在多个企业任职<br/>请选择本次要访问的企业</view>
99
- <view class="company_list">
100
- <view class="company_item" v-for="(item, i) in companyList" :key="i" @click="toHome(item)">
101
- <view class="_name">{{ item.company_name }}</view>
102
- <xd-font-icon icon="iconxiangyou_xian" :size="30"></xd-font-icon>
103
- </view>
104
- </view>
105
- <view slot="btn"></view>
106
- </xd-dailog>
107
156
  </view>
108
157
  </view>
109
158
  </template>
@@ -118,9 +167,13 @@
118
167
  import XdDailog from "@/components/XdDailog/XdDailog"
119
168
  import { jfbRootExec } from "@/utils/xd.event";
120
169
  import JfbBaseSaasLoginMixin from "./JfbBaseSaasLoginMixin";
170
+ import { mapState } from "vuex"
121
171
  import { getContainerPropsValue } from "@/utils/xd.base";
122
172
  import componentsMixins from "@/mixins/componentsMixins";
123
173
  import extsMixins from "@/mixins/extsMixins";
174
+ import getServiceUrl from "@/common/getServiceUrl";
175
+ import { Base64 } from "js-base64";
176
+ import * as dd from "dingtalk-jsapi"
124
177
  export default {
125
178
  name: "JfbBaseSaasLogin",
126
179
  components: {
@@ -136,6 +189,10 @@
136
189
  componentsMixins, extsMixins, JfbBaseSaasLoginMixin
137
190
  ],
138
191
  computed: {
192
+ ...mapState(['jfbAuthorize']),
193
+ panelIsChecked() {
194
+ return this.panel_1_checked.includes(1);
195
+ },
139
196
  panelTwoIsChecked() {
140
197
  return this.panel_2_checked.includes(1);
141
198
  },
@@ -147,15 +204,33 @@
147
204
  password: "",
148
205
  verification_code: ""
149
206
  },
207
+ showStep: 1,
150
208
  time: 0,
209
+ panel_1_checked: "",
151
210
  panel_2_checked: "",
211
+ pwdLogin: null,
212
+ phoneLogin: null,
213
+ accountLoginType: "phone", //phone: 验证码登录 pwd: 密码登录
152
214
  redirect_url: "", //401回跳地址
215
+ hasAuthLogin: false, //是否有授权登录
216
+ hasAccountLogin: false, //是否有账号登录 包含 验证码、密码登录
217
+ quickLogin: null,
218
+ biz_name: "login",
219
+
153
220
  dialogShow: false,
154
221
  companyList: [],
222
+ logo: "",
223
+ partnerName: "",
224
+ logoTextColor: "",
225
+ base: "",
226
+ sub_company_id: "1",
155
227
 
156
228
  //面板
157
229
  callback_url: "", //面板配置登录完跳转地址
158
230
  forget_pwd_url: "", //忘记密码跳转地址
231
+ phone_number_login_url: "", //手机号登陆URL
232
+ phone_auth_callback_url: "", //手机认证回调URL
233
+ error_callback_url: "", //错误回调URL
159
234
  }
160
235
  },
161
236
  watch: {
@@ -165,19 +240,134 @@
165
240
  },
166
241
  created() {
167
242
  this.init(this.container);
243
+ this.base = this.jfbAuthorize.getBasePath(this);
244
+ this.site_logo = getServiceUrl(this.projectAttr["site_logo"]);
168
245
  },
169
246
  methods: {
170
247
  onJfbLoad(options) {
171
248
  this.redirect_url = options.redirect_url ? Base64.decode(options.redirect_url): '';
249
+ if(options.sub_company_id){
250
+ this.sub_company_id = options.sub_company_id;
251
+ }else if(options['x-common']){
252
+ let decodeParams = Base64.decode(options['x-common']);
253
+ if(decodeParams.sub_company_id){
254
+ this.sub_company_id = decodeParams.sub_company_id;
255
+ }
256
+ }
257
+ this.p_getPlatform();
172
258
  },
173
259
  /**
174
260
  * @description 监听事件变化
175
261
  * @param container {object} 业务组件对象自己
176
262
  */
177
263
  init(container) {
264
+ let name, logo;
265
+ if (this.projectAttr["site_logo"])
266
+ logo = getServiceUrl(this.projectAttr["site_logo"], "size3");
178
267
  this.callback_url = getContainerPropsValue(container, "content.callback_url", {value: ''}).value;
179
268
  this.forget_pwd_url = getContainerPropsValue(container, "content.forget_pwd_url", {value: ''}).value;
269
+ this.logo = logo || "//dummyimage.com/100x100";
270
+ this.partnerName = name || "聚福宝福利";
271
+ this.logoTextColor = getContainerPropsValue(container, "content.logoTextColor", "#333");
272
+ },
273
+ handleRedirectUrl(){
274
+ let { redirect_url, callback_url } = this;
275
+
276
+ //不同项目直接域名替换
277
+ if (/^(@site_domain@).+$/.test(redirect_url)) {
278
+ redirect_url = redirect_url.replace(/@site_domain@/, location.origin)
279
+ }
280
+ try {
281
+ let redirectURL = new URL(redirect_url);
282
+ redirect_url = redirectURL.href;
283
+ } catch (e) {
284
+ redirect_url = location.origin + this.base + redirect_url;
285
+ }
286
+ return redirect_url;
287
+ },
288
+ getReqParams(){
289
+ let redirect_url = this.handleRedirectUrl();
290
+ let params = {
291
+ sub_company_id: this.sub_company_id,
292
+ callback_url: redirect_url,
293
+ phone_number_login_url: location.origin + this.base + this.phone_number_login_url,
294
+ phone_auth_callback_url: location.origin + this.base + this.phone_auth_callback_url,
295
+ error_callback_url: location.origin + this.base + this.error_callback_url,
296
+ };
297
+ return params;
180
298
  },
299
+ p_getPlatform(){
300
+ let params = this.getReqParams();
301
+
302
+ jfbRootExec("getPlatform", {
303
+ vm: this,
304
+ data: params
305
+ }).then(res => {
306
+ this.handleAuthResult(res);
307
+ })
308
+ },
309
+ /**
310
+ * @description 获取到登陆方式之后处理
311
+ */
312
+ handleAuthResult(res) {
313
+ if (res.quick_enabled) {
314
+ this.hasAuthLogin = true;
315
+ this.quickLogin = res.quick;
316
+ }
317
+ if (res.other.length > 0) {
318
+ this.hasAccountLogin = true;
319
+ res.other.forEach((item) => {
320
+ if (item.login_platform_code === "JFB") {
321
+ this.phoneLogin = item;
322
+ }
323
+ // else if (item.login_platform_code === "account") {
324
+ // this.pwdLogin = item;
325
+ // }
326
+ });
327
+ // if (!this.phoneLogin) this.accountLoginType = "pwd";
328
+ }
329
+ },
330
+ //企业微信登录
331
+ p_loginWxEnter(){
332
+ let params = this.getReqParams();
333
+ params['code'] = ""; //企业微信code
334
+ jfbRootExec("loginWxEnter", {
335
+ vm: this,
336
+ data: params
337
+ }).then(res => {
338
+
339
+ })
340
+ },
341
+
342
+ //获取钉钉免登码
343
+ p_loginDing(){
344
+ dd.getAuthCode({
345
+ corpId: 'ding12345xxx',
346
+ success: (res) => {
347
+ const { authCode } = res;
348
+ jfbRootExec("loginDing", {
349
+ vm: this,
350
+ data: {
351
+ sub_company_id: this.sub_company_id,
352
+ code: authCode
353
+ }
354
+ }).then(res => {
355
+ const { access_code, phone_auth, phone_number } = res;
356
+ //手机号是否认证: Y已认证 N未认证
357
+ if(phone_auth === 'N'){
358
+ this.$xdUniHelper.redirectTo({
359
+ url: `${phone_auth_callback_url}?access_code=${access_code}&phone_number=${phone_number}`
360
+ });
361
+ }else{
362
+ this.toHomeAfterLogin();
363
+ }
364
+ })
365
+ },
366
+ fail: () => {},
367
+ complete: () => {},
368
+ })
369
+ },
370
+ //账号登录
181
371
  doLoginForm() {
182
372
  const { phone_number, password, verification_code } = this.accountForm;
183
373
  let err_tip = "";
@@ -191,18 +381,16 @@
191
381
  }
192
382
 
193
383
  this.$xdShowLoading({})
194
- jfbRootExec("sassLogin", {
384
+ jfbRootExec("sassPhoneLogin", {
195
385
  vm: this,
196
386
  data: {
197
- biz_name: "login",
387
+ biz_name: this.biz_name,
198
388
  phone_number: phone_number,
199
389
  valid_code: verification_code,
200
390
  },
201
391
  })
202
392
  .then((res) => {
203
393
  this.$xdHideLoading()
204
- // this.jfbAuthorize.setAllToken(res);
205
- // this.toHomeAfterLogin();
206
394
  if(res.list.length === 0){
207
395
  uni.showToast({
208
396
  title: '该用户没有所属企业',
@@ -213,7 +401,7 @@
213
401
  this.companyList = res.list;
214
402
  this.dialogShow = true;
215
403
  }else{
216
- this.toHome(res.list[0])
404
+ this.p_passportSaasLogin(res.list[0])
217
405
  }
218
406
  })
219
407
  .catch(error => {
@@ -221,12 +409,25 @@
221
409
  this.$xdLog.catch(error)
222
410
  });
223
411
  },
224
- toHome(item){
225
- this.$xdUniHelper.redirectTo({
226
- url: `/apply/main/saas/home?company_id=${item.company_id}`
227
- });
228
- // this.toHomeAfterLogin();
412
+ //选择企业后,需要passport登录
413
+ p_passportSaasLogin(item){
414
+ let redirect_url = this.handleRedirectUrl();
415
+ const { phone_number, password, verification_code } = this.accountForm;
416
+ jfbRootExec("passportSaasLogin", {
417
+ vm: this,
418
+ data: {
419
+ access_token: item.access_code,
420
+ redirect_url,
421
+ phone_number,
422
+ valid_code: verification_code,
423
+ biz_name: this.biz_name
424
+ }
425
+ }).then(res => {
426
+ this.jfbAuthorize.setAllToken(res);
427
+ this.toHomeAfterLogin();
428
+ })
229
429
  },
430
+
230
431
  toHomeAfterLogin() {
231
432
  let { redirect_url, callback_url } = this;
232
433
  if (redirect_url) redirect_url = redirect_url;
@@ -247,6 +448,20 @@
247
448
  url: `/pages/content/content?${params}`
248
449
  })
249
450
  },
451
+ doLoginAccount() {
452
+ console.log("doLoginAccount", this.panel_1_checked);
453
+ if (this.panel_1_checked.includes(1)) {
454
+ this.showStep = 2;
455
+ } else {
456
+ this.$xdConfirm({
457
+ content: "请阅读并勾选读用户协议与隐私协议",
458
+ cancel: false,
459
+ confirmText: "我知道了",
460
+ $vm: this,
461
+ });
462
+ return;
463
+ }
464
+ },
250
465
  reGetCode() {
251
466
  if (this.time > 0) return;
252
467
  const { phone_number } = this.accountForm;
@@ -262,7 +477,7 @@
262
477
  vm: this,
263
478
  data: {
264
479
  phone_number,
265
- biz_name: "login",
480
+ biz_name: this.biz_name,
266
481
  },
267
482
  }).then((res) => {
268
483
  this.$xdHideLoading();
@@ -313,39 +528,6 @@
313
528
  border: 1px dashed rgba(0, 0, 0, 0);
314
529
  box-sizing: border-box;
315
530
  &__body{
316
- position: relative;
317
- .dia_title{
318
- color: #333333;
319
- font-size: 32rpx;
320
- font-weight: 500;
321
- margin: 60rpx 0;
322
- }
323
- .company_list{
324
- .company_item{
325
- display: flex;
326
- justify-content: space-between;
327
- background: #FE7A63;
328
- border-radius: 60rpx;
329
- padding: 20rpx 48rpx;
330
- color: #FFFFFF;
331
- margin: 20rpx 0;
332
- ._name{
333
- flex: 1;
334
- width: 100rpx;
335
- overflow: hidden;
336
- white-space: nowrap;
337
- text-overflow: ellipsis;
338
- }
339
- }
340
- }
341
- .not_login{
342
- position: absolute;
343
- bottom: 200rpx;
344
- text-align: center;
345
- width: 100%;
346
- color: #FE7A63;
347
- font-size: 24rpx;
348
- }
349
531
  .xd-form-checkbox {
350
532
  /deep/ .checklist-content .checklist-text {
351
533
  font-size: 26rpx !important;
@@ -370,41 +552,149 @@
370
552
  .form-group {
371
553
  padding: 40rpx 70rpx;
372
554
  }
555
+ .form-item {
556
+ /deep/ .uni-forms-item {
557
+ padding-left: unit(30rpx) !important;
558
+ }
559
+ }
373
560
  .get_code {
374
561
  color: @xd-base-color;
375
562
  font-size: 24rpx;
376
563
  margin-right: unit(20,rpx);
377
564
  }
378
- .form-item {
379
- /deep/ .uni-forms-item {
380
- padding-left: unit(30rpx) !important;
565
+ .panel-login-auth {
566
+ .logo-wrap {
567
+ text-align: center;
568
+ margin: unit(165,rpx) 0;
569
+ image {
570
+ width: 180rpx;
571
+ height: 180rpx;
572
+ margin-bottom: unit(12,rpx);
573
+ }
574
+ view {
575
+ font-size: unit(36,rpx);
576
+ font-weight: 600;
577
+ }
578
+ }
579
+ .login_types {
580
+ padding: 10rpx 50rpx;
581
+
582
+ .protocol {
583
+ font-size: 24rpx;
584
+ margin-top: 40rpx;
585
+ }
381
586
  }
382
587
  }
383
- /deep/ .uni-forms-item__label {
384
- .label-text {
588
+ .panel-login-password {
589
+ /deep/ .uni-forms-item__label {
590
+ .label-text {
591
+ font-size: 26rpx;
592
+ color: #a6a6a6;
593
+ }
594
+ }
595
+ /deep/ .uni-easyinput__placeholder-class {
385
596
  font-size: 26rpx;
597
+ color: #d4d4d4;
598
+ }
599
+ .phone-login-type {
600
+ display: flex;
601
+ color: #808080;
602
+ font-size: 32rpx;
603
+ padding: 40rpx 70rpx;
604
+ align-items: center;
605
+ ._item {
606
+ margin: 0 30rpx;
607
+ position: relative;
608
+ line-height: 2;
609
+ &:first-child {
610
+ margin-left: 0;
611
+ }
612
+
613
+ &.active {
614
+ color: #383838;
615
+ font-size: 36rpx;
616
+
617
+ text {
618
+ position: absolute;
619
+ height: 6rpx;
620
+ width: 90rpx;
621
+ border-radius: 6rpx;
622
+ left: 50%;
623
+ bottom: 0;
624
+ transform: translateX(-50%);
625
+ }
626
+ }
627
+ }
628
+ }
629
+ .forget_password {
630
+ font-size: 24rpx;
386
631
  color: #a6a6a6;
632
+ text-align: right;
633
+ margin: 20rpx 70rpx 0 0;
634
+ }
635
+
636
+ .not_login {
637
+ position: fixed;
638
+ width: 100%;
639
+ text-align: center;
640
+ bottom: 100rpx;
641
+ font-size: 24rpx;
642
+ color: #fe7a63;
387
643
  }
388
644
  }
389
- /deep/ .uni-easyinput__placeholder-class {
390
- font-size: 26rpx;
391
- color: #d4d4d4;
645
+ .panel-forget-password {
646
+ /deep/ .uni-forms-item__label {
647
+ .label-text {
648
+ font-size: 26rpx;
649
+ color: #a6a6a6;
650
+ }
651
+ }
652
+ /deep/ .uni-easyinput__placeholder-class {
653
+ font-size: 26rpx;
654
+ color: #d4d4d4;
655
+ }
656
+ .forget_tip {
657
+ box-sizing: border-box;
658
+ width: 600rpx;
659
+ border-radius: 10rpx;
660
+ box-shadow: 0px 0px 20px 0px #00000019;
661
+ padding: 64rpx 46rpx;
662
+ margin: 200rpx auto;
663
+ text-align: center;
664
+ font-size: 32rpx;
665
+ .contact_phone {
666
+ color: @xd-base-color;
667
+ font-size: 56rpx;
668
+ margin: 20rpx 0 30rpx;
669
+ }
670
+ }
392
671
  }
393
- .forget_password {
394
- font-size: 24rpx;
395
- color: #a6a6a6;
396
- text-align: right;
397
- margin: 20rpx 70rpx 0 0;
672
+ .panel-reset-password {
673
+ /deep/ .uni-forms-item__label {
674
+ width: 185rpx !important;
675
+ .label-text {
676
+ font-size: 26rpx;
677
+ color: #a6a6a6;
678
+ }
679
+ }
680
+ /deep/ .uni-easyinput__placeholder-class {
681
+ font-size: 26rpx;
682
+ color: #d4d4d4;
683
+ }
398
684
  }
399
685
  }
400
686
  }
401
- .flex {
402
- display: flex;
403
- }
404
- .flex-sub {
405
- flex: 1;
406
- }
407
- .align-center {
408
- align-items: center;
409
- }
687
+ .flex {
688
+ display: flex;
689
+ }
690
+ .flex-sub {
691
+ flex: 1;
692
+ }
693
+ .align-center {
694
+ align-items: center;
695
+ }
696
+
697
+ .login-pub {
698
+ margin-top: unit(40, rpx);
699
+ }
410
700
  </style>