hhdoctor-wmp-sdk 3.8.13 → 3.8.15
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/miniprogram_dist/hh-bottom/hh-bottom.js +333 -327
- package/miniprogram_dist/hh-im/cards.wxml +4 -0
- package/miniprogram_dist/hh-im/hh-card.js +2 -0
- package/miniprogram_dist/hh-im/hh-card.wxml +1 -1
- package/miniprogram_dist/hh-im/hh-im.wxml +3 -0
- package/miniprogram_dist/hh-rtc/phases/phase-8-expertwait/phase-expertwait.wxml +1 -1
- package/miniprogram_dist/hh-rtc/phases/phase-8-expertwait/phase-expertwait.wxss +3 -3
- package/miniprogram_dist/hhDoctor.js +2 -2
- package/miniprogram_dist/innerpages/view/view.js +3 -1
- package/miniprogram_dist/utils/commonUtil.js +6 -0
- package/package.json +1 -1
- package/src/hh-bottom/hh-bottom.js +333 -327
- package/src/hh-im/cards.wxml +4 -0
- package/src/hh-im/hh-card.js +2 -0
- package/src/hh-im/hh-card.wxml +1 -1
- package/src/hh-im/hh-im.wxml +3 -0
- package/src/hh-rtc/phases/phase-8-expertwait/phase-expertwait.wxml +1 -1
- package/src/hh-rtc/phases/phase-8-expertwait/phase-expertwait.wxss +3 -3
- package/src/hhDoctor.js +2 -2
- package/src/innerpages/view/view.js +3 -1
- package/src/utils/commonUtil.js +6 -0
|
@@ -4,353 +4,359 @@ var recordStardPosition = null;
|
|
|
4
4
|
const rm = wx.getRecorderManager();
|
|
5
5
|
const hhDoctor = require('../hhDoctor.js');
|
|
6
6
|
const tools = require('../utils/tools.js')
|
|
7
|
+
const { isGuangHeWmp } = require('../utils/commonUtil')
|
|
7
8
|
const SHARE_RIGHT_ENUM = require('../utils/enumUtil').SHARE_RIGHT_ENUM
|
|
8
9
|
let that;
|
|
9
10
|
Component({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
observers: {
|
|
35
|
-
'product': function (val) {
|
|
36
|
-
this.getRights(val)
|
|
37
|
-
},
|
|
38
|
-
'memberList': function (val) {
|
|
39
|
-
if (this.properties.memberList && this.properties.memberList.length) this.getRights(this.data.product)
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
lifetimes: {
|
|
43
|
-
attached() {
|
|
44
|
-
that = this;
|
|
45
|
-
rm.onStart(that._onRecordStart);
|
|
46
|
-
rm.onStop(that._onRecordStop);
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
pageLifetimes: {
|
|
50
|
-
show() {
|
|
51
|
-
this._checkRecordAuth()
|
|
52
|
-
this.bindBlurText()
|
|
53
|
-
},
|
|
54
|
-
hide() {
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 组件的初始数据
|
|
61
|
-
*/
|
|
62
|
-
data: {
|
|
63
|
-
_name: 'hh-bottom',
|
|
64
|
-
bottomHeight: 300, //底部输入和工具栏高度
|
|
65
|
-
inputText: '', //用户输入的文字
|
|
66
|
-
inputTypeClass: 'audio', //输入区域类型
|
|
67
|
-
inputTextVisible: true, //文本输入是否可见
|
|
68
|
-
recordMaskVisible: 'hidden', //录音遮罩层是否可见
|
|
69
|
-
recordBtnTip: '按住 说话', //录音按纽的提示文字
|
|
70
|
-
recordCancel: false, //是否取消录音
|
|
71
|
-
animationData: null, //顶部按纽栏动画对象
|
|
72
|
-
utilsAnimation: null, //工具栏动画对象
|
|
73
|
-
isInputTextFocus: false,
|
|
74
|
-
autoplay: false,
|
|
75
|
-
indicatorDots: true,
|
|
76
|
-
current: 0,
|
|
77
|
-
isAuthBox: false,
|
|
78
|
-
isRecordAuth: false,
|
|
79
|
-
isShowToolBar: false,
|
|
80
|
-
manyVideo: false,
|
|
81
|
-
rights: {},
|
|
82
|
-
kbHeight: 0, //键盘默认高度
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* 组件的方法列表
|
|
87
|
-
*/
|
|
88
|
-
methods: {
|
|
89
|
-
_requestComplete() {
|
|
90
|
-
this.getRights(this.data.product);
|
|
91
|
-
setTimeout(() => {
|
|
92
|
-
if (this.data._request && !this.data._request.inputPlaceHolder) {
|
|
93
|
-
this.data._request.inputPlaceHolder = '联系医助'
|
|
94
|
-
this.setData({ _request: this.data._request })
|
|
11
|
+
/**
|
|
12
|
+
* 组件的属性列表
|
|
13
|
+
*/
|
|
14
|
+
behaviors: [
|
|
15
|
+
require('../behaviors/hhStarter'),
|
|
16
|
+
require('../behaviors/hhCommon'),
|
|
17
|
+
],
|
|
18
|
+
properties: {
|
|
19
|
+
safeAreaHight: Number,
|
|
20
|
+
memberList: Array,
|
|
21
|
+
manyVideo: Boolean,
|
|
22
|
+
shareCard: {
|
|
23
|
+
type: Number,
|
|
24
|
+
value: 0
|
|
25
|
+
},
|
|
26
|
+
product: {
|
|
27
|
+
type: Object
|
|
28
|
+
},
|
|
29
|
+
productRightList: Array,
|
|
30
|
+
loadCfg: {
|
|
31
|
+
type: Object,
|
|
32
|
+
value: {}
|
|
95
33
|
}
|
|
96
|
-
}, 500);
|
|
97
34
|
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (!this.data._request.callBtnVisible) return this.setData({ rights: this.getRightsData(newRights) })
|
|
105
|
-
//给家人用(分享卡片)
|
|
106
|
-
this.checkShareRight(this.properties.shareCard, 1)
|
|
107
|
-
//if (this.checkShareRight(this.properties.shareCard, SHARE_RIGHT_ENUM.SHARE_CARD) && this.data.memberList.length && !this.data.memberList[0].pid) newRights['share_card'] = tools['share_card']
|
|
108
|
-
if (this.checkShareRight(this.properties.shareCard, SHARE_RIGHT_ENUM.SHARE_FAMILY) && this.data.memberList.length && !this.data.memberList[0].pid) newRights['share_family'] = tools['share_family']
|
|
109
|
-
//如果loadfCfg配置了hideProductRightListWmp,则隐藏以下所有权益
|
|
110
|
-
if (!this.properties.loadCfg?.hideProductRightListWmp) {
|
|
111
|
-
if (productRightList && this.data.memberList.length && 'temp' != this.data.memberList[0].kind && this.data._request.bottomRightsVisible) {
|
|
112
|
-
productRightList.map((item, index) => {
|
|
113
|
-
//不隐藏专家权益,由服务器控制是否显示 @yuanweigang @liufangyuan
|
|
114
|
-
if (item.serviceType && item.icon2) {
|
|
115
|
-
if (item.rule && typeof item.rule == 'string') {
|
|
116
|
-
item.rule = JSON.parse(item.rule)
|
|
117
|
-
}
|
|
118
|
-
item['index'] = index
|
|
119
|
-
newRights[item.serviceType] = item
|
|
120
|
-
}
|
|
121
|
-
})
|
|
35
|
+
observers: {
|
|
36
|
+
'product': function(val) {
|
|
37
|
+
this.getRights(val)
|
|
38
|
+
},
|
|
39
|
+
'memberList': function(val) {
|
|
40
|
+
if (this.properties.memberList && this.properties.memberList.length) this.getRights(this.data.product)
|
|
122
41
|
}
|
|
123
|
-
if (this.data.memberList.length && !this.data.memberList[0].isAccount && this.data.manyVideo) {
|
|
124
|
-
newRights['many_video'] = tools['many_video']
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
this.setData({ rights: this.getRightsData(newRights) })
|
|
128
|
-
},
|
|
129
|
-
/** 检查分享权限 */
|
|
130
|
-
checkShareRight(shareCardConfig, shareRight) {
|
|
131
|
-
if ('undefined' == typeof shareCardConfig) return 0
|
|
132
|
-
let hex = this.toHex(shareCardConfig)
|
|
133
|
-
let val = parseInt(hex.substr(hex.length - shareRight - 1, 1))
|
|
134
|
-
return val
|
|
135
|
-
},
|
|
136
|
-
toHex(val) {
|
|
137
|
-
let hex = new Number(parseInt(val)).toString(2)
|
|
138
|
-
if (hex.length >= 4) return hex
|
|
139
|
-
for (let i = 0; i < (5 - hex.length); i++) hex = ('0' + hex)
|
|
140
|
-
return hex
|
|
141
42
|
},
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
index % 8 == 0 && count++
|
|
148
|
-
if (typeof rightsData[count] == 'undefined') {
|
|
149
|
-
rightsData[count] = []
|
|
43
|
+
lifetimes: {
|
|
44
|
+
attached() {
|
|
45
|
+
that = this;
|
|
46
|
+
rm.onStart(that._onRecordStart);
|
|
47
|
+
rm.onStop(that._onRecordStop);
|
|
150
48
|
}
|
|
151
|
-
rightsData[count].push(item)
|
|
152
|
-
})
|
|
153
|
-
//console.log(rightsData)
|
|
154
|
-
|
|
155
|
-
return rightsData
|
|
156
49
|
},
|
|
50
|
+
pageLifetimes: {
|
|
51
|
+
show() {
|
|
52
|
+
this._checkRecordAuth()
|
|
53
|
+
this.bindBlurText()
|
|
54
|
+
},
|
|
55
|
+
hide() {
|
|
157
56
|
|
|
158
|
-
|
|
159
|
-
let newArr = [arr['camera'], arr['album']]
|
|
160
|
-
if (arr['many_video']) {
|
|
161
|
-
newArr.push(arr['many_video'])
|
|
162
|
-
delete arr['many_video']
|
|
163
|
-
}
|
|
164
|
-
delete arr['camera']
|
|
165
|
-
delete arr['album']
|
|
166
|
-
return newArr.concat(Object.values(arr))
|
|
167
|
-
},
|
|
168
|
-
bindEveryIcon(e) {
|
|
169
|
-
this.triggerEvent('everyIcon', e.currentTarget.dataset)
|
|
170
|
-
},
|
|
171
|
-
_share(e) {
|
|
172
|
-
this.triggerEvent('share', {}, {})
|
|
173
|
-
},
|
|
174
|
-
//点击右侧加号
|
|
175
|
-
_showHideUtils() {
|
|
176
|
-
this.setData({
|
|
177
|
-
isShowToolBar: !this.data.isShowToolBar
|
|
178
|
-
})
|
|
57
|
+
},
|
|
179
58
|
},
|
|
180
59
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
60
|
+
/**
|
|
61
|
+
* 组件的初始数据
|
|
62
|
+
*/
|
|
63
|
+
data: {
|
|
64
|
+
_name: 'hh-bottom',
|
|
65
|
+
bottomHeight: 300, //底部输入和工具栏高度
|
|
66
|
+
inputText: '', //用户输入的文字
|
|
67
|
+
inputTypeClass: 'audio', //输入区域类型
|
|
68
|
+
inputTextVisible: true, //文本输入是否可见
|
|
69
|
+
recordMaskVisible: 'hidden', //录音遮罩层是否可见
|
|
70
|
+
recordBtnTip: '按住 说话', //录音按纽的提示文字
|
|
71
|
+
recordCancel: false, //是否取消录音
|
|
72
|
+
animationData: null, //顶部按纽栏动画对象
|
|
73
|
+
utilsAnimation: null, //工具栏动画对象
|
|
74
|
+
isInputTextFocus: false,
|
|
75
|
+
autoplay: false,
|
|
76
|
+
indicatorDots: true,
|
|
77
|
+
current: 0,
|
|
78
|
+
isAuthBox: false,
|
|
79
|
+
isRecordAuth: false,
|
|
80
|
+
isShowToolBar: false,
|
|
81
|
+
manyVideo: false,
|
|
82
|
+
rights: {},
|
|
83
|
+
kbHeight: 0, //键盘默认高度
|
|
190
84
|
},
|
|
191
85
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
86
|
+
/**
|
|
87
|
+
* 组件的方法列表
|
|
88
|
+
*/
|
|
89
|
+
methods: {
|
|
90
|
+
_requestComplete() {
|
|
91
|
+
this.getRights(this.data.product);
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
if (this.data._request && !this.data._request.inputPlaceHolder) {
|
|
94
|
+
this.data._request.inputPlaceHolder = '联系医助'
|
|
95
|
+
this.setData({ _request: this.data._request })
|
|
96
|
+
}
|
|
97
|
+
}, 500);
|
|
98
|
+
},
|
|
99
|
+
getRights(product) {
|
|
100
|
+
let productRightList = this.properties.productRightList || product && product.productRightsList || []
|
|
101
|
+
let newRights = {}
|
|
102
|
+
newRights['album'] = tools['album']
|
|
103
|
+
newRights['camera'] = tools['camera']
|
|
104
|
+
//和缓新版sdk加号权益与光和不通,隐藏处理,光和有自己的权益入口
|
|
105
|
+
if (isGuangHeWmp()) {
|
|
106
|
+
return this.setData({ rights: this.getRightsData(newRights) })
|
|
107
|
+
}
|
|
108
|
+
//如果信息流不支持呼叫,则加号中只显示相机和相片
|
|
109
|
+
if (!this.data._request.callBtnVisible) return this.setData({ rights: this.getRightsData(newRights) })
|
|
110
|
+
//给家人用(分享卡片)
|
|
111
|
+
this.checkShareRight(this.properties.shareCard, 1)
|
|
112
|
+
//if (this.checkShareRight(this.properties.shareCard, SHARE_RIGHT_ENUM.SHARE_CARD) && this.data.memberList.length && !this.data.memberList[0].pid) newRights['share_card'] = tools['share_card']
|
|
113
|
+
if (this.checkShareRight(this.properties.shareCard, SHARE_RIGHT_ENUM.SHARE_FAMILY) && this.data.memberList.length && !this.data.memberList[0].pid) newRights['share_family'] = tools['share_family']
|
|
114
|
+
//如果loadfCfg配置了hideProductRightListWmp,则隐藏以下所有权益
|
|
115
|
+
if (!this.properties.loadCfg?.hideProductRightListWmp) {
|
|
116
|
+
if (productRightList && this.data.memberList.length && 'temp' != this.data.memberList[0].kind && this.data._request.bottomRightsVisible) {
|
|
117
|
+
productRightList.map((item, index) => {
|
|
118
|
+
//不隐藏专家权益,由服务器控制是否显示 @yuanweigang @liufangyuan
|
|
119
|
+
if (item.serviceType && item.icon2) {
|
|
120
|
+
if (item.rule && typeof item.rule == 'string') {
|
|
121
|
+
item.rule = JSON.parse(item.rule)
|
|
122
|
+
}
|
|
123
|
+
item['index'] = index
|
|
124
|
+
newRights[item.serviceType] = item
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
if (this.data.memberList.length && !this.data.memberList[0].isAccount && this.data.manyVideo) {
|
|
129
|
+
newRights['many_video'] = tools['many_video']
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
this.setData({ rights: this.getRightsData(newRights) })
|
|
133
|
+
},
|
|
134
|
+
/** 检查分享权限 */
|
|
135
|
+
checkShareRight(shareCardConfig, shareRight) {
|
|
136
|
+
if ('undefined' == typeof shareCardConfig) return 0
|
|
137
|
+
let hex = this.toHex(shareCardConfig)
|
|
138
|
+
let val = parseInt(hex.substr(hex.length - shareRight - 1, 1))
|
|
139
|
+
return val
|
|
140
|
+
},
|
|
141
|
+
toHex(val) {
|
|
142
|
+
let hex = new Number(parseInt(val)).toString(2)
|
|
143
|
+
if (hex.length >= 4) return hex
|
|
144
|
+
for (let i = 0; i < (5 - hex.length); i++) hex = ('0' + hex)
|
|
145
|
+
return hex
|
|
146
|
+
},
|
|
147
|
+
getRightsData(rights) {
|
|
148
|
+
let rightsData = []
|
|
149
|
+
let count = -1
|
|
150
|
+
let rightList = this.getArrSort(rights)
|
|
151
|
+
rightList.map((item, index) => {
|
|
152
|
+
index % 8 == 0 && count++
|
|
153
|
+
if (typeof rightsData[count] == 'undefined') {
|
|
154
|
+
rightsData[count] = []
|
|
155
|
+
}
|
|
156
|
+
rightsData[count].push(item)
|
|
157
|
+
})
|
|
158
|
+
//console.log(rightsData)
|
|
209
159
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
bindkeyboardheightchange(e) {
|
|
213
|
-
if (e.detail.height) this._showUtils(false);
|
|
214
|
-
setTimeout(() => {
|
|
215
|
-
that.setData({ kbHeight: e.detail.height })
|
|
216
|
-
that.triggerEvent('keyboardheightchange', e.detail)
|
|
217
|
-
}, 150)
|
|
218
|
-
},
|
|
160
|
+
return rightsData
|
|
161
|
+
},
|
|
219
162
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
163
|
+
getArrSort(arr) {
|
|
164
|
+
let newArr = [arr['camera'], arr['album']]
|
|
165
|
+
if (arr['many_video']) {
|
|
166
|
+
newArr.push(arr['many_video'])
|
|
167
|
+
delete arr['many_video']
|
|
168
|
+
}
|
|
169
|
+
delete arr['camera']
|
|
170
|
+
delete arr['album']
|
|
171
|
+
return newArr.concat(Object.values(arr))
|
|
172
|
+
},
|
|
173
|
+
bindEveryIcon(e) {
|
|
174
|
+
this.triggerEvent('everyIcon', e.currentTarget.dataset)
|
|
175
|
+
},
|
|
176
|
+
_share(e) {
|
|
177
|
+
this.triggerEvent('share', {}, {})
|
|
178
|
+
},
|
|
179
|
+
//点击右侧加号
|
|
180
|
+
_showHideUtils() {
|
|
181
|
+
this.setData({
|
|
182
|
+
isShowToolBar: !this.data.isShowToolBar
|
|
183
|
+
})
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
//显示隐藏工具栏
|
|
187
|
+
_showUtils(visible) {
|
|
188
|
+
// this.setData({
|
|
189
|
+
// bottomHeight: visible ? 260 : 70,
|
|
190
|
+
// safeAreaHight: visible ? 0 : 34
|
|
191
|
+
// })
|
|
192
|
+
this.setData({
|
|
193
|
+
isShowToolBar: visible
|
|
194
|
+
})
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
// 1. 切换显示语音输入和文字输入
|
|
198
|
+
_changeInputType() {
|
|
199
|
+
this._showUtils(false);
|
|
200
|
+
var isAudio = 'audio' == this.data.inputTypeClass;
|
|
201
|
+
this.setData({
|
|
202
|
+
inputTypeClass: isAudio ? 'keyboard' : 'audio',
|
|
203
|
+
inputTextVisible: !isAudio
|
|
204
|
+
})
|
|
205
|
+
},
|
|
206
|
+
//2. 获取文本焦点
|
|
207
|
+
bindFocusText() {
|
|
208
|
+
this.setData({ isInputTextFocus: true })
|
|
209
|
+
},
|
|
210
|
+
/** 3.失去文本焦点 */
|
|
211
|
+
bindBlurText() {
|
|
212
|
+
this.setData({ isInputTextFocus: false, kbHeight: 0 })
|
|
213
|
+
setTimeout(() => { that.triggerEvent('keyboardheightchange', { duration: 0, height: 0 }) }, 150)
|
|
214
|
+
|
|
215
|
+
},
|
|
216
|
+
/** 4.键盘高度发生变化 */
|
|
217
|
+
bindkeyboardheightchange(e) {
|
|
218
|
+
if (e.detail.height) this._showUtils(false);
|
|
219
|
+
setTimeout(() => {
|
|
220
|
+
that.setData({ kbHeight: e.detail.height })
|
|
221
|
+
that.triggerEvent('keyboardheightchange', e.detail)
|
|
222
|
+
}, 150)
|
|
223
|
+
},
|
|
250
224
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
225
|
+
/** 5.输入文本 */
|
|
226
|
+
_inputText(e) {
|
|
227
|
+
this.setData({
|
|
228
|
+
inputText: e.detail.value
|
|
229
|
+
})
|
|
230
|
+
},
|
|
231
|
+
/** 发送文本消息 */
|
|
232
|
+
_sendTextMsg(e) {
|
|
233
|
+
that.triggerEvent('sendTextMsg', that.data.inputText)
|
|
234
|
+
that.setData({
|
|
235
|
+
inputText: ''
|
|
236
|
+
})
|
|
237
|
+
},
|
|
238
|
+
_checkRecordAuth() {
|
|
239
|
+
wx.getSetting({
|
|
240
|
+
success(res) {
|
|
241
|
+
if (res.authSetting['scope.record'] === false) {
|
|
242
|
+
that.data.isRecordAuth = false;
|
|
243
|
+
}
|
|
244
|
+
if (res.authSetting['scope.record'] === true) {
|
|
245
|
+
that.data.isRecordAuth = true;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
},
|
|
250
|
+
bindAuthButton() {
|
|
257
251
|
that.setData({
|
|
258
|
-
|
|
259
|
-
isRecordAuth: true
|
|
252
|
+
isAuthBox: false
|
|
260
253
|
})
|
|
261
|
-
|
|
262
|
-
that.setData({ isAuthBox: true })
|
|
263
|
-
}
|
|
264
|
-
})
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
if (recording) {
|
|
268
|
-
wx.showToast({
|
|
269
|
-
title: '录音中请稍候',
|
|
270
|
-
icon: 'none'
|
|
271
|
-
})
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
254
|
+
},
|
|
274
255
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
256
|
+
// 录音 - 手指按下
|
|
257
|
+
_startRecord(e) {
|
|
258
|
+
if (!that.data.isRecordAuth) {
|
|
259
|
+
wx.authorize({
|
|
260
|
+
scope: 'scope.record',
|
|
261
|
+
success(s) {
|
|
262
|
+
that.setData({
|
|
263
|
+
isAuthBox: false,
|
|
264
|
+
isRecordAuth: true
|
|
265
|
+
})
|
|
266
|
+
},
|
|
267
|
+
fail() {
|
|
268
|
+
that.setData({ isAuthBox: true })
|
|
269
|
+
}
|
|
270
|
+
})
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (recording) {
|
|
274
|
+
wx.showToast({
|
|
275
|
+
title: '录音中请稍候',
|
|
276
|
+
icon: 'none'
|
|
277
|
+
})
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
285
280
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
281
|
+
this.setData({
|
|
282
|
+
recordBtnTip: '松开 结束',
|
|
283
|
+
recordMaskVisible: '',
|
|
284
|
+
recordCancel: false
|
|
285
|
+
})
|
|
286
|
+
recordStardPosition = e.touches[0].clientY;
|
|
287
|
+
rm.start({
|
|
288
|
+
format: 'mp3'
|
|
289
|
+
});
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
//录音 - 手指松开
|
|
293
|
+
_stopRecord(e) {
|
|
294
|
+
if (!that.data.isRecordAuth) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
this._doStopRecord()
|
|
298
|
+
.then(() => {
|
|
299
|
+
that.setData({
|
|
300
|
+
recordBtnTip: '按住 说话',
|
|
301
|
+
recordMaskVisible: 'hidden'
|
|
302
|
+
})
|
|
303
|
+
recordStardPosition = null;
|
|
304
|
+
})
|
|
305
|
+
},
|
|
306
|
+
//录音 - 停止录音
|
|
307
|
+
_doStopRecord() {
|
|
308
|
+
return new Promise((resolve, reject) => {
|
|
309
|
+
let t = setInterval(function() {
|
|
310
|
+
if (recording) {
|
|
311
|
+
clearInterval(t);
|
|
312
|
+
rm.stop();
|
|
313
|
+
resolve();
|
|
314
|
+
}
|
|
315
|
+
}, 100)
|
|
316
|
+
})
|
|
317
|
+
},
|
|
318
|
+
//录音 - 手指滑动 取消录音
|
|
319
|
+
_cancelRecord(e) {
|
|
320
|
+
if (recordStardPosition) {
|
|
321
|
+
var deltarY = Math.abs(e.touches[0].clientY - recordStardPosition);
|
|
322
|
+
if (deltarY > 50) {
|
|
323
|
+
this.setData({
|
|
324
|
+
recordCancel: true
|
|
325
|
+
})
|
|
326
|
+
} else {
|
|
327
|
+
this.setData({
|
|
328
|
+
recordCancel: false
|
|
329
|
+
})
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
//录音 - 开始录音
|
|
334
|
+
_onRecordStart() {
|
|
335
|
+
recording = true;
|
|
336
|
+
},
|
|
337
|
+
// 录音结束后调用上传
|
|
338
|
+
_onRecordStop(res) {
|
|
339
|
+
recording = false;
|
|
340
|
+
if (that.data.recordCancel) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (res.duration <= 500) {
|
|
344
|
+
wx.showToast({
|
|
345
|
+
title: '录音时长过短',
|
|
346
|
+
icon: 'none'
|
|
347
|
+
})
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
that.triggerEvent('sendAudio', {
|
|
351
|
+
tempFilePath: res.tempFilePath,
|
|
352
|
+
duration: res.duration
|
|
353
|
+
})
|
|
354
|
+
},
|
|
355
|
+
_callAsst(e) {
|
|
356
|
+
that.triggerEvent('callasst', { localVideoStatus: e.currentTarget.dataset.lvs })
|
|
357
|
+
},
|
|
358
|
+
_contactAsst(e) {
|
|
359
|
+
that.triggerEvent('contactasst', {})
|
|
324
360
|
}
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
//录音 - 开始录音
|
|
328
|
-
_onRecordStart() {
|
|
329
|
-
recording = true;
|
|
330
|
-
},
|
|
331
|
-
// 录音结束后调用上传
|
|
332
|
-
_onRecordStop(res) {
|
|
333
|
-
recording = false;
|
|
334
|
-
if (that.data.recordCancel) {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
if (res.duration <= 500) {
|
|
338
|
-
wx.showToast({
|
|
339
|
-
title: '录音时长过短',
|
|
340
|
-
icon: 'none'
|
|
341
|
-
})
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
that.triggerEvent('sendAudio', {
|
|
345
|
-
tempFilePath: res.tempFilePath,
|
|
346
|
-
duration: res.duration
|
|
347
|
-
})
|
|
348
|
-
},
|
|
349
|
-
_callAsst(e) {
|
|
350
|
-
that.triggerEvent('callasst', { localVideoStatus: e.currentTarget.dataset.lvs })
|
|
351
|
-
},
|
|
352
|
-
_contactAsst(e) {
|
|
353
|
-
that.triggerEvent('contactasst', {})
|
|
354
361
|
}
|
|
355
|
-
|
|
356
|
-
})
|
|
362
|
+
})
|