jufubao-base 1.0.119-beta2 → 1.0.119-beta4

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,153 @@
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
+ doLoginAuth(){
332
+ const { quickLogin } = this;
333
+ //登录平台name 聚福宝 钉钉 企业微信
334
+ if(quickLogin.login_platform_name === 'DD'){
335
+ this.p_loginDing();
336
+ }else if(quickLogin.login_platform_name === 'QW'){
337
+ this.p_loginWxEnter();
338
+ }
339
+ },
340
+ //企业微信登录
341
+ p_loginWxEnter(){
342
+ const { quickLogin } = this;
343
+ location.href = quickLogin.redirect_url;
344
+ // let params = this.getReqParams();
345
+ // params['code'] = ""; //企业微信code
346
+ // jfbRootExec("loginWxEnter", {
347
+ // vm: this,
348
+ // data: params
349
+ // }).then(res => {
350
+ // location.href = res.redirect_url;
351
+ // })
352
+ },
353
+ //获取钉钉免登码
354
+ p_loginDing(){
355
+ const { quickLogin } = this;
356
+
357
+ dd.getAuthCode({
358
+ corpId: quickLogin.corp_id,
359
+ success: (res) => {
360
+ console.log("钉钉授权成功", res);
361
+ const { authCode } = res;
362
+ jfbRootExec("loginDing", {
363
+ vm: this,
364
+ data: {
365
+ sub_company_id: this.sub_company_id,
366
+ code: authCode
367
+ }
368
+ }).then(res => {
369
+ const { access_code, phone_auth, phone_number } = res;
370
+ //手机号是否认证: Y已认证 N未认证
371
+ if(phone_auth === 'N'){
372
+ this.$xdUniHelper.redirectTo({
373
+ url: `${phone_auth_callback_url}?access_code=${access_code}&phone_number=${phone_number}`
374
+ });
375
+ }else{
376
+ //passport登录
377
+ this.p_passportSaasLogin({access_code})
378
+ }
379
+ })
380
+ },
381
+ fail: () => {
382
+ console.error("钉钉授权失败")
383
+ },
384
+ complete: () => {
385
+ console.info("钉钉授权完成")
386
+ },
387
+ })
388
+ },
389
+ //账号登录
181
390
  doLoginForm() {
182
391
  const { phone_number, password, verification_code } = this.accountForm;
183
392
  let err_tip = "";
@@ -191,18 +400,16 @@
191
400
  }
192
401
 
193
402
  this.$xdShowLoading({})
