xinelu-applet-ui/pagesB/solution/solution.vue

131 lines
3.6 KiB
Vue
Raw Normal View History

2023-11-01 17:33:57 +08:00
<template>
<view>
2023-11-08 14:10:01 +08:00
<view class="" @tap='goroom'>
跳转跳转跳转跳转跳转跳转跳转跳转跳转跳转跳转跳转跳转跳转跳转跳转跳转跳转跳转跳转跳转
</view>
2023-11-01 17:33:57 +08:00
</view>
</template>
<script>
2023-11-08 09:54:26 +08:00
import {
getUserSig
} from '@/api/pagesB/solution/solution.js'
2023-11-01 17:33:57 +08:00
export default {
data() {
return {
2023-11-02 11:40:28 +08:00
src: '',
2023-11-08 09:54:26 +08:00
userSig: '',
item: {},
2023-11-08 14:10:01 +08:00
roomId: '',
authorizeMic: '',
authorizeCamera: '',
hasOpenDeviceAuthorizeModal: '',
2023-11-01 17:33:57 +08:00
};
},
2023-11-02 11:40:28 +08:00
methods: {
2023-11-08 14:10:01 +08:00
goroom() {
2023-11-08 15:33:37 +08:00
this.checkDeviceAuthorize().then((result) => {
console.log('授权成功', result)
uni.navigateTo({
url: `/pagesmeeting/room/room?sdkAppID=1600006944&localVideo=true&localAudio=true&userID=${this.item.patientId}&userName=${this.item.receiver}&userSig=${this.userSig}&roomID=${this.roomId}`
})
})
.catch((error) => {
console.log('没有授权', error)
})
2023-11-08 14:10:01 +08:00
},
checkDeviceAuthorize() {
this.hasOpenDeviceAuthorizeModal = false
return new Promise((resolve, reject) => {
if (!wx.getSetting || !wx.getSetting()) {
// 微信测试版 获取授权API异常目前只能即使没授权也可以通过
resolve()
}
wx.getSetting().then((result) => {
console.log('getSetting', result)
this.authorizeMic = result.authSetting['scope.record']
this.authorizeCamera = result.authSetting['scope.camera']
if (result.authSetting['scope.camera'] && result.authSetting['scope.record']) {
// 授权成功
resolve()
} else {
// 没有授权,弹出授权窗口
// 注意: wx.authorize 只有首次调用会弹框,之后调用只返回结果,如果没有授权需要自行弹框提示处理
console.log('getSetting 没有授权,弹出授权窗口', result)
wx.authorize({
scope: 'scope.record',
}).then((res) => {
console.log('authorize mic', res)
this.authorizeMic = true
if (this.authorizeCamera) {
resolve()
}
})
.catch((error) => {
console.log('authorize mic error', error)
this.authorizeMic = false
})
wx.authorize({
scope: 'scope.camera',
}).then((res) => {
console.log('authorize camera', res)
this.authorizeCamera = true
if (this.authorizeMic) {
resolve()
} else {
this.openConfirm()
reject(new Error('authorize fail'))
}
})
.catch((error) => {
console.log('authorize camera error', error)
this.authorizeCamera = false
this.openConfirm()
reject(new Error('authorize fail'))
})
}
})
})
},
openConfirm() {
if (this.hasOpenDeviceAuthorizeModal) {
return
}
this.hasOpenDeviceAuthorizeModal = true
return uni.showModal({
content: '您没有打开麦克风和摄像头的权限,是否去设置打开?',
confirmText: '确认',
cancelText: '取消',
success: (res) => {
this.hasOpenDeviceAuthorizeModal = false
console.log(res)
// 点击“确认”时打开设置页面
if (res.confirm) {
console.log('用户点击确认')
wx.openSetting({
success: (res) => {},
})
} else {
console.log('用户点击取消')
}
},
})
},
2023-11-08 09:54:26 +08:00
info() {
getUserSig(this.item.patientId).then(res => {
this.userSig = res.data
})
},
2023-11-01 17:33:57 +08:00
},
2023-11-02 11:40:28 +08:00
onLoad(options) {
2023-11-08 09:54:26 +08:00
this.item = JSON.parse(options.item)
this.roomId = options.roomId
this.info()
2023-11-02 11:40:28 +08:00
}
2023-11-01 17:33:57 +08:00
}
</script>
<style lang="scss">
2023-11-08 14:10:01 +08:00
</style>