hh-doctor-sdk 0.7.4 → 0.7.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.
@@ -47,12 +47,13 @@ async function isDoctorAuth(doctorId) {
47
47
  if (res && res.data) {
48
48
  console.log(JSON.stringify(res.data.loginInfo));
49
49
  const loginInfo = res.data.loginInfo;
50
- return loginInfo && loginInfo.iscardcheck;
50
+ return loginInfo && loginInfo.iscardcheck === 1;
51
51
  // const isAuthHH = doctorInfo.authhh === 1;
52
52
  // return isAuthHH;
53
53
  // const haveLicense = (doctorInfo.superLicenseUrl && doctorInfo.superLicenseUrl.length > 0) || (doctorInfo.superLicense1Url && doctorInfo.superLicense1Url.length > 0);
54
54
  // return isAuthHH && haveLicense;
55
55
  }
56
+
56
57
  return false;
57
58
  } catch {
58
59
  return false;
@@ -27,7 +27,7 @@
27
27
  <view class="item-button" bindtap="_clickViewCase">
28
28
  <image
29
29
  class="item-button-img"
30
- src="http://image.hh-medic.com/icon/pacs/hh_chat_bingli.png"
30
+ src="https://image.hh-medic.com/icon/pacs/hh_chat_bingli.png"
31
31
  mode=""
32
32
  />
33
33
  <view class="control-button-text">病历资料</view>
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * 视频铃声
3
3
  */
4
+
5
+ // 真机上 InnerAudioContext 创建后立即 play 偶发不生效,
6
+ // 改为立即播放并在未开始时有限次重试,成功后即停止重试
7
+ const RING_MAX_RETRY = 5
8
+ const RING_RETRY_INTERVAL = 200
9
+
4
10
  module.exports = Behavior({
5
11
  data: {
6
12
  calling: {
@@ -18,27 +24,39 @@ module.exports = Behavior({
18
24
  * 播放呼叫铃声
19
25
  */
20
26
  playCallRing() {
21
- var audioContext = this.data.callingAudioContext
22
- if (!audioContext) audioContext = wx.createInnerAudioContext();
27
+ // 重新发起呼叫,先清理上一次的实例与重试
28
+ this.stopCallRing()
29
+
30
+ const audioContext = wx.createInnerAudioContext()
31
+ audioContext.src = this.data.calling.url
32
+ audioContext.loop = true
23
33
  this.setData({
24
34
  callingAudioContext: audioContext,
25
35
  })
26
- audioContext.stop()
27
- audioContext.src = this.data.calling.url
28
- audioContext.loop = true
29
- setTimeout(() => {
36
+
37
+ // 一旦真正开始播放,立即停止重试
38
+ audioContext.onPlay(() => this._clearRingPlayTimer())
39
+
40
+ let retry = 0
41
+ const tryPlay = () => {
42
+ // 实例已被 stopCallRing 销毁则终止,避免野实例继续播放
43
+ if (this.data.callingAudioContext !== audioContext) return
30
44
  audioContext.play()
31
- }, 300);
45
+ this._ringPlayTimer = setTimeout(() => {
46
+ if (retry++ < RING_MAX_RETRY) tryPlay()
47
+ }, RING_RETRY_INTERVAL)
48
+ }
49
+ tryPlay()
32
50
  },
33
51
  /**
34
52
  * 停止播放呼叫铃声
35
53
  */
36
54
  stopCallRing() {
37
- var audioContext = this.data.callingAudioContext
55
+ this._clearRingPlayTimer()
56
+ const audioContext = this.data.callingAudioContext
38
57
  if (audioContext) {
39
- audioContext.stop();
40
- audioContext.destroy();
41
- audioContext = null
58
+ audioContext.stop()
59
+ audioContext.destroy()
42
60
  this.setData({
43
61
  callingAudioContext: null,
44
62
  })
@@ -49,12 +67,21 @@ module.exports = Behavior({
49
67
  */
50
68
  playHangup() {
51
69
  this.stopCallRing()
52
- let audioContext = wx.createInnerAudioContext({
70
+ const audioContext = wx.createInnerAudioContext({
53
71
  useWebAudioImplement: false
54
72
  })
55
73
  audioContext.src = this.data.hangup.url
56
74
  audioContext.loop = false
57
75
  audioContext.play()
58
76
  },
77
+ /**
78
+ * 清除待执行的重试定时器
79
+ */
80
+ _clearRingPlayTimer() {
81
+ if (this._ringPlayTimer) {
82
+ clearTimeout(this._ringPlayTimer)
83
+ this._ringPlayTimer = null
84
+ }
85
+ },
59
86
  }
60
- })
87
+ })
@@ -65,6 +65,8 @@ Page({
65
65
  * 生命周期函数--监听页面卸载
66
66
  */
67
67
  onUnload() {
68
+ // 兜底:任何路径关闭页面都确保铃声停止,避免残留
69
+ this.stopCallRing()
68
70
  this.unBindIMMessageEvent()
69
71
  wx.hhImManager.destroy()
70
72
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hh-doctor-sdk",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "description": "和缓名医小程序SDK",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"