登录和接口请求
This commit is contained in:
@@ -7,6 +7,8 @@ import cryptoFramework from '@ohos.security.cryptoFramework';
|
||||
import util from '@ohos.util';
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import { rcp } from '@kit.RemoteCommunicationKit';
|
||||
import { HashMap } from '@kit.ArkTS';
|
||||
import { http } from '@kit.NetworkKit';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@@ -275,33 +277,71 @@ async function decryptString(str:string) {
|
||||
// B2e%2B96mEodDQ5EIsmcpfh6cJbH7WhjSkXrIz8JtGf2gREqwSckolodE2%2FdNTTssxvwLTAltHlphKiSYWT91IpBUkt30diwj0VF1elbS193JwyOF4AU%2FhJ%2FRYQtxUHrB%2BlRo65QEhktb7z79lsRuJwUKISPEbTkrCVzRx9QDGcihdsOe44ABgLH%2BmyFhgEsMC
|
||||
// B2e+96mEodDQ5EIsmcpfh6cJbH7WhjSkXrIz8JtGf2gREqwSckolodE2/dNTTssxvwLTAltHlphKiSYWT91IpBUkt30diwj0VF1elbS193JwyOF4AU/hJ/RYQtxUHrB+lRo65QEhktb7z79lsRuJwUKISPEbTkrCVzRx9QDGcihdsOe44ABgLH+myFhgEsMC
|
||||
async function pushScanPage(str:string) {
|
||||
const liceScanSuccess = `liveScanSuccess}${str}}${authStore.getUser().uuid},${authStore.getUser().realName},${authStore.getUser().photo}`
|
||||
const textEncoder = new util.TextEncoder()
|
||||
const inputData: Uint8Array = textEncoder.encodeInto(liceScanSuccess)
|
||||
const scanData = await AESEncryptionDecryption.aes128Encrypt(inputData,BasicConstant.ExpertAesKey)
|
||||
const base64Data = AESEncryptionDecryption.customBase64Encode(scanData)
|
||||
const encodedString = encodeURIComponent(base64Data)
|
||||
const postContent = new rcp.MultipartForm({
|
||||
'message': encodedString
|
||||
})
|
||||
const session = rcp.createSession()
|
||||
session.post(BasicConstant.sendWebsocketMsg, {
|
||||
data: postContent,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
const liceScanSuccess = `videoScanSuccess}${str}}${authStore.getUser().uuid},${authStore.getUser().realName},${authStore.getUser().photo}`
|
||||
// const textEncoder = new util.TextEncoder()
|
||||
// const inputData: Uint8Array = textEncoder.encodeInto(liceScanSuccess)
|
||||
// const scanData = await AESEncryptionDecryption.aes128Encrypt(inputData,BasicConstant.ExpertAesKey)
|
||||
// const base64Data = AESEncryptionDecryption.customBase64Encode(scanData)
|
||||
// const encodedString = encodeURIComponent(base64Data)
|
||||
// let hashMap: HashMap<string, string> = new HashMap()
|
||||
// hashMap.set('message',this.code)
|
||||
|
||||
const scanData =await AESEncryptionDecryption.aesEncrypt(liceScanSuccess,"deoep09_klodLdAo")
|
||||
const encodedString = encodeURIComponent(scanData)
|
||||
let httpRequest = http.createHttp();
|
||||
let data = "message="+encodedString;
|
||||
httpRequest.request(
|
||||
BasicConstant.sendWebsocketMsg,
|
||||
{
|
||||
method: http.RequestMethod.POST,
|
||||
// Optional, default is http.RequestMethod.GET//Developers can add header fields according to their own business needs
|
||||
header: { 'Content-Type': 'application/x-www-form-urlencoded' }, // This field is used to pass content when using POST requests
|
||||
extraData: data,
|
||||
connectTimeout: 60000, // Optional, default is 60000ms
|
||||
readTimeout: 60000, // Optional, default is 60000ms
|
||||
}, (err, data) => {
|
||||
if (!err) {
|
||||
// Data.read is the HTTP response content, which can be parsed according to business needs
|
||||
console.info('Result:' + JSON.stringify(data.result));
|
||||
console.info('code:' +
|
||||
JSON.stringify(data.responseCode)); // Data.reader is an HTTP response header that can be parsed according to business needs
|
||||
console.info('header:' + JSON.stringify(data.header));
|
||||
console.info('cookies:' +
|
||||
JSON.stringify(data.cookies)); // Starting from API8
|
||||
} else {
|
||||
console.info('error:' + JSON.stringify(err)); // Unsubscribe from HTTP response header events
|
||||
httpRequest.off('headersReceive'); // When the request is exhausted, call the destroy method to actively destroy it.
|
||||
httpRequest.destroy();
|
||||
}
|
||||
})
|
||||
.then((response) => {
|
||||
let json:Record<string,string> = JSON.parse(response+'') as Record<string,string>
|
||||
if(json.code == '1') {
|
||||
router.pushUrl({url:'pages/VideoPage/CustomScanPage'})
|
||||
} else {
|
||||
promptAction.showToast({ message: String(json.message), duration: 1000 })
|
||||
}
|
||||
})
|
||||
.catch((err: BusinessError) => {
|
||||
console.error(`Response err: Code is ${JSON.stringify(err.code)}, message is ${JSON.stringify(err)}`);
|
||||
})
|
||||
|
||||
// const postContent = new rcp.MultipartForm({
|
||||
// 'message': encodedString
|
||||
// })
|
||||
// const postContent: rcp.RequestContent = {
|
||||
// fields: {
|
||||
// 'message': encodedString,
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// const session = rcp.createSession()
|
||||
// session.post(BasicConstant.sendWebsocketMsg, {
|
||||
// data: postContent,
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/x-www-form-urlencoded'
|
||||
// }
|
||||
// })
|
||||
// .then((response) => {
|
||||
// let json:Record<string,string> = JSON.parse(response+'') as Record<string,string>
|
||||
// if(json.code == '1') {
|
||||
// router.pushUrl({url:'pages/VideoPage/CustomScanPage'})
|
||||
// } else {
|
||||
// promptAction.showToast({ message: String(json.message), duration: 1000 })
|
||||
// }
|
||||
// })
|
||||
// .catch((err: BusinessError) => {
|
||||
// console.error(`Response err: Code is ${JSON.stringify(err.code)}, message is ${JSON.stringify(err)}`);
|
||||
// })
|
||||
// hdHttp.post<string>(BasicConstant.sendWebsocketMsg, {
|
||||
// "message":base64Data
|
||||
// } as Record<string,string>).then(async (res: HdResponse<string>) => {
|
||||
@@ -319,3 +359,4 @@ async function pushScanPage(str:string) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,15 +14,15 @@ export struct MessageComp {
|
||||
// @Param pathStack: NavPathStack = new NavPathStack()
|
||||
@Param onUreadMessageChange?: (unreadCount?: number) => void = undefined
|
||||
|
||||
loadUnreadApplication = async () => {
|
||||
|
||||
try {
|
||||
const unreadCount = await ContactRepo.getAddApplicationUnreadCount()
|
||||
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
// loadUnreadApplication = async () => {
|
||||
//
|
||||
// try {
|
||||
// const unreadCount = await ContactRepo.getAddApplicationUnreadCount()
|
||||
//
|
||||
// } catch (err) {
|
||||
// console.log(err)
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
//获取会话列表未读数
|
||||
@@ -48,14 +48,14 @@ export struct MessageComp {
|
||||
|
||||
}
|
||||
)
|
||||
ChatKitClient.nim.friendService?.on('onFriendAddApplication', async (application: V2NIMFriendAddApplication) => {
|
||||
await this.loadUnreadApplication()
|
||||
})
|
||||
try {
|
||||
await this.loadUnreadApplication()
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
}
|
||||
// ChatKitClient.nim.friendService?.on('onFriendAddApplication', async (application: V2NIMFriendAddApplication) => {
|
||||
// await this.loadUnreadApplication()
|
||||
// })
|
||||
// try {
|
||||
// await this.loadUnreadApplication()
|
||||
// } catch (err) {
|
||||
// console.log(err)
|
||||
// }
|
||||
this.loadConfig()
|
||||
this.loadUnreadMessageCount()
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
applyListModel,
|
||||
authStore, BasicConstant,
|
||||
ChangeUtil,
|
||||
EmptyViewComp,
|
||||
hdHttp, HdLoadingDialog, HdResponse,
|
||||
HdTwoNav,
|
||||
PatientData,
|
||||
@@ -49,7 +50,7 @@ export struct PatientListComp {
|
||||
@State delectuuid:string=''
|
||||
@State delectname:string=''
|
||||
@State positionDelete:number = 0
|
||||
|
||||
@State isEmptyViewVisible: boolean = false; // 控制显隐的状态变量
|
||||
dialogDelete = new CustomDialogController({
|
||||
builder: DelectDialog(
|
||||
{
|
||||
@@ -123,20 +124,6 @@ export struct PatientListComp {
|
||||
console.log('服务器返回的患者数据:', json);
|
||||
if(json.data!=null)
|
||||
{
|
||||
// let regionRequestData: PatientsData[]=[...json.data]
|
||||
// regionRequestData =[...json.data]
|
||||
// regionRequestData.push(...json.data)
|
||||
// regionRequestData.push(...json.data)
|
||||
// regionRequestData.push(...json.data)
|
||||
// regionRequestData.push(...json.data)
|
||||
// regionRequestData.push(...json.data)
|
||||
// regionRequestData.push(...json.data)
|
||||
// regionRequestData.push(...json.data)
|
||||
// regionRequestData.push(...json.data)
|
||||
// regionRequestData.push(...json.data)
|
||||
// regionRequestData.push(...json.data)
|
||||
// regionRequestData.push(...json.data)
|
||||
// this.collationData(regionRequestData);
|
||||
if(json.data!=null&&json.data.length>0)
|
||||
{
|
||||
this.total=json.data.length
|
||||
@@ -146,6 +133,12 @@ export struct PatientListComp {
|
||||
preferenceStore.setItemNumber('old_patient_num',this.total/10)
|
||||
}
|
||||
this.collationData(json.data);
|
||||
this.isEmptyViewVisible=false
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isEmptyViewVisible=true
|
||||
this.dialog.close()
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +191,7 @@ export struct PatientListComp {
|
||||
},rightItemAction2:()=>{
|
||||
HMRouterMgr.push({pageUrl:'PatientsListSearchComp'})
|
||||
}})
|
||||
Stack({ }) {
|
||||
Stack({ alignContent:Alignment.Top}) {
|
||||
List({ scroller: this.scroller, space: 0, initialIndex: 0 }) {
|
||||
ListItem() {
|
||||
Column()
|
||||
@@ -303,6 +296,11 @@ export struct PatientListComp {
|
||||
.onClick(() => {
|
||||
HMRouterMgr.push({pageUrl:'PatientsGroup',param:"我的患者"})
|
||||
})
|
||||
if (this.isEmptyViewVisible){
|
||||
EmptyViewComp({promptText:'暂无随访患者',isVisibility:this.isEmptyViewVisible})
|
||||
.width('100%')
|
||||
.height('60%')
|
||||
}
|
||||
ForEach(this.regionDataGroupsList, (regionDataGroups: Groups, index) => {
|
||||
|
||||
ListItemGroup({ header: this.itemHead(regionDataGroups.title) }) {
|
||||
@@ -475,6 +473,7 @@ export struct PatientListComp {
|
||||
|
||||
}.width('100%')
|
||||
.height('100%')
|
||||
|
||||
}
|
||||
|
||||
private collationData(regionRequestData: PatientsData[]) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { authStore, hdHttp, HdResponse,HdNav,BasicConstant, logger,LoginInfo,ChangeUtil } from '@itcast/basic'
|
||||
import { authStore, hdHttp, HdResponse,HdNav,BasicConstant, logger,LoginInfo,ChangeUtil,
|
||||
patientDbManager } from '@itcast/basic'
|
||||
import { promptAction, router } from '@kit.ArkUI'
|
||||
import { BusinessError } from '@kit.BasicServicesKit';
|
||||
import HashMap from '@ohos.util.HashMap';
|
||||
@@ -127,7 +128,6 @@ export struct LoginComp {
|
||||
} else {
|
||||
this.loadPatients()//登录成功后获取患者数据存入数据库
|
||||
|
||||
this.loginstatus=true
|
||||
authStore.setUser(objs.data)
|
||||
// emitter.emit({ eventId: 100401 })
|
||||
logger.info('Response state'+state);
|
||||
|
||||
Reference in New Issue
Block a user