TASK: #116148 数字密码样式优化

This commit is contained in:
duanzhijiang 2022-10-15 16:43:28 +08:00
parent fd8d24e850
commit 5a0962e712
3 changed files with 89 additions and 72 deletions

View File

@ -21,19 +21,27 @@ export const sharedStyles: CSSResult = css`
height: 12px; height: 12px;
border-radius: 50%; border-radius: 50%;
display: inline-block; display: inline-block;
margin: 0 10px; margin-right: 20px;
background: #000000; background: #f4f4f4;
opacity: 0.2; opacity: 0.3;
}
#sSix {
margin: 0;
} }
#parent { #parent {
position: relative; position: relative;
height: 500px; height: 250px;
width: 500px; width: 250px;
left: 50%; left: 50%;
top: 66%; top: 53%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
.grid {
position: absolute;
display: grid;
grid-template-areas: '1 2 3 ' '4 5 6' '7 8 9';
gap: 20px;
}
p { p {
position: absolute; position: absolute;
@ -44,9 +52,9 @@ export const sharedStyles: CSSResult = css`
} }
#zero { #zero {
position: relative; position: absolute;
left: 42.5%; left: 36%;
top: 68%; top: 270px;
} }
button { button {
position: relative; position: relative;
@ -79,32 +87,26 @@ export const sharedStyles: CSSResult = css`
} }
#slideUp { #slideUp {
position: absolute; position: relative;
height: 500px; height: 100%;
width: 500px; width: 100%;
left: 50%; }
top: 50%; #textcenter {
transform: translate(-50%, -50%); text-align: center;
} }
.topText { .topText {
font-size: 20px; font-size: 20px;
height: 26.5px; height: 26.5px;
line-height: 26.5px; line-height: 26.5px;
width: 80px; width: 160px;
left: calc(50% - 80px / 2 + 3px); left: calc(50% - 160px / 2);
top: calc(50% - 26.5px / 2 - 168.75px); top: 31%;
} }
.spanContainer { .spanContainer {
position: relative;
left: 29%;
top: 23%;
}
.grid {
position: absolute; position: absolute;
display: grid; left: 50%;
grid-template-areas: '1 2 3 ' '4 5 6' '7 8 9' '. 0 .'; transform: translateX(-50%);
gap: 20px; top: 36.7%;
margin: 0 124px;
} }
.cancel, .cancel,
@ -118,13 +120,13 @@ export const sharedStyles: CSSResult = css`
height: 23.5px; height: 23.5px;
line-height: 23.5px; line-height: 23.5px;
font-size: 18px; font-size: 18px;
top: 73%; top: 118.5%;
} }
.cancel { .cancel {
left: 27%; left: 8%;
} }
.delete { .delete {
left: 65.5%; left: 78.5%;
} }
.cancel:hover, .cancel:hover,
.delete:hover { .delete:hover {

View File

@ -18,9 +18,9 @@ export class StarLockNumber extends LitElement {
@query('.topText') topText!: HTMLParagraphElement @query('.topText') topText!: HTMLParagraphElement
@query('.screen') screen!: HTMLDivElement @query('.screen') screen!: HTMLDivElement
@property({type: String}) mode = "default" @property({type: String}) mode = 'default'
@property({type: String}) cancelNote = "取消" @property({type: String}) cancelNote = '取消'
@property({type: String}) deleteNote = "删除" @property({type: String}) deleteNote = '删除'
@property({type: Boolean}) confirm = false @property({type: Boolean}) confirm = false
@property({type: Number}) tried = 0 @property({type: Number}) tried = 0
@property({type: Number}) time = 0 @property({type: Number}) time = 0
@ -33,35 +33,37 @@ export class StarLockNumber extends LitElement {
@property({type: String}) color = '' @property({type: String}) color = ''
@property({type: String}) opacity = '' @property({type: String}) opacity = ''
@property({type: String}) guess = '' @property({type: String}) guess = ''
@property({type: String}) passwd = '123456' @property({type: String}) passwd = ''
@property({type: String}) savewd = '' @property({type: String}) savewd = ''
protected firstUpdated( protected firstUpdated(
_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown> _changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>
): void { ): void {
switch(this.mode){ switch (this.mode) {
case "create": case 'create':
this.changeText = '新建密码'; this.changeText = '新建密码'
break; break
case "verify": case 'verify':
case "comfirm": case 'comfirm':
this.changeText = '输入密码'; this.changeText = '输入密码'
break; break
case "default": case 'default':
this.changeText = '星光麒麟密码组件' this.changeText = '星光麒麟密码组件'
} }
this.spanContainer.style.visibility = `visible` this.spanContainer.style.visibility = `visible`
this.parent.style.visibility = `visible` this.parent.style.visibility = `visible`
this.addEventListener('passcode-create-success',this) this.addEventListener('passcode-create-success', this)
this.addEventListener('passcode-verify-success',this) this.addEventListener('passcode-verify-success', this)
this.addEventListener('passcode-verify-error',this) this.addEventListener('passcode-verify-error', this)
this.addEventListener('passcode-reset',this) this.addEventListener('passcode-reset', this)
} }
render() { render() {
return html` return html`
<div id="slideUp"> <div id="slideUp">
<div id="textcenter">
<p class="topText">${this.changeText}</p> <p class="topText">${this.changeText}</p>
</div>
<div class="spanContainer"> <div class="spanContainer">
<span id="sOne"></span> <span id="sOne"></span>
<span id="sTwo"></span> <span id="sTwo"></span>
@ -108,9 +110,9 @@ export class StarLockNumber extends LitElement {
case 'passcode-create-success': case 'passcode-create-success':
this.guess = '' this.guess = ''
this.clicks = 0 this.clicks = 0
this.spanContainer.style.visibility = `hidden`; this.spanContainer.style.visibility = `hidden`
this.parent.style.visibility = `hidden`; this.parent.style.visibility = `hidden`
this.changeText = '保存成功'; this.changeText = '保存成功'
break break
case 'passcode-verify-success': case 'passcode-verify-success':
this.guess = '' this.guess = ''
@ -137,11 +139,11 @@ export class StarLockNumber extends LitElement {
for (let i = 0; i < 6; i++) { for (let i = 0; i < 6; i++) {
this.changeBgColor('#F4F4F4', i, 0.4) this.changeBgColor('#F4F4F4', i, 0.4)
} }
if(this.mode == "create"){ if (this.mode == 'create') {
this.changeText = '新建密码' this.changeText = '新建密码'
this.spanContainer.style.visibility = `visible` this.spanContainer.style.visibility = `visible`
this.parent.style.visibility = `visible` this.parent.style.visibility = `visible`
}else{ } else {
this.changeText = '输入密码' this.changeText = '输入密码'
} }
break break
@ -161,14 +163,17 @@ export class StarLockNumber extends LitElement {
this.changeBgColor('#F4F4F4', this.clicks, 1) this.changeBgColor('#F4F4F4', this.clicks, 1)
this.clicks += 1 this.clicks += 1
this.guess += (e.target as HTMLElement).dataset.num this.guess += (e.target as HTMLElement).dataset.num
}else if (this.clicks == 5){ } else if (this.clicks == 5) {
if (this.mode == "create"){ this.changeBgColor('#F4F4F4', this.clicks, 1)
this.clicks += 1
this.guess += (e.target as HTMLElement).dataset.num
if (this.mode == 'create') {
if (!this.confirm) { if (!this.confirm) {
this.changePasswd() this.changePasswd()
} else { } else {
this.confirmPasswd() this.confirmPasswd()
} }
}else if(this.mode == "verify"){ } else if (this.mode == 'verify') {
this.dispatchPasswd() this.dispatchPasswd()
} }
} }
@ -181,7 +186,7 @@ export class StarLockNumber extends LitElement {
} }
} else if ((e.target as Element).className === 'cancel') { } else if ((e.target as Element).className === 'cancel') {
//点击取消,返回锁屏 //点击取消,返回锁屏
// this.makeZero() this.makeZero()
for (let i = 0; i < 6; i++) { for (let i = 0; i < 6; i++) {
this.changeBgColor('#F4F4F4', i, 0.4) this.changeBgColor('#F4F4F4', i, 0.4)
} }
@ -191,6 +196,8 @@ export class StarLockNumber extends LitElement {
} }
touchEnd(e: TouchEvent) { touchEnd(e: TouchEvent) {
if ((e.target as Element).tagName === 'BUTTON') { if ((e.target as Element).tagName === 'BUTTON') {
console.log('this.guess', this.guess)
this.removeNumberBgColor() this.removeNumberBgColor()
} }
} }
@ -214,7 +221,7 @@ export class StarLockNumber extends LitElement {
} }
//发送密码 //发送密码
dispatchPasswd(){ dispatchPasswd() {
this.passwd = this.guess this.passwd = this.guess
this.guess = '' this.guess = ''
this.clicks = 0 this.clicks = 0
@ -242,7 +249,7 @@ export class StarLockNumber extends LitElement {
} }
//确认密码 //确认密码
confirmPasswd() { confirmPasswd() {
if (this.savewd.toString() == this.guess.toString() ) { if (this.savewd.toString() == this.guess.toString()) {
// if (1) { // if (1) {
this.passwd = this.savewd this.passwd = this.savewd
this.savewd = '' this.savewd = ''
@ -271,5 +278,5 @@ export class StarLockNumber extends LitElement {
this.confirm = false this.confirm = false
this.changeText = '更改密码' this.changeText = '更改密码'
} }
} }
} }

View File

@ -11,10 +11,18 @@ export class PanelDigicipher extends LitElement {
width: 100%; width: 100%;
background-color: rgb(183, 211, 227); background-color: rgb(183, 211, 227);
} }
#line {
position: absolute;
left: calc(50% - 1px);
width: 2px;
height: 100%;
background-color: black;
}
` `
render() { render() {
return html` return html`
<div class="screen"> <div class="screen">
<div id="line"></div>
<star-digicipher></star-digicipher> <star-digicipher></star-digicipher>
</div> </div>
` `