subject-two/entry/src/main/ets/pages/ExaminerLogin.ets

171 lines
6.5 KiB
Plaintext
Raw Normal View History

2024-06-04 11:19:22 +08:00
import router from '@ohos.router';
2024-06-04 12:08:32 +08:00
import TopLogo from './compontents/TopLogo';
2024-06-04 11:19:22 +08:00
import { examinerLoginService } from '../common/service/ExaminerService';
import Md5 from '../common/utils/md5';
import promptAction from '@ohos.promptAction';
2024-08-19 09:32:41 +08:00
import errorMsgDialog from './compontents/errorMsgDialog'
2024-01-05 11:11:15 +08:00
@Entry
@Component
2024-06-04 11:19:22 +08:00
export default struct Index {
2024-05-16 09:53:10 +08:00
@State ratio: number = 1700 / 960
2024-01-05 11:11:15 +08:00
@State url: string = ''
2024-06-04 11:19:22 +08:00
@State inputPlaceholderArr: string[] = ['用户账户', '密码'];
@State inputTextArr: string[] = ['', ''];
@State imgArr1: Resource[] = [$r('app.media.1_nor'), $r('app.media.2_nor'), $r('app.media.3_nor'), $r('app.media.4_nor'), $r('app.media.5_nor'), $r('app.media.6_nor'), $r('app.media.7_nor'), $r('app.media.8_nor'), $r('app.media.9_nor'), $r('app.media.0_nor'), $r('app.media.x_nor'), $r('app.media.clear_nor'), $r('app.media.delete_nor'), $r('app.media.confirm_nor')]
2024-01-05 11:11:15 +08:00
@State currentInputIndex: number = 0
@State @Watch('outClick') outFlag: boolean = false;
private vocObj = null;
2024-08-19 09:32:41 +08:00
private title = ''
private type = '2'
errorDialog: CustomDialogController = new CustomDialogController({
builder: errorMsgDialog({
title: this.title,
type: this.type,
cancel: () => {
},
confirm: () => {
}
}),
customStyle: true,
alignment: DialogAlignment.Center,
},
)
2024-01-05 11:11:15 +08:00
build() {
2024-02-26 15:01:27 +08:00
Column() {
2024-06-04 11:19:22 +08:00
TopLogo({ outFlag: $outFlag })
2024-01-05 11:11:15 +08:00
Column() {
2024-06-04 11:19:22 +08:00
Text('请考官输入用户名密码').fontColor('#FFAD33').fontSize(36 * this.ratio)
2024-02-26 15:01:27 +08:00
Row() {
2024-06-04 11:19:22 +08:00
ForEach(this.inputPlaceholderArr, (item: any, index: number) => {
Row() {
TextInput({ placeholder: `${item}`, text: this.inputTextArr[index] })
.fontSize(42 * this.ratio)
2024-02-26 15:01:27 +08:00
.fontColor('white')
2024-06-04 11:19:22 +08:00
.placeholderFont({ size: 42 * this.ratio })
2024-02-26 15:01:27 +08:00
.placeholderColor('gray')
.caretColor('white')
.backgroundColor('transparent')
.width('90%')
2024-06-04 11:19:22 +08:00
.margin({ left: '4%' })
2024-02-26 15:01:27 +08:00
.type(index === 0 ? InputType.Normal : InputType.Password)
.focusable(false)
.onClick(() => {
this.currentInputIndex = index;
})
}
2024-06-04 11:19:22 +08:00
.backgroundImage(this.currentInputIndex == index ? $r('app.media.kuang_pre') : $r('app.media.kuang_nor'))
.backgroundImageSize({ width: '100%', height: '100%' })
2024-02-26 15:01:27 +08:00
.width('48%')
.height('14.9%')
})
}
.width('90%')
2024-06-04 11:19:22 +08:00
.margin({ top: 25 * this.ratio }) //20
2024-02-26 15:01:27 +08:00
.justifyContent(FlexAlign.SpaceBetween)
2024-06-04 11:19:22 +08:00
2024-01-05 11:11:15 +08:00
Column() {
2024-06-04 11:19:22 +08:00
Flex({ wrap: FlexWrap.Wrap,
justifyContent: FlexAlign.SpaceAround,
alignContent: FlexAlign.SpaceAround }) {
ForEach(this.imgArr1, (item: Resource, index: number) => {
if (index === this.imgArr1.length - 1) {
2024-02-26 15:01:27 +08:00
Image(item).width('38%').height('24%').onClick(() => {
2024-01-05 11:11:15 +08:00
2024-06-04 11:19:22 +08:00
if (this.inputTextArr[0].trim() == '' || this.inputTextArr[1].trim() == '') {
2024-02-26 15:01:27 +08:00
promptAction.showToast({
message: '请输入用户名和密码',
duration: 3000
});
return
}
2024-01-05 11:11:15 +08:00
2024-02-26 15:01:27 +08:00
const param = {
carId: globalThis.carInfo.carId,
examinationRoomId: globalThis.carInfo.examinationRoomId,
username: this.inputTextArr[0],
password: Md5.Instance.get_md5(this.inputTextArr[1])
}
2024-08-19 09:32:41 +08:00
this.type='2'
this.errorDialog.open()
2024-07-02 08:59:03 +08:00
console.log('carInfo', JSON.stringify(globalThis.carInfo))
2024-02-26 15:01:27 +08:00
examinerLoginService(param).then(res => {
2024-08-19 09:32:41 +08:00
console.log('res?.examinerLoginRsp?.head?.resultCode',res?.examinerLoginRsp?.head?.resultCode,JSON.stringify(res))
this.errorDialog.close()
if(res?.examinerLoginRsp?.head?.resultCode=='1'){
2024-08-19 14:54:11 +08:00
// this.type='1'
// this.title=decodeURIComponent(res.examinerLoginRsp.head.resultMessage)
// console.log('this.titlt',this.title)
// this.errorDialog.open()
2024-08-19 09:32:41 +08:00
return
}
2024-02-26 15:01:27 +08:00
router.pushUrl({
url: 'pages/UserInfo',
2024-08-20 09:12:02 +08:00
params:{
type:1
}
2024-06-04 11:19:22 +08:00
}, router.RouterMode.Single);
2024-08-19 09:32:41 +08:00
2024-06-04 11:19:22 +08:00
console.log('res11', JSON.stringify(res))
globalThis.username = this.inputTextArr[0]
2024-08-19 09:32:41 +08:00
}).catch(err=>{
console.log('jiangsong12',JSON.stringify(err))
2024-01-05 11:11:15 +08:00
})
2024-02-26 15:01:27 +08:00
})
2024-06-04 11:19:22 +08:00
} else {
2024-02-26 15:01:27 +08:00
Image(item).width('18%').height('24%').onClick(() => {
// this.vocObj.playAudio({
// type: 1,
// name: 'media_button.wav'
// })
2024-06-04 11:19:22 +08:00
this.url = ''
if (index < 9) {
this.inputTextArr[this.currentInputIndex] += (index + 1).toString()
} else {
if (index === 9) {
this.inputTextArr[this.currentInputIndex] += (0).toString()
}
if (index === 10) {
this.inputTextArr[this.currentInputIndex] += 'X';
} else if (index === 11) {
this.inputTextArr[this.currentInputIndex] = '';
}
if (index === 12) {
2024-02-26 15:01:27 +08:00
this.inputTextArr[this.currentInputIndex] = this.inputTextArr[this.currentInputIndex].slice(0, -1)
}
}
console.log(this.inputTextArr[this.currentInputIndex])
})
}
})
2024-01-05 11:11:15 +08:00
}
2024-02-26 15:01:27 +08:00
.height('100%')
2024-01-05 11:11:15 +08:00
}
2024-06-04 11:19:22 +08:00
.margin({ top: 20 * this.ratio })
2024-02-26 15:01:27 +08:00
.width('90%')
.height('62.7%')
.backgroundColor('#E5E3DF')
2024-06-04 11:19:22 +08:00
.borderRadius(20 * this.ratio)
2024-01-05 11:11:15 +08:00
}
2024-06-04 11:19:22 +08:00
.margin({ top: -10 * this.ratio })
2024-02-26 15:01:27 +08:00
.justifyContent(FlexAlign.SpaceAround)
}
.width('100%')
.height('100%')
.justifyContent(FlexAlign.SpaceBetween)
2024-06-04 11:19:22 +08:00
.backgroundImagePosition({ x: 0, y: 0 })
2024-02-26 15:01:27 +08:00
.backgroundImage($r('app.media.index_bg'))
.backgroundImageSize({ width: '100%', height: '100%' })
2024-01-05 11:11:15 +08:00
}
2024-06-04 11:19:22 +08:00
2024-01-05 11:11:15 +08:00
aboutToAppear() {
2024-06-04 11:19:22 +08:00
this.url = ''
2024-01-05 11:11:15 +08:00
console.info('ExmainerLogin aboutToAppear');
}
2024-06-04 11:19:22 +08:00
2024-01-05 11:11:15 +08:00
onPageShow() {
}
2024-06-04 11:19:22 +08:00
outClick() {
2024-01-05 11:11:15 +08:00
}
}