OneKeyLoginPage.ets
3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { router } from '@kit.ArkUI'
import { Params } from 'wdBean/Index'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import HuaweiAuth from '../../utils/HuaweiAuth'
import { BusinessError } from '@kit.BasicServicesKit'
import { ToastUtils } from 'wdKit/Index'
@Entry
@Component
struct OneKeyLoginPage {
anonymousPhone: string = ''
@State agreeProtocol: boolean = false
aboutToAppear(): void {
this.anonymousPhone = HuaweiAuth.sharedInstance().anonymousPhone||""
}
build() {
Column() {
this.CloseRow()
Image($r("app.media.login_logo"))
.width(120)
.height(66)
.margin({ top: 78, bottom: 74})
.align(Alignment.Center)
Text(this.anonymousPhone)
.fontSize(30)
.fontWeight(600)
.fontColor("#222222")
.margin({bottom: 10})
.align(Alignment.Center)
this.ProtocolRow()
Row() {
Button("华为账号一键登录")
.type(ButtonType.Normal)
.height(48)
.backgroundColor(!this.agreeProtocol ? Color.Grey : Color.Red)
.width("100%")
.onClick((event) => {
if (!this.agreeProtocol) {
return
}
HuaweiAuth.sharedInstance().oneKeyLogin().then((authorizeCode) => {
//TODO: 调用服务端接口登录
ToastUtils.shortToast("获取到授权code: " + authorizeCode + ",由于需要后台接口支持,暂时先跳转其他登录方式")
setTimeout(() => {
router.replaceUrl({url: WDRouterPage.loginPage.url()})
}, 3000)
}).catch((error: BusinessError) => {
})
})
}
.padding({ left: 25, right: 25 })
.margin({top: 15})
Button("其他手机号登录")
.type(ButtonType.Normal)
.align(Alignment.Center)
.foregroundColor("#666666")
.backgroundColor(Color.White)
.onClick((event) => {
router.replaceUrl({url: WDRouterPage.loginPage.url()})
})
}
}
@Builder ProtocolRow() {
Row({space: 4}) {
Image(this.agreeProtocol ? $r('app.media.login_checkbox_select') : $r('app.media.login_checkbox_unselected'))
.width(15)
.height(15)
.onClick(() => {
this.agreeProtocol = !this.agreeProtocol
})
Text() {
Span("我已阅读并同意").fontColor("#999999").fontSize(12)
Span("《用户协议》").fontColor("#ED2800").fontSize(12).onClick(() => {
let bean = { contentID: "1", pageID: "" } as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean)
})
Span("、").fontColor("#999999").fontSize(12)
Span("《隐私政策》").fontColor("#ED2800").fontSize(12).onClick(() => {
let bean = { contentID: "2", pageID: "" } as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean)
})
Span("和").fontColor("#999999").fontSize(12)
Span("《华为账号用户认证协议》").fontColor("#ED2800").fontSize(12).onClick(() => {
let bean = { contentID: "4", pageID: "" } as Params
WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage, bean)
})
}
.layoutWeight(1)
}
.margin({top: 15})
.padding({ left: 25, right: 25 })
.width('100%')
}
@Builder CloseRow() {
Row() {
Blank()
Image($r('app.media.login_closed'))
.width(24)
.height(24)
.onClick(() => router.back())
}.margin({ top: 15, right: 15 })
.width("100%")
}
}