hh-doctor-sdk 0.8.0 → 0.8.4
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/components/apis/order-app-api.js +1 -3
- package/components/consultation/detail/behaviors/consultation-behaviors.js +23 -0
- package/components/consultation/detail/behaviors/consultation-chat-behaviors.js +21 -6
- package/components/consultation/detail/behaviors/consultation-header-media-behaviors.js +5 -3
- package/components/consultation/detail/consultation-detail-page.js +81 -1
- package/components/consultation/detail/consultation-detail-page.wxml +1 -1
- package/components/consultation/detail/widget/case-image-filter.js +1 -4
- package/components/consultation/reply/consultation-reply-page.js +1 -0
- package/components/public/behaviors/order-base-behaviors.js +18 -2
- package/components/public/cache-data.js +1 -1
- package/components/public/im-manager.js +175 -28
- package/components/public/pdf-viewer.js +9 -4
- package/components/public/user-cache-data.js +1 -1
- package/components/utils/httpUtils.js +4 -0
- package/components/video-chat/agora-rtc/agora-rtc.js +2 -2
- package/components/video-chat/video-chat.js +8 -5
- package/components/video-chat-page/behaviors/chat-sound-behaviors.js +2 -0
- package/components/video-chat-page/video-chat-page.js +5 -1
- package/package.json +1 -1
|
@@ -3,8 +3,6 @@ const httpUtils = require('../utils/httpUtils');
|
|
|
3
3
|
const dateFormat = require('../utils/dateUtils')
|
|
4
4
|
const hostDefine = require('./api-host-define')
|
|
5
5
|
const menuBuilder = require('../consultation/detail/widget/chat-bottom/chat-menu-builder');
|
|
6
|
-
const cacheData = require('../public/cache-data');
|
|
7
|
-
|
|
8
6
|
const apiPaths = {
|
|
9
7
|
login: {
|
|
10
8
|
hostType: hostDefine.hostTypes.order,
|
|
@@ -157,7 +155,7 @@ function getAgoraToken(orderId) {
|
|
|
157
155
|
}
|
|
158
156
|
|
|
159
157
|
function requestReply(type, params, body) {
|
|
160
|
-
|
|
158
|
+
params = { ...params }
|
|
161
159
|
var requestPath = apiPaths.needMoreByExpert
|
|
162
160
|
// refuse: 1,
|
|
163
161
|
// discuss: 2,
|
|
@@ -48,6 +48,29 @@ module.exports = Behavior({
|
|
|
48
48
|
})
|
|
49
49
|
},
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* 重拉当前订单并重绘信息流、顶部病历和底部按钮。
|
|
53
|
+
* 不先清空列表,避免信息流先消失再出现。
|
|
54
|
+
*/
|
|
55
|
+
refreshOrderFeed() {
|
|
56
|
+
const orderId = this.data.orderId
|
|
57
|
+
if (!orderId) {
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
this.loadOrder(() => {
|
|
61
|
+
if (!this._detailAlive || this.data.orderId !== orderId) {
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
this.buildOrderInfo()
|
|
65
|
+
const bottom = this.selectComponent('#chat-bottom')
|
|
66
|
+
if (bottom) {
|
|
67
|
+
bottom.initMenuData()
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
keepPage: true
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
|
|
51
74
|
isRequest() {
|
|
52
75
|
return cache.doctorId() == this.data.order.doctorid
|
|
53
76
|
},
|
|
@@ -84,20 +84,34 @@ module.exports = Behavior({
|
|
|
84
84
|
isRequest: isRequest,
|
|
85
85
|
}, () => {
|
|
86
86
|
setTimeout(() => {
|
|
87
|
-
|
|
88
|
-
wx.pageScrollTo({
|
|
89
|
-
scrollTop: res.bottom,
|
|
90
|
-
duration: 200
|
|
91
|
-
})
|
|
92
|
-
}).exec()
|
|
87
|
+
this.scrollMessagesToBottom()
|
|
93
88
|
}, 500);
|
|
94
89
|
})
|
|
95
90
|
}
|
|
96
91
|
},
|
|
97
92
|
|
|
93
|
+
scrollMessagesToBottom() {
|
|
94
|
+
const query = this.createSelectorQuery()
|
|
95
|
+
query.select('#message-bottom').boundingClientRect()
|
|
96
|
+
query.selectViewport().scrollOffset()
|
|
97
|
+
query.exec((res) => {
|
|
98
|
+
const anchor = res && res[0]
|
|
99
|
+
const viewport = res && res[1]
|
|
100
|
+
if (!anchor || !viewport) {
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
// bottom 相对当前屏幕,加上已滚动距离才是页面底部
|
|
104
|
+
wx.pageScrollTo({
|
|
105
|
+
scrollTop: anchor.bottom + viewport.scrollTop,
|
|
106
|
+
duration: 200
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
},
|
|
110
|
+
|
|
98
111
|
createLocalCustomItem(index, type, template) {
|
|
99
112
|
var message = {}
|
|
100
113
|
message.index = index
|
|
114
|
+
message.viewKey = `local-${index}`
|
|
101
115
|
message.type = type
|
|
102
116
|
message.template = template
|
|
103
117
|
message.custom = true
|
|
@@ -114,6 +128,7 @@ module.exports = Behavior({
|
|
|
114
128
|
const comments = data.comments
|
|
115
129
|
message.index = index
|
|
116
130
|
message.id = data.id
|
|
131
|
+
message.viewKey = data.id ? String(data.id) : `ask-${index}`
|
|
117
132
|
message.name = data.doctor.name
|
|
118
133
|
message.isRequest = isRequest
|
|
119
134
|
message.isSend = isSend
|
|
@@ -108,11 +108,13 @@ module.exports = Behavior({
|
|
|
108
108
|
},
|
|
109
109
|
|
|
110
110
|
pdfData(url) {
|
|
111
|
-
|
|
111
|
+
// 展示用文件名去掉 query,下载地址保留签名参数
|
|
112
|
+
let path = url || ''
|
|
113
|
+
const index = path.indexOf('?')
|
|
112
114
|
if (index >= 0) {
|
|
113
|
-
|
|
115
|
+
path = path.substring(0, index)
|
|
114
116
|
}
|
|
115
|
-
const name =
|
|
117
|
+
const name = path.substring(path.lastIndexOf('/') + 1)
|
|
116
118
|
return {
|
|
117
119
|
url: url,
|
|
118
120
|
name: name
|
|
@@ -6,6 +6,8 @@ var audioAnimationInterval
|
|
|
6
6
|
const hhNavigation = require('../../hh-navigation')
|
|
7
7
|
const doctorLoader = require('../../public/doctor-loader')
|
|
8
8
|
const permission = require('../../utils/permission-utils')
|
|
9
|
+
const imManager = require('../../public/im-manager')
|
|
10
|
+
const cache = require('../../public/cache-data')
|
|
9
11
|
const { urlEndsWith } = require('../../utils/common-utils')
|
|
10
12
|
|
|
11
13
|
Page({
|
|
@@ -21,6 +23,7 @@ Page({
|
|
|
21
23
|
* 生命周期函数--监听页面加载
|
|
22
24
|
*/
|
|
23
25
|
onLoad(options) {
|
|
26
|
+
this._detailAlive = true
|
|
24
27
|
wx.statLog.sendStatLog(options.orderId, '打开咨询单详情界面')
|
|
25
28
|
const doctorId = options.doctorId
|
|
26
29
|
doctorLoader.loadDoctor({
|
|
@@ -29,6 +32,7 @@ Page({
|
|
|
29
32
|
}, (res) => {
|
|
30
33
|
if (res) {
|
|
31
34
|
this.datePickerTime()
|
|
35
|
+
this._ensureIm()
|
|
32
36
|
}
|
|
33
37
|
})
|
|
34
38
|
const orderId = options.orderId
|
|
@@ -42,9 +46,11 @@ Page({
|
|
|
42
46
|
}, 1000);
|
|
43
47
|
return
|
|
44
48
|
}
|
|
49
|
+
this._orderId = String(orderId).trim()
|
|
45
50
|
this.setData({
|
|
46
51
|
orderId: orderId,
|
|
47
52
|
})
|
|
53
|
+
this._bindDoctorReply()
|
|
48
54
|
},
|
|
49
55
|
|
|
50
56
|
/**
|
|
@@ -58,6 +64,7 @@ Page({
|
|
|
58
64
|
* 生命周期函数--监听页面显示
|
|
59
65
|
*/
|
|
60
66
|
onShow() {
|
|
67
|
+
this._ensureIm()
|
|
61
68
|
if (this.data.showPreview) {
|
|
62
69
|
this.setData({
|
|
63
70
|
showPreview: false,
|
|
@@ -79,7 +86,9 @@ Page({
|
|
|
79
86
|
* 生命周期函数--监听页面卸载
|
|
80
87
|
*/
|
|
81
88
|
onUnload() {
|
|
82
|
-
|
|
89
|
+
this._detailAlive = false
|
|
90
|
+
this._unbindDoctorReply()
|
|
91
|
+
this._releaseIm()
|
|
83
92
|
},
|
|
84
93
|
|
|
85
94
|
/**
|
|
@@ -111,6 +120,76 @@ Page({
|
|
|
111
120
|
this.loadOrderInfo()
|
|
112
121
|
},
|
|
113
122
|
|
|
123
|
+
_ensureIm() {
|
|
124
|
+
// 复用全局 IM 连接,详情页只订阅刷新事件
|
|
125
|
+
if (!this._detailAlive) {
|
|
126
|
+
return
|
|
127
|
+
}
|
|
128
|
+
if (!wx.hhImManager || !cache.uuid() || !cache.videoToken()) {
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
if (!this._imRetained) {
|
|
132
|
+
this._imRetained = true
|
|
133
|
+
wx.hhImManager.init()
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
wx.hhImManager.ensureLogin()
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
_releaseIm() {
|
|
140
|
+
if (!this._imRetained || !wx.hhImManager) {
|
|
141
|
+
return
|
|
142
|
+
}
|
|
143
|
+
this._imRetained = false
|
|
144
|
+
wx.hhImManager.destroy()
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
_bindDoctorReply() {
|
|
148
|
+
if (!wx.eventBus || this.doctorReplyEventKey) {
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
this.doctorReplyEventKey = wx.eventBus.newKey()
|
|
152
|
+
wx.eventBus.on({
|
|
153
|
+
key: this.doctorReplyEventKey,
|
|
154
|
+
event: imManager.EventNames.DoctorReply,
|
|
155
|
+
listener: (params) => {
|
|
156
|
+
this._onDoctorReply(params)
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
_unbindDoctorReply() {
|
|
162
|
+
if (!this.doctorReplyEventKey || !wx.eventBus) {
|
|
163
|
+
return
|
|
164
|
+
}
|
|
165
|
+
wx.eventBus.off({
|
|
166
|
+
key: this.doctorReplyEventKey
|
|
167
|
+
})
|
|
168
|
+
this.doctorReplyEventKey = null
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
_sameOrder(orderId) {
|
|
172
|
+
const current = String(this._orderId || this.data.orderId || '').trim()
|
|
173
|
+
const detailOrderId = this.data.order && this.data.order.orderid
|
|
174
|
+
const detail = detailOrderId ? String(detailOrderId).trim() : ''
|
|
175
|
+
return orderId === current || (!!detail && orderId === detail)
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
_onDoctorReply(params) {
|
|
179
|
+
const orderId = params && params.orderId
|
|
180
|
+
if (!orderId || !this._sameOrder(orderId)) {
|
|
181
|
+
return
|
|
182
|
+
}
|
|
183
|
+
const now = Date.now()
|
|
184
|
+
if (this._replyNotifyAt && now - this._replyNotifyAt < 50) {
|
|
185
|
+
return
|
|
186
|
+
}
|
|
187
|
+
this._replyNotifyAt = now
|
|
188
|
+
wx.statLog.sendStatLog(orderId, '收到医助回复通知,刷新信息流')
|
|
189
|
+
this._stopPlayAudio(true)
|
|
190
|
+
this.refreshOrderFeed()
|
|
191
|
+
},
|
|
192
|
+
|
|
114
193
|
_tapLink(event) {
|
|
115
194
|
const url = event.currentTarget.dataset.link
|
|
116
195
|
// hhNavigation.webPage(url)
|
|
@@ -127,6 +206,7 @@ Page({
|
|
|
127
206
|
return
|
|
128
207
|
}
|
|
129
208
|
const player = wx.createInnerAudioContext()
|
|
209
|
+
player.obeyMuteSwitch = false
|
|
130
210
|
player.src = playerUrl
|
|
131
211
|
player.play()
|
|
132
212
|
player.onEnded(() => {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
</view>
|
|
43
43
|
</view>
|
|
44
44
|
<view class="chatting-body" wx:if="{{messages && messages.length > 0}}">
|
|
45
|
-
<block wx:for="{{messages}}" wx:key="
|
|
45
|
+
<block wx:for="{{messages}}" wx:key="viewKey">
|
|
46
46
|
<block wx:if="{{item.custom}}">
|
|
47
47
|
<template is="{{item.template}}" data="{{...item}}" />
|
|
48
48
|
</block>
|
|
@@ -16,16 +16,23 @@ module.exports = Behavior({
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* 进入视频界面先加载订单
|
|
19
|
-
* @param callback 回调
|
|
19
|
+
* @param callback 回调
|
|
20
|
+
* @param options keepPage 为 true 时失败只留日志,不提示也不退出页面
|
|
20
21
|
*/
|
|
21
|
-
loadOrder(callback) {
|
|
22
|
+
loadOrder(callback, options) {
|
|
22
23
|
// wx.showLoading({
|
|
23
24
|
// title: '加载订单数据...',
|
|
24
25
|
// mask: true,
|
|
25
26
|
// })
|
|
27
|
+
const requestToken = (this._orderLoadToken || 0) + 1
|
|
28
|
+
this._orderLoadToken = requestToken
|
|
26
29
|
const orderId = this.data.orderId
|
|
30
|
+
const isLatest = () => this._orderLoadToken === requestToken && this._detailAlive !== false
|
|
27
31
|
wx.statLog.sendStatLog(orderId, '开始获取订单详情数据')
|
|
28
32
|
api.getOrderDetail(orderId).then((res) => {
|
|
33
|
+
if (!isLatest()) {
|
|
34
|
+
return
|
|
35
|
+
}
|
|
29
36
|
wx.statLog.sendStatLog(orderId, '获取订单详情数据完成')
|
|
30
37
|
// wx.hideLoading()
|
|
31
38
|
const order = res.data.order
|
|
@@ -41,13 +48,22 @@ module.exports = Behavior({
|
|
|
41
48
|
feedbackStar: feedbackStar,
|
|
42
49
|
notifySetVideoTime: notifySetVideoTime,
|
|
43
50
|
}, () => {
|
|
51
|
+
if (!isLatest()) {
|
|
52
|
+
return
|
|
53
|
+
}
|
|
44
54
|
if (callback) {
|
|
45
55
|
callback()
|
|
46
56
|
}
|
|
47
57
|
})
|
|
48
58
|
}).catch((e) => {
|
|
59
|
+
if (!isLatest()) {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
49
62
|
wx.statLog.sendStatLog(orderId, `获取订单数据出错${JSON.stringify(e)}`)
|
|
50
63
|
wx.hideLoading()
|
|
64
|
+
if (options && options.keepPage) {
|
|
65
|
+
return
|
|
66
|
+
}
|
|
51
67
|
wx.showToast({
|
|
52
68
|
title: '加载订单出错',
|
|
53
69
|
})
|
|
@@ -4,33 +4,161 @@ const TencentCloudChat = require('../static/tim-wx')
|
|
|
4
4
|
const EventNames = {
|
|
5
5
|
IMLogin: 'IMLogin',
|
|
6
6
|
IMLogout: 'IMLogout',
|
|
7
|
-
IMCustomMessage: 'IMCustomMessage'
|
|
7
|
+
IMCustomMessage: 'IMCustomMessage',
|
|
8
|
+
DoctorReply: 'DoctorReply'
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
const hhNavigation = require('../hh-navigation')
|
|
11
12
|
const cache = require('../public/cache-data')
|
|
12
13
|
|
|
13
14
|
var chat
|
|
15
|
+
var retainCount = 0
|
|
14
16
|
|
|
15
17
|
let onMessageReceived = function (event) {
|
|
16
|
-
const messageList = event.data
|
|
18
|
+
const messageList = event.data || []
|
|
17
19
|
messageList.forEach((message) => {
|
|
18
|
-
if (message.type
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
if (message.type !== TencentCloudChat.TYPES.MSG_CUSTOM) {
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
const data = parseCustomData(message)
|
|
24
|
+
if (!data) {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
// 回复通知不是通话信令,迟到也不丢,处理完直接返回
|
|
28
|
+
const replyOrderId = readDoctorReplyOrderId(data)
|
|
29
|
+
if (replyOrderId !== null) {
|
|
30
|
+
handleDoctorReply(message, replyOrderId)
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
if (onMessage(data)) {
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
wx.eventBus.post({
|
|
37
|
+
params: data,
|
|
38
|
+
event: EventNames.IMCustomMessage
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
}
|
|
29
42
|
|
|
30
|
-
|
|
43
|
+
function parseCustomData(message) {
|
|
44
|
+
const payload = message && message.payload
|
|
45
|
+
const fields = [
|
|
46
|
+
payload && payload.data,
|
|
47
|
+
payload && payload.description,
|
|
48
|
+
payload && payload.extension,
|
|
49
|
+
message && message.cloudCustomData
|
|
50
|
+
]
|
|
51
|
+
let fallback = null
|
|
52
|
+
for (let i = 0; i < fields.length; i++) {
|
|
53
|
+
const data = parseJsonValue(fields[i])
|
|
54
|
+
if (!data || typeof data !== 'object' || Array.isArray(data)) {
|
|
55
|
+
continue
|
|
31
56
|
}
|
|
32
|
-
|
|
33
|
-
|
|
57
|
+
if (data.command === 'doctorReply') {
|
|
58
|
+
return data
|
|
59
|
+
}
|
|
60
|
+
if (!fallback) {
|
|
61
|
+
fallback = data
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return fallback
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function parseJsonValue(raw) {
|
|
68
|
+
if (!raw) {
|
|
69
|
+
return null
|
|
70
|
+
}
|
|
71
|
+
if (typeof raw === 'object') {
|
|
72
|
+
return raw
|
|
73
|
+
}
|
|
74
|
+
const text = String(raw).replace(/^\uFEFF/, '').trim()
|
|
75
|
+
if (!text) {
|
|
76
|
+
return null
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
const data = JSON.parse(text)
|
|
80
|
+
if (typeof data === 'string') {
|
|
81
|
+
return parseJsonValue(data)
|
|
82
|
+
}
|
|
83
|
+
return data
|
|
84
|
+
} catch (ex) {
|
|
85
|
+
const start = text.indexOf('{')
|
|
86
|
+
const end = text.lastIndexOf('}')
|
|
87
|
+
if (start < 0 || end <= start) {
|
|
88
|
+
return null
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
return JSON.parse(text.slice(start, end + 1))
|
|
92
|
+
} catch (e) {
|
|
93
|
+
return null
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 医助回复刷新通知。不是该指令时返回 null;没有订单号时返回空串。
|
|
100
|
+
* 空串也表示这条消息已消费,不能再交给通话信令。
|
|
101
|
+
*/
|
|
102
|
+
function readDoctorReplyOrderId(data) {
|
|
103
|
+
if (!data || data.command !== 'doctorReply') {
|
|
104
|
+
return null
|
|
105
|
+
}
|
|
106
|
+
if (data.orderId === null || data.orderId === undefined) {
|
|
107
|
+
return ''
|
|
108
|
+
}
|
|
109
|
+
return String(data.orderId).trim()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function handleDoctorReply(message, orderId) {
|
|
113
|
+
try {
|
|
114
|
+
markC2CMessageRead(message)
|
|
115
|
+
} catch (ex) {}
|
|
116
|
+
notifyDoctorReply(orderId)
|
|
117
|
+
try {
|
|
118
|
+
wx.statLog.sendStatLog(orderId || null, '收到订单回复刷新通知')
|
|
119
|
+
} catch (ex) {}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function notifyDoctorReply(orderId) {
|
|
123
|
+
const params = {
|
|
124
|
+
orderId: orderId
|
|
125
|
+
}
|
|
126
|
+
if (typeof getCurrentPages === 'function') {
|
|
127
|
+
const pages = getCurrentPages() || []
|
|
128
|
+
pages.forEach((page) => {
|
|
129
|
+
if (page && typeof page._onDoctorReply === 'function') {
|
|
130
|
+
page._onDoctorReply(params)
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
if (!wx.eventBus) {
|
|
135
|
+
return
|
|
136
|
+
}
|
|
137
|
+
wx.eventBus.post({
|
|
138
|
+
params: params,
|
|
139
|
+
event: EventNames.DoctorReply
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function markC2CMessageRead(message) {
|
|
144
|
+
if (!chat || !message || typeof chat.setMessageRead !== 'function') {
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
const conversationID = message.conversationID
|
|
148
|
+
const c2c = TencentCloudChat.TYPES.CONV_C2C
|
|
149
|
+
if (!conversationID) {
|
|
150
|
+
return
|
|
151
|
+
}
|
|
152
|
+
const isC2C = message.conversationType === c2c || conversationID.indexOf(c2c) === 0
|
|
153
|
+
if (!isC2C) {
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
chat.setMessageRead({
|
|
157
|
+
conversationID: conversationID
|
|
158
|
+
}).catch(() => {
|
|
159
|
+
wx.statLog.sendStatLog(null, '订单回复通知标已读失败')
|
|
160
|
+
})
|
|
161
|
+
}
|
|
34
162
|
|
|
35
163
|
function onMessage(message) {
|
|
36
164
|
const command = message.command
|
|
@@ -52,6 +180,7 @@ let onSdkNotReady = function (event) {
|
|
|
52
180
|
};
|
|
53
181
|
|
|
54
182
|
function init() {
|
|
183
|
+
retainCount++
|
|
55
184
|
if (chat != null) {
|
|
56
185
|
return
|
|
57
186
|
}
|
|
@@ -77,14 +206,26 @@ function init() {
|
|
|
77
206
|
* @param {*} userID 用户UserID
|
|
78
207
|
* @param {*} userSig 用户UserSign
|
|
79
208
|
*/
|
|
209
|
+
function ensureLogin() {
|
|
210
|
+
if (!chat || (chat.isLoggedIn && chat.isLoggedIn())) {
|
|
211
|
+
return
|
|
212
|
+
}
|
|
213
|
+
loginIm(cache.uuid(), cache.videoToken())
|
|
214
|
+
}
|
|
215
|
+
|
|
80
216
|
function loginIm(userID, userSig) {
|
|
81
|
-
wx.statLog.sendStatLog(null, '开始登录腾讯IM')
|
|
82
217
|
// console.error('开始登录腾讯IM')
|
|
83
|
-
if (chat) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
218
|
+
if (!chat || userID === null || userID === undefined || userID === '' || !userSig) {
|
|
219
|
+
return
|
|
220
|
+
}
|
|
221
|
+
if (chat.isLoggedIn && chat.isLoggedIn()) {
|
|
222
|
+
return
|
|
223
|
+
}
|
|
224
|
+
wx.statLog.sendStatLog(null, '开始登录腾讯IM')
|
|
225
|
+
chat.login({
|
|
226
|
+
userID: String(userID),
|
|
227
|
+
userSig
|
|
228
|
+
}).then((res) => {
|
|
88
229
|
wx.eventBus.post({
|
|
89
230
|
params: {
|
|
90
231
|
result: true
|
|
@@ -105,7 +246,6 @@ function loginIm(userID, userSig) {
|
|
|
105
246
|
event: EventNames.IMLogin
|
|
106
247
|
})
|
|
107
248
|
})
|
|
108
|
-
}
|
|
109
249
|
}
|
|
110
250
|
|
|
111
251
|
function logoutIm() {
|
|
@@ -115,17 +255,24 @@ function logoutIm() {
|
|
|
115
255
|
}
|
|
116
256
|
|
|
117
257
|
function destroy() {
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
258
|
+
if (retainCount === 0) {
|
|
259
|
+
return
|
|
260
|
+
}
|
|
261
|
+
retainCount--
|
|
262
|
+
// 详情页和通话页共用连接,还有页面持有时不销毁
|
|
263
|
+
if (retainCount > 0 || !chat) {
|
|
264
|
+
return
|
|
122
265
|
}
|
|
266
|
+
chat.destroy()
|
|
267
|
+
chat = null
|
|
123
268
|
}
|
|
124
269
|
|
|
125
270
|
module.exports = {
|
|
126
271
|
EventNames: EventNames,
|
|
127
272
|
init: init,
|
|
128
273
|
loginIm: loginIm,
|
|
274
|
+
ensureLogin: ensureLogin,
|
|
129
275
|
logoutIm: logoutIm,
|
|
130
|
-
destroy: destroy
|
|
276
|
+
destroy: destroy,
|
|
277
|
+
readDoctorReplyOrderId: readDoctorReplyOrderId
|
|
131
278
|
}
|
|
@@ -7,10 +7,15 @@ function viewPdfs(files) {
|
|
|
7
7
|
this.viewPdf(files[0].url)
|
|
8
8
|
} else {
|
|
9
9
|
const items = files.map((file) => {
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
let path = file.url || ''
|
|
11
|
+
const q = path.indexOf('?')
|
|
12
|
+
if (q >= 0) {
|
|
13
|
+
path = path.substring(0, q)
|
|
14
|
+
}
|
|
15
|
+
const last = path.lastIndexOf('/')
|
|
16
|
+
const fullFileName = path.substring(last + 1)
|
|
17
|
+
const dot = fullFileName.lastIndexOf('.')
|
|
18
|
+
return dot >= 0 ? fullFileName.substring(0, dot) : fullFileName
|
|
14
19
|
})
|
|
15
20
|
wx.showActionSheet({
|
|
16
21
|
itemList: items,
|
|
@@ -31,6 +31,7 @@ function _request(request, method, params, data) {
|
|
|
31
31
|
let url = `${host}${request.path}`
|
|
32
32
|
const doctorId = cache.doctorId()
|
|
33
33
|
const uuid = cache.uuid()
|
|
34
|
+
const userToken = cache.userToken()
|
|
34
35
|
|
|
35
36
|
let fullParams = { ...params || {}}
|
|
36
37
|
fullParams.sdkProductId = appConfig.appID
|
|
@@ -45,6 +46,9 @@ function _request(request, method, params, data) {
|
|
|
45
46
|
if (uuid) {
|
|
46
47
|
fullParams.uuid = uuid
|
|
47
48
|
}
|
|
49
|
+
if (userToken) {
|
|
50
|
+
fullParams.userToken = userToken
|
|
51
|
+
}
|
|
48
52
|
// 安全获取环境配置
|
|
49
53
|
let profileName = 'prod'
|
|
50
54
|
try {
|
|
@@ -455,7 +455,7 @@ Component({
|
|
|
455
455
|
*/
|
|
456
456
|
updateMedia(uid, options) {
|
|
457
457
|
if (this.data.mainRemotePlayer && `${this.data.mainRemotePlayer.uid}` === `${uid}`) {
|
|
458
|
-
let item =
|
|
458
|
+
let item = { ...this.data.mainRemotePlayer, ...options }
|
|
459
459
|
this.setData({
|
|
460
460
|
mainRemotePlayer: item
|
|
461
461
|
})
|
|
@@ -464,7 +464,7 @@ Component({
|
|
|
464
464
|
for (let i = 0; i < media.length; i++) {
|
|
465
465
|
let item = media[i];
|
|
466
466
|
if (`${item.uid}` === `${uid}`) {
|
|
467
|
-
media[i] =
|
|
467
|
+
media[i] = { ...item, ...options }
|
|
468
468
|
break
|
|
469
469
|
}
|
|
470
470
|
}
|
|
@@ -68,11 +68,13 @@ Component({
|
|
|
68
68
|
enterRoom(roomID) {
|
|
69
69
|
let strRoomID = '' + roomID
|
|
70
70
|
// 这里兼容房间号为字符串(整体单号)的情况
|
|
71
|
-
const config = /^\d+$/.test(roomID) ?
|
|
71
|
+
const config = /^\d+$/.test(roomID) ? {
|
|
72
|
+
...this.data._rtcConfig,
|
|
72
73
|
roomID
|
|
73
|
-
}
|
|
74
|
+
} : {
|
|
75
|
+
...this.data._rtcConfig,
|
|
74
76
|
strRoomID
|
|
75
|
-
}
|
|
77
|
+
}
|
|
76
78
|
this.setData({
|
|
77
79
|
pusher: this.TRTC.enterRoom(config),
|
|
78
80
|
}, () => {
|
|
@@ -99,12 +101,13 @@ Component({
|
|
|
99
101
|
beautyLevel: 0,
|
|
100
102
|
}
|
|
101
103
|
const pusher = this.TRTC.createPusher(pushConfig)
|
|
102
|
-
const newConfig =
|
|
104
|
+
const newConfig = {
|
|
105
|
+
...this.data._rtcConfig,
|
|
103
106
|
userID: cache.uuid(),
|
|
104
107
|
userSig: cache.videoToken(),
|
|
105
108
|
enableCamera: true,
|
|
106
109
|
enableMic: true,
|
|
107
|
-
}
|
|
110
|
+
}
|
|
108
111
|
this.setData({
|
|
109
112
|
_rtcConfig: newConfig,
|
|
110
113
|
pusher: pusher.pusherAttributes
|
|
@@ -28,6 +28,7 @@ module.exports = Behavior({
|
|
|
28
28
|
this.stopCallRing()
|
|
29
29
|
|
|
30
30
|
const audioContext = wx.createInnerAudioContext()
|
|
31
|
+
audioContext.obeyMuteSwitch = false
|
|
31
32
|
audioContext.src = this.data.calling.url
|
|
32
33
|
audioContext.loop = true
|
|
33
34
|
this.setData({
|
|
@@ -70,6 +71,7 @@ module.exports = Behavior({
|
|
|
70
71
|
const audioContext = wx.createInnerAudioContext({
|
|
71
72
|
useWebAudioImplement: false
|
|
72
73
|
})
|
|
74
|
+
audioContext.obeyMuteSwitch = false
|
|
73
75
|
audioContext.src = this.data.hangup.url
|
|
74
76
|
audioContext.loop = false
|
|
75
77
|
audioContext.play()
|
|
@@ -32,6 +32,7 @@ Page({
|
|
|
32
32
|
if (!this.checkParams(options)) {
|
|
33
33
|
return
|
|
34
34
|
}
|
|
35
|
+
this._imRetained = true
|
|
35
36
|
wx.hhImManager.init()
|
|
36
37
|
this._sendLog('打开呼叫界面')
|
|
37
38
|
wx.statLog.sendStatLog(this.data.orderId, '打开呼叫界面')
|
|
@@ -68,7 +69,10 @@ Page({
|
|
|
68
69
|
// 兜底:任何路径关闭页面都确保铃声停止,避免残留
|
|
69
70
|
this.stopCallRing()
|
|
70
71
|
this.unBindIMMessageEvent()
|
|
71
|
-
wx.hhImManager
|
|
72
|
+
if (this._imRetained && wx.hhImManager) {
|
|
73
|
+
this._imRetained = false
|
|
74
|
+
wx.hhImManager.destroy()
|
|
75
|
+
}
|
|
72
76
|
},
|
|
73
77
|
|
|
74
78
|
/**
|