更新云信和公益咨询相关代码
This commit is contained in:
@@ -14,7 +14,7 @@ export struct PerfactInputSheet {
|
||||
@State okText:ResourceStr='确定'
|
||||
@State cancelText:ResourceStr='取消'
|
||||
private inputCallBack: (input: string,title:string) => void = () => {};
|
||||
|
||||
@State needcancelCallBack:boolean=false
|
||||
// 修改构造函数
|
||||
constructor(controller: CustomDialogController, inputCallBack: (input: string,title:string) => void) {
|
||||
super();
|
||||
@@ -115,6 +115,8 @@ export struct PerfactInputSheet {
|
||||
.textAlign(TextAlign.Center)
|
||||
.width('45%').height(30)
|
||||
.onClick(() => {
|
||||
|
||||
|
||||
this.controller.close()
|
||||
})
|
||||
Text('').height(30).width(1)
|
||||
@@ -171,6 +173,10 @@ export struct PerfactInputSheet {
|
||||
|
||||
.width('45%').height(30)
|
||||
.onClick(() => {
|
||||
if(this.needcancelCallBack)
|
||||
{
|
||||
this.inputCallBack(this.inputText, 'needcancelCallBack');
|
||||
}
|
||||
this.controller.close()
|
||||
})
|
||||
Text('').height(30).width(1)
|
||||
|
||||
@@ -79,6 +79,7 @@ export class BasicConstant {
|
||||
static readonly listMyAnsweredInterrogation = BasicConstant.urlExpertAPI +"listMyAnsweredInterrogation";// 一问多答 我回答的一问多答列表
|
||||
static readonly getInterrogation = BasicConstant.urlExpertAPI +"getInterrogation";// 一问多答 详情页
|
||||
static readonly InterrogationPatientInfo = BasicConstant.urlExpertAPI +"InterrogationPatientInfo";// 一问多答 患者详情页
|
||||
static readonly updateInterrogationAnswer = BasicConstant.urlExpertAPI+"updateInterrogationAnswer";// 一问多答 编辑回答
|
||||
static readonly province=['全国','北京市','天津市','河北省','山西省'
|
||||
,'内蒙古自治区','辽宁省','吉林省','黑龙江省','上海市','江苏省','浙江省'
|
||||
,'安徽省','福建省','江西省','山东省','河南省','湖北省','湖南省','广东省',
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
|
||||
export interface ChatExtModel{
|
||||
gdxz_sessionType:string,//是否为公益咨询
|
||||
gdxz_consult_uuid:string,//公益咨询uuid
|
||||
gdxz_nickName:string//患者备注姓名
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { fileIo } from '@kit.CoreFileKit';
|
||||
import util from '@ohos.util';
|
||||
import { i18n } from '@kit.LocalizationKit';
|
||||
import { connection } from '@kit.NetworkKit';
|
||||
import http from '@ohos.net.http'
|
||||
export class ChangeUtil {
|
||||
/**
|
||||
* 将HashMap转成JsonString
|
||||
@@ -191,10 +192,46 @@ export class ChangeUtil {
|
||||
}
|
||||
|
||||
static stringIsUndefinedAndNull (string:string | undefined):boolean {
|
||||
if (string == undefined || string == "null" || string == "<null>" || string == "(null)" || string == 'undefined' || string.length <= 0) {
|
||||
if (string == null||string == undefined || string == "null" || string == "<null>" || string == "(null)" || string == 'undefined' || string.length <= 0) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static map2JsonO(map:HashMap<string, Object>) {
|
||||
let jsonObject: Record<string, Object> = {};
|
||||
map.forEach((value, key) => {
|
||||
if(key != undefined && value != undefined){
|
||||
jsonObject[key] = value;
|
||||
}
|
||||
})
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
static async getImageBase64(url: string): Promise<string> {
|
||||
// 创建 http 实例
|
||||
let httpRequest = http.createHttp();
|
||||
// 发起 GET 请求
|
||||
let response = await httpRequest.request(url, {
|
||||
method: http.RequestMethod.GET,
|
||||
// 重要:设置 responseType 为 arraybuffer,获取二进制数据
|
||||
expectDataType: http.HttpDataType.ARRAY_BUFFER
|
||||
});
|
||||
// 检查响应
|
||||
if (response.responseCode === 200 && response.result) {
|
||||
// 1. 转成 Uint8Array
|
||||
const buffernew=await ChangeUtil.compression(response.result as ArrayBuffer,"image/jpeg",0.5)
|
||||
// let uint8Arr = new Uint8Array(response.result as ArrayBuffer)
|
||||
const base64Helper = new util.Base64Helper();
|
||||
return base64Helper.encodeToStringSync(new Uint8Array(buffernew));
|
||||
// response.result 是 ArrayBuffer
|
||||
// let base64Str = base64.encode(response.result as ArrayBuffer);
|
||||
// // 可选:拼接 data url 前缀
|
||||
// return "data:image/png;base64," + base64Str;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -249,8 +249,7 @@ export class PatientDao {
|
||||
if (!this.rdbStore) {
|
||||
throw new Error('数据库连接为空');
|
||||
}
|
||||
|
||||
const sql = 'SELECT * FROM patients WHERE uuid = ?';
|
||||
const sql = 'SELECT * FROM patients WHERE LOWER(uuid) = LOWER(?)';
|
||||
const resultSet = await this.rdbStore.querySql(sql, [uuid]);
|
||||
|
||||
if (resultSet.rowCount > 0) {
|
||||
|
||||
@@ -67,7 +67,40 @@ class HdHttp {
|
||||
httpInstance.destroy()
|
||||
})
|
||||
}
|
||||
private requestObject<T>(path: string, method: http.RequestMethod = http.RequestMethod.POST, extraDatas :HashMap<string, Object>) {
|
||||
const httpInstance = http.createHttp()
|
||||
|
||||
const options: http.HttpRequestOptions = {
|
||||
method: http.RequestMethod.POST,
|
||||
// 可选,默认为60s
|
||||
connectTimeout: 60000,
|
||||
// 可选,默认为60s
|
||||
readTimeout: 60000,
|
||||
// 开发者根据自身业务需要添加header字段
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'sign':this.getSignO(extraDatas),
|
||||
'User-Agent':this.osFullName
|
||||
},
|
||||
extraData:ChangeUtil.map2JsonO(extraDatas)
|
||||
}
|
||||
|
||||
let fullUrl = this.baseURL + path
|
||||
|
||||
|
||||
return httpInstance.request(fullUrl, options).then((res) => {
|
||||
logger.info('Response param'+JSON.stringify(extraDatas))
|
||||
logger.info('Response fullUrl:' +fullUrl+ res.result);
|
||||
const result = res.result as HdResponse<T>
|
||||
return result
|
||||
}).catch((err: BusinessError) => {
|
||||
logger.info(fullUrl+`Response succeeded: ${err}`);
|
||||
promptAction.showToast({ message: err.message || '网络错误' })
|
||||
return Promise.reject(err)
|
||||
}).finally(() => {
|
||||
httpInstance.destroy()
|
||||
})
|
||||
}
|
||||
|
||||
private requestafter<T>(path: string, method: http.RequestMethod = http.RequestMethod.GET, extraData?: Object) {
|
||||
const httpInstance = http.createHttp()
|
||||
@@ -129,6 +162,9 @@ class HdHttp {
|
||||
posts<T>(url: string, data: HashMap<string, string>): Promise<HdResponse<T>> {
|
||||
return this.request<T>(url, http.RequestMethod.POST, data)
|
||||
}
|
||||
postO<T>(url: string, data: HashMap<string, Object>): Promise<HdResponse<T>> {
|
||||
return this.requestObject<T>(url, http.RequestMethod.POST, data)
|
||||
}
|
||||
httpReq<T>(url: string, datas: HashMap<string, string>): Promise<HdResponse<T>> {
|
||||
// 创建httpRequest对象。
|
||||
let httpRequest = http.createHttp();
|
||||
@@ -171,6 +207,47 @@ class HdHttp {
|
||||
})
|
||||
}
|
||||
|
||||
httpReqObject<T>(url: string, datas: HashMap<string, Object>): Promise<HdResponse<T>> {
|
||||
// 创建httpRequest对象。
|
||||
let httpRequest = http.createHttp();
|
||||
let url1 = "https://dev-app.igandan.com/app/manager/getSystemTimeStamp";
|
||||
let promise = httpRequest.request(
|
||||
// 请求url地址
|
||||
url1,
|
||||
{
|
||||
// 请求方式
|
||||
method: http.RequestMethod.GET,
|
||||
// 可选,默认为60s
|
||||
connectTimeout: 60000,
|
||||
// 可选,默认为60s
|
||||
readTimeout: 60000,
|
||||
// 开发者根据自身业务需要添加header字段
|
||||
header: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
// 处理响应结果。
|
||||
return promise.then(async (data) => {
|
||||
if (data.responseCode === http.ResponseCode.OK) {
|
||||
logger.info('Response httpReq:' + data.result);
|
||||
let json:TimestampBean = JSON.parse(data.result.toString()) as TimestampBean;
|
||||
let tp = json.timestamp;
|
||||
datas.set("user_uuid", authStore.getUser().uuid?authStore.getUser().uuid:'');
|
||||
datas.set("client_type", 'H');
|
||||
datas.set("version", await this.getVersion() );
|
||||
datas.set('timestamp',tp+'');
|
||||
return this.postO<T>(url, datas);
|
||||
} else {
|
||||
return this.postO<T>(url, datas);
|
||||
}
|
||||
}
|
||||
).catch((err:BusinessError) => {
|
||||
logger.info('Response httpReq error:' + JSON.stringify(err));
|
||||
return Promise.reject(err);
|
||||
}).finally(() => {
|
||||
httpRequest.destroy()
|
||||
})
|
||||
}
|
||||
httpReqSimply<T>(url: string) {
|
||||
// 创建httpRequest对象。
|
||||
let httpRequest = http.createHttp();
|
||||
@@ -203,6 +280,29 @@ class HdHttp {
|
||||
})
|
||||
}
|
||||
|
||||
getSignO(extraDatas1:HashMap<string, Object>): string {
|
||||
let secret= extraDatas1.get("timestamp")+''
|
||||
if(secret!=null) {
|
||||
let keyValueStr: string = "";
|
||||
let entriesArray: Array<string> = Array.from(extraDatas1.keys());
|
||||
entriesArray.sort();
|
||||
|
||||
let sortedMap:HashMap<string, Object> = new HashMap();
|
||||
entriesArray.forEach((value: string, index: number) => {
|
||||
sortedMap.set(value,extraDatas1.get(value));
|
||||
// keyValueStr +=value+extraDatas1.get(value)
|
||||
keyValueStr +=value+JSON.stringify(extraDatas1.get(value))
|
||||
});
|
||||
keyValueStr = keyValueStr + CryptoJS.MD5(secret).toString();
|
||||
keyValueStr = keyValueStr.replaceAll(" ", "").replaceAll("\"", "").replaceAll(":","=");
|
||||
let Md5keyValueStr: string = CryptoJS.MD5(keyValueStr).toString();
|
||||
let base64Str:string=Base64Util.encodeToStrSync(Md5keyValueStr);
|
||||
return base64Str;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
getSign(extraDatas1:HashMap<string, string>): string {
|
||||
let secret= extraDatas1.get("timestamp")
|
||||
if(secret!=null) {
|
||||
|
||||
Reference in New Issue
Block a user