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.
Files changed (131) hide show
  1. package/components/apis/api-host-define.js +69 -0
  2. package/components/apis/consultation-reply-api.js +21 -0
  3. package/components/apis/dicom-api.js +31 -0
  4. package/components/apis/family-api.js +20 -0
  5. package/components/apis/file-upload-api.js +35 -0
  6. package/components/apis/order-app-api.js +206 -0
  7. package/components/apis/stat-log-api.js +42 -0
  8. package/components/apis/video-chat-log-api.js +47 -0
  9. package/components/apis/video-message-api.js +88 -0
  10. package/components/consultation/detail/behaviors/chat-cell-base-behaviors.js +29 -0
  11. package/components/consultation/detail/behaviors/consultation-behaviors.js +60 -0
  12. package/components/consultation/detail/behaviors/consultation-chat-behaviors.js +321 -0
  13. package/components/consultation/detail/behaviors/consultation-header-media-behaviors.js +176 -0
  14. package/components/consultation/detail/behaviors/consultation-header-text-behaviors.js +325 -0
  15. package/components/consultation/detail/behaviors/consultation-reply-behaviors.js +67 -0
  16. package/components/consultation/detail/consultation-detail-page.js +219 -0
  17. package/components/consultation/detail/consultation-detail-page.json +10 -0
  18. package/components/consultation/detail/consultation-detail-page.wxml +65 -0
  19. package/components/consultation/detail/consultation-detail-page.wxss +51 -0
  20. package/components/consultation/detail/widget/case-image-filter.js +47 -0
  21. package/components/consultation/detail/widget/chat-base-cell/chat-base-cell.js +31 -0
  22. package/components/consultation/detail/widget/chat-base-cell/chat-base-cell.json +4 -0
  23. package/components/consultation/detail/widget/chat-base-cell/chat-base-cell.wxml +17 -0
  24. package/components/consultation/detail/widget/chat-base-cell/chat-base-cell.wxss +9 -0
  25. package/components/consultation/detail/widget/chat-bottom/chat-bottom.js +100 -0
  26. package/components/consultation/detail/widget/chat-bottom/chat-bottom.json +4 -0
  27. package/components/consultation/detail/widget/chat-bottom/chat-bottom.wxml +24 -0
  28. package/components/consultation/detail/widget/chat-bottom/chat-bottom.wxss +54 -0
  29. package/components/consultation/detail/widget/chat-bottom/chat-menu-builder.js +131 -0
  30. package/components/consultation/detail/widget/chat-cell-template/chat-cell-template.wxml +173 -0
  31. package/components/consultation/detail/widget/chat-cell.wxss +394 -0
  32. package/components/consultation/detail/widget/detail-media/detail-media.js +47 -0
  33. package/components/consultation/detail/widget/detail-media/detail-media.json +4 -0
  34. package/components/consultation/detail/widget/detail-media/detail-media.wxml +12 -0
  35. package/components/consultation/detail/widget/detail-media/detail-media.wxss +57 -0
  36. package/components/consultation/detail/widget/detail-text/detail-text.js +31 -0
  37. package/components/consultation/detail/widget/detail-text/detail-text.json +4 -0
  38. package/components/consultation/detail/widget/detail-text/detail-text.wxml +6 -0
  39. package/components/consultation/detail/widget/detail-text/detail-text.wxss +14 -0
  40. package/components/consultation/evaluate/evaluate-page.js +157 -0
  41. package/components/consultation/evaluate/evaluate-page.json +3 -0
  42. package/components/consultation/evaluate/evaluate-page.wxml +42 -0
  43. package/components/consultation/evaluate/evaluate-page.wxss +103 -0
  44. package/components/consultation/list/behaviors/consultation-list-base-behaviors.js +144 -0
  45. package/components/consultation/list/consultation-list-page.js +84 -0
  46. package/components/consultation/list/consultation-list-page.json +5 -0
  47. package/components/consultation/list/consultation-list-page.wxml +53 -0
  48. package/components/consultation/list/consultation-list-page.wxss +105 -0
  49. package/components/consultation/reply/behaviors/reply-base-behaviors.js +175 -0
  50. package/components/consultation/reply/consultation-reply-page.js +251 -0
  51. package/components/consultation/reply/consultation-reply-page.json +6 -0
  52. package/components/consultation/reply/consultation-reply-page.wxml +103 -0
  53. package/components/consultation/reply/consultation-reply-page.wxss +169 -0
  54. package/components/consultation/reply/widget/audio-record-view/audio-record-view.js +144 -0
  55. package/components/consultation/reply/widget/audio-record-view/audio-record-view.json +4 -0
  56. package/components/consultation/reply/widget/audio-record-view/audio-record-view.wxml +27 -0
  57. package/components/consultation/reply/widget/audio-record-view/audio-record-view.wxss +197 -0
  58. package/components/hh-doctor.js +36 -0
  59. package/components/hh-navigation.js +87 -0
  60. package/components/public/app-config.js +13 -0
  61. package/components/public/behaviors/order-base-behaviors.js +53 -0
  62. package/components/public/cache-data.js +134 -0
  63. package/components/public/doctor-loader.js +60 -0
  64. package/components/public/im-manager.js +135 -0
  65. package/components/public/pdf-viewer.js +59 -0
  66. package/components/public/stat-log.js +13 -0
  67. package/components/static/Agora_Miniapp_SDK_for_WeChat.js +2 -0
  68. package/components/static/trtc-wx.js +2 -0
  69. package/components/uikit/css/common.wxss +23 -0
  70. package/components/uikit/custom-bottom-pop/custom-bottom-pop.js +37 -0
  71. package/components/uikit/custom-bottom-pop/custom-bottom-pop.json +4 -0
  72. package/components/uikit/custom-bottom-pop/custom-bottom-pop.wxml +9 -0
  73. package/components/uikit/custom-bottom-pop/custom-bottom-pop.wxss +79 -0
  74. package/components/uikit/date-time-picker/date-time-picker.js +115 -0
  75. package/components/uikit/web-view-page/web-view-page.js +87 -0
  76. package/components/uikit/web-view-page/web-view-page.json +3 -0
  77. package/components/uikit/web-view-page/web-view-page.wxml +6 -0
  78. package/components/uikit/web-view-page/web-view-page.wxss +1 -0
  79. package/components/utils/checksumUtils.js +56 -0
  80. package/components/utils/common-utils.js +59 -0
  81. package/components/utils/dateUtils.js +142 -0
  82. package/components/utils/eventBus.js +77 -0
  83. package/components/utils/httpUtils.js +123 -0
  84. package/components/utils/number-utils.js +48 -0
  85. package/components/utils/permission-utils.js +164 -0
  86. package/components/video-chat/agora-rtc/agora-player/agora-player.js +106 -0
  87. package/components/video-chat/agora-rtc/agora-player/agora-player.json +4 -0
  88. package/components/video-chat/agora-rtc/agora-player/agora-player.wxml +24 -0
  89. package/components/video-chat/agora-rtc/agora-player/agora-player.wxss +1 -0
  90. package/components/video-chat/agora-rtc/agora-pusher/agora-pusher.js +92 -0
  91. package/components/video-chat/agora-rtc/agora-pusher/agora-pusher.json +4 -0
  92. package/components/video-chat/agora-rtc/agora-pusher/agora-pusher.wxml +22 -0
  93. package/components/video-chat/agora-rtc/agora-pusher/agora-pusher.wxss +1 -0
  94. package/components/video-chat/agora-rtc/agora-rtc.js +391 -0
  95. package/components/video-chat/agora-rtc/agora-rtc.json +7 -0
  96. package/components/video-chat/agora-rtc/agora-rtc.wxml +39 -0
  97. package/components/video-chat/agora-rtc/agora-rtc.wxss +1 -0
  98. package/components/video-chat/callback/callback.js +39 -0
  99. package/components/video-chat/callback/callback.json +4 -0
  100. package/components/video-chat/callback/callback.wxml +29 -0
  101. package/components/video-chat/callback/callback.wxss +26 -0
  102. package/components/video-chat/calling/calling.js +75 -0
  103. package/components/video-chat/calling/calling.json +4 -0
  104. package/components/video-chat/calling/calling.wxml +32 -0
  105. package/components/video-chat/calling/calling.wxss +45 -0
  106. package/components/video-chat/controller/controller.js +86 -0
  107. package/components/video-chat/controller/controller.json +4 -0
  108. package/components/video-chat/controller/controller.wxml +73 -0
  109. package/components/video-chat/controller/controller.wxss +71 -0
  110. package/components/video-chat/remote-player/remote-player.js +42 -0
  111. package/components/video-chat/remote-player/remote-player.json +4 -0
  112. package/components/video-chat/remote-player/remote-player.wxml +37 -0
  113. package/components/video-chat/remote-player/remote-player.wxss +1 -0
  114. package/components/video-chat/video-chat.js +297 -0
  115. package/components/video-chat/video-chat.json +7 -0
  116. package/components/video-chat/video-chat.wxml +56 -0
  117. package/components/video-chat/video-chat.wxss +97 -0
  118. package/components/video-chat-page/behaviors/chat-files-behaviors.js +243 -0
  119. package/components/video-chat-page/behaviors/chat-log-behaviors.js +90 -0
  120. package/components/video-chat-page/behaviors/chat-sound-behaviors.js +60 -0
  121. package/components/video-chat-page/behaviors/video-chat-behaviors.js +524 -0
  122. package/components/video-chat-page/case-group-view/case-group-view.js +38 -0
  123. package/components/video-chat-page/case-group-view/case-group-view.json +4 -0
  124. package/components/video-chat-page/case-group-view/case-group-view.wxml +32 -0
  125. package/components/video-chat-page/case-group-view/case-group-view.wxss +44 -0
  126. package/components/video-chat-page/video-chat-defines.js +39 -0
  127. package/components/video-chat-page/video-chat-page.js +212 -0
  128. package/components/video-chat-page/video-chat-page.json +14 -0
  129. package/components/video-chat-page/video-chat-page.wxml +88 -0
  130. package/components/video-chat-page/video-chat-page.wxss +45 -0
  131. package/package.json +18 -0