194
- jfbRootExec("sassLogin", {
403
+ jfbRootExec("sassPhoneLogin", {
195
404
  vm: this,
196
405
  data: {
197
- biz_name: "login",
406
+ biz_name: this.biz_name,
198
407
  phone_number: phone_number,
199
408
  valid_code: verification_code,
200
409
  },
201
410
  })
202
411
  .then((res) => {
203
412
  this.$xdHideLoading()
204
- // this.jfbAuthorize.setAllToken(res);
205
- // this.toHomeAfterLogin();
206
413
  if(res.list.length === 0){
207
414
  uni.showToast({
208
415
  title: '该用户没有所属企业',
@@ -213,7 +420,7 @@
213
420
  this.companyList = res.list;
214
421
  this.dialogShow = true;
215
422
  }else{
216
- this.toHome(res.list[0])
423
+ this.p_passportSaasLogin(res.list[0])
217
424
  }
218
425
  })
219
426
  .catch(error => {
@@ -221,12 +428,24 @@
221
428
  this.$xdLog.catch(error)
222
429
  });
223
430
  },
224
- toHome(item){
225
- this.$xdUniHelper.redirectTo({
226
- url: `/apply/main/saas/home?company_id=${item.company_id}`
227
- });
228
- // this.toHomeAfterLogin();
431
+ //选择企业后,需要passport登录
432
+ p_passportSaasLogin({access_code}){
433
+ let redirect_url = this.handleRedirectUrl();
434
+ const { phone_number, password, verification_code } = this.accountForm;
435
+ jfbRootExec("passportSaasLogin", {
436
+ vm: this,
437
+ data: {
438
+ access_token: access_code,
439
+ phone_number,
440
+ valid_code: verification_code,
441
+ biz_name: this.biz_name
442
+ }
443
+ }).then(res => {
444
+ this.jfbAuthorize.setAllToken(res);
445
+ this.toHomeAfterLogin();
446
+ })
229
447
  },
448
+
230
449
  toHomeAfterLogin() {
231
450
  let { redirect_url, callback_url } = this;
232
451
  if (redirect_url) redirect_url = redirect_url;
@@ -247,6 +466,20 @@
247
466
  url: `/pages/content/content?${params}`
248
467
  })
249
468
  },
469
+ doLoginAccount() {
470
+ console.log("doLoginAccount", this.panel_1_checked);
471
+ if (this.panel_1_checked.includes(1)) {
472
+ this.showStep = 2;
473
+ } else {
474
+ this.$xdConfirm({
475
+ content: "请阅读并勾选读用户协议与隐私协议",
476
+ cancel: false,
477
+ confirmText: "我知道了",
478
+ $vm: this,
479
+ });
480
+ return;
481
+ }
482
+ },
250
483
  reGetCode() {
251
484
  if (this.time > 0) return;
252
485
  const { phone_number } = this.accountForm;
@@ -262,7 +495,7 @@
262
495
  vm: this,
263
496
  data: {
264
497
  phone_number,
265
- biz_name: "login",
498
+ biz_name: this.biz_name,
266
499
  },
267
500
  }).then((res) => {
268
501
  this.$xdHideLoading();
@@ -313,39 +546,6 @@
313
546
  border: 1px dashed rgba(0, 0, 0, 0);
314
547
  box-sizing: border-box;
315
548
  &__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
549
  .xd-form-checkbox {
350
550
  /deep/ .checklist-content .checklist-text {
351
551
  font-size: 26rpx !important;
@@ -370,41 +570,149 @@
370
570
  .form-group {
371
571
  padding: 40rpx 70rpx;
372
572
  }
573
+ .form-item {
574
+ /deep/ .uni-forms-item {
575
+ padding-left: unit(30rpx) !important;
576
+ }
577
+ }
373
578
  .get_code {
374
579
  color: @xd-base-color;
375
580
  font-size: 24rpx;
376
581
  margin-right: unit(20,rpx);
377
582
  }
378
- .form-item {
379
- /deep/ .uni-forms-item {
380
- padding-left: unit(30rpx) !important;
583
+ .panel-login-auth {
584
+ .logo-wrap {
585
+ text-align: center;
586
+ margin: unit(165,rpx) 0;
587
+ image {
588
+ width: 180rpx;
589
+ height: 180rpx;
590
+ margin-bottom: unit(12,rpx);
591
+ }
592
+ view {
593
+ font-size: unit(36,rpx);
594
+ font-weight: 600;
595
+ }
596
+ }
597
+ .login_types {
598
+ padding: 10rpx 50rpx;
599
+
600
+ .protocol {
601
+ font-size: 24rpx;
602
+ margin-top: 40rpx;
603
+ }
381
604
  }
382
605
  }
383
- /deep/ .uni-forms-item__label {
384
- .label-text {
606
+ .panel-login-password {
607
+ /deep/ .uni-forms-item__label {
608
+ .label-text {
609
+ font-size: 26rpx;
610
+ color: #a6a6a6;
611
+ }
612
+ }
613
+ /deep/ .uni-easyinput__placeholder-class {
385
614
  font-size: 26rpx;
615
+ color: #d4d4d4;
616
+ }
617
+ .phone-login-type {
618
+ display: flex;
619
+ color: #808080;
620
+ font-size: 32rpx;
621
+ padding: 40rpx 70rpx;
622
+ align-items: center;
623
+ ._item {
624
+ margin: 0 30rpx;
625
+ position: relative;
626
+ line-height: 2;
627
+ &:first-child {
628
+ margin-left: 0;
629
+ }
630
+
631
+ &.active {
632
+ color: #383838;
633
+ font-size: 36rpx;
634
+
635
+ text {
636
+ position: absolute;
637
+ height: 6rpx;
638
+ width: 90rpx;
639
+ border-radius: 6rpx;
640
+ left: 50%;
641
+ bottom: 0;
642
+ transform: translateX(-50%);
643
+ }
644
+ }
645
+ }
646
+ }
647
+ .forget_password {
648
+ font-size: 24rpx;
386
649
  color: #a6a6a6;
650
+ text-align: right;
651
+ margin: 20rpx 70rpx 0 0;
652
+ }
653
+
654
+ .not_login {
655
+ position: fixed;
656
+ width: 100%;
657
+ text-align: center;
658
+ bottom: 100rpx;
659
+ font-size: 24rpx;
660
+ color: #fe7a63;
387
661
  }
388
662
  }
389
- /deep/ .uni-easyinput__placeholder-class {
390
- font-size: 26rpx;
391
- color: #d4d4d4;
663
+ .panel-forget-password {
664
+ /deep/ .uni-forms-item__label {
665
+ .label-text {
666
+ font-size: 26rpx;
667
+ color: #a6a6a6;
668
+ }
669
+ }
670
+ /deep/ .uni-easyinput__placeholder-class {
671
+ font-size: 26rpx;
672
+ color: #d4d4d4;
673
+ }
674
+ .forget_tip {
675
+ box-sizing: border-box;
676
+ width: 600rpx;
677
+ border-radius: 10rpx;
678
+ box-shadow: 0px 0px 20px 0px #00000019;
679
+ padding: 64rpx 46rpx;
680
+ margin: 200rpx auto;
681
+ text-align: center;
682
+ font-size: 32rpx;
683
+ .contact_phone {
684
+ color: @xd-base-color;
685
+ font-size: 56rpx;
686
+ margin: 20rpx 0 30rpx;
687
+ }
688
+ }
392
689
  }
393
- .forget_password {
394
- font-size: 24rpx;
395
- color: #a6a6a6;
396
- text-align: right;
397
- margin: 20rpx 70rpx 0 0;
690
+ .panel-reset-password {
691
+ /deep/ .uni-forms-item__label {
692
+ width: 185rpx !important;
693
+ .label-text {
694
+ font-size: 26rpx;
695
+ color: #a6a6a6;
696
+ }
697
+ }
698
+ /deep/ .uni-easyinput__placeholder-class {
699
+ font-size: 26rpx;
700
+ color: #d4d4d4;
701
+ }
398
702
  }
399
703
  }
400
704
  }
401
- .flex {
402
- display: flex;
403
- }
404
- .flex-sub {
405
- flex: 1;
406
- }
407
- .align-center {
408
- align-items: center;
409
- }
705
+ .flex {
706
+ display: flex;
707
+ }
708
+ .flex-sub {
709
+ flex: 1;
710
+ }
711
+ .align-center {
712
+ align-items: center;
713
+ }
714
+
715
+ .login-pub {
716
+ margin-top: unit(40, rpx);
717
+ }
410
718
  </style>