hh-doctor-sdk 0.0.1
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/api-host-define.js +69 -0
- package/components/apis/consultation-reply-api.js +21 -0
- package/components/apis/dicom-api.js +31 -0
- package/components/apis/family-api.js +20 -0
- package/components/apis/file-upload-api.js +35 -0
- package/components/apis/order-app-api.js +206 -0
- package/components/apis/stat-log-api.js +42 -0
- package/components/apis/video-chat-log-api.js +47 -0
- package/components/apis/video-message-api.js +88 -0
- package/components/consultation/detail/behaviors/chat-cell-base-behaviors.js +29 -0
- package/components/consultation/detail/behaviors/consultation-behaviors.js +60 -0
- package/components/consultation/detail/behaviors/consultation-chat-behaviors.js +321 -0
- package/components/consultation/detail/behaviors/consultation-header-media-behaviors.js +176 -0
- package/components/consultation/detail/behaviors/consultation-header-text-behaviors.js +325 -0
- package/components/consultation/detail/behaviors/consultation-reply-behaviors.js +67 -0
- package/components/consultation/detail/consultation-detail-page.js +219 -0
- package/components/consultation/detail/consultation-detail-page.json +10 -0
- package/components/consultation/detail/consultation-detail-page.wxml +65 -0
- package/components/consultation/detail/consultation-detail-page.wxss +51 -0
- package/components/consultation/detail/widget/case-image-filter.js +47 -0
- package/components/consultation/detail/widget/chat-base-cell/chat-base-cell.js +31 -0
- package/components/consultation/detail/widget/chat-base-cell/chat-base-cell.json +4 -0
- package/components/consultation/detail/widget/chat-base-cell/chat-base-cell.wxml +17 -0
- package/components/consultation/detail/widget/chat-base-cell/chat-base-cell.wxss +9 -0
- package/components/consultation/detail/widget/chat-bottom/chat-bottom.js +100 -0
- package/components/consultation/detail/widget/chat-bottom/chat-bottom.json +4 -0
- package/components/consultation/detail/widget/chat-bottom/chat-bottom.wxml +24 -0
- package/components/consultation/detail/widget/chat-bottom/chat-bottom.wxss +54 -0
- package/components/consultation/detail/widget/chat-bottom/chat-menu-builder.js +131 -0
- package/components/consultation/detail/widget/chat-cell-template/chat-cell-template.wxml +173 -0
- package/components/consultation/detail/widget/chat-cell.wxss +394 -0
- package/components/consultation/detail/widget/detail-media/detail-media.js +47 -0
- package/components/consultation/detail/widget/detail-media/detail-media.json +4 -0
- package/components/consultation/detail/widget/detail-media/detail-media.wxml +12 -0
- package/components/consultation/detail/widget/detail-media/detail-media.wxss +57 -0
- package/components/consultation/detail/widget/detail-text/detail-text.js +31 -0
- package/components/consultation/detail/widget/detail-text/detail-text.json +4 -0
- package/components/consultation/detail/widget/detail-text/detail-text.wxml +6 -0
- package/components/consultation/detail/widget/detail-text/detail-text.wxss +14 -0
- package/components/consultation/evaluate/evaluate-page.js +157 -0
- package/components/consultation/evaluate/evaluate-page.json +3 -0
- package/components/consultation/evaluate/evaluate-page.wxml +42 -0
- package/components/consultation/evaluate/evaluate-page.wxss +103 -0
- package/components/consultation/list/behaviors/consultation-list-base-behaviors.js +144 -0
- package/components/consultation/list/consultation-list-page.js +84 -0
- package/components/consultation/list/consultation-list-page.json +5 -0
- package/components/consultation/list/consultation-list-page.wxml +53 -0
- package/components/consultation/list/consultation-list-page.wxss +105 -0
- package/components/consultation/reply/behaviors/reply-base-behaviors.js +175 -0
- package/components/consultation/reply/consultation-reply-page.js +251 -0
- package/components/consultation/reply/consultation-reply-page.json +6 -0
- package/components/consultation/reply/consultation-reply-page.wxml +103 -0
- package/components/consultation/reply/consultation-reply-page.wxss +169 -0
- package/components/consultation/reply/widget/audio-record-view/audio-record-view.js +144 -0
- package/components/consultation/reply/widget/audio-record-view/audio-record-view.json +4 -0
- package/components/consultation/reply/widget/audio-record-view/audio-record-view.wxml +27 -0
- package/components/consultation/reply/widget/audio-record-view/audio-record-view.wxss +197 -0
- package/components/hh-doctor.js +36 -0
- package/components/hh-navigation.js +87 -0
- package/components/public/app-config.js +13 -0
- package/components/public/behaviors/order-base-behaviors.js +53 -0
- package/components/public/cache-data.js +134 -0
- package/components/public/doctor-loader.js +60 -0
- package/components/public/im-manager.js +135 -0
- package/components/public/pdf-viewer.js +59 -0
- package/components/public/stat-log.js +13 -0
- package/components/static/Agora_Miniapp_SDK_for_WeChat.js +2 -0
- package/components/static/trtc-wx.js +2 -0
- package/components/uikit/css/common.wxss +23 -0
- package/components/uikit/custom-bottom-pop/custom-bottom-pop.js +37 -0
- package/components/uikit/custom-bottom-pop/custom-bottom-pop.json +4 -0
- package/components/uikit/custom-bottom-pop/custom-bottom-pop.wxml +9 -0
- package/components/uikit/custom-bottom-pop/custom-bottom-pop.wxss +79 -0
- package/components/uikit/date-time-picker/date-time-picker.js +115 -0
- package/components/uikit/web-view-page/web-view-page.js +87 -0
- package/components/uikit/web-view-page/web-view-page.json +3 -0
- package/components/uikit/web-view-page/web-view-page.wxml +6 -0
- package/components/uikit/web-view-page/web-view-page.wxss +1 -0
- package/components/utils/checksumUtils.js +56 -0
- package/components/utils/common-utils.js +59 -0
- package/components/utils/dateUtils.js +142 -0
- package/components/utils/eventBus.js +77 -0
- package/components/utils/httpUtils.js +123 -0
- package/components/utils/number-utils.js +48 -0
- package/components/utils/permission-utils.js +164 -0
- package/components/video-chat/agora-rtc/agora-player/agora-player.js +106 -0
- package/components/video-chat/agora-rtc/agora-player/agora-player.json +4 -0
- package/components/video-chat/agora-rtc/agora-player/agora-player.wxml +24 -0
- package/components/video-chat/agora-rtc/agora-player/agora-player.wxss +1 -0
- package/components/video-chat/agora-rtc/agora-pusher/agora-pusher.js +92 -0
- package/components/video-chat/agora-rtc/agora-pusher/agora-pusher.json +4 -0
- package/components/video-chat/agora-rtc/agora-pusher/agora-pusher.wxml +22 -0
- package/components/video-chat/agora-rtc/agora-pusher/agora-pusher.wxss +1 -0
- package/components/video-chat/agora-rtc/agora-rtc.js +391 -0
- package/components/video-chat/agora-rtc/agora-rtc.json +7 -0
- package/components/video-chat/agora-rtc/agora-rtc.wxml +39 -0
- package/components/video-chat/agora-rtc/agora-rtc.wxss +1 -0
- package/components/video-chat/callback/callback.js +39 -0
- package/components/video-chat/callback/callback.json +4 -0
- package/components/video-chat/callback/callback.wxml +29 -0
- package/components/video-chat/callback/callback.wxss +26 -0
- package/components/video-chat/calling/calling.js +75 -0
- package/components/video-chat/calling/calling.json +4 -0
- package/components/video-chat/calling/calling.wxml +32 -0
- package/components/video-chat/calling/calling.wxss +45 -0
- package/components/video-chat/controller/controller.js +86 -0
- package/components/video-chat/controller/controller.json +4 -0
- package/components/video-chat/controller/controller.wxml +73 -0
- package/components/video-chat/controller/controller.wxss +71 -0
- package/components/video-chat/remote-player/remote-player.js +42 -0
- package/components/video-chat/remote-player/remote-player.json +4 -0
- package/components/video-chat/remote-player/remote-player.wxml +37 -0
- package/components/video-chat/remote-player/remote-player.wxss +1 -0
- package/components/video-chat/video-chat.js +297 -0
- package/components/video-chat/video-chat.json +7 -0
- package/components/video-chat/video-chat.wxml +56 -0
- package/components/video-chat/video-chat.wxss +97 -0
- package/components/video-chat-page/behaviors/chat-files-behaviors.js +243 -0
- package/components/video-chat-page/behaviors/chat-log-behaviors.js +90 -0
- package/components/video-chat-page/behaviors/chat-sound-behaviors.js +60 -0
- package/components/video-chat-page/behaviors/video-chat-behaviors.js +524 -0
- package/components/video-chat-page/case-group-view/case-group-view.js +38 -0
- package/components/video-chat-page/case-group-view/case-group-view.json +4 -0
- package/components/video-chat-page/case-group-view/case-group-view.wxml +32 -0
- package/components/video-chat-page/case-group-view/case-group-view.wxss +44 -0
- package/components/video-chat-page/video-chat-defines.js +39 -0
- package/components/video-chat-page/video-chat-page.js +212 -0
- package/components/video-chat-page/video-chat-page.json +14 -0
- package/components/video-chat-page/video-chat-page.wxml +88 -0
- package/components/video-chat-page/video-chat-page.wxss +45 -0
- package/package.json +18 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// components/video-chat/controller/controller.js
|
|
2
|
+
|
|
3
|
+
var numberForamt = require('../../utils/number-utils')
|
|
4
|
+
|
|
5
|
+
Component({
|
|
6
|
+
properties: {
|
|
7
|
+
startChatTime: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
value: false
|
|
10
|
+
},
|
|
11
|
+
newCases: {
|
|
12
|
+
type: Boolean,
|
|
13
|
+
value: false
|
|
14
|
+
},
|
|
15
|
+
isInVoice: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
value: false,
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
data: {
|
|
22
|
+
chatTime: 0,
|
|
23
|
+
chatTimeText: '',
|
|
24
|
+
timer: null,
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
observers: {
|
|
28
|
+
'chatTime': function () {
|
|
29
|
+
let time = this.data.chatTime
|
|
30
|
+
this.setData({
|
|
31
|
+
chatTimeText: numberForamt.formatSecond(time)
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
lifetimes: {
|
|
37
|
+
ready: function () {
|
|
38
|
+
if (this.data.timer) {
|
|
39
|
+
clearInterval(this.data.timer)
|
|
40
|
+
this.setData({
|
|
41
|
+
timer: null
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
if (this.properties.startChatTime) {
|
|
45
|
+
this.setData({
|
|
46
|
+
timer: setInterval(() => {
|
|
47
|
+
this.setData({
|
|
48
|
+
chatTime: this.data.chatTime + 1
|
|
49
|
+
})
|
|
50
|
+
}, 1000)
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
detached: function () {
|
|
55
|
+
if (this.data.timer) {
|
|
56
|
+
clearInterval(this.data.timer)
|
|
57
|
+
this.setData({
|
|
58
|
+
timer: null
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
methods: {
|
|
65
|
+
/**
|
|
66
|
+
* 挂断被点击
|
|
67
|
+
*/
|
|
68
|
+
_hangupClick() {
|
|
69
|
+
this.triggerEvent("hangup")
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 点击切换语音或视频
|
|
74
|
+
*/
|
|
75
|
+
_changeVoice() {
|
|
76
|
+
this.triggerEvent("changeVoice")
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 查看病历资料
|
|
81
|
+
*/
|
|
82
|
+
_clickViewCase() {
|
|
83
|
+
this.triggerEvent("clickViewCase")
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
})
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<view class="bottom-3 bottom">
|
|
2
|
+
<view wx:if="{{newCases}}" class="new-files-tip">
|
|
3
|
+
患者上传了新的病历资料,
|
|
4
|
+
<view class="underline" bindtap="_clickViewCase"> 点击查看 </view>
|
|
5
|
+
</view>
|
|
6
|
+
<view wx:if="{{startChatTime}}" class="chat-time">{{chatTimeText}}</view>
|
|
7
|
+
<view class="bottom-3-container">
|
|
8
|
+
<view class="'bottom-3-content'">
|
|
9
|
+
<view class="item-button" bindtap="_changeVoice">
|
|
10
|
+
<image
|
|
11
|
+
class="item-button-img"
|
|
12
|
+
src="https://image.hh-medic.com/icon/pacs/hh_change_voice.png"
|
|
13
|
+
mode=""
|
|
14
|
+
/>
|
|
15
|
+
<view class="control-button-text"
|
|
16
|
+
>{{isInVoice ? '切换视频' : '切换语音'}}</view
|
|
17
|
+
>
|
|
18
|
+
</view>
|
|
19
|
+
<view class="item-button" bindtap="_hangupClick">
|
|
20
|
+
<image
|
|
21
|
+
class="item-button-img"
|
|
22
|
+
src="https://image.hh-medic.com/icon/pacs/hh_hangup.png"
|
|
23
|
+
mode=""
|
|
24
|
+
/>
|
|
25
|
+
<view class="control-button-text">挂断</view>
|
|
26
|
+
</view>
|
|
27
|
+
<view class="item-button" bindtap="_clickViewCase">
|
|
28
|
+
<image
|
|
29
|
+
class="item-button-img"
|
|
30
|
+
src="http://image.hh-medic.com/icon/pacs/hh_chat_bingli.png"
|
|
31
|
+
mode=""
|
|
32
|
+
/>
|
|
33
|
+
<view class="control-button-text">病历资料</view>
|
|
34
|
+
<view wx:if="{{newCases}}" class="new-tip">NEW</view>
|
|
35
|
+
</view>
|
|
36
|
+
<!-- <view class="item-button" bindtap="_checkCaseClick">
|
|
37
|
+
<image
|
|
38
|
+
class="item-button-img"
|
|
39
|
+
src="https://image.hh-medic.com/icon/pacs/hh_patient_info.png"
|
|
40
|
+
mode=""
|
|
41
|
+
/>
|
|
42
|
+
<view>病历资料</view>
|
|
43
|
+
</view>
|
|
44
|
+
|
|
45
|
+
<view class="item-button" bindtap="_checkPdfClick">
|
|
46
|
+
<image
|
|
47
|
+
class="item-button-img"
|
|
48
|
+
src="https://image.hh-medic.com/icon/pacs/hh_pdf.png"
|
|
49
|
+
mode=""
|
|
50
|
+
/>
|
|
51
|
+
<view>PDF报告</view>
|
|
52
|
+
</view>
|
|
53
|
+
|
|
54
|
+
<view class="item-button" bindtap="_checkDicomClick">
|
|
55
|
+
<image
|
|
56
|
+
class="item-button-img"
|
|
57
|
+
src="https://image.hh-medic.com/icon/pacs/hh_dicom.png"
|
|
58
|
+
mode=""
|
|
59
|
+
/>
|
|
60
|
+
<view>DICOM</view>
|
|
61
|
+
</view>
|
|
62
|
+
|
|
63
|
+
<view class="item-button" bindtap="_changeCameraClick">
|
|
64
|
+
<image
|
|
65
|
+
class="item-button-img"
|
|
66
|
+
src="https://image.hh-medic.com/icon/pacs/hh_change_camera.png"
|
|
67
|
+
mode=""
|
|
68
|
+
/>
|
|
69
|
+
<view>翻转</view>
|
|
70
|
+
</view> -->
|
|
71
|
+
</view>
|
|
72
|
+
</view>
|
|
73
|
+
</view>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* components/video-chat/controller/controller.wxss */
|
|
2
|
+
@import "../video-chat.wxss";
|
|
3
|
+
|
|
4
|
+
.bottom-3 {
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
align-items: center;
|
|
7
|
+
width: 100%;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.bottom-3-container {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: row;
|
|
13
|
+
width: 100%;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
background-color: transparent;
|
|
16
|
+
padding-bottom: 30rpx;
|
|
17
|
+
border-radius: 20rpx 20rpx 0 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.bottom-3-content {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: row;
|
|
23
|
+
width: 100%;
|
|
24
|
+
height: 180rpx;
|
|
25
|
+
justify-content: space-around;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.chat-time {
|
|
29
|
+
color: white;
|
|
30
|
+
font-size: 30rpx;
|
|
31
|
+
display: flex;
|
|
32
|
+
align-content: center;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
margin-bottom: 20rpx;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.control-button-text {
|
|
38
|
+
font-size: 32rpx;
|
|
39
|
+
color: white;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.new-tip {
|
|
43
|
+
position: absolute;
|
|
44
|
+
height: 36rpx;
|
|
45
|
+
background-color: red;
|
|
46
|
+
font-size: 24rpx;
|
|
47
|
+
color: white;
|
|
48
|
+
right: -30rpx;
|
|
49
|
+
padding: 0 14rpx;
|
|
50
|
+
top: 0rpx;
|
|
51
|
+
text-align: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
line-height: 36rpx;
|
|
54
|
+
border-radius: 18rpx;
|
|
55
|
+
margin-bottom: 30rpx;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.new-files-tip {
|
|
59
|
+
display: flex;
|
|
60
|
+
flex-direction: row;
|
|
61
|
+
background-color: rgba(0, 0, 0, 0.6);
|
|
62
|
+
font-size: 32rpx;
|
|
63
|
+
color: white;
|
|
64
|
+
padding: 8rpx 20rpx;
|
|
65
|
+
border-radius: 12rpx;
|
|
66
|
+
margin-bottom: 30rpx;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.underline {
|
|
70
|
+
text-decoration: underline;
|
|
71
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// components/video-chat/small_remote_player/small_remote_player.js
|
|
2
|
+
Component({
|
|
3
|
+
/**
|
|
4
|
+
* 组件的属性列表
|
|
5
|
+
*/
|
|
6
|
+
properties: {
|
|
7
|
+
remoteUser: null,
|
|
8
|
+
showSmall: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
value: true
|
|
11
|
+
},
|
|
12
|
+
isInVoice: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
value: false,
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 组件的初始数据
|
|
20
|
+
*/
|
|
21
|
+
data: {
|
|
22
|
+
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 组件的方法列表
|
|
27
|
+
*/
|
|
28
|
+
methods: {
|
|
29
|
+
_playerStateChange(event) {
|
|
30
|
+
this.triggerEvent('playerStateChange', event)
|
|
31
|
+
},
|
|
32
|
+
_playerFullscreenChange(event) {
|
|
33
|
+
this.triggerEvent('playerFullscreenChange', event)
|
|
34
|
+
},
|
|
35
|
+
_playerNetStatus(event) {
|
|
36
|
+
this.triggerEvent('playerNetStatus', event)
|
|
37
|
+
},
|
|
38
|
+
_playerAudioVolumeNotify(event) {
|
|
39
|
+
this.triggerEvent('playerAudioVolumeNotify', event)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<view class="{{showSmall ? 'remote_small' : 'match-parent position-absolute'}}">
|
|
2
|
+
<live-player
|
|
3
|
+
wx:if="{{remoteUser}}"
|
|
4
|
+
id="{{remoteUser.streamID}}"
|
|
5
|
+
class="match-parent position-absolute"
|
|
6
|
+
data-userid="{{remoteUser.userID}}"
|
|
7
|
+
data-streamid="{{remoteUser.streamID}}"
|
|
8
|
+
data-streamtype="{{remoteUser.streamType}}"
|
|
9
|
+
src="{{remoteUser.src}}"
|
|
10
|
+
mode="{{remoteUser.mode}}"
|
|
11
|
+
autoplay="{{remoteUser.autoplay}}"
|
|
12
|
+
mute-audio="{{remoteUser.muteAudio}}"
|
|
13
|
+
mute-video="{{remoteUser.muteVideo}}"
|
|
14
|
+
orientation="{{remoteUser.orientation}}"
|
|
15
|
+
object-fit="{{remoteUser.objectFit}}"
|
|
16
|
+
background-mute="{{remoteUser.enableBackgroundMute}}"
|
|
17
|
+
min-cache="{{remoteUser.minCache}}"
|
|
18
|
+
max-cache="{{remoteUser.maxCache}}"
|
|
19
|
+
sound-mode="{{remoteUser.soundMode}}"
|
|
20
|
+
enable-recv-message="{{remoteUser.enableRecvMessage}}"
|
|
21
|
+
auto-pause-if-navigate="{{remoteUser.autoPauseIfNavigate}}"
|
|
22
|
+
auto-pause-if-open-native="{{remoteUser.autoPauseIfOpenNative}}"
|
|
23
|
+
bindstatechange="_playerStateChange"
|
|
24
|
+
bindfullscreenchange="_playerFullscreenChange"
|
|
25
|
+
bindnetstatus="_playerNetStatus"
|
|
26
|
+
bindaudiovolumenotify="_playerAudioVolumeNotify"
|
|
27
|
+
/>
|
|
28
|
+
<view
|
|
29
|
+
wx:if="{{isInVoice}}"
|
|
30
|
+
class="cover-view {{showSmall ? 'small' : 'big'}}"
|
|
31
|
+
>
|
|
32
|
+
<image
|
|
33
|
+
class="{{showSmall ? 'voice-mode-avatar-small' : 'voice-mode-avatar'}}"
|
|
34
|
+
src="https://image.hh-medic.com/icon/pacs/hh_sdk_audio_avatar.png"
|
|
35
|
+
/>
|
|
36
|
+
</view>
|
|
37
|
+
</view>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "../video-chat.wxss";
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
// pages/video-chat/video-chat.js
|
|
2
|
+
import TRTC from '../static/trtc-wx'
|
|
3
|
+
const logApi = require('../apis/video-chat-log-api')
|
|
4
|
+
const cache = require('../public/cache-data')
|
|
5
|
+
|
|
6
|
+
Component({
|
|
7
|
+
properties: {
|
|
8
|
+
callback: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
value: false
|
|
11
|
+
},
|
|
12
|
+
smallVideoTop: {
|
|
13
|
+
type: Number,
|
|
14
|
+
value: 0
|
|
15
|
+
},
|
|
16
|
+
expertAvatar: {
|
|
17
|
+
type: String,
|
|
18
|
+
value: null
|
|
19
|
+
},
|
|
20
|
+
isInVoice: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
value: false,
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 页面的初始数据
|
|
28
|
+
*/
|
|
29
|
+
data: {
|
|
30
|
+
_rtcConfig: {
|
|
31
|
+
sdkAppID: '1400073238', // 必要参数 开通实时音视频服务创建应用后分配的 sdkAppID
|
|
32
|
+
scene: 'scene',
|
|
33
|
+
userID: '', // 必要参数 用户 ID 可以由您的帐号系统指定
|
|
34
|
+
userSig: '', // 必要参数 身份签名,相当于登录密码的作用
|
|
35
|
+
enableMic: true, // 进房默认开启音频上行
|
|
36
|
+
enableCamera: true, // 进房默认开启视频上
|
|
37
|
+
},
|
|
38
|
+
pusher: null,
|
|
39
|
+
remotePlayerList: [],
|
|
40
|
+
mainRemotePlayer: null,
|
|
41
|
+
mainRemoteUser: null,
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
lifetimes: {
|
|
45
|
+
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
|
46
|
+
attached: function () {
|
|
47
|
+
// this.bindIMMessageEvent()
|
|
48
|
+
},
|
|
49
|
+
moved: function () {},
|
|
50
|
+
detached: function () {
|
|
51
|
+
// this.unBindIMMessageEvent()
|
|
52
|
+
},
|
|
53
|
+
ready: function () {
|
|
54
|
+
this.createTRTC()
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
methods: {
|
|
59
|
+
enterRoom(roomID) {
|
|
60
|
+
let strRoomID = '' + roomID
|
|
61
|
+
// 这里兼容房间号为字符串(整体单号)的情况
|
|
62
|
+
const config = /^\d+$/.test(roomID) ? Object.assign(this.data._rtcConfig, {
|
|
63
|
+
roomID
|
|
64
|
+
}) : Object.assign(this.data._rtcConfig, {
|
|
65
|
+
strRoomID
|
|
66
|
+
})
|
|
67
|
+
this.setData({
|
|
68
|
+
pusher: this.TRTC.enterRoom(config),
|
|
69
|
+
}, () => {
|
|
70
|
+
this.TRTC.getPusherInstance().start() //开始推流
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
// 退出房间
|
|
75
|
+
exitRoom() {
|
|
76
|
+
const result = this.TRTC.exitRoom()
|
|
77
|
+
let playerList = result.playerList
|
|
78
|
+
let mainRemotePlayer = playerList[0] == undefined ? null : playerList[0]
|
|
79
|
+
let remotePlayerList = playerList.slice(1, playerList.length)
|
|
80
|
+
this.setData({
|
|
81
|
+
pusher: result.pusher,
|
|
82
|
+
mainRemotePlayer: mainRemotePlayer,
|
|
83
|
+
remotePlayerList: remotePlayerList,
|
|
84
|
+
})
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
createTRTC() {
|
|
88
|
+
this.TRTC = new TRTC(this)
|
|
89
|
+
const pushConfig = {
|
|
90
|
+
beautyLevel: 0,
|
|
91
|
+
}
|
|
92
|
+
const pusher = this.TRTC.createPusher(pushConfig)
|
|
93
|
+
const newConfig = Object.assign(this.data._rtcConfig, {
|
|
94
|
+
userID: cache.uuid(),
|
|
95
|
+
userSig: cache.videoToken(),
|
|
96
|
+
enableCamera: true,
|
|
97
|
+
enableMic: true,
|
|
98
|
+
})
|
|
99
|
+
this.setData({
|
|
100
|
+
_rtcConfig: newConfig,
|
|
101
|
+
pusher: pusher.pusherAttributes
|
|
102
|
+
}, () => {
|
|
103
|
+
this.bindTRTCRoomEvent()
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
// 事件监听
|
|
108
|
+
bindTRTCRoomEvent() {
|
|
109
|
+
const TRTC_EVENT = this.TRTC.EVENT
|
|
110
|
+
// 初始化事件订阅
|
|
111
|
+
this.TRTC.on(TRTC_EVENT.LOCAL_JOIN, (event) => {
|
|
112
|
+
this.triggerEvent('sendLog', logApi.logTypes.connect)
|
|
113
|
+
if (!this.properties.callback) {
|
|
114
|
+
this.triggerEvent('sendCallMessage')
|
|
115
|
+
}
|
|
116
|
+
})
|
|
117
|
+
this.TRTC.on(TRTC_EVENT.LOCAL_LEAVE, (event) => {
|
|
118
|
+
this.triggerEvent("directHangup")
|
|
119
|
+
})
|
|
120
|
+
this.TRTC.on(TRTC_EVENT.ERROR, (event) => {
|
|
121
|
+
|
|
122
|
+
})
|
|
123
|
+
// 远端用户加入
|
|
124
|
+
this.TRTC.on(TRTC_EVENT.REMOTE_USER_JOIN, (event) => {
|
|
125
|
+
if (!this.properties.callback) {
|
|
126
|
+
const {
|
|
127
|
+
userID
|
|
128
|
+
} = event.data
|
|
129
|
+
this.triggerEvent('updateVideoState', 'chatting')
|
|
130
|
+
this.triggerEvent('remoteUserJoin', `${userID}`)
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
// 远端用户退出
|
|
134
|
+
this.TRTC.on(TRTC_EVENT.REMOTE_USER_LEAVE, (event) => {
|
|
135
|
+
const {
|
|
136
|
+
userID,
|
|
137
|
+
playerList
|
|
138
|
+
} = event.data
|
|
139
|
+
this.triggerEvent('remoteUserLeave', `${userID}`)
|
|
140
|
+
this._updatePlayerList(playerList)
|
|
141
|
+
})
|
|
142
|
+
// 远端用户推送视频
|
|
143
|
+
this.TRTC.on(TRTC_EVENT.REMOTE_VIDEO_ADD, (event) => {
|
|
144
|
+
const {
|
|
145
|
+
player
|
|
146
|
+
} = event.data
|
|
147
|
+
// 开始播放远端的视频流,默认是不播放的
|
|
148
|
+
this.setPlayerAttributesHandler(player, {
|
|
149
|
+
muteVideo: false
|
|
150
|
+
})
|
|
151
|
+
})
|
|
152
|
+
// 远端用户取消推送视频
|
|
153
|
+
this.TRTC.on(TRTC_EVENT.REMOTE_VIDEO_REMOVE, (event) => {
|
|
154
|
+
const {
|
|
155
|
+
player
|
|
156
|
+
} = event.data
|
|
157
|
+
// 开始播放远端的视频流,默认是不播放的
|
|
158
|
+
this.setPlayerAttributesHandler(player, {
|
|
159
|
+
muteVideo: true
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
// 远端用户推送音频
|
|
163
|
+
this.TRTC.on(TRTC_EVENT.REMOTE_AUDIO_ADD, (event) => {
|
|
164
|
+
const {
|
|
165
|
+
player
|
|
166
|
+
} = event.data
|
|
167
|
+
this.setPlayerAttributesHandler(player, {
|
|
168
|
+
muteAudio: false
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
})
|
|
172
|
+
// 远端用户取消推送音频
|
|
173
|
+
this.TRTC.on(TRTC_EVENT.REMOTE_AUDIO_REMOVE, (event) => {
|
|
174
|
+
const {
|
|
175
|
+
player
|
|
176
|
+
} = event.data
|
|
177
|
+
this.setPlayerAttributesHandler(player, {
|
|
178
|
+
muteAudio: true
|
|
179
|
+
})
|
|
180
|
+
})
|
|
181
|
+
// 远端用户音量更新
|
|
182
|
+
this.TRTC.on(TRTC_EVENT.REMOTE_AUDIO_VOLUME_UPDATE, (event) => {
|
|
183
|
+
const {
|
|
184
|
+
playerList
|
|
185
|
+
} = event.data
|
|
186
|
+
this._updatePlayerList(playerList)
|
|
187
|
+
})
|
|
188
|
+
// 本地用户音量更新
|
|
189
|
+
this.TRTC.on(TRTC_EVENT.LOCAL_AUDIO_VOLUME_UPDATE, (event) => {
|
|
190
|
+
const {
|
|
191
|
+
pusher
|
|
192
|
+
} = event.data
|
|
193
|
+
this.setData({
|
|
194
|
+
pusher: pusher
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
},
|
|
198
|
+
// 请保持跟 wxml 中绑定的事件名称一致
|
|
199
|
+
_pusherStateChangeHandler(event) {
|
|
200
|
+
this.TRTC.pusherEventHandler(event)
|
|
201
|
+
},
|
|
202
|
+
_pusherNetStatusHandler(event) {
|
|
203
|
+
this.TRTC.pusherNetStatusHandler(event)
|
|
204
|
+
},
|
|
205
|
+
_pusherErrorHandler(event) {
|
|
206
|
+
this.TRTC.pusherErrorHandler(event)
|
|
207
|
+
},
|
|
208
|
+
_pusherBGMStartHandler(event) {
|
|
209
|
+
this.TRTC.pusherBGMStartHandler(event)
|
|
210
|
+
},
|
|
211
|
+
_pusherBGMProgressHandler(event) {
|
|
212
|
+
this.TRTC.pusherBGMProgressHandler(event)
|
|
213
|
+
},
|
|
214
|
+
_pusherBGMCompleteHandler(event) {
|
|
215
|
+
this.TRTC.pusherBGMCompleteHandler(event)
|
|
216
|
+
},
|
|
217
|
+
_pusherAudioVolumeNotify(event) {
|
|
218
|
+
this.TRTC.pusherAudioVolumeNotify(event)
|
|
219
|
+
},
|
|
220
|
+
_playerStateChange(event) {
|
|
221
|
+
this.TRTC.playerEventHandler(event.detail)
|
|
222
|
+
},
|
|
223
|
+
_playerFullscreenChange(event) {
|
|
224
|
+
this.TRTC.playerFullscreenChange(event.detail)
|
|
225
|
+
},
|
|
226
|
+
_playerNetStatus(event) {
|
|
227
|
+
this.TRTC.playerNetStatus(event.detail)
|
|
228
|
+
},
|
|
229
|
+
_playerAudioVolumeNotify(event) {
|
|
230
|
+
const userId = event.currentTarget.dataset.userid
|
|
231
|
+
const exist = this.data.remotePlayerList != null && this.data.remotePlayerList.includes(userId)
|
|
232
|
+
if (exist) {
|
|
233
|
+
this.TRTC.playerAudioVolumeNotify(event.detail)
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
setPusherAttributesHandler(options) {
|
|
237
|
+
this.setData({
|
|
238
|
+
pusher: this.TRTC.setPusherAttributes(options),
|
|
239
|
+
})
|
|
240
|
+
},
|
|
241
|
+
// 设置某个 player 属性
|
|
242
|
+
setPlayerAttributesHandler(player, options) {
|
|
243
|
+
let playerList = this.TRTC.setPlayerAttributes(player.streamID, options)
|
|
244
|
+
this._updatePlayerList(playerList)
|
|
245
|
+
},
|
|
246
|
+
//更新playerList
|
|
247
|
+
_updatePlayerList(playerList) {
|
|
248
|
+
if (playerList && playerList.length > 0) {
|
|
249
|
+
if (playerList.length > 1) {
|
|
250
|
+
let mainRemotePlayer = playerList[0]
|
|
251
|
+
const userId = mainRemotePlayer.userID
|
|
252
|
+
let remotePlayerList = playerList.slice(1, playerList.length)
|
|
253
|
+
this.setData({
|
|
254
|
+
mainRemoteUser: userId,
|
|
255
|
+
mainRemotePlayer: mainRemotePlayer,
|
|
256
|
+
remotePlayerList: remotePlayerList
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
} else {
|
|
260
|
+
let mainRemotePlayer = playerList[0]
|
|
261
|
+
const userId = mainRemotePlayer.userID
|
|
262
|
+
this.setData({
|
|
263
|
+
mainRemoteUser: null,
|
|
264
|
+
mainRemotePlayer: null,
|
|
265
|
+
remotePlayerList: null
|
|
266
|
+
}, () => {
|
|
267
|
+
this.setData({
|
|
268
|
+
mainRemoteUser: userId,
|
|
269
|
+
mainRemotePlayer: mainRemotePlayer,
|
|
270
|
+
})
|
|
271
|
+
})
|
|
272
|
+
}
|
|
273
|
+
} else {
|
|
274
|
+
this.setData({
|
|
275
|
+
mainRemotePlayer: null,
|
|
276
|
+
remotePlayerList: null
|
|
277
|
+
})
|
|
278
|
+
// 此时房间内远端用户都离开了,需要自己也离开房间
|
|
279
|
+
this.setPusherAttributesHandler({
|
|
280
|
+
enableCamera: false,
|
|
281
|
+
enableMic: false
|
|
282
|
+
})
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
switchAudioVideo(toAudio) {
|
|
286
|
+
if (toAudio) {
|
|
287
|
+
this.TRTC.getPusherInstance().pause()
|
|
288
|
+
} else {
|
|
289
|
+
this.TRTC.getPusherInstance().resume()
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
switchCamera() {
|
|
293
|
+
const frontCamera = this.data.pusher.frontCamera === 'front' ? 'back' : 'front'
|
|
294
|
+
this.TRTC.getPusherInstance().switchCamera(frontCamera)
|
|
295
|
+
},
|
|
296
|
+
}
|
|
297
|
+
})
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<remote-player
|
|
2
|
+
id="{{mainRemoteUser}}"
|
|
3
|
+
wx:if="{{mainRemotePlayer}}"
|
|
4
|
+
remoteUser="{{mainRemotePlayer}}"
|
|
5
|
+
showSmall="{{false}}"
|
|
6
|
+
isInVoice="{{isInVoice}}"
|
|
7
|
+
bind:playerStateChange="_playerStateChange"
|
|
8
|
+
bind:playerFullscreenChange="_playerFullscreenChange"
|
|
9
|
+
bind:playerNetStatus="_playerNetStatus"
|
|
10
|
+
bind:playerAudioVolumeNotify="_playerAudioVolumeNotify"
|
|
11
|
+
/>
|
|
12
|
+
<view
|
|
13
|
+
class="{{mainRemotePlayer ? 'small-item-container' :'match-parent black-background position-absolute'}}"
|
|
14
|
+
>
|
|
15
|
+
<view
|
|
16
|
+
style="margin-top: {{mainRemotePlayer ? smallVideoTop : 0}}px;"
|
|
17
|
+
class="{{mainRemotePlayer ? 'local-view' : 'match-parent position-absolute'}}"
|
|
18
|
+
>
|
|
19
|
+
<live-pusher
|
|
20
|
+
class="match-parent"
|
|
21
|
+
bindstatechange="_pusherStateChangeHandler"
|
|
22
|
+
bindnetstatus="_pusherNetStatusHandler"
|
|
23
|
+
binderror="_pusherErrorHandler"
|
|
24
|
+
bindbgmstart="_pusherBGMStartHandler"
|
|
25
|
+
bindbgmprogress="_pusherBGMProgressHandler"
|
|
26
|
+
bindbgmcomplete="_pusherBGMCompleteHandler"
|
|
27
|
+
bindaudiovolumenotify="_pusherAudioVolumeNotify"
|
|
28
|
+
enable-camera="{{pusher.enableCamera}}"
|
|
29
|
+
enable-mic="{{pusher.enableMic}}"
|
|
30
|
+
muted="{{!pusher.enableMic}}"
|
|
31
|
+
enable-agc="{{pusher.enableAgc}}"
|
|
32
|
+
enable-ans="{{pusher.enableAns}}"
|
|
33
|
+
mode="{{pusher.mode}}"
|
|
34
|
+
url="{{pusher.url}}"
|
|
35
|
+
/>
|
|
36
|
+
<view wx:if="{{isInVoice}}" class="cover-view small">
|
|
37
|
+
<image class="pusher-cover-image" src="{{expertAvatar}}" />
|
|
38
|
+
</view>
|
|
39
|
+
</view>
|
|
40
|
+
<view
|
|
41
|
+
wx:if="{{remotePlayerList}}"
|
|
42
|
+
wx:for="{{remotePlayerList}}"
|
|
43
|
+
wx:key="userID"
|
|
44
|
+
>
|
|
45
|
+
<remote-player
|
|
46
|
+
wx:if="{{item}}"
|
|
47
|
+
remoteUser="{{item}}"
|
|
48
|
+
showSmall="{{true}}"
|
|
49
|
+
isInVoice="{{isInVoice}}"
|
|
50
|
+
bind:playerStateChange="_playerStateChange"
|
|
51
|
+
bind:playerFullscreenChange="_playerFullscreenChange"
|
|
52
|
+
bind:playerNetStatus="_playerNetStatus"
|
|
53
|
+
bind:playerAudioVolumeNotify="_playerAudioVolumeNotify"
|
|
54
|
+
/>
|
|
55
|
+
</view>
|
|
56
|
+
</view>
|