1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084 |
- <template>
- <div id="roomsDetail">
- <el-row style="height: 100vh;background: #FFF8DC1f">
- <el-col :span="24">
- <el-col :span="24" class="video" :style="{ height: oheight }"> </el-col>
- </el-col>
- <el-col :span="24">
- <el-col :span="24">
- <van-overlay :show="show" :style="{ height: oheight, width: '100%' }">
- <div id="transformid" class="wrapper" :style="{ transform: transform, height: vheight, width: vwidth, padding: vpadding, position: 'absolute' }">
- <van-col id="look-video-left" :span="stremlist.length == 2 ? 16 : 0" :style="{ height: oheight }"> </van-col>
- <van-col id="look-video-right" :style="{ height: oheight }" :span="stremlist.length == 1 ? 24 : 8"> </van-col>
- </div>
- <div id="othediv" v-show="othedivshow" :style="{ transform: transform, width: vwidth, padding: othepadding, position: 'absolute' }">
- <el-col
- :span="24"
- id="otheplaydiv"
- :style="{ height: otheheight, width: vwidth, background: background_ }"
- v-for="(item, index) in stremMeetlist"
- :key="index"
- >
- <div :id="item.id" :style="{ height: otheheight, width: othewidth }" class="video-box col-div othe-video-left"></div>
- </el-col>
- </div>
- </van-overlay>
- </el-col>
- <el-col :span="24" id="videobtnid" :style="`text-align:${balign};bottom:${bbottom};top:${btop}`">
- <el-button type="warning" round @click="full()" size="mini"><i class="el-icon-rank"></i></el-button>
- </el-col>
- </el-col>
- <el-col :span="24" class="chatrow">
- <el-col :span="12" class="num">
- <span>直播中:{{ total }}</span>
- </el-col>
- <el-col :span="12" class="meetBtn">
- <el-button v-show="switchbtn" type="warning" round size="small" @click="roomMeetBtn()"
- >苹果用户互动<i class="el-icon-camera el-icon--right"></i
- ></el-button>
- </el-col>
- </el-col>
- <el-col :span="24" class="gnanBtn">
- <van-tabs type="card" @click="tabsClick">
- <van-tab title="会议简介">
- <van-col :span="24">
- <van-col class="content">{{ roomInfos.content }}</van-col>
- </van-col>
- <van-col :span="24">
- <van-swipe :autoplay="3000">
- <van-swipe-item v-for="(advert, index) in roomInfos.adverts" :key="index">
- <img width="100%" height="100px" v-lazy="advert.imgdir" @click="imgclick(advert.imgurl)" />
- </van-swipe-item>
- </van-swipe>
- </van-col>
- </van-tab>
- <van-tab title="互动留言">
- <el-col :span="24" class="hdly">
- <el-col :span="24" class="chatInfo" id="chatSell">
- <el-col :span="24" class="list" v-for="(item, index) in dataList" :key="index">
- <p>
- <span :class="item.sendname == user.name ? 'selfColor' : ''">{{ item.sendname }}:</span>
- <span>{{ item.content }}</span>
- </p>
- </el-col>
- </el-col>
- <el-col :span="24" class="submit">
- <el-col :span="20" class="input">
- <el-input type="textarea" maxlength="5000" :rows="1" v-model="content"></el-input>
- </el-col>
- <el-col :span="4" class="btn">
- <el-button type="primary" size="mini" @click="chatCreate">发送</el-button>
- </el-col>
- </el-col>
- </el-col>
- </van-tab>
- <van-tab title="参与成员">
- <el-col :span="24" class="chry">
- <el-col :span="6" class="userList" v-for="(item, index) in userList" :key="index">
- <i class="el-icon-user-solid"></i>
- <p>{{ item.username }}</p>
- </el-col>
- </el-col>
- </van-tab>
- <van-tab title="申请评分">
- <van-col span="24">
- <van-form @submit="sqClick">
- <van-field v-model="form.hosname" left-icon="wap-home-o" name="hosname" label="单位" placeholder="请填写单位名称" />
- <van-field v-model="form.deptname" left-icon="apps-o" name="deptname" label="科室" placeholder="请填写科室名称" />
- <van-field v-model="form.level" left-icon="gem-o" name="level" label="职称" placeholder="请填写职称" />
- <van-field v-model="form.major" left-icon="user-o" name="major" label="专业" placeholder="请填写专业" />
- <van-field v-model="form.isxf" name="isxf" left-icon="star-o" label="学分" type="number" placeholder="请填写需要授予学分" />
- <div style="margin: 16px;">
- <van-button round block type="info" native-type="sqClick">
- 申请
- </van-button>
- </div>
- </van-form>
- </van-col>
- </van-tab>
- </van-tabs>
- </el-col>
- </el-row>
- <van-popup v-model="showQuest" position="bottom">
- <van-col :span="24" class="questtitle">
- <span>{{ questInfo.name }}</span>
- </van-col>
- <van-col class="questpopup" :span="24" v-for="(item, index) in questInfo.question" :key="index">
- <p style="margin:5px 0;">
- {{ index + 1 }}({{ item.type == '0' ? '单选' : item.type == '1' ? '多选' : item.type == '2' ? '问答' : '未识别' }})、{{ item.topic }}
- </p>
- <span v-if="item.type == '0'">
- <van-radio-group v-model="item.answer">
- <van-radio v-for="(i, ri) in item.option" :key="`${index}-${ri}`" :name="i.opname">{{ i.opname }}</van-radio>
- </van-radio-group>
- </span>
- <span v-if="item.type == '1'">
- <van-checkbox-group v-model="item.answer">
- <van-checkbox shape="square" v-for="(i, ci) in item.option" :key="`${index}-${ci}`" :name="i.opname">{{ i.opname }}</van-checkbox>
- </van-checkbox-group>
- </span>
- <span v-if="item.type == '2'">
- <van-field v-model="item.answer" type="textarea" rows="2" autosize placeholder="请输入" maxlength="200" show-word-limit />
- </span>
- </van-col>
- <van-col :span="24" class="questbtn">
- <van-button color="linear-gradient(to right, #4bb0ff, #6149f6)" @click="submitQuest">提交</van-button>
- </van-col>
- </van-popup>
- </div>
- </template>
- <script>
- import TRTC from 'trtc-js-sdk';
- import { mapState, createNamespacedHelpers } from 'vuex';
- import Vue from 'vue';
- import { Swipe, SwipeItem, Lazyload } from 'vant';
- import { Image as VanImage } from 'vant';
- import wx from 'weixin-js-sdk';
- Vue.use(Swipe);
- Vue.use(SwipeItem);
- Vue.use(VanImage);
- Vue.use(Lazyload);
- const { mapActions: uploadquestion } = createNamespacedHelpers('uploadquestion');
- const { mapActions: gensign } = createNamespacedHelpers('gensign');
- const { mapActions: room } = createNamespacedHelpers('room');
- const { mapActions: quest } = createNamespacedHelpers('quest');
- const { mapActions: chat } = createNamespacedHelpers('chat');
- export default {
- name: 'roomsDetail',
- props: {},
- components: {},
- data: function() {
- return {
- client_: null,
- localStream_: null,
- sdkAppId_: '1400380125',
- userId_: '',
- roomInfos: {},
- sendmemo: '',
- total: 0,
- transform: 'rotate(0)',
- oheight: '200px',
- vwidth: '100%',
- vheight: '200px',
- rheight: '200px',
- rwidth: '30%',
- lheight: '200px',
- lwidth: '70%',
- show: true,
- vpadding: '0',
- othepadding: '200px 0px 0px 0px',
- othetop: '200px',
- balign: 'right',
- btop: '160px',
- bbottom: '',
- isscreen: false,
- content: '',
- dataList: [],
- lvideoid_: '',
- rvideoid_: '',
- userList: [],
- form: {},
- showQuest: false,
- queid: '',
- questInfo: {},
- switchbtn: false,
- switchmeetbtn: false,
- iscamera: false,
- otheheight: '10px',
- othewidth: '20%',
- bcolor: '#000',
- index_: 0,
- userindex_: 1,
- background_: '#000',
- swichusers: [],
- sbuser: '',
- othedivshow: false,
- shmaiindex: 0,
- stremlist: [],
- stremMeetlist: [],
- stremOtherlist: [],
- swichzjrid: '',
- swichzjrstatus: false,
- };
- },
- created() {
- this.initclient();
- this.lookuserSearch();
- this.lookusercountsel();
- this.chatSearch();
- this.userswichrole();
- },
- mounted() {
- this.channel();
- },
- destroyed() {
- const that = this;
- window.addEventListener('pagehide', function() {
- console.log('页面要关闭了');
- that.recordSave();
- });
- },
- methods: {
- ...gensign(['gensignFetch']),
- ...room(['lookuserFetch', 'fetch', 'lookusercount', 'lookquery', 'lookupdate', 'lookrecord', 'lookuserswichrole']),
- ...chat(['query', 'create']),
- ...quest(['questfetch']),
- ...uploadquestion({ upcreate: 'create', upquery: 'query' }),
- reviewVideo(newstrem, newid, oldstrem, oldid) {
- oldstrem.stop();
- newstrem.stop();
- oldstrem.play(newid);
- newstrem.play(oldid);
- },
- stermPlay(strem, id) {
- strem.play(id);
- },
- stermStop(strem) {
- strem.stop();
- },
- zbfullbtn() {
- const width = document.documentElement.clientWidth;
- const lvr_ = document.getElementById('look-video-right');
- let style = 'width:' + width + 'px;';
- style += 'height:200px;';
- style += 'position:absolute;top:0;left:0;';
- style += 'z-index:1;';
- lvr_.style.cssText = style;
- },
- zbfpbtn() {
- const width = document.documentElement.clientWidth;
- const lvr_ = document.getElementById('look-video-right');
- let stylel = 'width:30%;';
- stylel += 'height:200px;';
- lvr_.style.cssText = style;
- const lvl_ = document.getElementById('look-video-left');
- let stylell = 'width:70%;';
- stylell += 'height:200px;';
- lvl_.style.cssText = stylell;
- },
- swichposition(objid) {
- console.log('in swichposition---' + objid);
- if (objid) {
- console.log(this.stremMeetlist);
- const oldstrem_ = _.find(this.stremlist, { type: 'mainr' });
- console.log(oldstrem_);
- const swichstrem = _.find(this.stremMeetlist, { swichuserid: objid });
- if (swichstrem) {
- this.reviewVideo(swichstrem.strem, swichstrem.id, oldstrem_.strem, 'look-video-right');
- }
- } else {
- console.log('share--' + this.othedivshow);
- const oldstrem_ = _.find(this.stremlist, { type: 'mainr' });
- this.stermStop(oldstrem_.strem);
- console.log('ddddddddd' + this.swichzjrid);
- if (!this.swichzjrid) {
- console.log('ddddddddd');
- this.stermPlay(oldstrem_.strem, 'look-video-right');
- }
- if (this.othedivshow) {
- for (const elm of this.stremMeetlist) {
- this.stermStop(elm.strem);
- }
- }
- }
- },
- async recordSave() {
- console.log(2121);
- let data = {};
- data.type = '1';
- data.roomid = this.id;
- data.roomname = this.roomname;
- data.userid = this.user.uid;
- data.username = this.user.name;
- const res = await this.lookrecord(data);
- },
- async sqClick() {
- this.form.roomid = this.id;
- this.form.userid = this.user.uid;
- const res = await this.lookupdate(this.form);
- if (this.$checkRes(res)) {
- console.log(res.data);
- this.$message({
- message: '操作成功',
- type: 'success',
- });
- }
- },
- async tabsClick(name, title) {
- if (title === '参与成员') {
- this.lookuserQuery();
- }
- },
- async lookuserQuery({ skip = 0, limit = 1000 } = {}) {
- const info = { roomid: this.id };
- let res = await this.lookquery({ skip, limit, ...info });
- this.$set(this, `userList`, res.data);
- },
- async chatSearch({ skip = 0, limit = 1000 } = {}) {
- const info = { roomid: this.id };
- let res = await this.query({ skip, limit, ...info });
- this.$set(this, `dataList`, res.data);
- },
- async chatCreate() {
- let data = {};
- data.roomid = this.id;
- data.type = '0';
- data.content = this.content;
- data.sendid = this.user.uid;
- data.sendname = this.user.name;
- const res = await this.create(data);
- if (this.$checkRes(res)) {
- //this.$message('发送成功');
- this.content = '';
- }
- },
- channel() {
- console.log('in function:');
- console.log(`/exchange/switch_shmai_` + this.id);
- this.$stomp({
- [`/exchange/public_chat_` + this.id]: this.onMessage,
- });
- this.$stomp({
- [`/exchange/switch_role_` + this.user.uid]: this.onSwichMessage,
- });
- this.$stomp({
- [`/exchange/switch_shmai_` + this.id]: this.onSwichShmaiMessage,
- });
- this.$stomp({
- [`/exchange/quest_publish_` + this.id]: this.onQueMessage,
- });
- this.$stomp({
- [`/exchange/switch_zjr_` + this.id]: this.onZjrMessage,
- });
- this.$stomp({
- [`/exchange/switch_zb_` + this.id]: this.onZbMessage,
- });
- },
- onMessage(message) {
- // console.log('receive a message: ', message.body);
- let body = _.get(message, 'body');
- if (body) {
- body = JSON.parse(body);
- this.dataList.push(body);
- this.content = '';
- }
- this.$nextTick(() => {
- document.getElementById('chatSell').scrollTop = document.getElementById('chatSell').scrollHeight + 275;
- });
- },
- onQueMessage(message) {
- // console.log('receive a message: ', message.body);
- this.showQuest = true;
- let body = _.get(message, 'body');
- if (body) {
- body = JSON.parse(body);
- this.queid = body.queid;
- this.questSearch();
- }
- },
- onSwichMessage(message) {
- // console.log('receive a message: ', message.body);
- let body = _.get(message, 'body');
- if (body) {
- body = JSON.parse(body);
- if (body.switchrole === 'anchor' && body.userid === this.user.uid) {
- this.switchbtn = true;
- this.switchmeetbtn = true;
- this.roomMeetSwich();
- } else {
- this.switchbtn = false;
- this.switchmeetbtn = false;
- }
- if (body.switchrole === 'audience') {
- const oldstrem_ = _.find(this.stremlist, { type: 'mainr' });
- if (oldstrem_) {
- this.stermStop(oldstrem_.strem);
- this.stermPlay(oldstrem_.strem, 'look-video-right');
- }
- console.log('移除body.userid--' + body.userid);
- console.log('移除this.user.uid--' + this.user.uid);
- if (body.userid === this.user.uid) {
- console.log(this.localStream_);
- this.stermStop(this.localStream_);
- this.localStream_.muteAudio();
- this.localStream_.muteVideo();
- this.localStream_.close();
- const newdatas = [];
- for (const elm of this.stremMeetlist) {
- if (elm.swichuserid !== body.userid) {
- newdatas.push(elm);
- }
- }
- this.$set(this, `stremMeetlist`, newdatas);
- }
- }
- }
- },
- onSwichShmaiMessage(message) {
- let body = _.get(message, 'body');
- console.log(body);
- console.log(this.user.uid);
- if (body) {
- body = JSON.parse(body);
- this.swichposition(body.shmaiid);
- }
- },
- onZjrMessage(message) {
- let body = _.get(message, 'body');
- if (body) {
- body = JSON.parse(body);
- if (body.switchzjr) {
- this.swichzjrstatus = true;
- this.swichzjrid = body.switchzjr;
- this.swichzjrVideo(body.switchzjr);
- } else {
- this.swichzjrstatus = false;
- }
- }
- },
- onZbMessage(message) {
- let body = _.get(message, 'body');
- if (body) {
- body = JSON.parse(body);
- this.swichzjrstatus = false;
- this.swichzbVideo(body);
- }
- },
- onOtheMessage(message) {
- let body = _.get(message, 'body');
- if (body) {
- body = JSON.parse(body);
- if (body.otheid) {
- this.switchbtn = true;
- this.roomMeetBtn();
- } else {
- this.switchbtn = false;
- }
- }
- },
- async swichzjrVideo(switchzjr) {
- //
- if (this.stremOtherlist.length > 0) {
- const swichstrem = _.find(this.stremOtherlist, { switchzjrid: switchzjr, type: 'other' });
- if (swichstrem) {
- for (const oldstrem_ of this.stremlist) {
- if (oldstrem_.type === 'mainr') {
- this.stermStop(oldstrem_.strem);
- }
- }
- this.stermPlay(swichstrem.strem, 'look-video-right');
- }
- }
- },
- async swichzbVideo(body) {
- //
- const mainstrem_ = _.find(this.stremlist, { type: 'mainr' });
- const newdatas = [];
- if (body.switchzjr) {
- const othestrem_ = _.find(this.stremOtherlist, { switchzjrid: body.switchzjr, type: 'other' });
- if (othestrem_) {
- this.stermStop(othestrem_.strem);
- }
- }
- if (mainstrem_) {
- newdatas.push(mainstrem_);
- this.$set(this, `stremlist`, newdatas);
- this.stermStop(mainstrem_.strem);
- this.stermPlay(mainstrem_.strem, 'look-video-right');
- }
- const sharestrem_ = _.find(this.stremlist, { type: 'share' });
- if (sharestrem_) {
- this.stermStop(sharestrem_.strem);
- }
- },
- async userswichrole() {
- // 根据房间id查询房间详细信息
- let result = await this.lookuserswichrole({ roomid: this.id, userid: this.user.uid });
- if (this.$checkRes(result)) {
- if (result.data && result.data.switchrole === 'anchor') {
- this.switchbtn = true;
- }
- }
- },
- roomMeetBtn() {
- const url = '/pages/meeting/meeting?uid=' + this.user.uid + '&username=' + this.user.name + '&rid=' + this.id + '&roomname=' + this.roomname;
- console.log(url);
- wx.miniProgram.navigateTo({ url });
- },
- async roomMeetSwich() {
- this.othedivshow = true;
- this.oheight = '270px';
- this.otheheight = '70px';
- this.iscamera = true;
- const _userid = 'meetu-' + this.userId_;
- this.localStream_ = await TRTC.createStream({
- audio: true,
- video: true,
- // cameraId: this.cameraId,
- // microphoneId: this.microphoneId,
- userId: _userid,
- });
- this.localStream_.setVideoProfile('480p');
- await this.localStream_.initialize();
- console.log('initialize local stream success');
- // publish the local stream
- await this.client_.publish(this.localStream_);
- this.index_ = this.index_ + 1;
- if (this.index_ < 11) {
- // const otheplaydiv = document.getElementById('otheplaydiv');
- const id_ = 'othe-video-' + this.index_;
- const newdata_ = { strem: this.localStream_, index: this.index_, id: id_, swichuserid: this.userId_ };
- this.stremMeetlist.push(newdata_);
- // const newdiv = '<div id="' + id_ + '" style="height: 70px, width: 20%" class="video-box col-div othe-video-left"></div>';
- // otheplaydiv.appendChild(newdiv);
- const newdata = { swichuserid: this.userId_, swichindex: this.index_ };
- this.swichusers.push(newdata);
- console.log('将用户push到列表里' + this.swichusers);
- this.$nextTick(() => {
- this.localStream_.play(id_);
- });
- }
- },
- async questSearch() {
- if (this.queid) {
- const result = await this.questfetch(this.queid);
- if (this.$checkRes(result)) {
- console.log(result.data);
- this.$set(this, `questInfo`, result.data);
- }
- }
- },
- async submitQuest() {
- let form = { roomid: this.id, userid: this.user.uid, questionnaireid: this.queid };
- let answers = [];
- for (const question of this.questInfo.question) {
- answers.push({ questionid: question._id, answer: JSON.stringify(question.answer) });
- }
- form.answers = answers;
- console.log(form);
- let res = await this.upcreate(form);
- if (res.errcode == '0') {
- this.showQuest = false;
- }
- },
- async lookuserSearch() {
- if (this.user.uid) {
- let data = {};
- data.roomid = this.id;
- data.roomname = this.roomname;
- data.userid = this.user.uid;
- data.username = this.user.name;
- const res = await this.lookuserFetch(data);
- }
- // 根据房间id查询房间详细信息
- let result = await this.fetch(this.id);
- if (this.$checkRes(result)) {
- console.log(result.data);
- this.$set(this, `roomInfos`, result.data);
- if (result.data.switchzjr) {
- this.swichzjrid = result.data.switchzjr;
- this.swichzjrstatus = true;
- }
- // 根据房间信息判断是否回答问卷
- if (result.data.isque === '1') {
- const info = { roomid: this.id, userid: this.user.uid, questionnaireid: result.data.queid };
- const skip = 0;
- const limit = 10;
- const upres = await this.upquery({ skip, limit, ...info });
- if (this.$checkRes(upres)) {
- if (upres.data.length === 0) {
- this.showQuest = true;
- this.queid = result.data.queid;
- this.questSearch();
- }
- }
- }
- // 根据是否上麦进行上麦判断
- }
- },
- async lookusercountsel() {
- // 根据房间id查询房间详细信息
- let result = await this.lookusercount({ roomname: this.roomname });
- if (this.$checkRes(result)) {
- console.log(result.total);
- this.$set(this, `total`, result.total);
- }
- },
- onSubmit() {
- console.log(this.sendmemo);
- },
- async initclient() {
- this.userId_ = this.user.uid;
- const _userid = 'meetu-' + this.userId_;
- const res = await this.gensignFetch({ userid: _userid });
- if (this.$checkRes(res)) {
- this.client_ = TRTC.createClient({
- mode: 'live',
- sdkAppId: this.sdkAppId_,
- userId: _userid,
- userSig: res.data,
- });
- await this.client_.join({ roomId: this.roomname, role: 'anchor' });
- this.client_.on('stream-subscribed', event => {
- const remoteStream = event.stream;
- // 远端流订阅成功,播放远端音视频流
- console.log(remoteStream);
- this.show = true;
- console.log('111' + remoteStream.getType());
- console.log('111' + remoteStream.getUserId());
- console.log('111' + remoteStream.getId());
- const userid_ = remoteStream.getUserId();
- const res_ = userid_.indexOf('-');
- const useridsplit_ = userid_.substring(0, 5);
- const userid_zs = userid_.substring(6);
- console.log('222--->' + useridsplit_);
- console.log('555--->' + userid_zs);
- if (useridsplit_ === 'share') {
- console.log('进入分享模式' + useridsplit_);
- const newdata_ = { strem: remoteStream, type: 'share' };
- const sharestrem_ = _.find(this.stremlist, { type: 'share' });
- if (sharestrem_) {
- const newdatas = [];
- newdatas.push(newdata_);
- const mainstrem_ = _.find(this.stremlist, { type: 'mainr' });
- if (mainstrem_) {
- newdatas.push(mainstrem_);
- }
- this.$set(this, `stremlist`, newdatas);
- } else {
- this.stremlist.push(newdata_);
- }
- this.lvideoid_ = 'video_' + remoteStream.getId();
- //this.zbfpbtn();
- this.swichposition();
- this.othedivshow = false;
- if (!this.isscreen) {
- this.oheight = '200px';
- this.otheheight = '1px';
- }
- console.log('进入分享模式' + this.lvideoid_);
- remoteStream
- .play('look-video-left')
- .then(() => {
- // autoplay success
- // 播放成功时调用css属性
- const _lvideoid_ = document.getElementById(this.lvideoid_);
- const style = 'width: 100%; height: 100%; position: absolute; transform: rotateY(0); object-fit: fill';
- _lvideoid_.style.cssText = style;
- })
- .catch(e => {
- const errorCode = e.getCode();
- if (errorCode === 0x4043) {
- // PLAY_NOT_ALLOWED,引导用户手势操作恢复音视频播放
- remoteStream.resume();
- }
- });
- } else if (useridsplit_ === 'mainr') {
- console.log('333');
- this.rvideoid_ = 'video_' + remoteStream.getId();
- // this.zbfullbtn();
- const newdata_ = { strem: remoteStream, type: 'mainr' };
- const mainstrem_ = _.find(this.stremlist, { type: 'mainr' });
- if (mainstrem_) {
- const newdatas = [];
- newdatas.push(newdata_);
- const sharestrem_ = _.find(this.stremlist, { type: 'share' });
- if (sharestrem_) {
- newdatas.push(sharestrem_);
- }
- this.$set(this, `stremlist`, newdatas);
- } else {
- this.stremlist.push(newdata_);
- }
- console.log('this.swichzjrid---' + this.swichzjrid);
- if (this.swichzjrid) {
- const swichstrem = _.find(this.stremOtherlist, { switchzjrid: this.swichzjrid, type: 'other' });
- if (swichstrem) {
- this.stermStop(swichstrem.strem);
- this.stermPlay(swichstrem.strem, 'look-video-right');
- } else {
- remoteStream
- .play('look-video-right')
- .then(() => {
- // autoplay success
- })
- .catch(e => {
- const errorCode = e.getCode();
- if (errorCode === 0x4043) {
- // PLAY_NOT_ALLOWED,引导用户手势操作恢复音视频播放
- remoteStream.resume();
- }
- });
- }
- } else {
- remoteStream
- .play('look-video-right')
- .then(() => {
- // autoplay success
- })
- .catch(e => {
- const errorCode = e.getCode();
- if (errorCode === 0x4043) {
- // PLAY_NOT_ALLOWED,引导用户手势操作恢复音视频播放
- remoteStream.resume();
- }
- });
- }
- } else if (useridsplit_ === 'other') {
- console.log('333');
- this.rvideoid_ = 'video_' + remoteStream.getId();
- const newdata_ = { strem: remoteStream, type: 'other', switchzjrid: userid_zs };
- this.stremOtherlist.push(newdata_);
- if (this.swichzjrid) {
- this.swichzjrVideo(userid_zs);
- }
- } else if (useridsplit_ === 'meetu') {
- console.log('333');
- console.log('公众号进入画面' + this.index_);
- this.othedivshow = true;
- this.oheight = '270px';
- this.otheheight = '70px';
- this.iscamera = true;
- this.index_ = this.index_ + 1;
- if (this.index_ < 11) {
- const id_ = 'othe-video-' + this.index_;
- const newdata_ = { strem: remoteStream, index: this.index_, id: id_, swichuserid: userid_zs };
- this.stremMeetlist.push(newdata_);
- console.log(id_);
- const newdata = { swichuserid: userid_zs, swichindex: this.index_ };
- this.swichusers.push(newdata);
- console.log('将用户push到列表里' + newdata);
- this.stermStop(remoteStream);
- this.$nextTick(() => {
- remoteStream.play(id_);
- });
- }
- } else if (useridsplit_ === 'wxxcx') {
- console.log('小程序进入画面' + this.index_);
- this.index_ = this.index_ + 1;
- if (this.index_ < 11) {
- const id_ = 'othe-video-' + this.index_;
- console.log(id_);
- remoteStream.play(id_);
- }
- }
- });
- // 监听远端流增加事件
- this.client_.on('stream-added', event => {
- const remoteStream = event.stream;
- console.log('222' + remoteStream.getType());
- // 订阅远端音频和视频流
- this.client_.subscribe(remoteStream, { audio: true, video: true }).catch(e => {
- console.error('failed to subscribe remoteStream');
- });
- });
- this.client_.on('stream-removed', event => {
- const remoteStream = event.stream;
- console.log('stop----');
- console.log(event);
- if (remoteStream) {
- const userid_ = remoteStream.getUserId();
- const useridsplit_ = userid_.substring(0, 5);
- const userid_zs = userid_.substring(6);
- console.log(useridsplit_);
- if (useridsplit_ === 'wxxcx' || useridsplit_ === 'meetu') {
- console.log('退出userid_' + useridsplit_);
- // 订阅远端音频和视频流
- if (this.index_ > 0) {
- this.index_ = this.index_ - 1;
- }
- const newdatas = [];
- for (const elm of this.stremMeetlist) {
- if (elm.swichuserid !== userid_zs) {
- newdatas.push(elm);
- }
- }
- this.$set(this, `stremMeetlist`, newdatas);
- } else if (useridsplit_ === 'share') {
- const newdatas = [];
- for (const elm of this.stremlist) {
- if (elm.type !== 'share') {
- newdatas.push(elm);
- }
- }
- this.$set(this, `stremlist`, newdatas);
- } else if (useridsplit_ === 'mainr') {
- const newdatas = [];
- this.$set(this, `stremlist`, newdatas);
- } else if (useridsplit_ === 'other') {
- const newdatas = [];
- for (const elm of this.stremOtherlist) {
- if (elm.switchzjrid !== userid_zs) {
- newdatas.push(elm);
- }
- }
- this.$set(this, `stremOtherlist`, newdatas);
- }
- }
- remoteStream.stop();
- });
- this.client_.on('mute-video', event => {
- const userid_ = event.userId;
- const useridsplit_ = userid_.substring(0, 5);
- const useridzs_ = userid_.substring(6);
- if (useridsplit_ === 'wxxcx' || useridsplit_ === 'meetu') {
- console.log('退出userid_' + useridzs_);
- const swichstrem = _.find(this.stremMeetlist, { swichuserid: useridzs_ });
- this.stermStop(swichstrem.strem);
- // 订阅远端音频和视频流
- if (this.index_ > 0) {
- this.index_ = this.index_ - 1;
- }
- const newdatas = [];
- for (const elm of this.stremMeetlist) {
- if (elm.swichuserid !== useridzs_) {
- newdatas.push(elm);
- }
- }
- this.$set(this, `stremMeetlist`, newdatas);
- }
- console.log('退出');
- console.log(event);
- console.log('退出remoteStream' + userid_);
- console.log('333--index---->' + this.index_);
- });
- }
- },
- imgclick(url) {
- location.href = url;
- },
- forOtherId(_index) {
- const index_ = _index + 1;
- return 'othe-video-' + index_;
- },
- full() {
- this.show = true;
- const width = document.documentElement.clientWidth;
- const height = document.documentElement.clientHeight;
- if (!this.isscreen) {
- console.log('全屏');
- this.isscreen = true;
- const transformid_ = document.getElementById('transformid');
- let style = 'width:' + height + 'px;';
- style += 'height:' + width + 'px;';
- style += '-webkit-transform: rotate(90deg); transform: rotate(90deg);';
- // 注意旋转中点的处理
- style += '-webkit-transform-origin: ' + width / 2 + 'px ' + width / 2 + 'px;';
- style += 'transform-origin: ' + width / 2 + 'px ' + width / 2 + 'px;';
- transformid_.style.cssText = style;
- this.transform = 'rotate(90deg)';
- // this.vwidth = height;
- console.log(height);
- console.log('this.othedivshow---' + this.othedivshow);
- if (this.othedivshow) {
- this.vheight = `${width - 70}px`;
- this.vwidth = `${height}px`;
- this.lheight = `${width - 70}px`;
- this.rheight = `${width - 70}px`;
- this.otheheight = '70px';
- this.oheight = `${width - 70}px`;
- } else {
- this.vheight = `${width}px`;
- this.vwidth = `${height}px`;
- this.lheight = `${width}px`;
- this.rheight = `${width}px`;
- this.oheight = `${width}px`;
- this.otheheight = '0px';
- //this.othepadding = `${width}px 0 0 0`;
- }
- this.balign = 'left';
- this.btop = '';
- this.bbottom = '10px';
- if (this.othedivshow) {
- const othediv_ = document.getElementById('othediv');
- let styleothe = 'width:' + height + 'px;';
- styleothe += 'height:' + 70 + 'px;';
- styleothe += '-webkit-transform: rotate(90deg); transform: rotate(90deg);';
- // // 注意旋转中点的处理
- styleothe += '-webkit-transform-origin: ' + width / 2 + 'px ' + width / 2 + 'px;';
- styleothe += 'transform-origin: ' + width / 2 + 'px ' + width / 2 + 'px;';
- othediv_.style.cssText = styleothe;
- this.otheheight = '70px';
- this.othewidth = '20%';
- const ppp_ = `${width - 70}px`;
- this.othepadding = `${width - 70}px 0 0 0`;
- }
- } else {
- console.log('退出全屏');
- this.isscreen = false;
- if (this.othedivshow) {
- this.oheight = '270px';
- } else {
- this.oheight = '200px';
- }
- const transformid_ = document.getElementById('transformid');
- let style = 'width:' + width + 'px;';
- style += 'height: 200px;';
- transformid_.style.cssText = style;
- this.transform = 'rotate(0deg)';
- // this.vwidth = height;
- console.log(height);
- this.vheight = `200px`;
- this.vwidth = `${width}px`;
- this.lheight = `200px`;
- this.rheight = `200px`;
- this.balign = 'right';
- this.btop = '160px';
- this.bbottom = '';
- if (this.othedivshow) {
- const othediv_ = document.getElementById('othediv');
- let styleothe = 'width:' + width + 'px;';
- styleothe += 'height:' + 70 + 'px;';
- // // 注意旋转中点的处理
- othediv_.style.cssText = styleothe;
- this.otheheight = '70px';
- this.othewidth = '20%';
- const ppp_ = `${width - 70}px`;
- this.othepadding = '200px 0 0 0';
- }
- }
- },
- },
- computed: {
- ...mapState(['user']),
- id() {
- return this.$route.query.id;
- },
- roomname() {
- return this.$route.query.roomname;
- },
- pageTitle() {
- return `${this.$route.meta.title}`;
- },
- },
- metaInfo() {
- return { title: this.$route.meta.title };
- },
- };
- </script>
- <style lang="less" scoped>
- .video {
- top: 0;
- left: 0;
- width: 100%;
- }
- .content {
- height: 425px;
- overflow: auto;
- padding: 10px;
- text-indent: 2rem;
- }
- .my-swipe .van-swipe-item {
- color: #fff;
- font-size: 20px;
- line-height: 120px;
- text-align: center;
- background-color: #39a9ed;
- }
- /deep/.video-js {
- height: 190px !important;
- border-radius: 10px;
- }
- .look-video-left {
- float: left;
- background: #000;
- grid-area: 1/1/3/4;
- justify-content: flex-end;
- }
- .look-video-right {
- float: right;
- background: #000;
- grid-area: 1/1/3/4;
- justify-content: flex-end;
- }
- #othediv {
- width: 100%;
- min-height: 0px;
- word-wrap: break-word;
- word-break: break-all;
- overflow: hidden;
- }
- .othe-video-left {
- float: left;
- background: #000;
- grid-area: 1/1/3/4;
- justify-content: flex-end;
- }
- .wrapper {
- background: #000;
- position: absolute;
- width: 100%;
- }
- .van-overlay {
- position: fixed;
- top: 0;
- left: 0;
- z-index: 1;
- width: 100%;
- height: 200px;
- background-color: rgba(0, 0, 0, 0.7);
- }
- #videobtnid {
- position: absolute;
- width: 100%;
- z-index: 999;
- padding: 0 10px;
- }
- .questpopup {
- padding: 10px 10px;
- }
- .questpopup div {
- padding: 8px 0 0 5px;
- }
- .questtitle {
- padding: 8px 0 0 5px;
- text-align: center;
- font-size: 18px;
- font-weight: bold;
- }
- .questbtn {
- text-align: center;
- padding: 10px 0 15px 0;
- }
- /deep/.van-cell {
- padding: 10px 15px;
- font-size: 16px;
- background-color: #ffffff1f;
- }
- .chatrow {
- padding: 10px 15px;
- }
- .gnanBtn {
- min-height: 425px;
- }
- .van-tabs {
- min-height: 425px;
- }
- /deep/.van-tabs__nav--card {
- margin: 0 10px;
- }
- .hdly {
- position: absolute;
- width: 100%;
- bottom: 0;
- }
- /deep/.el-button--mini,
- .el-button--mini.is-round {
- padding: 9px 18px;
- }
- .chry {
- padding: 10px;
- .userList {
- text-align: center;
- padding: 10px 0;
- box-shadow: 0 0 5px #ccc;
- border-radius: 5px;
- }
- }
- </style>
|