@@ -0,0 +1,123 @@
1
+ const sha1 = require('./checksumUtils')
2
+ const cache = require('../public/cache-data')
3
+ const appConfig = require('../public/app-config')
4
+ const hostDefine = require('../apis/api-host-define')
5
+
6
+ var cookie = ''
7
+
8
+ /**
9
+ * 发送post请求联网
10
+ * @param path 联网path
11
+ * @param params 被拼接到url上的get参数
12
+ * @param data post请求body数据
13
+ */
14
+ function httpPost(request, params, data) {
15
+ return _request(request, 'POST', params, data)
16
+ }
17
+
18
+ /**
19
+ * 发送post请求联网
20
+ * @param path 联网path
21
+ * @param params 被拼接到url上的get参数
22
+ * @param data post请求body数据
23
+ */
24
+ function httpGet(request, params, data) {
25
+ return _request(request, 'GET', params, data)
26
+ }
27
+
28
+ function _request(request, method, params, data) {
29
+ return new Promise((resolve, reject) => {
30
+ var host = hostDefine.host(request.hostType)
31
+ var url = `${host}${request.path}`
32
+ const doctorId = cache.doctorId()
33
+ const uuid = cache.uuid()
34
+
35
+ var fullParams = Object.assign({}, params || {})
36
+ fullParams.sdkProductId = appConfig.appID
37
+ fullParams.pid = appConfig.appID
38
+ fullParams.app_version = appConfig.appVersion
39
+ fullParams.actionSource = 'wxApp'
40
+ fullParams.device_token = ''
41
+ if (doctorId) {
42
+ fullParams.doctor_id = doctorId
43
+ fullParams.user_id = doctorId
44
+ }
45
+ if (uuid) {
46
+ fullParams.uuid = uuid
47
+ }
48
+ fullParams.session_id = appConfig.sessionId
49
+ fullParams.random = new Date().getTime()
50
+
51
+ for (let [key, value] of Object.entries(fullParams)) {
52
+ if (!url.includes(`&${key}=`)) {
53
+ url = `${url}${url.includes('?') ? '&' : '?'}${key}=${encodeURIComponent(value)}`
54
+ }
55
+ }
56
+ var timestamp = new Date().getTime()
57
+ var nonce = timestamp.toString()
58
+ var curTime = Number.parseInt(timestamp / 1000)
59
+ var checkSum = sha1.sha1(appConfig.appSecret + nonce + curTime)
60
+
61
+ const header = {
62
+ 'Accept': 'application/json',
63
+ 'content-type': 'application/json',
64
+ 'cookie': cookie,
65
+ 'APPTYPE': 'pc',
66
+ 'AppKey': appConfig.appKey,
67
+ 'Nonce': nonce,
68
+ 'CurTime': curTime,
69
+ 'CheckSum': checkSum
70
+ }
71
+ if (request.download) {
72
+ wx.downloadFile({
73
+ url: url,
74
+ success: function (res) {
75
+ if (res.statusCode == 200) {
76
+ resolve(res.data);
77
+ } else {
78
+ reject(res);
79
+ }
80
+ },
81
+ fail: function (err) {
82
+ reject(err);
83
+ },
84
+ })
85
+ } else {
86
+ wx.request({
87
+ url: url,
88
+ data: data,
89
+ method: method,
90
+ header: header,
91
+ success: function (res) {
92
+ if (res.header['set-cookie']) {
93
+ setCookie(res.header['set-cookie']);
94
+ }
95
+ if (res.header['Set-Cookie']) {
96
+ setCookie(res.header['Set-Cookie']);
97
+ }
98
+ if (success(res)) {
99
+ resolve(res.data);
100
+ } else {
101
+ reject(res);
102
+ }
103
+ },
104
+ fail: function (err) {
105
+ reject(err);
106
+ },
107
+ })
108
+ }
109
+ })
110
+ }
111
+
112
+ function success(res) {
113
+ return res && res.statusCode == 200 && res.data && res.data.status == 200;
114
+ }
115
+
116
+ function setCookie(value) {
117
+ cookie = value;
118
+ }
119
+
120
+ module.exports = {
121
+ post: httpPost,
122
+ get: httpGet,
123
+ }
@@ -0,0 +1,48 @@
1
+ function formatCount(count) {
2
+ var counter = parseInt(count)
3
+ if (counter > 100000000) {
4
+ return (counter / 100000000).toFixed(1) + "亿"
5
+ } else if (counter > 10000) {
6
+ return (counter / 10000).toFixed(1) + "万"
7
+ } else {
8
+ return counter + ""
9
+ }
10
+ }
11
+
12
+ /**
13
+ * 毫秒级转换时间显示
14
+ * @param {} duration 毫秒数
15
+ */
16
+ function formatDuration(duration) {
17
+ duration = duration / 1000
18
+ return formatSecond(duration)
19
+ }
20
+
21
+ /**
22
+ * 毫秒级转换时间显示
23
+ * @param {} seconds 秒数
24
+ */
25
+ function formatSecond(seconds) {
26
+ var hour = Math.floor(seconds / 3600)
27
+ var minute = Math.floor(seconds / 60)
28
+ var second = seconds % 60
29
+ if (hour > 0) {
30
+ return padLeftZero(hour) + ":" + padLeftZero(minute) + ":" + padLeftZero(second)
31
+ }
32
+ return padLeftZero(minute) + ":" + padLeftZero(second)
33
+ }
34
+
35
+ /**
36
+ *
37
+ * @param {时间显示补0} time
38
+ */
39
+ function padLeftZero(time) {
40
+ time = time + ""
41
+ return ("00" + time).slice(time.length)
42
+ }
43
+
44
+ module.exports = {
45
+ formatCount: formatCount,
46
+ formatDuration: formatDuration,
47
+ formatSecond: formatSecond
48
+ }
@@ -0,0 +1,164 @@
1
+ const permissionScopes = {
2
+ camera: {
3
+ scope: 'scope.camera',
4
+ content: '请前往设置页打开摄像头权限'
5
+ },
6
+ record: {
7
+ scope: 'scope.record',
8
+ content: '请前往设置页打开麦克风权限'
9
+ },
10
+ }
11
+
12
+ function getSettingRecord(options = {
13
+ scope: permissionScopes.record.scope,
14
+ content: permissionScopes.record.content
15
+ }) {
16
+ return new Promise((resolve, reject) => {
17
+ wx.getSetting({
18
+ success: (res) => {
19
+ let auth = res.authSetting[options.scope]
20
+ if (auth === true) {
21
+ resolve(true)
22
+ } else if (auth === undefined) {
23
+ wx.authorize({
24
+ scope: options.scope,
25
+ success() {
26
+ resolve(true)
27
+ },
28
+ fail(res) {
29
+ resolve(false)
30
+ }
31
+ })
32
+ } else if (auth === false) {
33
+ resolve(false)
34
+ }
35
+ }
36
+ })
37
+ })
38
+ }
39
+
40
+ function checkScopeCamera() {
41
+ return new Promise((resolve, reject) => {
42
+ const options = {
43
+ scope: permissionScopes.camera.scope,
44
+ content: permissionScopes.camera.content
45
+ }
46
+ getSettingRecord(options).then(res => {
47
+ if (res) {
48
+ resolve()
49
+ } else {
50
+ showPermissionTip(options.content, options.scope).then(() => {
51
+ resolve()
52
+ }).catch(() => {
53
+ reject()
54
+ })
55
+ }
56
+ })
57
+ })
58
+ }
59
+
60
+ function checkScopeRecord() {
61
+ return new Promise((resolve, reject) => {
62
+ const options = {
63
+ scope: permissionScopes.record.scope,
64
+ content: permissionScopes.record.content
65
+ }
66
+ getSettingRecord(options).then(res => {
67
+ if (res) {
68
+ resolve()
69
+ } else {
70
+ showPermissionTip(options.content, options.scope).then(() => {
71
+ resolve()
72
+ }).catch(() => {
73
+ reject()
74
+ })
75
+ }
76
+ })
77
+ })
78
+ }
79
+
80
+ function checkMediaPermission() {
81
+ return new Promise((resolve, reject) => {
82
+ const optionsRecord = {
83
+ scope: permissionScopes.record.scope,
84
+ content: permissionScopes.record.content
85
+ }
86
+ const promiseRecord = getSettingRecord(optionsRecord)
87
+
88
+ const optionsCamera = {
89
+ scope: permissionScopes.camera.scope,
90
+ content: permissionScopes.camera.content
91
+ }
92
+ const promiseCamera = getSettingRecord(optionsCamera)
93
+ Promise.all([promiseRecord, promiseCamera]).then(res => {
94
+ if (res[0] && res[1]) {
95
+ resolve()
96
+ } else {
97
+ var scopes = new Array()
98
+ var error = ''
99
+ if (!res[0]) {
100
+ error = '请前往设置页打开麦克风'
101
+ scopes.push(permissionScopes.record.scope)
102
+ }
103
+ if (!res[1]) {
104
+ if (error != '') {
105
+ error = error + '和摄像头权限'
106
+ } else {
107
+ error = '请前往设置页打开摄像头权限'
108
+ }
109
+ scopes.push(permissionScopes.camera.scope)
110
+ }
111
+ showPermissionTip(error, scopes).then(() => {
112
+ resolve()
113
+ }).catch(() => {
114
+ reject()
115
+ })
116
+ }
117
+ })
118
+ })
119
+ }
120
+
121
+ function showPermissionTip(error, ...scopes) {
122
+ return new Promise((resolve, reject) => {
123
+ wx.showModal({
124
+ title: '授权提示',
125
+ content: error,
126
+ complete: (res) => {
127
+ if (res.confirm) {
128
+ wx.openSetting({
129
+ success: (settingRes) => {
130
+ var result = true
131
+ scopes.forEach((scope) => {
132
+ if (typeof scope === 'string') {
133
+ if (!settingRes.authSetting[scope]) {
134
+ result = false
135
+ }
136
+ } else {
137
+ scope.forEach((value) => {
138
+ if (!settingRes.authSetting[value]) {
139
+ result = false
140
+ }
141
+ })
142
+ }
143
+ })
144
+ if (result) {
145
+ resolve()
146
+ } else {
147
+ reject()
148
+ }
149
+ }
150
+ })
151
+ }
152
+ if (res.cancel) {
153
+ reject()
154
+ }
155
+ }
156
+ })
157
+ })
158
+ }
159
+
160
+ module.exports = {
161
+ checkMediaPermission: checkMediaPermission,
162
+ checkScopeRecord: checkScopeRecord,
163
+ checkScopeCamera: checkScopeCamera
164
+ }
@@ -0,0 +1,106 @@
1
+ // components/video-chat/agora-rtc/agora-player/agora-player.js
2
+ Component({
3
+
4
+ /**
5
+ * 组件的属性列表
6
+ */
7
+ properties: {
8
+ showSmall: {
9
+ type: Boolean,
10
+ value: false
11
+ },
12
+ uid: {
13
+ type: String,
14
+ value: ""
15
+ },
16
+ url: {
17
+ type: String,
18
+ value: ""
19
+ },
20
+ isInVoice: {
21
+ type: Boolean,
22
+ value: false
23
+ }
24
+ },
25
+
26
+ /**
27
+ * 组件的初始数据
28
+ */
29
+ data: {
30
+ playContext: null,
31
+ detached: false
32
+ },
33
+
34
+ /**
35
+ * 组件的方法列表
36
+ */
37
+ methods: {
38
+ onPlayerNetstatus: function (e) {
39
+ this.triggerEvent('netstatus', e)
40
+ },
41
+
42
+ onPlayerStatechange: function (e) {
43
+ this.triggerEvent('statechange', e)
44
+ let uid = parseInt(e.target.id.split("-")[1]);
45
+ if (e.detail.code === 2004) {
46
+ if (this.data.status === "loading") {
47
+ this.setData({
48
+ status: "ok"
49
+ });
50
+ }
51
+ } else if (e.detail.code === -2301) {
52
+ this.setData({
53
+ status: "error"
54
+ })
55
+ }
56
+ },
57
+
58
+ start: function () {
59
+ const uid = this.data.uid;
60
+ if (this.data.status === "ok") {
61
+ return;
62
+ }
63
+ if (this.data.detached) {
64
+ return;
65
+ }
66
+ if (this.data.playContext) {
67
+ this.data.playContext.play();
68
+ }
69
+ },
70
+
71
+ /**
72
+ * stop live pusher context
73
+ */
74
+ stop: function () {
75
+ const uid = this.data.uid;
76
+ this.data.playContext.stop();
77
+ },
78
+
79
+ /**
80
+ * rotate video by rotation
81
+ */
82
+ rotate: function (rotation) {
83
+ let orientation = rotation === 90 || rotation === 270 ? "horizontal" : "vertical";
84
+ this.setData({
85
+ orientation: orientation
86
+ });
87
+ },
88
+ },
89
+ /**
90
+ * 组件生命周期
91
+ */
92
+ ready: function () {
93
+ this.data.playContext || (this.data.playContext = wx.createLivePlayerContext(`player-${this.data.uid}`, this));
94
+ if (this.data.url) {
95
+ this.start();
96
+ }
97
+ },
98
+
99
+ moved: function () {},
100
+
101
+ detached: function () {
102
+ this.data.playContext && this.data.playContext.stop();
103
+ this.data.detached = true;
104
+ }
105
+
106
+ })
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {}
4
+ }
@@ -0,0 +1,24 @@
1
+ <view class="{{showSmall ? 'remote_small' : 'match-parent position-absolute'}}">
2
+ <live-player
3
+ wx:if="{{uid}}"
4
+ class="{{showSmall ? 'remote_small' : 'match-parent position-absolute'}}"
5
+ id="player-{{uid}}"
6
+ uid="{{uid}}"
7
+ debug="{{false}}"
8
+ src="{{url}}"
9
+ autoplay="true"
10
+ mode="RTC"
11
+ object-fit="fillCrop"
12
+ bindnetstatus="onPlayerNetstatus"
13
+ bindstatechange="onPlayerStatechange"
14
+ />
15
+ <view
16
+ wx:if="{{isInVoice}}"
17
+ class="cover-view {{showSmall ? 'small' : 'big'}}"
18
+ >
19
+ <image
20
+ class="{{showSmall ? 'voice-mode-avatar-small' : 'voice-mode-avatar'}}"
21
+ src="https://image.hh-medic.com/icon/pacs/hh_sdk_audio_avatar.png"
22
+ />
23
+ </view>
24
+ </view>
@@ -0,0 +1 @@
1
+ @import "../../video-chat.wxss";
@@ -0,0 +1,92 @@
1
+ // components/video-chat/agora-rtc/agora-pusher/agora-pusher.js
2
+ Component({
3
+
4
+ /**
5
+ * 组件的属性列表
6
+ */
7
+ properties: {
8
+ url: {
9
+ type: String,
10
+ value: ''
11
+ },
12
+ chatting: {
13
+ type: Boolean,
14
+ value: true
15
+ },
16
+ smallVideoTop: {
17
+ type: Number,
18
+ value: 0
19
+ },
20
+ isInVoice: {
21
+ type: Boolean,
22
+ value: false
23
+ },
24
+ expertAvatar: {
25
+ type: String,
26
+ value: ''
27
+ }
28
+ },
29
+
30
+ /**
31
+ * 组件的初始数据
32
+ */
33
+ data: {
34
+ pusherContext: null,
35
+ detached: false
36
+ },
37
+
38
+ /**
39
+ * 组件的方法列表
40
+ */
41
+ methods: {
42
+ /**
43
+ * start live pusher via context
44
+ * in most cases you should not call this manually in your page
45
+ * as this will be automatically called in component ready method
46
+ */
47
+ start() {
48
+ this.data.pusherContext.stop();
49
+ if (this.data.detached) {
50
+ return;
51
+ }
52
+ this.data.pusherContext.start();
53
+ },
54
+ stop() {
55
+ this.data.pusherContext.stop();
56
+ },
57
+ switchCamera() {
58
+ this.data.pusherContext.switchCamera();
59
+ },
60
+ recorderStateChange: function (e) {
61
+ this.triggerEvent('statechange', e);
62
+ if (e.detail.code === -1307) {
63
+ this.setData({
64
+ status: "error"
65
+ })
66
+ this.triggerEvent('pushfailed');
67
+ }
68
+ if (e.detail.code === 1008) {
69
+ if (this.data.status === "loading") {
70
+ this.setData({
71
+ status: "ok"
72
+ })
73
+ }
74
+ }
75
+ },
76
+ recorderNetChange: function (e) {
77
+ this.triggerEvent('netstatus', e);
78
+ }
79
+ },
80
+
81
+ /**
82
+ * 组件生命周期
83
+ */
84
+ ready: function () {
85
+ this.data.pusherContext || (this.data.pusherContext = wx.createLivePusherContext(this));
86
+ },
87
+ moved: function () {},
88
+ detached: function () {
89
+ this.data.pusherContext && this.data.pusherContext.stop();
90
+ this.data.detached = true;
91
+ }
92
+ })
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {}
4
+ }
@@ -0,0 +1,22 @@
1
+ <view
2
+ style="margin-top: {{chatting ? smallVideoTop : 0}}px;"
3
+ class="{{chatting ? 'local-view' : 'match-parent black-background position-absolute'}}"
4
+ >
5
+ <live-pusher
6
+ wx:if="{{url}}"
7
+ class="match-parent position-absolute"
8
+ url="{{url}}"
9
+ debug="{{false}}"
10
+ mode="RTC"
11
+ autopush="{{true}}"
12
+ bindnetstatus="recorderNetChange"
13
+ background-mute="{{true}}"
14
+ enable-mic="{{true}}"
15
+ beauty="0"
16
+ enable-camera="{{true}}"
17
+ bindstatechange="recorderStateChange"
18
+ />
19
+ <view wx:if="{{isInVoice}}" class="cover-view small">
20
+ <image class="pusher-cover-image" src="{{expertAvatar}}" />
21
+ </view>
22
+ </view>
@@ -0,0 +1 @@
1
+ @import "../../video-chat.wxss";