hh-doctor-sdk 0.6.0 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +1 -0
- package/components/apis/ai-expert-api.js +29 -0
- package/components/apis/family-api.js +12 -0
- package/components/apis/order-app-api.js +14 -0
- package/components/apis/stat-log-api.js +1 -1
- package/components/expert-ai-order/ai-doctor-page.js +438 -0
- package/components/expert-ai-order/ai-doctor-page.json +10 -0
- package/components/expert-ai-order/ai-doctor-page.wxml +65 -0
- package/components/expert-ai-order/ai-doctor-page.wxss +332 -0
- package/components/expert-ai-order/components/ai-card-consultation-create/ai-card-consultation-create.js +24 -0
- package/components/expert-ai-order/components/ai-card-consultation-create/ai-card-consultation-create.json +4 -0
- package/components/expert-ai-order/components/ai-card-consultation-create/ai-card-consultation-create.wxml +30 -0
- package/components/expert-ai-order/components/ai-card-consultation-create/ai-card-consultation-create.wxss +73 -0
- package/components/expert-ai-order/components/ai-card-consultation-info/ai-card-consultation-info.js +70 -0
- package/components/expert-ai-order/components/ai-card-consultation-info/ai-card-consultation-info.json +7 -0
- package/components/expert-ai-order/components/ai-card-consultation-info/ai-card-consultation-info.wxml +17 -0
- package/components/expert-ai-order/components/ai-card-consultation-info/ai-card-consultation-info.wxss +71 -0
- package/components/expert-ai-order/components/ai-card-expert-info/ai-card-expert-info.js +24 -0
- package/components/expert-ai-order/components/ai-card-expert-info/ai-card-expert-info.json +4 -0
- package/components/expert-ai-order/components/ai-card-expert-info/ai-card-expert-info.wxml +6 -0
- package/components/expert-ai-order/components/ai-card-expert-info/ai-card-expert-info.wxss +27 -0
- package/components/expert-ai-order/components/ai-card-image/ai-card-image.js +27 -0
- package/components/expert-ai-order/components/ai-card-image/ai-card-image.json +4 -0
- package/components/expert-ai-order/components/ai-card-image/ai-card-image.wxml +6 -0
- package/components/expert-ai-order/components/ai-card-image/ai-card-image.wxss +28 -0
- package/components/expert-ai-order/components/ai-card-step/ai-card-step.js +27 -0
- package/components/expert-ai-order/components/ai-card-step/ai-card-step.json +4 -0
- package/components/expert-ai-order/components/ai-card-step/ai-card-step.wxml +9 -0
- package/components/expert-ai-order/components/ai-card-step/ai-card-step.wxss +58 -0
- package/components/expert-ai-order/components/ai-card-text/ai-card-text.js +30 -0
- package/components/expert-ai-order/components/ai-card-text/ai-card-text.json +4 -0
- package/components/expert-ai-order/components/ai-card-text/ai-card-text.wxml +6 -0
- package/components/expert-ai-order/components/ai-card-text/ai-card-text.wxss +36 -0
- package/components/expert-ai-order/components/ai-card-tip-text/ai-card-tip-text.js +24 -0
- package/components/expert-ai-order/components/ai-card-tip-text/ai-card-tip-text.json +4 -0
- package/components/expert-ai-order/components/ai-card-tip-text/ai-card-tip-text.wxml +3 -0
- package/components/expert-ai-order/components/ai-card-tip-text/ai-card-tip-text.wxss +8 -0
- package/components/expert-ai-order/components/expert-list-item/expert-list-item.js +43 -0
- package/components/expert-ai-order/components/expert-list-item/expert-list-item.json +4 -0
- package/components/expert-ai-order/components/expert-list-item/expert-list-item.wxml +25 -0
- package/components/expert-ai-order/components/expert-list-item/expert-list-item.wxss +111 -0
- package/components/expert-ai-order/constants/expert-ai-consultation-card-type.js +4 -0
- package/components/expert-ai-order/select-expert-page.js +133 -0
- package/components/expert-ai-order/select-expert-page.json +11 -0
- package/components/expert-ai-order/select-expert-page.wxml +20 -0
- package/components/expert-ai-order/select-expert-page.wxss +28 -0
- package/components/hh-navigation.js +22 -2
- package/components/public/user-cache-data.js +32 -0
- package/components/static/nim-wx.js +13 -0
- package/components/uikit/custom-pulldown-refresh/custom-pulldown-refresh.js +358 -0
- package/components/uikit/custom-pulldown-refresh/custom-pulldown-refresh.json +4 -0
- package/components/uikit/custom-pulldown-refresh/custom-pulldown-refresh.wxml +50 -0
- package/components/uikit/custom-pulldown-refresh/custom-pulldown-refresh.wxss +173 -0
- package/components/uikit/tabbar-content-view/tabbar-content-view.js +262 -0
- package/components/uikit/tabbar-content-view/tabbar-content-view.json +4 -0
- package/components/uikit/tabbar-content-view/tabbar-content-view.wxml +56 -0
- package/components/uikit/tabbar-content-view/tabbar-content-view.wxss +186 -0
- package/components/uikit/web-view-page/web-view-page.js +1 -0
- package/components/utils/httpUtils.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"editor.bracketPairColorization.enabled": true, "editor.guides.bracketPairs": "active"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import appConfig from '../public/app-config';
|
|
2
|
+
import cache from '../public/cache-data'
|
|
3
|
+
const getSoundWSUrl = 'commonai2/ws/voice/ars/stream'
|
|
4
|
+
|
|
5
|
+
function getSoundWsUrl(query) {
|
|
6
|
+
const queryString = transQueryData(query);
|
|
7
|
+
const isTest = getApp().globalData.profileName == 'test'
|
|
8
|
+
return `wss://mhealth${ isTest ? '-test' : '' }.hh-medic.com/${ getSoundWSUrl }?${ queryString }`
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function transQueryData(query) {
|
|
12
|
+
const userToken = cache.userToken()
|
|
13
|
+
let params = {
|
|
14
|
+
sdkProductId: appConfig.appID,
|
|
15
|
+
userToken: userToken,
|
|
16
|
+
memberUserToken: userToken,
|
|
17
|
+
app_version: appConfig.appVersion,
|
|
18
|
+
actionSource: 'wxdoctor',
|
|
19
|
+
wxAppId: appConfig.appID,
|
|
20
|
+
timestamp: new Date().getTime(),
|
|
21
|
+
...(query || {}),
|
|
22
|
+
}
|
|
23
|
+
return Object.keys(params).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`).join("&")
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
getSoundWsUrl,
|
|
28
|
+
transQueryData
|
|
29
|
+
}
|
|
@@ -6,6 +6,10 @@ const apiPaths = {
|
|
|
6
6
|
hostType: hostDefine.hostTypes.family,
|
|
7
7
|
path: '/expert/famDoctorDetail'
|
|
8
8
|
},
|
|
9
|
+
userInfo: {
|
|
10
|
+
hostType: hostDefine.hostTypes.family,
|
|
11
|
+
path: '/user/userInfo'
|
|
12
|
+
}
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
function getDoctorInfo(doctorUUID) {
|
|
@@ -15,6 +19,14 @@ function getDoctorInfo(doctorUUID) {
|
|
|
15
19
|
return httpUtils.post(apiPaths.doctorDetail, params, {})
|
|
16
20
|
}
|
|
17
21
|
|
|
22
|
+
function getUserInfo(userToken) {
|
|
23
|
+
const params = {
|
|
24
|
+
userToken
|
|
25
|
+
}
|
|
26
|
+
return httpUtils.post(apiPaths.userInfo, params, {})
|
|
27
|
+
}
|
|
28
|
+
|
|
18
29
|
module.exports = {
|
|
19
30
|
getDoctorInfo,
|
|
31
|
+
getUserInfo
|
|
20
32
|
}
|
|
@@ -72,6 +72,10 @@ const apiPaths = {
|
|
|
72
72
|
endConsultation: {
|
|
73
73
|
hostType: hostDefine.hostTypes.order,
|
|
74
74
|
path: '/orderask/update_ask_order_status'
|
|
75
|
+
},
|
|
76
|
+
getExpertListByStandardId: {
|
|
77
|
+
hostType: hostDefine.hostTypes.family,
|
|
78
|
+
path: '/expert/list'
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
|
|
@@ -216,6 +220,15 @@ function endConsultation(orderId) {
|
|
|
216
220
|
return httpUtils.post(apiPaths.endConsultation, params, null)
|
|
217
221
|
}
|
|
218
222
|
|
|
223
|
+
function getExpertListByStandardId(userToken, uuid) {
|
|
224
|
+
let params = {
|
|
225
|
+
standardId: 1955,
|
|
226
|
+
userToken,
|
|
227
|
+
uuid
|
|
228
|
+
}
|
|
229
|
+
return httpUtils.post(apiPaths.getExpertListByStandardId, params, null)
|
|
230
|
+
}
|
|
231
|
+
|
|
219
232
|
module.exports = {
|
|
220
233
|
login,
|
|
221
234
|
getRoomId,
|
|
@@ -229,4 +242,5 @@ module.exports = {
|
|
|
229
242
|
feedback,
|
|
230
243
|
fileData,
|
|
231
244
|
endConsultation,
|
|
245
|
+
getExpertListByStandardId,
|
|
232
246
|
}
|
|
@@ -43,7 +43,7 @@ function pointLog(type, content, orderId) {
|
|
|
43
43
|
}
|
|
44
44
|
const currentPage = pages[pages.length - 1]
|
|
45
45
|
const route = currentPage.route
|
|
46
|
-
if (!route.includes('
|
|
46
|
+
if (!route.includes('video-chat-page/video-chat-page')) {
|
|
47
47
|
return
|
|
48
48
|
}
|
|
49
49
|
const isTest = cache.isTest()
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
const api = require('../apis/ai-expert-api').default
|
|
2
|
+
const NIM = require('../static/nim-wx')
|
|
3
|
+
import userCacheData from "../public/user-cache-data"
|
|
4
|
+
|
|
5
|
+
const TARGET_SAMPLES = 640;
|
|
6
|
+
const options = {
|
|
7
|
+
format: 'pcm', // 录音格式
|
|
8
|
+
frameSize: 1,
|
|
9
|
+
duration: 600000,
|
|
10
|
+
sampleRate: 16000,
|
|
11
|
+
numberOfChannels: 1,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
Page({
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 页面的初始数据
|
|
18
|
+
*/
|
|
19
|
+
data: {
|
|
20
|
+
expert: null,
|
|
21
|
+
toolType: 'keyboard',
|
|
22
|
+
showAddList: false,
|
|
23
|
+
hasRecordPermission: false,
|
|
24
|
+
waveArr: new Array(16).fill(0), // 说话中的动画
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 生命周期函数--监听页面加载
|
|
29
|
+
*/
|
|
30
|
+
onLoad(options) {
|
|
31
|
+
wx.setNavigationBarTitle({
|
|
32
|
+
title: '专家会诊',
|
|
33
|
+
})
|
|
34
|
+
this.checkPermission()
|
|
35
|
+
const expert = decodeURIComponent(options.expert)
|
|
36
|
+
this.setData({
|
|
37
|
+
expert: JSON.parse(expert)
|
|
38
|
+
})
|
|
39
|
+
this.initIM()
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
onUnload() {
|
|
43
|
+
this.destroyIM()
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
// 初始化im
|
|
47
|
+
initIM() {
|
|
48
|
+
if (this.nim) {
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
const uuid = userCacheData.getUuid()
|
|
52
|
+
const videoToken = userCacheData.getVideoToken()
|
|
53
|
+
this.nim = NIM.getInstance({
|
|
54
|
+
appkey: "e0fc60d858fb19925dcef8bc82ce66af",
|
|
55
|
+
account: uuid + '',
|
|
56
|
+
token: videoToken,
|
|
57
|
+
lbsUrls: [
|
|
58
|
+
"https://lbs.netease.im/lbs/wxwebconf.jsp"
|
|
59
|
+
],
|
|
60
|
+
linkUrl: "wlnimsc0.netease.im",
|
|
61
|
+
});
|
|
62
|
+
this.nim.on('logined', () => {
|
|
63
|
+
// hhDoctor.addLog('1','网易云信IM 连接成功')
|
|
64
|
+
console.log("网易云信IM 连接成功");
|
|
65
|
+
});
|
|
66
|
+
this.nim.on('disconnect', () => {
|
|
67
|
+
// hhDoctor.addLog('1','网易云信IM 断开连接')
|
|
68
|
+
console.log("网易云信消息断开连接");
|
|
69
|
+
})
|
|
70
|
+
this.nim.on('sysMsg', (msg) => {
|
|
71
|
+
console.log("收到网易云信消息", msg);
|
|
72
|
+
// hhDoctor.addLog('1',`收到网易云信消息${ msg }`)
|
|
73
|
+
this.onImMessage(msg)
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
this.nim.connect();
|
|
77
|
+
},
|
|
78
|
+
// 释放 IM 资源
|
|
79
|
+
destroyIM() {
|
|
80
|
+
if (this.nim) {
|
|
81
|
+
this.nim.destroy();
|
|
82
|
+
this.nim = null;
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
// 初始化录音管理器
|
|
87
|
+
initRecorderManager() {
|
|
88
|
+
this.recorderManager = wx.getRecorderManager();
|
|
89
|
+
this.recorderManager.onStart(() => {
|
|
90
|
+
console.log('录音开始');
|
|
91
|
+
// hhDoctor.addLog('1',`录音开始`)
|
|
92
|
+
// onStart异步触发 如果点一下按钮很快取消已经取消了 则取消录音
|
|
93
|
+
if( !this.isWSRecording ){
|
|
94
|
+
console.log( '快速点击语音取消,手动取消录音')
|
|
95
|
+
// hhDoctor.addLog('1',`快速点击语音取消,手动取消录音`)
|
|
96
|
+
this.recorderManager.stop();
|
|
97
|
+
if( this.sendTimer ){
|
|
98
|
+
clearInterval( this.sendTimer )
|
|
99
|
+
}
|
|
100
|
+
}else{
|
|
101
|
+
// 是否发送end消息
|
|
102
|
+
this.isSendEnd = false;
|
|
103
|
+
if( this.sendTimer ){
|
|
104
|
+
console.log('快速点击录音,还有正在执行的定时器,手动清除')
|
|
105
|
+
// hhDoctor.addLog('1',`快速点击录音,还有正在执行的定时器,手动清除`)
|
|
106
|
+
clearInterval( this.sendTimer )
|
|
107
|
+
}
|
|
108
|
+
// 定时器:每 40ms 发送一次音频数据
|
|
109
|
+
this.sendTimer = setInterval(() => {
|
|
110
|
+
this.processAudioBuffer()
|
|
111
|
+
}, 40);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
this.bufferPool = new Int16Array(0);
|
|
117
|
+
|
|
118
|
+
this.recorderManager.onFrameRecorded((res) => {
|
|
119
|
+
const pcmBuffer = new Int16Array(res.frameBuffer);
|
|
120
|
+
const combinedBuffer = new Int16Array(this.bufferPool.length + pcmBuffer.length);
|
|
121
|
+
combinedBuffer.set(this.bufferPool);
|
|
122
|
+
combinedBuffer.set(pcmBuffer, this.bufferPool.length);
|
|
123
|
+
this.bufferPool = combinedBuffer;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
this.recorderManager.onStop((res) => {
|
|
127
|
+
console.log('录音结束', this.bufferPool?.length);
|
|
128
|
+
// hhDoctor.addLog('1',`录音结束`)
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
// 点击加号
|
|
133
|
+
handleChangeAdd() {
|
|
134
|
+
this.setData({
|
|
135
|
+
showAddList: !this.data.showAddList
|
|
136
|
+
})
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
// 语音流式识别 初始化websocket
|
|
140
|
+
initWS() {
|
|
141
|
+
this.socketTask = wx.connectSocket({
|
|
142
|
+
url: api.getSoundWsUrl({
|
|
143
|
+
sessionId: this.data.sessionId
|
|
144
|
+
})
|
|
145
|
+
});
|
|
146
|
+
this.socketTask.onOpen(() => {
|
|
147
|
+
console.log("语音识别 WebSocket 已连接");
|
|
148
|
+
// hhDoctor.addLog('1',`语音识别 WebSocket 已连接`)
|
|
149
|
+
if( !this.isWSRecording ){
|
|
150
|
+
console.log( '连接ws成功后,停止了录音,手动关闭ws连接' );
|
|
151
|
+
// hhDoctor.addLog('1',`连接ws成功后,停止了录音,手动关闭ws连接`)
|
|
152
|
+
this.closeWS();
|
|
153
|
+
}
|
|
154
|
+
this.sentenceText = ''; //语音识别到的文字拼接使用
|
|
155
|
+
this.audioText = '' //语音识别到的文字拼接使用
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
this.socketTask.onMessage((res) => {
|
|
159
|
+
console.log("语音识别 收到服务器消息:", res);
|
|
160
|
+
// hhDoctor.addLog('1',`语音识别 收到服务器消息:${ res }`)
|
|
161
|
+
const data = JSON.parse(res.data);
|
|
162
|
+
|
|
163
|
+
const wssText = data?.sentence?.text;
|
|
164
|
+
if (wssText) {
|
|
165
|
+
this.sentenceText = wssText;
|
|
166
|
+
|
|
167
|
+
if (data?.sentence?.endTime) {
|
|
168
|
+
this.audioText += wssText;
|
|
169
|
+
this.sentenceText = '';
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 结束的直接发送
|
|
174
|
+
if( data?.serviceCode === 'SpeechRecognitionEnd' ){
|
|
175
|
+
this.sendWebsocketText();
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
this.socketTask.onError((err) => {
|
|
180
|
+
console.log("语音识别 WebSocket 错误:", err);
|
|
181
|
+
// hhDoctor.addLog('1',`语音识别 WebSocket 错误:${ err }`)
|
|
182
|
+
this.setData({
|
|
183
|
+
isRecording: false,
|
|
184
|
+
isCancel: false,
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
this.socketTask.onClose(() => {
|
|
189
|
+
if( this.sendTimer ){
|
|
190
|
+
clearInterval(this.sendTimer);
|
|
191
|
+
}
|
|
192
|
+
console.log("语音识别 WebSocket 关闭");
|
|
193
|
+
// hhDoctor.addLog('1',`语音识别 WebSocket 关闭`)
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
closeWS(){
|
|
198
|
+
console.log('发送关闭ws信息');
|
|
199
|
+
hhDoctor.addLog('1',`发送关闭ws信息`)
|
|
200
|
+
this.socketTask?.send({
|
|
201
|
+
data:JSON.stringify({
|
|
202
|
+
"serviceCode": "SpeechRecognitionEnd",
|
|
203
|
+
"requestId": new Date().getTime() + ''
|
|
204
|
+
})
|
|
205
|
+
});
|
|
206
|
+
this.socketTask?.close();
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
// 处理音频数据,保证每次 40ms 的片段后再发送
|
|
210
|
+
processAudioBuffer() {
|
|
211
|
+
if (!this.socketTask || this.socketTask.readyState !== 1) {
|
|
212
|
+
console.log("WebSocket 未连接");
|
|
213
|
+
// hhDoctor.addLog('1',`WebSocket 未连接`)
|
|
214
|
+
if (!this.isWSRecording) {
|
|
215
|
+
// 已经录音结束断了连接的清空
|
|
216
|
+
console.log('websocket 断开连接 剩余还未发送的字节数:', this.bufferPool ? this.bufferPool.length : 0, '定时器ID', this.sendTimer)
|
|
217
|
+
this.bufferPool = new Int16Array(0);
|
|
218
|
+
this.sendWebsocketText();
|
|
219
|
+
clearInterval(this.sendTimer);
|
|
220
|
+
}
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (this.bufferPool && this.bufferPool.length >= TARGET_SAMPLES) {
|
|
224
|
+
this.sendAudioFrame(this.bufferPool.slice(0, TARGET_SAMPLES)); // 发送 640 个样本(40ms)
|
|
225
|
+
this.bufferPool = this.bufferPool.slice(TARGET_SAMPLES); // 剩余部分存入 bufferPool 继续累计
|
|
226
|
+
return
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// 如果录音结束
|
|
230
|
+
if (this.isWSRecording === false) {
|
|
231
|
+
// 还有未发送的 直接发送
|
|
232
|
+
if (this.bufferPool && this.bufferPool.length > 0) {
|
|
233
|
+
this.sendAudioFrame(this.bufferPool);
|
|
234
|
+
this.bufferPool = new Int16Array(0);
|
|
235
|
+
|
|
236
|
+
return
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
console.log( '缓存的音频数据都发送完毕' );
|
|
240
|
+
// 发送end消息
|
|
241
|
+
if( !this.isSendEnd ){
|
|
242
|
+
this.isSendEnd = true;
|
|
243
|
+
console.log( '发送end消息' )
|
|
244
|
+
// hhDoctor.addLog('1',`缓存的音频数据都发送完毕,向ws发送end消息`)
|
|
245
|
+
this.socketTask?.send({
|
|
246
|
+
data:JSON.stringify({
|
|
247
|
+
"serviceCode": "SpeechRecognitionEnd",
|
|
248
|
+
"requestId": new Date().getTime() + ''
|
|
249
|
+
})
|
|
250
|
+
})
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
// 发送语音识别识别到的文字
|
|
256
|
+
sendWebsocketText(){
|
|
257
|
+
if (!this.data.isCancel) {
|
|
258
|
+
if (this.sentenceText || this.audioText) {
|
|
259
|
+
this.handleSend({
|
|
260
|
+
textContent: this.audioText + this.sentenceText
|
|
261
|
+
})
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
// 发送
|
|
267
|
+
handleSend(data) {
|
|
268
|
+
if (this.data.apiLoading) {
|
|
269
|
+
console.log('连续点击')
|
|
270
|
+
hhDoctor.addLog('1',`用户在AI回复中点击了发送`)
|
|
271
|
+
this.showAskingLoading();
|
|
272
|
+
return Promise.reject()
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
this.setData({
|
|
276
|
+
apiLoading: true,
|
|
277
|
+
isSend: true,
|
|
278
|
+
})
|
|
279
|
+
return Promise.resolve().then(() => {
|
|
280
|
+
if (!data.textContent && !data?.fileObjList?.length) {
|
|
281
|
+
wx.showToast({
|
|
282
|
+
title: '请输入您的问题',
|
|
283
|
+
mask: true,
|
|
284
|
+
icon: 'none',
|
|
285
|
+
duration: 3000,
|
|
286
|
+
})
|
|
287
|
+
this.setData({
|
|
288
|
+
apiLoading: false
|
|
289
|
+
})
|
|
290
|
+
return 'no-text';
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// wx.showLoading({
|
|
294
|
+
// title:'小蓝思考中'
|
|
295
|
+
// })
|
|
296
|
+
api.userSend({
|
|
297
|
+
callType: CALLTYPE,
|
|
298
|
+
sessionId: this.data.sessionId,
|
|
299
|
+
}, data)
|
|
300
|
+
this.isScrollToFull = true;
|
|
301
|
+
})
|
|
302
|
+
},
|
|
303
|
+
|
|
304
|
+
// 语音识别相关事件
|
|
305
|
+
handleTouchStart(e) {
|
|
306
|
+
if (!this.data.hasRecordPermission) {
|
|
307
|
+
this.requestRecordPermission();
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (this.data.isAsking) {
|
|
312
|
+
this.showAskingLoading();
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
this.setData({
|
|
317
|
+
isRecording: true,
|
|
318
|
+
isCancel: false,
|
|
319
|
+
startY: e.touches[0].pageY // 记录开始按下的位置
|
|
320
|
+
});
|
|
321
|
+
wx.vibrateShort({
|
|
322
|
+
type: 'medium'
|
|
323
|
+
});
|
|
324
|
+
console.log("touch start");
|
|
325
|
+
this.touchStartTime = new Date().getTime();
|
|
326
|
+
// 录音中
|
|
327
|
+
this.isWSRecording = true;
|
|
328
|
+
// this.initWS();
|
|
329
|
+
|
|
330
|
+
// 初始化录音管理器并开始录音
|
|
331
|
+
this.initRecorderManager();
|
|
332
|
+
this.recorderManager?.start(options); // 开始录音
|
|
333
|
+
},
|
|
334
|
+
// 语音识别相关事件
|
|
335
|
+
handleTouchMove(e) {
|
|
336
|
+
const moveY = e.touches[0].pageY;
|
|
337
|
+
if (this.data.startY - moveY > 30) {
|
|
338
|
+
// 如果上划超过30像素,则取消发送
|
|
339
|
+
this.setData({
|
|
340
|
+
isCancel: true
|
|
341
|
+
});
|
|
342
|
+
} else {
|
|
343
|
+
this.setData({
|
|
344
|
+
isCancel: false
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
// 语音识别相关事件
|
|
349
|
+
handleTouchEnd() {
|
|
350
|
+
console.log('touch end' )
|
|
351
|
+
this.setData({
|
|
352
|
+
isRecording: false,
|
|
353
|
+
});
|
|
354
|
+
// 录音中
|
|
355
|
+
this.isWSRecording = false;
|
|
356
|
+
if( new Date().getTime() - this.touchStartTime < 200 ){
|
|
357
|
+
wx.showToast({
|
|
358
|
+
title: '录音时长过短',
|
|
359
|
+
icon:'none',
|
|
360
|
+
mask:true
|
|
361
|
+
})
|
|
362
|
+
}
|
|
363
|
+
if (this.data.isCancel) {
|
|
364
|
+
console.log('取消语音输入');
|
|
365
|
+
this.recorderManager?.stop();
|
|
366
|
+
this.closeWS();
|
|
367
|
+
} else {
|
|
368
|
+
this.recorderManager?.stop();
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
// 语音识别相关事件
|
|
372
|
+
handleTouchCancel() {
|
|
373
|
+
console.log('touch cancel')
|
|
374
|
+
this.setData({
|
|
375
|
+
isRecording: false,
|
|
376
|
+
isCancel: false
|
|
377
|
+
});
|
|
378
|
+
console.log("录音被取消");
|
|
379
|
+
this.closeWS();
|
|
380
|
+
this.recorderManager?.stop(); // 停止录音
|
|
381
|
+
},
|
|
382
|
+
|
|
383
|
+
// 检查录音权限
|
|
384
|
+
checkPermission() {
|
|
385
|
+
wx.getSetting({
|
|
386
|
+
success: (res) => {
|
|
387
|
+
this.setData({
|
|
388
|
+
hasRecordPermission: res.authSetting['scope.record'] ? true : false,
|
|
389
|
+
hasCameraPermission: res.authSetting['scope.camera'] ? true : false,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
},
|
|
394
|
+
|
|
395
|
+
// 请求录音权限
|
|
396
|
+
requestRecordPermission() {
|
|
397
|
+
console.log( this.data.hasRecordPermission,'this.data.hasRecordPermission' )
|
|
398
|
+
if (!this.data.hasRecordPermission) {
|
|
399
|
+
wx.authorize({
|
|
400
|
+
scope: 'scope.record',
|
|
401
|
+
success: () => {
|
|
402
|
+
this.setData({
|
|
403
|
+
hasRecordPermission: true
|
|
404
|
+
});
|
|
405
|
+
console.log('录音权限已授权');
|
|
406
|
+
},
|
|
407
|
+
fail: () => {
|
|
408
|
+
console.log('fali')
|
|
409
|
+
// 用户拒绝授权
|
|
410
|
+
wx.showModal({
|
|
411
|
+
title: '录音权限',
|
|
412
|
+
content: '需要录音权限,请在设置中开启',
|
|
413
|
+
showCancel: false,
|
|
414
|
+
success(res) {
|
|
415
|
+
if (res.confirm) {
|
|
416
|
+
wx.openSetting()
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
// 切换语音输入还是键盘输入
|
|
425
|
+
handleChangeToolType() {
|
|
426
|
+
// 切换到键盘自动聚焦
|
|
427
|
+
|
|
428
|
+
this.setData({
|
|
429
|
+
toolType: this.data.toolType == 'speak' ? 'keyboard' : 'speak'
|
|
430
|
+
},()=>{
|
|
431
|
+
if( this.data.toolType === 'keyboard' ){
|
|
432
|
+
this.setData({
|
|
433
|
+
textareaFocus:true
|
|
434
|
+
})
|
|
435
|
+
}
|
|
436
|
+
})
|
|
437
|
+
},
|
|
438
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"usingComponents": {
|
|
3
|
+
"ai-card-text": "./components/ai-card-text/ai-card-text",
|
|
4
|
+
"ai-card-image": "./components/ai-card-image/ai-card-image",
|
|
5
|
+
"ai-card-tip-text": "./components/ai-card-tip-text/ai-card-tip-text",
|
|
6
|
+
"ai-card-consultation-create": "./components/ai-card-consultation-create/ai-card-consultation-create",
|
|
7
|
+
"ai-card-consultation-info": "./components/ai-card-consultation-info/ai-card-consultation-info"
|
|
8
|
+
},
|
|
9
|
+
"disableScroll": true
|
|
10
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<view class="body">
|
|
2
|
+
<view class="expert-info">
|
|
3
|
+
<image src="{{expert.photo}}" />
|
|
4
|
+
<view>{{expert.name}}</view>
|
|
5
|
+
<view class="expert-hospital">{{expert.hospital}}</view>
|
|
6
|
+
</view>
|
|
7
|
+
<div class="message-list">
|
|
8
|
+
<ai-card-text is-self="{{false}}" text="您好,我是缪中荣医生的会诊助理,为帮助专家准确了解您的情况,请先简要说明本次咨询目的和病情描述。" />
|
|
9
|
+
<ai-card-text is-self="{{true}}" text="王俊,男,53岁,选择视频问诊" />
|
|
10
|
+
<ai-card-image is-self="{{false}}" />
|
|
11
|
+
<ai-card-image is-self="{{true}}" />
|
|
12
|
+
<ai-card-tip-text />
|
|
13
|
+
<ai-card-consultation-create />
|
|
14
|
+
<ai-card-consultation-info type="{{0}}"/>
|
|
15
|
+
<ai-card-consultation-info type="{{1}}"/>
|
|
16
|
+
</div>
|
|
17
|
+
<view class="bottom-bar" id="bottom-menu">
|
|
18
|
+
<!-- 键盘输入 -->
|
|
19
|
+
<view wx:if="{{toolType == 'keyboard'}}" class="input-wrap">
|
|
20
|
+
<image class="input-wrap-voice-image" src="https://image.hh-medic.com/icon/pacs/button_voice.png" bindtap="handleChangeToolType" />
|
|
21
|
+
<textarea class="input" placeholder="请输入您的问题..." placeholder-style="color: #7B809E;" auto-height value="{{inputText}}" bindinput='changeInputText' cursor-spacing='80' bindconfirm="handleSendText" adjust-position='{{false}}' bindblur='bindBlurText' bindkeyboardheightchange='bindkeyboardheightchange' bindlinechange="handleLineChange" confirm-type="done" show-confirm-bar="{{false}}" focus="{{textareaFocus}}" />
|
|
22
|
+
<image class="input-wrap-send-image" src="https://image.hh-medic.com/icon/pacs/button_send_black.png" />
|
|
23
|
+
</view>
|
|
24
|
+
<!-- 语音输入 -->
|
|
25
|
+
<view wx:else>
|
|
26
|
+
<view hidden="{{ !isRecording }}" class="speak-tips {{ isCancel ? 'speak-tips-cancel' : ''}}">
|
|
27
|
+
<view>
|
|
28
|
+
松开发送 上滑取消
|
|
29
|
+
</view>
|
|
30
|
+
</view>
|
|
31
|
+
<view class="speak-container">
|
|
32
|
+
<image class="image-keyboard" src="https://imgs.hh-medic.com/union/ai/keyboard.png" mode="scaleToFill" bindtap="handleChangeToolType" />
|
|
33
|
+
<view class="speak {{ isRecording ? 'speak-recording' : ''}} {{ isRecording && isCancel ? 'speak-cancel' : ''}}" catchtouchstart="handleTouchStart" catchtouchmove="handleTouchMove" catchtouchend="handleTouchEnd" catchtouchcancel="handleTouchCancel">
|
|
34
|
+
<view hidden="{{ isRecording }}">
|
|
35
|
+
<view class="speak-text">
|
|
36
|
+
按住
|
|
37
|
+
<image src="https://imgs.hh-medic.com/union/ai/speak-ai.png" mode="scaleToFill" />
|
|
38
|
+
说话
|
|
39
|
+
</view>
|
|
40
|
+
</view>
|
|
41
|
+
<!-- 语音输入动画 -->
|
|
42
|
+
<view class="voicebars" hidden="{{ !isRecording }}">
|
|
43
|
+
<view wx:for="{{ waveArr }}" wx:for-item="bar" wx:key="index"></view>
|
|
44
|
+
</view>
|
|
45
|
+
</view>
|
|
46
|
+
</view>
|
|
47
|
+
</view>
|
|
48
|
+
<view class="tools-wrap">
|
|
49
|
+
<view class="tools">
|
|
50
|
+
<view class="tools-item">
|
|
51
|
+
<image wx:if="{{!isAsking}}" src="https://image.hh-medic.com/icon/pacs/button_camera.png" mode="scaleToFill" bindtap="handleChooseMedia" data-camera-type="camera" />
|
|
52
|
+
拍照
|
|
53
|
+
</view>
|
|
54
|
+
<view class="tools-item">
|
|
55
|
+
<image wx:if="{{!isAsking}}" src="https://image.hh-medic.com/icon/pacs/button_album.png" mode="scaleToFill" bindtap="handleChooseMedia" data-camera-type="camera" />
|
|
56
|
+
相册
|
|
57
|
+
</view>
|
|
58
|
+
<view class="tools-item">
|
|
59
|
+
<image wx:if="{{!isAsking}}" src="https://image.hh-medic.com/icon/pacs/button_file.png" mode="scaleToFill" bindtap="handleChooseMedia" data-camera-type="camera" />
|
|
60
|
+
文件
|
|
61
|
+
</view>
|
|
62
|
+
</view>
|
|
63
|
+
</view>
|
|
64
|
+
</view>
|
|
65
|
+
</view>
|