|
@@ -5,6 +5,7 @@ import user from '$config/user';
|
|
|
|
|
|
import {RowWheat} from '../const';
|
|
import {RowWheat} from '../const';
|
|
import {InstructionsMessageType} from "$utils/request";
|
|
import {InstructionsMessageType} from "$utils/request";
|
|
|
|
+import {WheatUseStatus} from "@/pages/talking/const/wheat";
|
|
|
|
|
|
export default <LibMixins>{
|
|
export default <LibMixins>{
|
|
|
|
|
|
@@ -17,13 +18,24 @@ export default <LibMixins>{
|
|
|
|
|
|
provide(){
|
|
provide(){
|
|
return {
|
|
return {
|
|
|
|
+ // 打开用户信息
|
|
openUserInfo:(event,userInfo)=> this.openUserInfo(event,userInfo),
|
|
openUserInfo:(event,userInfo)=> this.openUserInfo(event,userInfo),
|
|
|
|
+ // 申请上麦
|
|
applyForWheat:(index:number|undefined,host:boolean=false)=> this.applyForWheat(index,host),
|
|
applyForWheat:(index:number|undefined,host:boolean=false)=> this.applyForWheat(index,host),
|
|
|
|
+ // 下麦
|
|
exitForWheat:()=> this.exitForWheat(),
|
|
exitForWheat:()=> this.exitForWheat(),
|
|
|
|
+ // 取消排麦
|
|
cancelForWheat:()=> this.cancelForWheat(),
|
|
cancelForWheat:()=> this.cancelForWheat(),
|
|
|
|
+ // 获取房间信息
|
|
getRoomInfo: ()=> this.roomInfo,
|
|
getRoomInfo: ()=> this.roomInfo,
|
|
|
|
+ // 获取通话对象
|
|
getUseAgora:()=> this.useAgora || {},
|
|
getUseAgora:()=> this.useAgora || {},
|
|
- lockForWheat:(index)=>this.lockForWheat(index)
|
|
|
|
|
|
+ // 锁定麦位
|
|
|
|
+ lockForWheat:(index)=>this.lockForWheat(index),
|
|
|
|
+ // 解锁麦位
|
|
|
|
+ unLockForWheat:(index)=>this.unLockForWheat(index),
|
|
|
|
+ // 抱人上麦
|
|
|
|
+ allowForWheat:(user,index=undefined)=> this.allowForWheat(user,index)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -41,6 +53,62 @@ export default <LibMixins>{
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ // 允许某人上麦
|
|
|
|
+ allowForWheat(user,index=undefined){
|
|
|
|
+
|
|
|
|
+ return new Promise<void>((resolve, reject)=>{
|
|
|
|
+
|
|
|
|
+ if (this.allowForWheatStatus) return reject();
|
|
|
|
+
|
|
|
|
+ index = typeof index === 'number' ? index : this.getMicroIndex();
|
|
|
|
+
|
|
|
|
+ if (index !== null ) {
|
|
|
|
+ return popup.$confirm({
|
|
|
|
+ title:'是否操作'+user.nick_name+'上麦?',
|
|
|
|
+ successAsyncText:'操作成功',
|
|
|
|
+ confirm:()=>{
|
|
|
|
+ return new Promise( (c_resolve, c_reject) =>{
|
|
|
|
+ this.$request({
|
|
|
|
+ url:'room/room_owner_up_micro',
|
|
|
|
+ data:{
|
|
|
|
+ micro_id:index,
|
|
|
|
+ uid:user.uid,
|
|
|
|
+ rid: this.$params.rid
|
|
|
|
+ },
|
|
|
|
+ token:true,
|
|
|
|
+ failMessage:true,
|
|
|
|
+ next:({status})=> this.allowForWheatStatus = status,
|
|
|
|
+ message: InstructionsMessageType.other
|
|
|
|
+ }).then((data)=>{
|
|
|
|
+ if (data.isSuccess) {
|
|
|
|
+ this.updateMicro(index,user);
|
|
|
|
+ resolve(data);
|
|
|
|
+ c_resolve(true);
|
|
|
|
+ } else {
|
|
|
|
+ reject();
|
|
|
|
+ return c_resolve(false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }).catch(()=>{
|
|
|
|
+ c_reject();
|
|
|
|
+ reject();
|
|
|
|
+ });
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ cancel:function () {
|
|
|
|
+ return reject();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ popup.$toast('暂无可用麦位');
|
|
|
|
+ return reject();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+
|
|
// 申请上麦
|
|
// 申请上麦
|
|
applyForWheat(index:number|undefined,host:boolean=false){
|
|
applyForWheat(index:number|undefined,host:boolean=false){
|
|
|
|
|
|
@@ -51,7 +119,7 @@ export default <LibMixins>{
|
|
if (this.isAdmin) {
|
|
if (this.isAdmin) {
|
|
return popup.$confirm({
|
|
return popup.$confirm({
|
|
title: host ? '是否上主持位?' : this.wheat_status === RowWheat.none ? '是否上麦?' :'是否切换麦位?',
|
|
title: host ? '是否上主持位?' : this.wheat_status === RowWheat.none ? '是否上麦?' :'是否切换麦位?',
|
|
- successAsyncText:'上麦成功',
|
|
|
|
|
|
+ successAsyncText:this.wheat_status === RowWheat.none ? '上麦成功' : '切换成功',
|
|
confirm:()=>{
|
|
confirm:()=>{
|
|
|
|
|
|
index = typeof index === 'number' ? index : this.getMicroIndex();
|
|
index = typeof index === 'number' ? index : this.getMicroIndex();
|
|
@@ -149,10 +217,10 @@ export default <LibMixins>{
|
|
message: InstructionsMessageType.other
|
|
message: InstructionsMessageType.other
|
|
}).then((data)=>{
|
|
}).then((data)=>{
|
|
if (data.isSuccess) {
|
|
if (data.isSuccess) {
|
|
|
|
+ resolve(true);
|
|
this.upMicro({
|
|
this.upMicro({
|
|
uid:user.uid()
|
|
uid:user.uid()
|
|
});
|
|
});
|
|
- resolve(true);
|
|
|
|
} else {
|
|
} else {
|
|
resolve(false);
|
|
resolve(false);
|
|
}
|
|
}
|
|
@@ -200,7 +268,8 @@ export default <LibMixins>{
|
|
|
|
|
|
if (this.lockForWheatStatus) return;
|
|
if (this.lockForWheatStatus) return;
|
|
|
|
|
|
- if (index) {
|
|
|
|
|
|
+ // 麦位上不允许有人
|
|
|
|
+ if (index !== undefined && this.getMicroEmptyStatus(index)) {
|
|
popup.$confirm({
|
|
popup.$confirm({
|
|
title: '是否锁麦?',
|
|
title: '是否锁麦?',
|
|
successAsyncText: '锁麦成功',
|
|
successAsyncText: '锁麦成功',
|
|
@@ -218,7 +287,43 @@ export default <LibMixins>{
|
|
message: InstructionsMessageType.other
|
|
message: InstructionsMessageType.other
|
|
}).then((data)=>{
|
|
}).then((data)=>{
|
|
if (data.isSuccess) {
|
|
if (data.isSuccess) {
|
|
|
|
+ this.setMicroMcStatus(index,WheatUseStatus.lock);
|
|
|
|
+ resolve(true);
|
|
|
|
+ } else {
|
|
|
|
+ resolve(false);
|
|
|
|
+ }
|
|
|
|
+ }).catch(reject);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 解锁
|
|
|
|
+ unLockForWheat(index:number=0) {
|
|
|
|
+ if (this.unlockForWheatStatus) return;
|
|
|
|
+ // 同样麦位不允许有人
|
|
|
|
+ if (index !== undefined && this.getMicroEmptyStatus(index)) {
|
|
|
|
+ popup.$confirm({
|
|
|
|
+ title: '是否开放麦位?',
|
|
|
|
+ successAsyncText: '解锁成功',
|
|
|
|
+ confirm:()=>{
|
|
|
|
+ return new Promise((resolve, reject)=>{
|
|
|
|
+ return this.$request({
|
|
|
|
+ url:'room/unlock_room_micro',
|
|
|
|
+ data:{
|
|
|
|
+ rid: this.$params.rid,
|
|
|
|
+ micro_id:index
|
|
|
|
+ },
|
|
|
|
+ token:true,
|
|
|
|
+ failMessage:true,
|
|
|
|
+ next:({status})=> this.unlockForWheatStatus = status,
|
|
|
|
+ message: InstructionsMessageType.other
|
|
|
|
+ }).then((data)=>{
|
|
|
|
+ if (data.isSuccess) {
|
|
|
|
+ this.setMicroMcStatus(index,WheatUseStatus.normal);
|
|
resolve(true);
|
|
resolve(true);
|
|
} else {
|
|
} else {
|
|
resolve(false);
|
|
resolve(false);
|
|
@@ -228,9 +333,9 @@ export default <LibMixins>{
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+ },
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|