|
@@ -4,7 +4,7 @@ import {PopupExportComponent} from "$popup/popup-export/const";
|
|
|
import user from '$config/user';
|
|
|
|
|
|
import {RowWheat} from '../const';
|
|
|
-import {InstructionsMessageType} from "$utils/request";
|
|
|
+import {InstructionsCacheType, InstructionsMessageType} from "$utils/request";
|
|
|
import {WheatUseStatus} from "@/pages/talking/const/wheat";
|
|
|
|
|
|
export default <LibMixins>{
|
|
@@ -30,6 +30,8 @@ export default <LibMixins>{
|
|
|
getRoomInfo: ()=> this.roomInfo,
|
|
|
// 获取通话对象
|
|
|
getUseAgora:()=> this.useAgora || {},
|
|
|
+ // 获取聊天对象
|
|
|
+ getAgoraRTMIM:()=> this.agoraRTMIM || {},
|
|
|
// 锁定麦位
|
|
|
lockForWheat:(index)=>this.lockForWheat(index),
|
|
|
// 解锁麦位
|
|
@@ -44,11 +46,33 @@ export default <LibMixins>{
|
|
|
// 打开用户信息
|
|
|
openUserInfo(event,userInfo){
|
|
|
if (userInfo && userInfo.uid) {
|
|
|
- popup.$popup.open(PopupExportComponent.user,{
|
|
|
- el:event,
|
|
|
- value:true,
|
|
|
- item:userInfo
|
|
|
- });
|
|
|
+ if (this.openUserStatus) return;
|
|
|
+ this.$request({
|
|
|
+ url:'room/get_room_user_info',
|
|
|
+ data:{
|
|
|
+ rid: this.$params.rid,
|
|
|
+ uid: userInfo.uid
|
|
|
+ },
|
|
|
+ token:true,
|
|
|
+ cache:{
|
|
|
+ type: InstructionsCacheType.memory
|
|
|
+ },
|
|
|
+ next:({status})=> this.openUserStatus = status,
|
|
|
+ loading:'加载中'
|
|
|
+ }).then((data)=>{
|
|
|
+ popup.$popup.open(PopupExportComponent.user,{
|
|
|
+ el:event,
|
|
|
+ value:true,
|
|
|
+ item:data.data,
|
|
|
+ giveGift:(user)=>{
|
|
|
+ popup.$popup.open(PopupExportComponent.user);
|
|
|
+ if (user.uid) {
|
|
|
+ this.triggerChangeGiveUserId(user.uid,user);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+
|
|
|
}
|
|
|
|
|
|
},
|
|
@@ -68,31 +92,38 @@ export default <LibMixins>{
|
|
|
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 {
|
|
|
+
|
|
|
+ this.getUserWheatInfo(user.uid).then((wheatInfo)=>{
|
|
|
+
|
|
|
+ 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,wheatInfo);
|
|
|
+ this.sendWheatQueueInfo(wheatInfo,false);
|
|
|
+ resolve(data);
|
|
|
+ c_resolve(true);
|
|
|
+ } else {
|
|
|
+ reject();
|
|
|
+ return c_resolve(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ }).catch(()=>{
|
|
|
+ c_reject();
|
|
|
reject();
|
|
|
- return c_resolve(false);
|
|
|
- }
|
|
|
+ });
|
|
|
+ }).catch(c_reject);
|
|
|
+
|
|
|
|
|
|
- }).catch(()=>{
|
|
|
- c_reject();
|
|
|
- reject();
|
|
|
- });
|
|
|
})
|
|
|
},
|
|
|
cancel:function () {
|
|
@@ -126,34 +157,34 @@ export default <LibMixins>{
|
|
|
|
|
|
if (index != null) {
|
|
|
return new Promise<boolean>( (resolve, reject)=> {
|
|
|
- return this.$request({
|
|
|
- url:host ? 'room/host_up_micro' : 'room/user_up_micro',
|
|
|
- data:{
|
|
|
- rid: this.$params.rid,
|
|
|
- micro_id:typeof index === 'number'?index:''
|
|
|
- },
|
|
|
- token:true,
|
|
|
- failMessage:true,
|
|
|
- next:({status})=> this.applyForWheatStatus = status,
|
|
|
- message: InstructionsMessageType.other
|
|
|
- }).then((data)=>{
|
|
|
- if (data.isSuccess) {
|
|
|
- resolve(true);
|
|
|
-
|
|
|
- if (host) {
|
|
|
- this.updateHostMicro(user.user);
|
|
|
+ this.getUserWheatInfo(user.uid()).then((wheatInfo)=>{
|
|
|
+ return this.$request({
|
|
|
+ url:host ? 'room/host_up_micro' : 'room/user_up_micro',
|
|
|
+ data:{
|
|
|
+ rid: this.$params.rid,
|
|
|
+ micro_id:typeof index === 'number'?index:''
|
|
|
+ },
|
|
|
+ token:true,
|
|
|
+ failMessage:true,
|
|
|
+ next:({status})=> this.applyForWheatStatus = status,
|
|
|
+ message: InstructionsMessageType.other
|
|
|
+ }).then((data)=>{
|
|
|
+ if (data.isSuccess) {
|
|
|
+ resolve(true);
|
|
|
+ if (host) {
|
|
|
+ this.updateHostMicro(wheatInfo);
|
|
|
+ } else {
|
|
|
+ this.downMicro({
|
|
|
+ index,
|
|
|
+ user:wheatInfo
|
|
|
+ });
|
|
|
+ }
|
|
|
} else {
|
|
|
- this.downMicro({
|
|
|
- index,
|
|
|
- user:user.user
|
|
|
- });
|
|
|
+ resolve(false);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- } else {
|
|
|
- resolve(false);
|
|
|
- }
|
|
|
+ }).catch(reject);
|
|
|
}).catch(reject);
|
|
|
+
|
|
|
});
|
|
|
} else {
|
|
|
return popup.$toast('暂无可用麦位');
|
|
@@ -181,6 +212,8 @@ export default <LibMixins>{
|
|
|
if (data.isSuccess) {
|
|
|
// 设置状态为排麦中
|
|
|
this.setMicroStatus(RowWheat.queuing);
|
|
|
+ // 向其他人广播 目前个人处于排麦中
|
|
|
+ this.sendWheatQueueInfo(user.user,true);
|
|
|
resolve(true);
|
|
|
} else {
|
|
|
resolve(false);
|
|
@@ -197,6 +230,38 @@ export default <LibMixins>{
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ // 获取用户上麦信息
|
|
|
+ getUserWheatInfo(uid){
|
|
|
+ return new Promise((resolve, reject)=>{
|
|
|
+ return this.$request({
|
|
|
+ url:'hxuser/get_base_user_info',
|
|
|
+ data:{
|
|
|
+ uid
|
|
|
+ },
|
|
|
+ token:true,
|
|
|
+ failMessage:true,
|
|
|
+ message: InstructionsMessageType.other
|
|
|
+ }).then((data)=>{
|
|
|
+ if (data.isSuccess) {
|
|
|
+ data = data.data;
|
|
|
+ resolve({
|
|
|
+ avatar_base_image: data.avatar_base_image,
|
|
|
+ avatar_play_image: data.avatar_play_image,
|
|
|
+ charm_value: data.charm_level_info.now_value,
|
|
|
+ uid: data.uid,
|
|
|
+ nick_name:data.nick_name,
|
|
|
+ sex: data.sex,
|
|
|
+ head_pic: data.head_pic
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ reject();
|
|
|
+ }
|
|
|
+
|
|
|
+ }).catch(reject);
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
// 下麦
|
|
|
exitForWheat(){
|
|
|
if (this.hasMicroInfo(user.uid())) {
|
|
@@ -216,14 +281,10 @@ export default <LibMixins>{
|
|
|
next:({status})=> this.exitForWheatStatus = status,
|
|
|
message: InstructionsMessageType.other
|
|
|
}).then((data)=>{
|
|
|
- if (data.isSuccess) {
|
|
|
- resolve(true);
|
|
|
- this.upMicro({
|
|
|
- uid:user.uid()
|
|
|
- });
|
|
|
- } else {
|
|
|
- resolve(false);
|
|
|
- }
|
|
|
+ this.upMicro({
|
|
|
+ uid:user.uid()
|
|
|
+ });
|
|
|
+ resolve(true);
|
|
|
}).catch(reject);
|
|
|
})
|
|
|
}
|
|
@@ -252,6 +313,7 @@ export default <LibMixins>{
|
|
|
}).then((data)=>{
|
|
|
if (data.isSuccess) {
|
|
|
this.setMicroStatus(RowWheat.none);
|
|
|
+ this.sendWheatQueueInfo(user.user,false);
|
|
|
resolve(true);
|
|
|
} else {
|
|
|
resolve(false);
|
|
@@ -341,4 +403,4 @@ export default <LibMixins>{
|
|
|
|
|
|
|
|
|
|
|
|
-}
|
|
|
+}
|