roomDetail.vue 33 KB

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