roomDetail.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926
  1. <template>
  2. <div id="roomsDetail">
  3. <el-row>
  4. <el-col :span="24" class="video" :style="{ height: oheight }"> </el-col>
  5. </el-row>
  6. <van-overlay :show="show" :style="{ height: oheight, width: '100%' }">
  7. <div id="transformid" class="wrapper" :style="{ transform: transform, height: vheight, width: vwidth, padding: vpadding, position: 'absolute' }">
  8. <div :style="{ height: lheight, width: lwidth }" id="look-video-left" class="video-box col-div look-video-left"></div>
  9. <div id="look-video-right" :style="{ height: rheight, width: rwidth }" class="video-box col-div look-video-right"></div>
  10. </div>
  11. <div id="othediv" v-show="othedivshow" :style="{ transform: transform, height: otheheight, width: vwidth, padding: othepadding, position: 'absolute' }">
  12. <div id="otheplaydiv" :style="{ height: otheheight, width: vwidth, background: background_ }">
  13. <div id="othe-video-1" :style="{ height: otheheight, width: othewidth }" class="video-box col-div othe-video-left"></div>
  14. <div id="othe-video-2" :style="{ height: otheheight, width: othewidth }" class="video-box col-div othe-video-left"></div>
  15. <div id="othe-video-3" :style="{ height: otheheight, width: othewidth }" class="video-box col-div othe-video-left"></div>
  16. <div id="othe-video-4" :style="{ height: otheheight, width: othewidth }" class="video-box col-div othe-video-left"></div>
  17. <div id="othe-video-5" :style="{ height: otheheight, width: othewidth }" class="video-box col-div othe-video-left"></div>
  18. </div>
  19. </div>
  20. <div class="videoBtn" id="videobtnid" :style="{ top: btop, right: bright }">
  21. <el-button type="warning" round @click="full()" size="mini"><i class="el-icon-rank"></i></el-button>
  22. </div>
  23. </van-overlay>
  24. <el-row class="chatrow">
  25. <el-col :span="24" class="info">
  26. <el-col :span="12" class="num">
  27. <span>观看:{{ total }}</span>
  28. </el-col>
  29. <el-col :span="12" class="meetBtn">
  30. <el-button v-show="switchbtn" type="warning" round size="small" @click="roomMeetBtn()">小程序<i class="el-icon-camera el-icon--right"></i></el-button>
  31. </el-col>
  32. </el-col>
  33. </el-row>
  34. <van-tabs type="card" @click="tabsClick">
  35. <van-tab title="会议简介">
  36. <van-col :span="24">
  37. <van-col class="content">{{ roomInfos.content }}</van-col>
  38. </van-col>
  39. <van-col :span="24">
  40. <van-swipe :autoplay="3000">
  41. <van-swipe-item v-for="(advert, index) in roomInfos.adverts" :key="index">
  42. <img width="100%" height="100px" v-lazy="advert.imgdir" @click="imgclick(advert.imgurl)" />
  43. </van-swipe-item>
  44. </van-swipe>
  45. </van-col>
  46. </van-tab>
  47. <van-tab title="互动留言">
  48. <el-row>
  49. <el-col :span="24" class="info">
  50. <el-col :span="24" class="chat">
  51. <el-col :span="24" class="chatInfo" id="chatSell">
  52. <el-col :span="24" class="list" v-for="(item, index) in dataList" :key="index">
  53. <p>
  54. <span :class="item.sendname == user.name ? 'selfColor' : ''">{{ item.sendname }}:</span>
  55. <span>{{ item.content }}</span>
  56. </p>
  57. </el-col>
  58. </el-col>
  59. </el-col>
  60. <el-col :span="24" class="submit">
  61. <el-col :span="19" class="input">
  62. <el-input type="textarea" maxlength="5000" show-word-limit v-model="content"></el-input>
  63. </el-col>
  64. <el-col :span="5" class="btn">
  65. <el-button type="primary" size="mini" @click="chatCreate">发送</el-button>
  66. </el-col>
  67. </el-col>
  68. </el-col>
  69. </el-row>
  70. </van-tab>
  71. <van-tab title="参与成员">
  72. <van-col :span="24" class="userList">
  73. <van-grid :column-num="3">
  74. <van-grid-item v-for="(item, index) in userList" :key="index" icon="manager" :text="item.username" />
  75. </van-grid>
  76. </van-col>
  77. </van-tab>
  78. <van-tab title="申请评分">
  79. <van-col :span="24">
  80. <van-field v-model="isxf" name="isxf" left-icon="star-o" label="学分" type="number" placeholder="请填写需要授予学分" />
  81. </van-col>
  82. <van-col :span="24" style="text-align:center">
  83. <van-button icon="star-o" type="primary" @click="sqClick">
  84. 申请
  85. </van-button>
  86. </van-col>
  87. </van-tab>
  88. </van-tabs>
  89. <van-popup v-model="showQuest" position="bottom">
  90. <van-col :span="24" class="questtitle">
  91. <span>{{ questInfo.name }}</span>
  92. </van-col>
  93. <van-col class="questpopup" :span="24" v-for="(item, index) in questInfo.question" :key="index">
  94. <p style="margin:5px 0;">
  95. {{ index + 1 }}({{ item.type == '0' ? '单选' : item.type == '1' ? '多选' : item.type == '2' ? '问答' : '未识别' }})、{{ item.topic }}
  96. </p>
  97. <span v-if="item.type == '0'">
  98. <van-radio-group v-model="item.answer">
  99. <van-radio v-for="(i, ri) in item.option" :key="`${index}-${ri}`" :name="i.opname">{{ i.opname }}</van-radio>
  100. </van-radio-group>
  101. </span>
  102. <span v-if="item.type == '1'">
  103. <van-checkbox-group v-model="item.answer">
  104. <van-checkbox shape="square" v-for="(i, ci) in item.option" :key="`${index}-${ci}`" :name="i.opname">{{ i.opname }}</van-checkbox>
  105. </van-checkbox-group>
  106. </span>
  107. <span v-if="item.type == '2'">
  108. <van-field v-model="item.answer" type="textarea" rows="2" autosize placeholder="请输入" maxlength="200" show-word-limit />
  109. </span>
  110. </van-col>
  111. <van-col :span="24" class="questbtn">
  112. <van-button color="linear-gradient(to right, #4bb0ff, #6149f6)" @click="submitQuest">提交</van-button>
  113. </van-col>
  114. </van-popup>
  115. </div>
  116. </template>
  117. <script>
  118. import TRTC from 'trtc-js-sdk';
  119. import { mapState, createNamespacedHelpers } from 'vuex';
  120. import Vue from 'vue';
  121. import { Swipe, SwipeItem, Lazyload } from 'vant';
  122. import { Image as VanImage } from 'vant';
  123. import wx from 'weixin-js-sdk';
  124. Vue.use(Swipe);
  125. Vue.use(SwipeItem);
  126. Vue.use(VanImage);
  127. Vue.use(Lazyload);
  128. const { mapActions: uploadquestion } = createNamespacedHelpers('uploadquestion');
  129. const { mapActions: gensign } = createNamespacedHelpers('gensign');
  130. const { mapActions: room } = createNamespacedHelpers('room');
  131. const { mapActions: quest } = createNamespacedHelpers('quest');
  132. const { mapActions: chat } = createNamespacedHelpers('chat');
  133. export default {
  134. name: 'roomsDetail',
  135. props: {},
  136. components: {},
  137. data: function() {
  138. return {
  139. client_: null,
  140. localStream_: null,
  141. sdkAppId_: '1400380125',
  142. userId_: '',
  143. roomInfos: {},
  144. sendmemo: '',
  145. total: 0,
  146. transform: 'rotate(0)',
  147. oheight: '200px',
  148. vwidth: '100%',
  149. vheight: '200px',
  150. rheight: '200px',
  151. rwidth: '30%',
  152. lheight: '200px',
  153. lwidth: '70%',
  154. show: true,
  155. vpadding: '0',
  156. othepadding: '200px 0px 0px 0px',
  157. othetop: '200px',
  158. btop: '167px',
  159. bright: '10px',
  160. isscreen: false,
  161. content: '',
  162. dataList: [],
  163. lvideoid_: '',
  164. rvideoid_: '',
  165. userList: [],
  166. isxf: '',
  167. showQuest: false,
  168. queid: '',
  169. questInfo: {},
  170. switchbtn: false,
  171. switchmeetbtn: false,
  172. iscamera: false,
  173. otheheight: '10px',
  174. othewidth: '20%',
  175. bcolor: '#000',
  176. index_: 0,
  177. userindex_: 1,
  178. background_: '#000',
  179. swichusers: [],
  180. sbuser: '',
  181. othedivshow: false,
  182. shmaiindex: 0,
  183. };
  184. },
  185. created() {
  186. this.initclient();
  187. this.lookuserSearch();
  188. this.lookusercountsel();
  189. this.chatSearch();
  190. this.userswichrole();
  191. },
  192. mounted() {
  193. this.channel();
  194. },
  195. destroyed() {
  196. const that = this;
  197. window.addEventListener('pagehide', function() {
  198. console.log('页面要关闭了');
  199. that.recordSave();
  200. });
  201. },
  202. methods: {
  203. ...gensign(['gensignFetch']),
  204. ...room(['lookuserFetch', 'fetch', 'lookusercount', 'lookquery', 'lookupdate', 'lookrecord', 'lookuserswichrole']),
  205. ...chat(['query', 'create']),
  206. ...quest(['questfetch']),
  207. ...uploadquestion({ upcreate: 'create', upquery: 'query' }),
  208. zbfullbtn() {
  209. const width = document.documentElement.clientWidth;
  210. const lvr_ = document.getElementById('look-video-right');
  211. let style = 'width:' + width + 'px;';
  212. style += 'height:200px;';
  213. style += 'position:absolute;top:0;left:0;';
  214. style += 'z-index:1;';
  215. lvr_.style.cssText = style;
  216. },
  217. zbfpbtn() {
  218. const width = document.documentElement.clientWidth;
  219. const lvr_ = document.getElementById('look-video-right');
  220. let stylel = 'width:30%;';
  221. stylel += 'height:200px;';
  222. lvr_.style.cssText = style;
  223. const lvl_ = document.getElementById('look-video-left');
  224. let stylell = 'width:70%;';
  225. stylell += 'height:200px;';
  226. lvl_.style.cssText = stylell;
  227. },
  228. swichposition(objid) {
  229. console.log('in swichposition---' + objid);
  230. if (objid) {
  231. console.log(this.swichusers);
  232. const width = document.documentElement.clientWidth;
  233. for (const elm of this.swichusers) {
  234. if (elm.swichuserid === objid) {
  235. console.log('elm--->' + elm);
  236. const id_ = 'othe-video-' + elm.swichindex;
  237. this.shmaiindex = elm.swichindex;
  238. const thr_ = document.getElementById(id_);
  239. let style = 'width:70%;';
  240. style += 'height:200px;';
  241. style += 'position:absolute;top:0;left:0;';
  242. style += 'z-index:1;';
  243. thr_.style.cssText = style;
  244. } else {
  245. const id_ = 'othe-video-' + elm.swichindex;
  246. const thr_ = document.getElementById(id_);
  247. const left_ = (width / 5) * (elm.swichindex - 1);
  248. let style = 'width:20%;';
  249. style += 'height:70px;';
  250. style += 'position:absolute;top:200;';
  251. style = 'left:' + left_ + 'px;';
  252. thr_.style.cssText = style;
  253. }
  254. }
  255. } else {
  256. console.log('share--' + this.othedivshow);
  257. if (this.othedivshow) {
  258. if (this.shmaiindex !== 0) {
  259. const id_ = 'othe-video-' + this.shmaiindex;
  260. const thr_ = document.getElementById(id_);
  261. const left_ = (width / 5) * (i - 1);
  262. let style = 'width:20%;';
  263. style += 'height:70px;';
  264. style += 'background: blue;';
  265. style += 'position:absolute;top:200px;';
  266. style = 'left:' + left_ + 'px;';
  267. thr_.style.cssText = style;
  268. }
  269. }
  270. console.log('share设置大小--' + this.shmaiindex);
  271. const lvl_ = document.getElementById('look-video-left');
  272. let stylell = 'width:70%;';
  273. stylell += 'height:200px;';
  274. lvl_.style.cssText = stylell;
  275. }
  276. const lvr_ = document.getElementById('look-video-right');
  277. let stylel = 'width:30%;';
  278. stylel += 'height:200px;';
  279. lvr_.style.cssText = stylel;
  280. },
  281. async recordSave() {
  282. console.log(2121);
  283. let data = {};
  284. data.type = '1';
  285. data.roomid = this.id;
  286. data.roomname = this.roomname;
  287. data.userid = this.user.uid;
  288. data.username = this.user.name;
  289. const res = await this.lookrecord(data);
  290. },
  291. async sqClick() {
  292. let data = {};
  293. data.roomid = this.id;
  294. data.isxf = this.isxf;
  295. data.userid = this.user.uid;
  296. const res = await this.lookupdate(data);
  297. if (this.$checkRes(res)) {
  298. console.log(res.data);
  299. this.$message({
  300. message: '操作成功',
  301. type: 'success',
  302. });
  303. }
  304. },
  305. async tabsClick(name, title) {
  306. if (title === '参与成员') {
  307. this.lookuserQuery();
  308. }
  309. },
  310. async lookuserQuery({ skip = 0, limit = 1000 } = {}) {
  311. const info = { roomid: this.id };
  312. let res = await this.lookquery({ skip, limit, ...info });
  313. this.$set(this, `userList`, res.data);
  314. },
  315. async chatSearch({ skip = 0, limit = 1000 } = {}) {
  316. const info = { roomid: this.id };
  317. let res = await this.query({ skip, limit, ...info });
  318. this.$set(this, `dataList`, res.data);
  319. },
  320. async chatCreate() {
  321. let data = {};
  322. data.roomid = this.id;
  323. data.type = '0';
  324. data.content = this.content;
  325. data.sendid = this.user.uid;
  326. data.sendname = this.user.name;
  327. const res = await this.create(data);
  328. if (this.$checkRes(res)) {
  329. //this.$message('发送成功');
  330. this.content = '';
  331. }
  332. },
  333. channel() {
  334. console.log('in function:');
  335. console.log(`/exchange/switch_shmai_` + this.id);
  336. this.$stomp({
  337. [`/exchange/public_chat_` + this.id]: this.onMessage,
  338. });
  339. this.$stomp({
  340. [`/exchange/switch_role_` + this.user.uid]: this.onSwichMessage,
  341. });
  342. this.$stomp({
  343. [`/exchange/switch_shmai_` + this.id]: this.onSwichShmaiMessage,
  344. });
  345. this.$stomp({
  346. [`/exchange/quest_publish_` + this.id]: this.onQueMessage,
  347. });
  348. // this.$stomp({
  349. // [`/exchange/othe_publish_` + this.id]: this.onOtheMessage,
  350. // });
  351. },
  352. onMessage(message) {
  353. // console.log('receive a message: ', message.body);
  354. let body = _.get(message, 'body');
  355. if (body) {
  356. body = JSON.parse(body);
  357. this.dataList.push(body);
  358. this.content = '';
  359. }
  360. this.$nextTick(() => {
  361. document.getElementById('chatSell').scrollTop = document.getElementById('chatSell').scrollHeight + 275;
  362. });
  363. },
  364. onQueMessage(message) {
  365. // console.log('receive a message: ', message.body);
  366. this.showQuest = true;
  367. let body = _.get(message, 'body');
  368. if (body) {
  369. body = JSON.parse(body);
  370. this.queid = body.queid;
  371. this.questSearch();
  372. }
  373. },
  374. onSwichMessage(message) {
  375. // console.log('receive a message: ', message.body);
  376. let body = _.get(message, 'body');
  377. if (body) {
  378. body = JSON.parse(body);
  379. if (body.switchrole === 'anchor' && body.userid === this.user.uid) {
  380. this.switchbtn = true;
  381. this.switchmeetbtn = true;
  382. this.roomMeetSwich();
  383. } else {
  384. this.switchbtn = false;
  385. this.switchmeetbtn = false;
  386. }
  387. if (body.switchrole !== 'anchor' && body.userid === this.user.uid) {
  388. const videoTrack = this.localStream_.getVideoTrack();
  389. if (videoTrack) {
  390. this.localStream_.removeTrack(videoTrack).then(() => {
  391. console.log('remove video call success');
  392. // 关闭摄像头
  393. videoTrack.stop();
  394. // this.client_.unpublish(this.localStream_).then(() => {
  395. // // 取消发布本地流成功
  396. // });
  397. });
  398. }
  399. }
  400. }
  401. },
  402. onSwichShmaiMessage(message) {
  403. let body = _.get(message, 'body');
  404. console.log(body);
  405. console.log(this.user.uid);
  406. if (body) {
  407. body = JSON.parse(body);
  408. this.swichposition(body.shmaiid);
  409. }
  410. },
  411. onOtheMessage(message) {
  412. let body = _.get(message, 'body');
  413. if (body) {
  414. body = JSON.parse(body);
  415. if (body.otheid) {
  416. this.switchbtn = true;
  417. this.roomMeetBtn();
  418. } else {
  419. this.switchbtn = false;
  420. }
  421. }
  422. },
  423. async userswichrole() {
  424. // 根据房间id查询房间详细信息
  425. let result = await this.lookuserswichrole({ roomid: this.id, userid: this.user.uid });
  426. if (this.$checkRes(result)) {
  427. if (result.data && result.data.switchrole === 'anchor') {
  428. this.switchbtn = true;
  429. }
  430. }
  431. },
  432. roomMeetBtn() {
  433. const url = '/pages/meeting/meeting?uid=' + this.user.uid + '&username=' + this.user.name + '&rid=' + this.id + '&roomname=' + this.roomname;
  434. console.log(url);
  435. wx.miniProgram.navigateTo({ url });
  436. },
  437. async roomMeetSwich() {
  438. this.othedivshow = true;
  439. this.oheight = '270px';
  440. this.otheheight = '70px';
  441. this.iscamera = true;
  442. const _userid = 'meetu-' + this.userId_;
  443. this.localStream_ = await TRTC.createStream({
  444. audio: true,
  445. video: true,
  446. // cameraId: this.cameraId,
  447. // microphoneId: this.microphoneId,
  448. userId: _userid,
  449. });
  450. this.localStream_.setVideoProfile('480p');
  451. await this.localStream_.initialize();
  452. console.log('initialize local stream success');
  453. // publish the local stream
  454. await this.client_.publish(this.localStream_);
  455. this.index_ = this.index_ + 1;
  456. if (this.index_ < 6) {
  457. // const otheplaydiv = document.getElementById('otheplaydiv');
  458. const id_ = 'othe-video-' + this.index_;
  459. // const newdiv = '<div id="' + id_ + '" style="height: 70px, width: 20%" class="video-box col-div othe-video-left"></div>';
  460. // otheplaydiv.appendChild(newdiv);
  461. const newdata = { swichuserid: this.userId_, swichindex: this.index_ };
  462. this.swichusers.push(newdata);
  463. console.log('将用户push到列表里' + this.swichusers);
  464. this.localStream_.play(id_);
  465. }
  466. },
  467. async questSearch() {
  468. if (this.queid) {
  469. const result = await this.questfetch(this.queid);
  470. if (this.$checkRes(result)) {
  471. console.log(result.data);
  472. this.$set(this, `questInfo`, result.data);
  473. }
  474. }
  475. },
  476. async submitQuest() {
  477. let form = { roomid: this.id, userid: this.user.uid, questionnaireid: this.queid };
  478. let answers = [];
  479. for (const question of this.questInfo.question) {
  480. answers.push({ questionid: question._id, answer: JSON.stringify(question.answer) });
  481. }
  482. form.answers = answers;
  483. console.log(form);
  484. let res = await this.upcreate(form);
  485. if (res.errcode == '0') {
  486. this.showQuest = false;
  487. }
  488. },
  489. async lookuserSearch() {
  490. if (this.user.uid) {
  491. let data = {};
  492. data.roomid = this.id;
  493. data.roomname = this.roomname;
  494. data.userid = this.user.uid;
  495. data.username = this.user.name;
  496. const res = await this.lookuserFetch(data);
  497. }
  498. // 根据房间id查询房间详细信息
  499. let result = await this.fetch(this.id);
  500. if (this.$checkRes(result)) {
  501. console.log(result.data);
  502. this.$set(this, `roomInfos`, result.data);
  503. // 根据房间信息判断是否回答问卷
  504. if (result.data.isque === '1') {
  505. const info = { roomid: this.id, userid: this.user.uid, questionnaireid: result.data.queid };
  506. const skip = 0;
  507. const limit = 10;
  508. const upres = await this.upquery({ skip, limit, ...info });
  509. if (this.$checkRes(upres)) {
  510. if (upres.data.length === 0) {
  511. this.showQuest = true;
  512. this.queid = result.data.queid;
  513. this.questSearch();
  514. }
  515. }
  516. }
  517. // 根据是否上麦进行上麦判断
  518. }
  519. },
  520. async lookusercountsel() {
  521. // 根据房间id查询房间详细信息
  522. let result = await this.lookusercount({ roomname: this.roomname });
  523. if (this.$checkRes(result)) {
  524. console.log(result.total);
  525. this.$set(this, `total`, result.total);
  526. }
  527. },
  528. onSubmit() {
  529. console.log(this.sendmemo);
  530. },
  531. async initclient() {
  532. this.userId_ = this.user.uid;
  533. const _userid = 'meetu-' + this.userId_;
  534. const res = await this.gensignFetch({ userid: _userid });
  535. if (this.$checkRes(res)) {
  536. this.client_ = TRTC.createClient({
  537. mode: 'live',
  538. sdkAppId: this.sdkAppId_,
  539. userId: _userid,
  540. userSig: res.data,
  541. });
  542. await this.client_.join({ roomId: this.roomname, role: 'anchor' });
  543. this.client_.on('stream-subscribed', event => {
  544. const remoteStream = event.stream;
  545. // 远端流订阅成功,播放远端音视频流
  546. console.log(remoteStream);
  547. this.show = true;
  548. console.log('111' + remoteStream.getType());
  549. console.log('111' + remoteStream.getUserId());
  550. console.log('111' + remoteStream.getId());
  551. const userid_ = remoteStream.getUserId();
  552. const res_ = userid_.indexOf('-');
  553. const useridsplit_ = userid_.substring(0, 5);
  554. const userid_zs = userid_.substring(5);
  555. console.log('222--->' + useridsplit_);
  556. console.log('555--->' + userid_zs);
  557. if (useridsplit_ === 'share') {
  558. console.log('进入分享模式' + useridsplit_);
  559. this.lvideoid_ = 'video_' + remoteStream.getId();
  560. //this.zbfpbtn();
  561. this.swichposition();
  562. this.othedivshow = false;
  563. this.oheight = '200px';
  564. this.otheheight = '1px';
  565. console.log('进入分享模式' + this.lvideoid_);
  566. remoteStream
  567. .play('look-video-left')
  568. .then(() => {
  569. // autoplay success
  570. // 播放成功时调用css属性
  571. const _lvideoid_ = document.getElementById(this.lvideoid_);
  572. const style = 'width: 100%; height: 200px; position: absolute; transform: rotateY(0); object-fit: fill';
  573. _lvideoid_.style.cssText = style;
  574. })
  575. .catch(e => {
  576. const errorCode = e.getCode();
  577. if (errorCode === 0x4043) {
  578. // PLAY_NOT_ALLOWED,引导用户手势操作恢复音视频播放
  579. remoteStream.resume();
  580. }
  581. });
  582. } else if (useridsplit_ === 'mainr') {
  583. console.log('333');
  584. this.rvideoid_ = 'video_' + remoteStream.getId();
  585. // this.zbfullbtn();
  586. remoteStream
  587. .play('look-video-right')
  588. .then(() => {
  589. // autoplay success
  590. })
  591. .catch(e => {
  592. const errorCode = e.getCode();
  593. if (errorCode === 0x4043) {
  594. // PLAY_NOT_ALLOWED,引导用户手势操作恢复音视频播放
  595. remoteStream.resume();
  596. }
  597. });
  598. } else if (useridsplit_ === 'other') {
  599. console.log('333');
  600. this.rvideoid_ = 'video_' + remoteStream.getId();
  601. remoteStream
  602. .play('look-video-right')
  603. .then(() => {
  604. // autoplay success
  605. })
  606. .catch(e => {
  607. const errorCode = e.getCode();
  608. if (errorCode === 0x4043) {
  609. // PLAY_NOT_ALLOWED,引导用户手势操作恢复音视频播放
  610. remoteStream.resume();
  611. }
  612. });
  613. } else if (useridsplit_ === 'meetu') {
  614. console.log('333');
  615. console.log('公众号进入画面' + this.index_);
  616. this.othedivshow = true;
  617. this.oheight = '270px';
  618. this.otheheight = '70px';
  619. this.iscamera = true;
  620. this.index_ = this.index_ + 1;
  621. if (this.index_ < 6) {
  622. const id_ = 'othe-video-' + this.index_;
  623. console.log(id_);
  624. const newdata = { swichuserid: this.userid_zs, swichindex: this.index_ };
  625. this.swichusers.push(newdata);
  626. console.log('将用户push到列表里' + this.swichusers);
  627. if (this.user.uid === this.userid_zs) {
  628. this.userindex_ = this.index_;
  629. }
  630. remoteStream.play(id_);
  631. }
  632. } else if (useridsplit_ === 'wxxcx') {
  633. console.log('小程序进入画面' + this.index_);
  634. this.index_ = this.index_ + 1;
  635. if (this.index_ < 6) {
  636. const id_ = 'othe-video-' + this.index_;
  637. console.log(id_);
  638. remoteStream.play(id_);
  639. }
  640. }
  641. });
  642. // 监听远端流增加事件
  643. this.client_.on('stream-added', event => {
  644. const remoteStream = event.stream;
  645. console.log('222' + remoteStream.getType());
  646. // 订阅远端音频和视频流
  647. this.client_.subscribe(remoteStream, { audio: true, video: true }).catch(e => {
  648. console.error('failed to subscribe remoteStream');
  649. });
  650. });
  651. this.client_.on('stream-removed', event => {
  652. const remoteStream = event.stream;
  653. console.log('stop----');
  654. if (remoteStream) {
  655. const userid_ = remoteStream.getUserId();
  656. const useridsplit_ = userid_.substring(0, 5);
  657. if (useridsplit_ === 'wxxcx' || useridsplit_ === 'meetu') {
  658. console.log('退出userid_' + useridsplit_);
  659. // 订阅远端音频和视频流
  660. if (this.index_ > 0) {
  661. this.index_ = this.index_ - 1;
  662. }
  663. }
  664. }
  665. remoteStream.stop();
  666. });
  667. this.client_.on('mute-video', event => {
  668. const remoteStream = event.stream;
  669. console.log('退出');
  670. console.log('退出remoteStream' + remoteStream);
  671. if (remoteStream) {
  672. const userid_ = remoteStream.getUserId();
  673. const useridsplit_ = userid_.substring(0, 5);
  674. console.log('退出userid_' + userid_);
  675. if (useridsplit_ === 'wxxcx' || useridsplit_ === 'meetu') {
  676. console.log('退出userid_' + useridsplit_);
  677. // 订阅远端音频和视频流
  678. if (this.index_ > 0) {
  679. this.index_ = this.index_ - 1;
  680. }
  681. }
  682. }
  683. console.log('333--index---->' + this.index);
  684. });
  685. }
  686. },
  687. imgclick(url) {
  688. location.href = url;
  689. },
  690. full() {
  691. this.show = true;
  692. const width = document.documentElement.clientWidth;
  693. const height = document.documentElement.clientHeight;
  694. if (!this.isscreen) {
  695. console.log('全屏');
  696. this.isscreen = true;
  697. this.oheight = height;
  698. const transformid_ = document.getElementById('transformid');
  699. let style = 'width:' + height + 'px;';
  700. style += 'height:' + width + 'px;';
  701. style += '-webkit-transform: rotate(90deg); transform: rotate(90deg);';
  702. // 注意旋转中点的处理
  703. style += '-webkit-transform-origin: ' + width / 2 + 'px ' + width / 2 + 'px;';
  704. style += 'transform-origin: ' + width / 2 + 'px ' + width / 2 + 'px;';
  705. transformid_.style.cssText = style;
  706. this.transform = 'rotate(90deg)';
  707. // this.vwidth = height;
  708. console.log(height);
  709. if (this.othedivshow) {
  710. this.vheight = `${width - 70}px`;
  711. this.vwidth = `${height}px`;
  712. this.lheight = `${width - 70}px`;
  713. this.rheight = `${width - 70}px`;
  714. } else {
  715. this.vheight = `${width}px`;
  716. this.vwidth = `${height}px`;
  717. this.lheight = `${width}px`;
  718. this.rheight = `${width}px`;
  719. }
  720. this.btop = `${height - 40}px`;
  721. this.bright = `${width - 50}px`;
  722. if (this.othedivshow) {
  723. const othediv_ = document.getElementById('othediv');
  724. let styleothe = 'width:' + height + 'px;';
  725. styleothe += 'height:' + 70 + 'px;';
  726. styleothe += '-webkit-transform: rotate(90deg); transform: rotate(90deg);';
  727. // // 注意旋转中点的处理
  728. styleothe += '-webkit-transform-origin: ' + width / 2 + 'px ' + width / 2 + 'px;';
  729. styleothe += 'transform-origin: ' + width / 2 + 'px ' + width / 2 + 'px;';
  730. othediv_.style.cssText = styleothe;
  731. this.otheheight = '70px';
  732. this.othewidth = '20%';
  733. const ppp_ = `${width - 70}px`;
  734. this.othepadding = `${width - 70}px 0 0 0`;
  735. }
  736. } else {
  737. console.log('退出全屏');
  738. this.isscreen = false;
  739. if (this.othedivshow) {
  740. this.oheight = '270px';
  741. } else {
  742. this.oheight = '200px';
  743. }
  744. const transformid_ = document.getElementById('transformid');
  745. let style = 'width:' + width + 'px;';
  746. style += 'height: 200px;';
  747. transformid_.style.cssText = style;
  748. this.transform = 'rotate(0deg)';
  749. // this.vwidth = height;
  750. console.log(height);
  751. this.vheight = `200px`;
  752. this.vwidth = `${width}px`;
  753. this.lheight = `200px`;
  754. this.rheight = `200px`;
  755. this.btop = `167px`;
  756. this.bright = `10px`;
  757. if (this.othedivshow) {
  758. const othediv_ = document.getElementById('othediv');
  759. let styleothe = 'width:' + width + 'px;';
  760. styleothe += 'height:' + 70 + 'px;';
  761. // // 注意旋转中点的处理
  762. othediv_.style.cssText = styleothe;
  763. this.otheheight = '70px';
  764. this.othewidth = '20%';
  765. const ppp_ = `${width - 70}px`;
  766. this.othepadding = '200px 0 0 0';
  767. }
  768. }
  769. },
  770. },
  771. computed: {
  772. ...mapState(['user']),
  773. id() {
  774. return this.$route.query.id;
  775. },
  776. roomname() {
  777. return this.$route.query.roomname;
  778. },
  779. pageTitle() {
  780. return `${this.$route.meta.title}`;
  781. },
  782. },
  783. metaInfo() {
  784. return { title: this.$route.meta.title };
  785. },
  786. };
  787. </script>
  788. <style lang="less" scoped>
  789. .video {
  790. top: 0;
  791. left: 0;
  792. width: 100%;
  793. }
  794. .content {
  795. padding: 10px;
  796. }
  797. .info {
  798. .title {
  799. text-align: center;
  800. padding: 10px 0;
  801. font-size: 16px;
  802. font-weight: bold;
  803. }
  804. .num {
  805. padding: 10px 0;
  806. font-size: 16px;
  807. }
  808. .advert {
  809. background: #fff;
  810. padding: 10px;
  811. }
  812. .chat {
  813. min-height: 280px;
  814. max-height: 300px;
  815. overflow-y: auto;
  816. padding: 0 0 50px 0;
  817. .chatInfo {
  818. .list {
  819. margin: 10px 0 10px 0;
  820. span:first-child {
  821. float: left;
  822. width: 17%;
  823. text-align: center;
  824. overflow: hidden;
  825. text-overflow: ellipsis;
  826. white-space: nowrap;
  827. // font-weight: bold;
  828. }
  829. span:last-child {
  830. float: right;
  831. width: 82%;
  832. }
  833. }
  834. }
  835. }
  836. .submit {
  837. width: 100%;
  838. position: absolute;
  839. bottom: 0px;
  840. .el-button {
  841. width: 100%;
  842. padding: 20px 0;
  843. }
  844. }
  845. }
  846. .my-swipe .van-swipe-item {
  847. color: #fff;
  848. font-size: 20px;
  849. line-height: 120px;
  850. text-align: center;
  851. background-color: #39a9ed;
  852. }
  853. /deep/.video-js {
  854. height: 190px !important;
  855. border-radius: 10px;
  856. }
  857. .look-video-left {
  858. float: left;
  859. background: #000;
  860. grid-area: 1/1/3/4;
  861. justify-content: flex-end;
  862. }
  863. .look-video-right {
  864. float: right;
  865. background: #000;
  866. grid-area: 1/1/3/4;
  867. justify-content: flex-end;
  868. }
  869. .othe-video-left {
  870. float: left;
  871. background: #000;
  872. grid-area: 1/1/3/4;
  873. justify-content: flex-end;
  874. }
  875. .wrapper {
  876. background: #000;
  877. position: absolute;
  878. width: 100%;
  879. }
  880. .van-overlay {
  881. position: fixed;
  882. top: 0;
  883. left: 0;
  884. z-index: 1;
  885. width: 100%;
  886. height: 200px;
  887. background-color: rgba(0, 0, 0, 0.7);
  888. }
  889. .videoBtn {
  890. z-index: 999;
  891. position: absolute;
  892. }
  893. .userList {
  894. height: 300px;
  895. min-height: 300px;
  896. overflow-y: auto;
  897. padding: 0 10px;
  898. margin: 0 0 10px 0;
  899. }
  900. .questpopup {
  901. padding: 10px 10px;
  902. }
  903. .questpopup div {
  904. padding: 8px 0 0 5px;
  905. }
  906. .questtitle {
  907. padding: 8px 0 0 5px;
  908. text-align: center;
  909. font-size: 18px;
  910. font-weight: bold;
  911. }
  912. .questbtn {
  913. text-align: center;
  914. padding: 10px 0 15px 0;
  915. }
  916. /deep/.van-cell {
  917. padding: 25px 16px;
  918. font-size: 16px;
  919. }
  920. </style>