@cloudbase/lowcode-builder 1.8.74 → 1.8.75
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/lib/builder/config/index.d.ts +2 -5
- package/lib/builder/config/index.js +3 -6
- package/lib/builder/core/index.js +13 -23
- package/lib/builder/core/plugin.d.ts +1 -7
- package/lib/builder/core/plugin.js +0 -2
- package/lib/builder/mp/BuildContext.d.ts +4 -0
- package/lib/builder/mp/index.d.ts +2 -2
- package/lib/builder/mp/index.js +179 -124
- package/lib/builder/mp/materials.d.ts +1 -1
- package/lib/builder/mp/materials.js +10 -19
- package/lib/builder/mp/mixMode.d.ts +9 -3
- package/lib/builder/mp/mixMode.js +70 -137
- package/lib/builder/mp/mp_config.d.ts +1 -1
- package/lib/builder/mp/mp_config.js +26 -18
- package/lib/builder/mp/wxml.js +3 -2
- package/lib/builder/util/common.d.ts +1 -0
- package/lib/builder/util/common.js +8 -1
- package/lib/builder/util/net.d.ts +10 -1
- package/lib/builder/util/net.js +47 -8
- package/lib/builder.web.js +13 -13
- package/package.json +6 -5
- package/template/mp/app/weapps-api.js +19 -1
- package/template/mp/app.js +3 -120
- package/template/mp/common/info/index.js +5 -4
- package/template/mp/common/info/index.wxml +2 -2
- package/template/mp/common/privacyModal/index.js +3 -2
- package/template/mp/common/util.js +24 -12
- package/template/mp/common/weapp-page.js +11 -4
- package/template/mp/datasources/index.js.tpl +122 -2
- package/template/mp/packages/$wd_system/pages/login/components/input/index.js +40 -0
- package/template/mp/packages/$wd_system/pages/login/components/input/index.json +4 -0
- package/template/mp/packages/$wd_system/pages/login/components/input/index.wxml +11 -0
- package/template/mp/packages/$wd_system/pages/login/index.js +161 -0
- package/template/mp/packages/$wd_system/pages/login/index.json +16 -0
- package/template/mp/packages/$wd_system/pages/login/index.wxml +60 -0
- package/template/mp/packages/$wd_system/pages/login/index.wxss +60 -0
- package/template/mp/packages/$wd_system/pages/login/methods/loginByPassword.js +55 -0
- package/template/mp/packages/$wd_system/pages/login/methods/loginByWXPhone.js +68 -0
- package/template/mp/packages/$wd_system/pages/login/methods/loginSuccessCallBack.js +20 -0
- package/template/mp/page/index.js +4 -1
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { app, $app } from '../../../../app/weapps-api'
|
|
2
|
+
import loginByPassword from './methods/loginByPassword'
|
|
3
|
+
import loginByWXPhone from './methods/loginByWXPhone'
|
|
4
|
+
|
|
5
|
+
function decodePageQuery(query) {
|
|
6
|
+
return Object.keys(query).reduce((decoded, key) => {
|
|
7
|
+
decoded[key] = decodeURIComponent(query[key]);
|
|
8
|
+
return decoded;
|
|
9
|
+
}, {});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let loginConfig
|
|
13
|
+
Component({
|
|
14
|
+
data: {
|
|
15
|
+
params: {},
|
|
16
|
+
initing: true,
|
|
17
|
+
error: null,
|
|
18
|
+
settingData: {
|
|
19
|
+
"logo": "",
|
|
20
|
+
"agreement": {
|
|
21
|
+
"items": [],
|
|
22
|
+
"enable": false
|
|
23
|
+
},
|
|
24
|
+
"miniprogram": [],
|
|
25
|
+
},
|
|
26
|
+
pageStyle: '',
|
|
27
|
+
agreement: false,
|
|
28
|
+
wxLoginStatus: '',
|
|
29
|
+
passwordVisible: false,
|
|
30
|
+
enablePassword: false,
|
|
31
|
+
enableMpPhone: false
|
|
32
|
+
},
|
|
33
|
+
methods: {
|
|
34
|
+
async getPhoneCodeNumber(e) {
|
|
35
|
+
if (
|
|
36
|
+
e?.detail?.errMsg?.includes('fail') ||
|
|
37
|
+
e?.detail?.errno ||
|
|
38
|
+
!e?.detail?.code
|
|
39
|
+
) {
|
|
40
|
+
console.warn(
|
|
41
|
+
'获取手机号授权令牌失败:',
|
|
42
|
+
!e?.detail.code ? { errMsg: '可能基础库版本过低' } : e.detail
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
$app.showModal({
|
|
46
|
+
"cancelColor": "#000000",
|
|
47
|
+
"cancelText": "取消",
|
|
48
|
+
"confirmColor": "#576B95",
|
|
49
|
+
"confirmText": "确认",
|
|
50
|
+
"showCancel": true,
|
|
51
|
+
"title": "获取手机号授权令牌失败",
|
|
52
|
+
"content": `获取手机号授权令牌失败: ${e.detail.errno || e.detail?.errMsg || '可能基础库版本过低'}`
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return loginByWXPhone(this, { event: e })
|
|
59
|
+
},
|
|
60
|
+
async onLoad(options) {
|
|
61
|
+
try {
|
|
62
|
+
const config = await this._getLoginConfig().catch(() => {
|
|
63
|
+
return this._getLoginConfig()
|
|
64
|
+
})
|
|
65
|
+
const query = decodePageQuery(options || {});
|
|
66
|
+
let settingData = {
|
|
67
|
+
"logo": config.logo || "https://sso-1303824488.cos.ap-shanghai.myqcloud.com/logo.svg",
|
|
68
|
+
"agreement": {
|
|
69
|
+
"items": [],
|
|
70
|
+
"enable": false,
|
|
71
|
+
...config.agreement
|
|
72
|
+
},
|
|
73
|
+
"miniprogram": config.miniprogram || [],
|
|
74
|
+
}
|
|
75
|
+
this.setData({
|
|
76
|
+
params: query,
|
|
77
|
+
settingData,
|
|
78
|
+
enablePassword: this._getEnablePassword(settingData),
|
|
79
|
+
enableMpPhone: this._getEnableMpPhone(settingData),
|
|
80
|
+
pageStyle: `${this.data.pageStyle}; background-color: ${config.backgroundColor || '#fff'};`,
|
|
81
|
+
initing: false
|
|
82
|
+
})
|
|
83
|
+
} catch(e) {
|
|
84
|
+
this.setData({
|
|
85
|
+
initing: false,
|
|
86
|
+
error: {
|
|
87
|
+
message: '获取登录配置失败,' + (e.message || '')
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
togglePasswordVisible() {
|
|
93
|
+
this.setData({
|
|
94
|
+
passwordVisible: !this.data.passwordVisible
|
|
95
|
+
})
|
|
96
|
+
},
|
|
97
|
+
loginByPassword(e) {
|
|
98
|
+
const values = e.detail.value
|
|
99
|
+
|
|
100
|
+
return loginByPassword(this, { username: values?.username?.value, password: values?.password?.value })
|
|
101
|
+
},
|
|
102
|
+
showAgreement(e) {
|
|
103
|
+
const index = e.currentTarget?.dataset?.index
|
|
104
|
+
const agreementContent = this.data.settingData.agreement.items[index].value
|
|
105
|
+
this.setData({
|
|
106
|
+
agreementContent,
|
|
107
|
+
isShowAgreement: !!agreementContent
|
|
108
|
+
})
|
|
109
|
+
},
|
|
110
|
+
checkAgreement(e) {
|
|
111
|
+
if (this.data.settingData.agreement.enable && !this.data.agreement) {
|
|
112
|
+
app.showToast({ title: '请阅读并勾选底部协议', icon: 'error', duartion: Math.min(1500, title.length * 200) })
|
|
113
|
+
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
},
|
|
118
|
+
onAgreementChange(e) {
|
|
119
|
+
this.setData({
|
|
120
|
+
agreement: e.detail.value.length > 0
|
|
121
|
+
})
|
|
122
|
+
},
|
|
123
|
+
_getEnablePassword(settingData) {
|
|
124
|
+
const config = settingData || this.data.settingData
|
|
125
|
+
return config.miniprogram?.find?.(item => item.type === 'password')?.enable ?? false
|
|
126
|
+
},
|
|
127
|
+
_getEnableMpPhone(settingData) {
|
|
128
|
+
const config = settingData || this.data.settingData
|
|
129
|
+
return !!config.miniprogram.find(function (item) { return item.type === 'miniprogram_phone' }
|
|
130
|
+
)
|
|
131
|
+
},
|
|
132
|
+
async _getLoginConfig() {
|
|
133
|
+
const { staticResourceDomain, loginConfigVersion, id } = app.__internal__?.getConfig() || {};
|
|
134
|
+
if (staticResourceDomain && loginConfigVersion && id) {
|
|
135
|
+
const url = app.__internal__?.resolveStaticResourceUrl?.(`/__auth/app/${id}/login.config.${loginConfigVersion}.json`)
|
|
136
|
+
if (!loginConfig) {
|
|
137
|
+
loginConfig = await new Promise((resolve, reject) => {
|
|
138
|
+
wx.request({
|
|
139
|
+
// url: `https://lowcode-1gk9y5ik310a94df-1307578329.tcloudbaseapp.com/__auth/app/app-8ph9atcy/login.config.v1_97dab26a85842c557de0ecb47cbb9bc1.json`,
|
|
140
|
+
url,
|
|
141
|
+
success: res => {
|
|
142
|
+
if(String(res.statusCode).startsWith('2')){
|
|
143
|
+
resolve(res.data)
|
|
144
|
+
} else {
|
|
145
|
+
reject(new Error(`statusCode: ${res.statusCode} 获取${url}失败`))
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
fail: e => {
|
|
149
|
+
reject(e)
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
return loginConfig
|
|
155
|
+
} else {
|
|
156
|
+
throw new Error('缺少登录配置');
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"usingComponents": {
|
|
3
|
+
"login-input": "./components/input/index",
|
|
4
|
+
"gsd-h5-react-Modal": "../../../../materials/gsd-h5-react/components/modal/index",
|
|
5
|
+
"gsd-h5-react-ScrollView": "../../../../materials/gsd-h5-react/components/scrollView/index",
|
|
6
|
+
"gsd-h5-react-RichTextView": "../../../../materials/gsd-h5-react/components/richText/index",
|
|
7
|
+
"wd-ph": "../../../../common/placeholder/index",
|
|
8
|
+
"wd-info": "../../../../common/info/index"
|
|
9
|
+
},
|
|
10
|
+
"componentPlaceholder": {
|
|
11
|
+
"gsd-h5-react-Modal": "wd-ph",
|
|
12
|
+
"gsd-h5-react-ScrollView": "wd-ph",
|
|
13
|
+
"gsd-h5-react-RichTextView": "wd-ph"
|
|
14
|
+
},
|
|
15
|
+
"navigationBarTitleText": "登录"
|
|
16
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<page-meta page-style="{{pageStyle}}">
|
|
2
|
+
<view wx:if="{{!initing && !error}}" id="wd-page-root" data-weui-theme="light">
|
|
3
|
+
<view id="id33" style="width:90%;margin:0px auto;display:flex;flex-direction:column;max-width:50rem;" class="login-class">
|
|
4
|
+
<view id="id44" style="margin:80px 0px;">
|
|
5
|
+
<image id="id15" style="margin:0px auto;display:flex;justify-content:center;width: 120px;height: 120px;" class="weda-ui weda-image" mode="aspectFit" src="{{settingData.logo}}" />
|
|
6
|
+
</view>
|
|
7
|
+
<view id="container1" wx:if="{{enablePassword}}">
|
|
8
|
+
<form bindsubmit="loginByPassword">
|
|
9
|
+
<login-input id="input1" name="username" placeholder="请输入用户名" type="text" />
|
|
10
|
+
<view id="container2" style="margin-bottom:30px;position:relative;">
|
|
11
|
+
<login-input id="input2" name="password" placeholder="请输入密码" type="{{passwordVisible?'text':'password'}}" />
|
|
12
|
+
<image id="image1" style="width:20PX;height:20PX;position:absolute;right:17px;top:20px;z-index: 9999;" class="weda-ui weda-image wd-event-tap" mode="widthFix" src="{{passwordVisible?'https://qcloudimg.tencent-cloud.cn/raw/487eba32ccfc23ebc68f8fac005d6919.svg':'https://qcloudimg.tencent-cloud.cn/raw/0b6cef53d62a3356e3bcc5bd83341482.svg'}}" bind:tap="togglePasswordVisible" />
|
|
13
|
+
</view>
|
|
14
|
+
<button id="button1" class="weda-ui weda-button weui-btn weui-btn_primary wd-event-tap" style="width:100%;border-radius:5px;" size="md" form-type="submit">
|
|
15
|
+
账号密码登录
|
|
16
|
+
</button>
|
|
17
|
+
</form>
|
|
18
|
+
</view>
|
|
19
|
+
<view id="id37" style="display:flex;flex-direction:column;">
|
|
20
|
+
<view id="id48" style="width:100%;margin-top:20px;position:relative;" wx:if="{{enableMpPhone}}">
|
|
21
|
+
<button style="width:100%;margin-top:0px;z-index:1;font-weight:normal;border-radius:0.5713rem;background:rgb(7, 193, 96);position:absolute;left:0px;top:0px;" bindgetphonenumber="getPhoneCodeNumber" aria-disabled="false" open-type="getPhoneNumber" role="button" class="weda-ui weda-button weui-btn weui-btn_primary weui-btn_wechat">登录</button>
|
|
22
|
+
<button id="id47" style="width:100%;margin-top:0px;z-index:1;font-weight:normal;border-radius:0.5713rem;background:rgb(7, 193, 96);position:absolute;left:0px;top:0px;" role="button" class="weda-ui weda-button weui-btn weui-btn_primary wd-event-tap wd-event-tap" bind:tap="checkAgreement" wx:if="{{settingData.agreement.enable && !agreement}}">登录</button>
|
|
23
|
+
</view>
|
|
24
|
+
</view>
|
|
25
|
+
<view id="id11" style="display:flex;justify-content:center;flex-direction:row;font-size:0.8rem;position:fixed;left:0px;right:0px;bottom:50px;" class="have-read" wx:if="{{settingData.agreement.enable}}">
|
|
26
|
+
<view id="id19" class="weda-ui weda-ui-to-wd">
|
|
27
|
+
<view class="weda-ui weda-checkbox wd-event-change">
|
|
28
|
+
<view class="weda-ui weda-formcells weui-cells weui-cells_checkbox weui-flex">
|
|
29
|
+
<view class="weui-flex__item">
|
|
30
|
+
<view class="weui-cell__bd weui-flex">
|
|
31
|
+
<checkbox-group bind:change="onAgreementChange">
|
|
32
|
+
<label role="checkbox" aria-disables="false" aria-checked="false" class="weui-cell weui-cell_active weui-check__label">
|
|
33
|
+
<view class="weui-cell__hd">
|
|
34
|
+
<checkbox aria-disables="false" value="haveRead" role="checkbox" aria-checked="false" class="weui-check"></checkbox>
|
|
35
|
+
<i class="weui-icon-checked"></i>
|
|
36
|
+
</view>
|
|
37
|
+
<view class="weui-cell__bd">
|
|
38
|
+
<view>我已阅读并同意</view>
|
|
39
|
+
</view>
|
|
40
|
+
</label>
|
|
41
|
+
</checkbox-group>
|
|
42
|
+
</view>
|
|
43
|
+
</view>
|
|
44
|
+
</view>
|
|
45
|
+
</view>
|
|
46
|
+
</view>
|
|
47
|
+
<text class="weda-text weda-ui wd-event-tap" style="white-space: pre-line; margin:0px 5px;display:flex;align-items:center;color:rgb(68, 144, 238);text-align:center;white-space:pre-line;" wx:if="{{settingData.agreement.items[0].enable}}" data-index="0" bind:tap="showAgreement">《{{settingData.agreement.items[0].label}}》</text>
|
|
48
|
+
<text id="id14" style="white-space: pre-warp; display:flex;align-items:center;white-space:pre-line;" class="weda-text weda-ui" wx:if="{{settingData.agreement.items[0].enable && settingData.agreement.items[1].enable}}">和</text>
|
|
49
|
+
<text class="weda-text weda-ui wd-event-tap" id="id12" style="white-space: pre-line; margin:0px 5px;display:flex;align-items:center;color:rgb(68, 144, 238);white-space:pre-line;" data-index="1" wx:if="{{settingData.agreement.items[1].enable}}" bind:tap="showAgreement">《{{settingData.agreement.items[1].label}}》</text>
|
|
50
|
+
</view>
|
|
51
|
+
</view>
|
|
52
|
+
<gsd-h5-react-Modal id="id4" style="position: absolute;" isDefaultButton="{{false}}" visible="{{isShowAgreement}}" bind:close="showAgreement">
|
|
53
|
+
<scroll-view id="id6" style="height:500px;margin-top:20px;" class="weda-ui" scroll-y="true">
|
|
54
|
+
<gsd-h5-react-RichTextView id="id5" style="height: 60%" value="{{agreementContent}}" />
|
|
55
|
+
</scroll-view>
|
|
56
|
+
</gsd-h5-react-Modal>
|
|
57
|
+
</view>
|
|
58
|
+
<wd-info type="{{initing? 'loading': 'auth'}}" wx:if="{{initing || error}}" message="{{loading?'加载配置中...':' '}}" error="{{error}}" />
|
|
59
|
+
</page-meta>
|
|
60
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
button,
|
|
2
|
+
button:hover,
|
|
3
|
+
button,
|
|
4
|
+
button:active {
|
|
5
|
+
color: white;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.login-class .weda-ui .wedatea2td-input,
|
|
9
|
+
.login-class .weda-ui .wedatea2td-button {
|
|
10
|
+
border: none;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.login-class .weda-ui .wedatea2td-input,
|
|
14
|
+
.login-class .weda-ui .weda-input {
|
|
15
|
+
width: 100%;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.login-class .weda-ui .wedatea2td-btn {
|
|
19
|
+
border: none;
|
|
20
|
+
line-height: 1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.login-class .weda-ui .wedatea2td-btn::after {
|
|
24
|
+
border: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.login-class .weda-ui .weui-cells:before,
|
|
28
|
+
.login-class .weda-ui .weui-cells::after {
|
|
29
|
+
display: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.login-class .token-container .weda-button {
|
|
33
|
+
width: 11rem;
|
|
34
|
+
padding: 0.5rem;
|
|
35
|
+
color: #1e6fd8;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.login-class .token-container .weda-button::after {
|
|
39
|
+
border: none;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.login-class .token-container .weda-button[disabled] {
|
|
43
|
+
color: #d0d0d0;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.login-class .have-read .weui-cells {
|
|
47
|
+
font-size: 0.8rem;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.login-class .have-read .weui-cell {
|
|
51
|
+
padding: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.login-class .have-read .weui-cells_checkbox .weui-cell__hd {
|
|
55
|
+
padding-right: 0.5rem;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.login-class .have-read .weui-cells_checkbox .weui-icon-checked {
|
|
59
|
+
width: 1.2rem;
|
|
60
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { app } from '../../../../../app/weapps-api';
|
|
2
|
+
import loginSuccessCallBack from './loginSuccessCallBack'
|
|
3
|
+
/**
|
|
4
|
+
* 账号密码登录
|
|
5
|
+
*/
|
|
6
|
+
export default async function (instance, {username, password}) {
|
|
7
|
+
const cloudbase = await app.cloud.getCloudInstance();
|
|
8
|
+
const auth = cloudbase.authInstance || cloudbase.auth;
|
|
9
|
+
|
|
10
|
+
// 校验
|
|
11
|
+
if (typeof username !== 'string' || typeof password !== 'string') {
|
|
12
|
+
throw new Error('账号密码填写不合法');
|
|
13
|
+
}
|
|
14
|
+
username = username.trim();
|
|
15
|
+
password = password.trim();
|
|
16
|
+
// 发起校验
|
|
17
|
+
// const validateResult = await Promise.all([$w.input1.custom.handleValidate(), $w.input2.handleValidate()]);
|
|
18
|
+
// if (validateResult.some((item) => item.length !== 0) || !username || !password) {
|
|
19
|
+
// app.showModal({
|
|
20
|
+
// title: '无法提交',
|
|
21
|
+
// content: '账号或密码填写不合法',
|
|
22
|
+
// showCancel: false,
|
|
23
|
+
// });
|
|
24
|
+
// return;
|
|
25
|
+
// }
|
|
26
|
+
// 登录
|
|
27
|
+
try {
|
|
28
|
+
const res = await auth.signIn({ username, password });
|
|
29
|
+
// 登录完成
|
|
30
|
+
loginSuccessCallBack(instance);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
console.error(e)
|
|
33
|
+
// 错误处理
|
|
34
|
+
if (e?.error === 'invalid_password') {
|
|
35
|
+
app.showModal({
|
|
36
|
+
title: '登录失败',
|
|
37
|
+
content: '密码错误',
|
|
38
|
+
showCancel: false,
|
|
39
|
+
});
|
|
40
|
+
} else if (e?.error === 'not_found') {
|
|
41
|
+
app.showModal({
|
|
42
|
+
title: '登录失败',
|
|
43
|
+
content: '用户不存在',
|
|
44
|
+
showCancel: false,
|
|
45
|
+
});
|
|
46
|
+
} else {
|
|
47
|
+
app.showModal({
|
|
48
|
+
title: '登录失败',
|
|
49
|
+
content: JSON.stringify(e),
|
|
50
|
+
showCancel: false,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { app } from '../../../../../app/weapps-api';
|
|
2
|
+
import loginSuccessCallBack from './loginSuccessCallBack'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export default async function (instance, { event }) {
|
|
6
|
+
try {
|
|
7
|
+
const cloud = await app.cloud.getCloudInstance();
|
|
8
|
+
const auth = cloud.auth;
|
|
9
|
+
const { appId: providerId } = wx.getAccountInfoSync().miniProgram;
|
|
10
|
+
const endpointType = app.__internal__ && app.__internal__.getCloudSdkConfig && app.__internal__.getCloudSdkConfig('endpointType');
|
|
11
|
+
const isTcbApi = endpointType === 'tcb-api';
|
|
12
|
+
const phoneCode = event.detail.code
|
|
13
|
+
const providerInfo = {};
|
|
14
|
+
if (isTcbApi) {
|
|
15
|
+
const { code } = await wx.login();
|
|
16
|
+
providerInfo.provider_id = providerId;
|
|
17
|
+
providerInfo.provider_code = code;
|
|
18
|
+
} else {
|
|
19
|
+
const tokenRes = await app.cloud.callWedaApi({
|
|
20
|
+
action: 'GetMiniProgramUserTicket',
|
|
21
|
+
data: {
|
|
22
|
+
Type: `externalUser`,
|
|
23
|
+
EncryptedPhoneData: phoneCode,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const token = tokenRes?.token || tokenRes;
|
|
27
|
+
if (!token) {
|
|
28
|
+
throw new Error('invalid empty mp user ticket');
|
|
29
|
+
}
|
|
30
|
+
providerInfo.provider_id = 'weda';
|
|
31
|
+
providerInfo.provider_access_token = `${
|
|
32
|
+
app.utils._getConfig
|
|
33
|
+
? app.utils._getConfig().envId
|
|
34
|
+
: app.__internal__ && app.__internal__.getConfig && app.__internal__.getConfig().envId
|
|
35
|
+
} ${token}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let providerToken = await auth.grantProviderToken(providerInfo);
|
|
39
|
+
if (providerToken.code) {
|
|
40
|
+
throw providerToken;
|
|
41
|
+
}
|
|
42
|
+
if (isTcbApi) {
|
|
43
|
+
providerToken = await auth.patchProviderToken({
|
|
44
|
+
provider_token: providerToken.provider_token,
|
|
45
|
+
provider_id: providerId,
|
|
46
|
+
provider_params: {
|
|
47
|
+
code: phoneCode
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
const signInRes = await auth.signInWithProvider({
|
|
52
|
+
provider_token: providerToken.provider_token,
|
|
53
|
+
});
|
|
54
|
+
if (signInRes.code) {
|
|
55
|
+
throw signInRes;
|
|
56
|
+
}
|
|
57
|
+
await app.cloud.signIn({ userType: 'externalUser', force: true });
|
|
58
|
+
loginSuccessCallBack(instance);
|
|
59
|
+
} catch (e) {
|
|
60
|
+
console.error('登录失败:', e);
|
|
61
|
+
app.showModal({
|
|
62
|
+
title: '登录失败',
|
|
63
|
+
content: e.errMsg || e.message || JSON.stringify(e),
|
|
64
|
+
showCancel: false,
|
|
65
|
+
})
|
|
66
|
+
throw e;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { app } from '../../../../../app/weapps-api';
|
|
2
|
+
|
|
3
|
+
export default function (instance) {
|
|
4
|
+
const { params: query } = instance.data
|
|
5
|
+
try {
|
|
6
|
+
let params = query.sourcePageParams || {};
|
|
7
|
+
if (typeof params === 'string') {
|
|
8
|
+
try {
|
|
9
|
+
params = JSON.parse(params)
|
|
10
|
+
} catch (error) { }
|
|
11
|
+
}
|
|
12
|
+
query.sourcePageId ? app.redirectTo({
|
|
13
|
+
pageId: query.sourcePageId,
|
|
14
|
+
packageName: query.sourcePagePackageName || undefined,
|
|
15
|
+
params,
|
|
16
|
+
}) : app.relaunchHome();
|
|
17
|
+
} catch (e) {
|
|
18
|
+
app.relaunchHome();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -62,6 +62,8 @@ const eventFlows = [<% eventFlows.map(flow => {%> { <% const { eventHandlers, ..
|
|
|
62
62
|
},<%}) %>
|
|
63
63
|
]
|
|
64
64
|
|
|
65
|
+
const datasetProfile = <%= datasetProfile %>
|
|
66
|
+
|
|
65
67
|
createPage({
|
|
66
68
|
app,
|
|
67
69
|
pageContext: $page,
|
|
@@ -76,5 +78,6 @@ createPage({
|
|
|
76
78
|
query,
|
|
77
79
|
eventFlows,
|
|
78
80
|
pageAttributes: <%= pageAttributes? JSON.stringify(pageAttributes):'{}' %>,
|
|
79
|
-
resetShare: <%= resetShare
|
|
81
|
+
resetShare: <%= resetShare %>,
|
|
82
|
+
datasetProfile
|
|
80
83
|
})
|