hh-doctor-sdk 0.8.2 → 0.8.6

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.
@@ -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
- var params = Object.assign({}, params || {})
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
- wx.createSelectorQuery().select('#scroll-body').boundingClientRect(res => {
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
@@ -6,6 +6,9 @@ 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')
11
+ const appConfig = require('../../public/app-config')
9
12
  const { urlEndsWith } = require('../../utils/common-utils')
10
13
 
11
14
  Page({
@@ -15,12 +18,15 @@ Page({
15
18
  /**
16
19
  * 页面的初始数据
17
20
  */
18
- data: {},
21
+ data: {
22
+ sdkVersion: appConfig.sdkVersion,
23
+ },
19
24
 
20
25
  /**
21
26
  * 生命周期函数--监听页面加载
22
27
  */
23
28
  onLoad(options) {
29
+ this._detailAlive = true
24
30
  wx.statLog.sendStatLog(options.orderId, '打开咨询单详情界面')
25
31
  const doctorId = options.doctorId
26
32
  doctorLoader.loadDoctor({
@@ -29,6 +35,7 @@ Page({
29
35
  }, (res) => {
30
36
  if (res) {
31
37
  this.datePickerTime()
38
+ this._ensureIm()
32
39
  }
33
40
  })
34
41
  const orderId = options.orderId
@@ -42,9 +49,11 @@ Page({
42
49
  }, 1000);
43
50
  return
44
51
  }
52
+ this._orderId = String(orderId).trim()
45
53
  this.setData({
46
54
  orderId: orderId,
47
55
  })
56
+ this._bindDoctorReply()
48
57
  },
49
58
 
50
59
  /**
@@ -58,6 +67,7 @@ Page({
58
67
  * 生命周期函数--监听页面显示
59
68
  */
60
69
  onShow() {
70
+ this._ensureIm()
61
71
  if (this.data.showPreview) {
62
72
  this.setData({
63
73
  showPreview: false,
@@ -79,7 +89,9 @@ Page({
79
89
  * 生命周期函数--监听页面卸载
80
90
  */
81
91
  onUnload() {
82
-
92
+ this._detailAlive = false
93
+ this._unbindDoctorReply()
94
+ this._releaseIm()
83
95
  },
84
96
 
85
97
  /**
@@ -111,6 +123,76 @@ Page({
111
123
  this.loadOrderInfo()
112
124
  },
113
125
 
126
+ _ensureIm() {
127
+ // 复用全局 IM 连接,详情页只订阅刷新事件
128
+ if (!this._detailAlive) {
129
+ return
130
+ }
131
+ if (!wx.hhImManager || !cache.uuid() || !cache.videoToken()) {
132
+ return
133
+ }
134
+ if (!this._imRetained) {
135
+ this._imRetained = true
136
+ wx.hhImManager.init()
137
+ return
138
+ }
139
+ wx.hhImManager.ensureLogin()
140
+ },
141
+
142
+ _releaseIm() {
143
+ if (!this._imRetained || !wx.hhImManager) {
144
+ return
145
+ }
146
+ this._imRetained = false
147
+ wx.hhImManager.destroy()
148
+ },
149
+
150
+ _bindDoctorReply() {
151
+ if (!wx.eventBus || this.doctorReplyEventKey) {
152
+ return
153
+ }
154
+ this.doctorReplyEventKey = wx.eventBus.newKey()
155
+ wx.eventBus.on({
156
+ key: this.doctorReplyEventKey,
157
+ event: imManager.EventNames.DoctorReply,
158
+ listener: (params) => {
159
+ this._onDoctorReply(params)
160
+ }
161
+ })
162
+ },
163
+
164
+ _unbindDoctorReply() {
165
+ if (!this.doctorReplyEventKey || !wx.eventBus) {
166
+ return
167
+ }
168
+ wx.eventBus.off({
169
+ key: this.doctorReplyEventKey
170
+ })
171
+ this.doctorReplyEventKey = null
172
+ },
173
+
174
+ _sameOrder(orderId) {
175
+ const current = String(this._orderId || this.data.orderId || '').trim()
176
+ const detailOrderId = this.data.order && this.data.order.orderid
177
+ const detail = detailOrderId ? String(detailOrderId).trim() : ''
178
+ return orderId === current || (!!detail && orderId === detail)
179
+ },
180
+
181
+ _onDoctorReply(params) {
182
+ const orderId = params && params.orderId
183
+ if (!orderId || !this._sameOrder(orderId)) {
184
+ return
185
+ }
186
+ const now = Date.now()
187
+ if (this._replyNotifyAt && now - this._replyNotifyAt < 50) {
188
+ return
189
+ }
190
+ this._replyNotifyAt = now
191
+ wx.statLog.sendStatLog(orderId, '收到医助回复通知,刷新信息流')
192
+ this._stopPlayAudio(true)
193
+ this.refreshOrderFeed()
194
+ },
195
+
114
196
  _tapLink(event) {
115
197
  const url = event.currentTarget.dataset.link
116
198
  // hhNavigation.webPage(url)
@@ -127,6 +209,7 @@ Page({
127
209
  return
128
210
  }
129
211
  const player = wx.createInnerAudioContext()
212
+ player.obeyMuteSwitch = false
130
213
  player.src = playerUrl
131
214
  player.play()
132
215
  player.onEnded(() => {
@@ -1,5 +1,6 @@
1
1
  <import src="../detail/widget/chat-cell-template/chat-cell-template" />
2
- <view class="match-parent body-display">
2
+ <view class="sdk-version-mark">hh-doctor-sdk {{sdkVersion}}(IM 刷新版)</view>
3
+ <view class="match-parent body-display sdk-detail-body">
3
4
  <view
4
5
  id="scroll-body"
5
6
  class="body-display"
@@ -42,7 +43,7 @@
42
43
  </view>
43
44
  </view>
44
45
  <view class="chatting-body" wx:if="{{messages && messages.length > 0}}">
45
- <block wx:for="{{messages}}" wx:key="message">
46
+ <block wx:for="{{messages}}" wx:key="viewKey">
46
47
  <block wx:if="{{item.custom}}">
47
48
  <template is="{{item.template}}" data="{{...item}}" />
48
49
  </block>
@@ -6,6 +6,27 @@ page {
6
6
  height: 100%;
7
7
  }
8
8
 
9
+ .sdk-version-mark {
10
+ position: fixed;
11
+ top: 0;
12
+ left: 0;
13
+ right: 0;
14
+ z-index: 9999;
15
+ background-color: #ff4d4f;
16
+ color: #ffffff;
17
+ font-size: 28rpx;
18
+ font-weight: bold;
19
+ text-align: center;
20
+ line-height: 1.4;
21
+ padding: 16rpx 24rpx;
22
+ padding-top: calc(16rpx + env(safe-area-inset-top));
23
+ box-shadow: 0 4rpx 12rpx rgba(255, 77, 79, 0.45);
24
+ }
25
+
26
+ .sdk-detail-body {
27
+ padding-top: calc(72rpx + env(safe-area-inset-top));
28
+ }
29
+
9
30
  .body-display {
10
31
  position: absolute;
11
32
  width: 100%;
@@ -110,6 +110,7 @@ Page({
110
110
  return
111
111
  }
112
112
  const player = wx.createInnerAudioContext()
113
+ player.obeyMuteSwitch = false
113
114
  player.src = playerUrl
114
115
  player.play()
115
116
  player.onEnded(() => {
@@ -1,3 +1,5 @@
1
+ const sdkVersion = require('./sdk-version')
2
+
1
3
  const appVersion = '7.1.6'
2
4
  const appID = '10423'
3
5
  const appKey = ''
@@ -6,6 +8,7 @@ const sessionId = '1776843236242882600'
6
8
  const sessionIdProd = '1792831747042312418'
7
9
 
8
10
  module.exports = {
11
+ sdkVersion,
9
12
  appVersion,
10
13
  appID,
11
14
  appKey,
@@ -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
  })
@@ -8,7 +8,7 @@ function cache(data) {
8
8
  // const uuid = data.doctor.uuid
9
9
  // wx.hhImManager.loginIm(uuid, token)
10
10
  // }
11
- const newData = Object.assign(doctorOptions, data)
11
+ const newData = { ...doctorOptions, ...data }
12
12
  wx.doctorOptions = newData
13
13
  }
14
14
 
@@ -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 === TencentCloudChat.TYPES.MSG_CUSTOM) {
19
- try {
20
- const data = JSON.parse(message.payload.data)
21
- if (onMessage(data)) {
22
- return
23
- }
24
- wx.eventBus.post({
25
- params: data,
26
- event: EventNames.IMCustomMessage
27
- })
28
- } catch (ex) {
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
- chat.login({
85
- userID: userID.toString(),
86
- userSig
87
- }).then((res) => {
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 (chat) {
119
- // console.error('销毁腾讯IM实例')
120
- chat.destroy()
121
- chat = null
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
  }
@@ -0,0 +1,2 @@
1
+ /** 发版 npm 时与 package.json version 保持一致(会打进 miniprogram 包) */
2
+ module.exports = '0.8.6'
@@ -1,6 +1,6 @@
1
1
  function cacheUser(data) {
2
2
  const userInfo = wx.cacheUserInfo || {}
3
- const newData = Object.assign(userInfo, data)
3
+ const newData = { ...userInfo, ...data }
4
4
  wx.cacheUserInfo = newData
5
5
  }
6
6
 
@@ -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 = Object.assign(this.data.mainRemotePlayer, options)
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] = Object.assign(item, options)
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) ? Object.assign(this.data._rtcConfig, {
71
+ const config = /^\d+$/.test(roomID) ? {
72
+ ...this.data._rtcConfig,
72
73
  roomID
73
- }) : Object.assign(this.data._rtcConfig, {
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 = Object.assign(this.data._rtcConfig, {
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.destroy()
72
+ if (this._imRetained && wx.hhImManager) {
73
+ this._imRetained = false
74
+ wx.hhImManager.destroy()
75
+ }
72
76
  },
73
77
 
74
78
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hh-doctor-sdk",
3
- "version": "0.8.2",
3
+ "version": "0.8.6",
4
4
  "description": "和缓名医小程序SDK",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"