roomDetail.vue 37 KB

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