|
@@ -1,138 +1,21 @@
|
|
|
-import user from '$config/user';
|
|
|
-import {RowWheat} from "@/pages/talking/const";
|
|
|
+import user from '$utils/control/user';
|
|
|
+import {Shield, UserConfigType} from "$utils/control/user/const";
|
|
|
|
|
|
export default <LibMixins>{
|
|
|
|
|
|
methods:{
|
|
|
|
|
|
- // 初始化麦位信息之后触发
|
|
|
- installMicroInfo(){
|
|
|
+ // 入场
|
|
|
+ addAdmission(item){
|
|
|
|
|
|
- let data = [this.microInfo.host_info,...this.microInfo.mc_list];
|
|
|
-
|
|
|
- let resultData = {};
|
|
|
- // 循环处理
|
|
|
- data.map((item)=>{
|
|
|
- if (item && item.mc_user_info && item.mc_user_info.uid) {
|
|
|
- resultData[item.mc_user_info.uid] = item;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
- this.micro_info = resultData;
|
|
|
- },
|
|
|
-
|
|
|
- // 查看用户是否出现在麦位信息中
|
|
|
- hasMicroInfo(){
|
|
|
- if (user.isLogin()) {
|
|
|
- return this.micro_info[user.uid()];
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- // 获取空缺麦位的位置
|
|
|
- getMicroIndex(uid =undefined){
|
|
|
- let mcList = this.microInfo.mc_list || [];
|
|
|
- for (let i=0,count=mcList.length;i<count;i++) {
|
|
|
- if (uid) {
|
|
|
- if (mcList[i] && mcList[i].mc_user_info && mcList[i].mc_user_info.uid === uid) {
|
|
|
- return i;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!mcList[i] || !mcList[i].mc_user_info || !mcList[i].mc_user_info.uid) {
|
|
|
- return i;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return null;
|
|
|
- },
|
|
|
-
|
|
|
- // 进入麦位坐下
|
|
|
- updateMicro(index:number | undefined,user){
|
|
|
-
|
|
|
- if (index === undefined) index = this.getMicroIndex();
|
|
|
-
|
|
|
- if (typeof index === 'number' && this.microInfo.mc_list) {
|
|
|
-
|
|
|
- // 如果存在于其他麦位直接退出
|
|
|
- this.exitMicro(user.uid);
|
|
|
-
|
|
|
- this.microInfo.mc_list[index].mc_status = 3;
|
|
|
- this.microInfo.mc_list[index].mc_user_info = user;
|
|
|
-
|
|
|
- // 更新麦位信息
|
|
|
- this.installMicroInfo();
|
|
|
+ // 检查权限是否屏蔽了进场特效
|
|
|
+ if (!user.getDataItem(UserConfigType.shield,Shield.approach) && item.zq_play_image) {
|
|
|
+ // 添加入场动画
|
|
|
+ this.$refs.admission && this.$refs.admission.pushQueue(item);
|
|
|
}
|
|
|
|
|
|
- },
|
|
|
-
|
|
|
- // 进入主持麦位
|
|
|
- updateHostMicro(user){
|
|
|
- // 如果满足以下条件触发
|
|
|
- if (this.microInfo && this.microInfo.host_info && !this.microInfo.host_info.uid) {
|
|
|
- // 如果存在于其他麦位直接退出
|
|
|
- this.exitMicro(user.uid);
|
|
|
- this.microInfo.host_info.mc_status = 3;
|
|
|
- this.microInfo.host_info.mc_user_info = user;
|
|
|
- // 更新麦位信息
|
|
|
- this.installMicroInfo();
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- // 设置坐下麦位
|
|
|
- downMicro({
|
|
|
- index,
|
|
|
- host,
|
|
|
- user
|
|
|
- }:Record<string, any> = {}){
|
|
|
-
|
|
|
- if (user) {
|
|
|
- if (host) {
|
|
|
- this.updateHostMicro(user);
|
|
|
- } else {
|
|
|
- this.updateMicro(index,user);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- this.setMicroStatus(RowWheat.wheat);
|
|
|
- return this.useAgora.joinPublished();
|
|
|
- },
|
|
|
-
|
|
|
- // 离开麦位
|
|
|
- upMicro({
|
|
|
- uid
|
|
|
- } = {}){
|
|
|
- if (uid) {
|
|
|
- this.exitMicro(uid);
|
|
|
- }
|
|
|
- this.setMicroStatus(RowWheat.none);
|
|
|
- return this.useAgora.unPublish();
|
|
|
- },
|
|
|
-
|
|
|
- exitMicro(uid){
|
|
|
- if (uid) {
|
|
|
- let item = this.micro_info[uid];
|
|
|
- if (item) {
|
|
|
- item.mc_status = 2;
|
|
|
- item.mc_user_info = {};
|
|
|
- // 更新麦位信息
|
|
|
- this.installMicroInfo();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- },
|
|
|
-
|
|
|
- setMicroStatus(status){
|
|
|
- if (this.wheat_status !== status) {
|
|
|
- this.wheat_status = status;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
- },
|
|
|
-
|
|
|
- created(){
|
|
|
- this.micro_info = {};
|
|
|
}
|
|
|
|
|
|
}
|