89 lines
2.9 KiB
Plaintext
89 lines
2.9 KiB
Plaintext
import { AESEncryptionDecryption, authStore, BasicConstant, HdNav, ScanUtil } from '@itcast/basic'
|
||
import { promptAction, router } from '@kit.ArkUI'
|
||
import { http } from '@kit.NetworkKit'
|
||
|
||
@Component
|
||
export struct CustomScanResultComp {
|
||
@State params:Record<string,string> = router.getParams() as Record<string,string>
|
||
|
||
build() {
|
||
Column() {
|
||
HdNav({isLeftAction:false,title:'扫描登录',showRightIcon:false,showRightText:false})
|
||
|
||
Image($r('app.media.scan_success_icon'))
|
||
.objectFit(ImageFit.Contain)
|
||
.width(210)
|
||
.height(74)
|
||
.margin({top:70})
|
||
|
||
Text('确认电脑登录\n为确保账号安全,请确认是您本人操作')
|
||
.textAlign(TextAlign.Center)
|
||
.fontSize(16)
|
||
.fontColor('rgba(102,102,102,1)')
|
||
.margin({top:50})
|
||
|
||
Text('确认登录')
|
||
.textAlign(TextAlign.Center)
|
||
.fontSize(18)
|
||
.fontColor(Color.White)
|
||
.width('90%')
|
||
.height(40)
|
||
.backgroundColor($r('app.color.main_color'))
|
||
.borderRadius(3)
|
||
.margin({left:15,right:15,top:100})
|
||
.onClick(()=>isAuthorization(this.params.id,true))
|
||
|
||
Text('确认登录')
|
||
.textAlign(TextAlign.Center)
|
||
.fontSize(18)
|
||
.fontColor('rgba(153,153,153,1)')
|
||
.borderWidth(1)
|
||
.borderColor('rgba(153,153,153,1)')
|
||
.width('90%')
|
||
.height(40)
|
||
.backgroundColor(Color.White)
|
||
.borderRadius(3)
|
||
.margin({left:15,right:15,top:20})
|
||
.onClick(()=>isAuthorization(this.params.id,false))
|
||
}
|
||
}
|
||
}
|
||
|
||
async function isAuthorization(str:string,type:boolean) {
|
||
let scanString = ''
|
||
if (type) {
|
||
scanString = `watchliveTo}${str}}${authStore.getUser().uuid},${authStore.getUser().realName},${authStore.getUser().photo}`
|
||
} else {
|
||
scanString = `watchliveCancel}${str}}${authStore.getUser().uuid},${authStore.getUser().realName},${authStore.getUser().photo}`
|
||
}
|
||
const scanData = await AESEncryptionDecryption.aesEncrypt(scanString,BasicConstant.ExpertAesKey)
|
||
const encodedString = encodeURIComponent(scanData)
|
||
let httpRequest = http.createHttp();
|
||
let data = "message="+encodedString;
|
||
httpRequest.request(
|
||
BasicConstant.sendWebsocketMsg,
|
||
{
|
||
method: http.RequestMethod.POST,
|
||
header: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||
extraData: data,
|
||
connectTimeout: 60000,
|
||
readTimeout: 60000,
|
||
}, (err, data) => {
|
||
if (!err) {
|
||
console.info('Result:' + JSON.stringify(data.result));
|
||
let json:Record<string,string> = JSON.parse(data.result+'') as Record<string,string>
|
||
if (type) {
|
||
promptAction.showToast({ message: String(json.message), duration: 1000 })
|
||
}
|
||
if(json.code == '1') {
|
||
router.back()
|
||
} else {
|
||
console.error('获取患者信息失败:'+json.message)
|
||
}
|
||
} else {
|
||
console.info('error:' + JSON.stringify(err))
|
||
httpRequest.off('headersReceive')
|
||
httpRequest.destroy()
|
||
}
|
||
})
|
||
} |