roomDetail.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982
  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. newstrem.stop();
  228. oldstrem.play(newid);
  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. const swichstrem = _.find(this.stremMeetlist, { swichuserid: objid });
  264. if (swichstrem) {
  265. this.reviewVideo(swichstrem.strem, swichstrem.id, oldstrem_.strem, 'look-video-right');
  266. }
  267. } else {
  268. console.log('share--' + this.othedivshow);
  269. const oldstrem_ = _.find(this.stremlist, { type: 'mainr' });
  270. this.stermStop(oldstrem_.strem);
  271. this.stermPlay(oldstrem_.strem, 'look-video-right');
  272. if (this.othedivshow) {
  273. for (const elm of this.stremMeetlist) {
  274. this.stermStop(elm.strem);
  275. }
  276. }
  277. }
  278. },
  279. async recordSave() {
  280. console.log(2121);
  281. let data = {};
  282. data.type = '1';
  283. data.roomid = this.id;
  284. data.roomname = this.roomname;
  285. data.userid = this.user.uid;
  286. data.username = this.user.name;
  287. const res = await this.lookrecord(data);
  288. },
  289. async sqClick() {
  290. this.form.roomid = this.id;
  291. this.form.userid = this.user.uid;
  292. const res = await this.lookupdate(this.form);
  293. if (this.$checkRes(res)) {
  294. console.log(res.data);
  295. this.$message({
  296. message: '操作成功',
  297. type: 'success',
  298. });
  299. }
  300. },
  301. async tabsClick(name, title) {
  302. if (title === '参与成员') {
  303. this.lookuserQuery();
  304. }
  305. },
  306. async lookuserQuery({ skip = 0, limit = 1000 } = {}) {
  307. const info = { roomid: this.id };
  308. let res = await this.lookquery({ skip, limit, ...info });
  309. this.$set(this, `userList`, res.data);
  310. },
  311. async chatSearch({ skip = 0, limit = 1000 } = {}) {
  312. const info = { roomid: this.id };
  313. let res = await this.query({ skip, limit, ...info });
  314. this.$set(this, `dataList`, res.data);
  315. },
  316. async chatCreate() {
  317. let data = {};
  318. data.roomid = this.id;
  319. data.type = '0';
  320. data.content = this.content;
  321. data.sendid = this.user.uid;
  322. data.sendname = this.user.name;
  323. const res = await this.create(data);
  324. if (this.$checkRes(res)) {
  325. //this.$message('发送成功');
  326. this.content = '';
  327. }
  328. },
  329. channel() {
  330. console.log('in function:');
  331. console.log(`/exchange/switch_shmai_` + this.id);
  332. this.$stomp({
  333. [`/exchange/public_chat_` + this.id]: this.onMessage,
  334. });
  335. this.$stomp({
  336. [`/exchange/switch_role_` + this.user.uid]: this.onSwichMessage,
  337. });
  338. this.$stomp({
  339. [`/exchange/switch_shmai_` + this.id]: this.onSwichShmaiMessage,
  340. });
  341. this.$stomp({
  342. [`/exchange/quest_publish_` + this.id]: this.onQueMessage,
  343. });
  344. this.$stomp({
  345. [`/exchange/switch_zjr_` + this.id]: this.onZjrMessage,
  346. });
  347. this.$stomp({
  348. [`/exchange/switch_zb_` + this.id]: this.onZbMessage,
  349. });
  350. },
  351. onMessage(message) {
  352. // console.log('receive a message: ', message.body);
  353. let body = _.get(message, 'body');
  354. if (body) {
  355. body = JSON.parse(body);
  356. this.dataList.push(body);
  357. this.content = '';
  358. }
  359. this.$nextTick(() => {
  360. document.getElementById('chatSell').scrollTop = document.getElementById('chatSell').scrollHeight + 275;
  361. });
  362. },
  363. onQueMessage(message) {
  364. // console.log('receive a message: ', message.body);
  365. this.showQuest = true;
  366. let body = _.get(message, 'body');
  367. if (body) {
  368. body = JSON.parse(body);
  369. this.queid = body.queid;
  370. this.questSearch();
  371. }
  372. },
  373. onSwichMessage(message) {
  374. // console.log('receive a message: ', message.body);
  375. let body = _.get(message, 'body');
  376. if (body) {
  377. body = JSON.parse(body);
  378. if (body.switchrole === 'anchor' && body.userid === this.user.uid) {
  379. this.switchbtn = true;
  380. this.switchmeetbtn = true;
  381. this.roomMeetSwich();
  382. } else {
  383. this.switchbtn = false;
  384. this.switchmeetbtn = false;
  385. }
  386. if (body.switchrole !== 'anchor' && body.userid === this.user.uid) {
  387. const videoTrack = this.localStream_.getVideoTrack();
  388. if (videoTrack) {
  389. this.localStream_.removeTrack(videoTrack).then(() => {
  390. console.log('remove video call success');
  391. // 关闭摄像头
  392. videoTrack.stop();
  393. // this.client_.unpublish(this.localStream_).then(() => {
  394. // // 取消发布本地流成功
  395. // });
  396. });
  397. const oldstrem_ = _.find(this.stremlist, { type: 'mainr' });
  398. this.stermStop(this.localStream_);
  399. this.stermStop(oldstrem_.strem);
  400. this.stermPlay(oldstrem_.strem, 'look-video-right');
  401. }
  402. }
  403. }
  404. },
  405. onSwichShmaiMessage(message) {
  406. let body = _.get(message, 'body');
  407. console.log(body);
  408. console.log(this.user.uid);
  409. if (body) {
  410. body = JSON.parse(body);
  411. this.swichposition(body.shmaiid);
  412. }
  413. },
  414. onZjrMessage(message) {
  415. let body = _.get(message, 'body');
  416. if (body) {
  417. body = JSON.parse(body);
  418. if (body.switchzjr) {
  419. this.swichzjrstatus = true;
  420. this.swichzjrid = body.switchzjr;
  421. this.swichzjrVideo(body.switchzjr);
  422. } else {
  423. this.swichzjrstatus = false;
  424. }
  425. }
  426. },
  427. onZbMessage(message) {
  428. let body = _.get(message, 'body');
  429. if (body) {
  430. body = JSON.parse(body);
  431. this.swichzjrstatus = false;
  432. this.swichzbVideo(body.switchzjr);
  433. }
  434. },
  435. onOtheMessage(message) {
  436. let body = _.get(message, 'body');
  437. if (body) {
  438. body = JSON.parse(body);
  439. if (body.otheid) {
  440. this.switchbtn = true;
  441. this.roomMeetBtn();
  442. } else {
  443. this.switchbtn = false;
  444. }
  445. }
  446. },
  447. async swichzjrVideo(switchzjr) {
  448. //
  449. const swichstrem = _.find(this.stremOtherlist, { switchzjrid: switchzjr, type: 'other' });
  450. if (swichstrem) {
  451. const oldstrem_ = _.find(this.stremlist, { type: 'mainr' });
  452. if (oldstrem_) {
  453. this.stermStop(oldstrem_.strem);
  454. }
  455. this.stermPlay(swichstrem.strem, 'look-video-right');
  456. }
  457. },
  458. async swichzbVideo(switchzjr) {
  459. //
  460. const oldstrem_ = _.find(this.stremlist, { type: 'mainr' });
  461. if (oldstrem_) {
  462. this.stermStop(oldstrem_.strem);
  463. this.stermPlay(oldstrem_.strem, 'look-video-right');
  464. }
  465. const swichstrem = _.find(this.stremMeetlist, { swichuserid: switchzjr });
  466. if (swichstrem) {
  467. this.stermStop(swichstrem.strem);
  468. this.stermPlay(oldstrem_.strem, swichstrem.id);
  469. }
  470. },
  471. async userswichrole() {
  472. // 根据房间id查询房间详细信息
  473. let result = await this.lookuserswichrole({ roomid: this.id, userid: this.user.uid });
  474. if (this.$checkRes(result)) {
  475. if (result.data && result.data.switchrole === 'anchor') {
  476. this.switchbtn = true;
  477. }
  478. }
  479. },
  480. roomMeetBtn() {
  481. const url = '/pages/meeting/meeting?uid=' + this.user.uid + '&username=' + this.user.name + '&rid=' + this.id + '&roomname=' + this.roomname;
  482. console.log(url);
  483. wx.miniProgram.navigateTo({ url });
  484. },
  485. async roomMeetSwich() {
  486. this.othedivshow = true;
  487. this.oheight = '270px';
  488. this.otheheight = '70px';
  489. this.iscamera = true;
  490. const _userid = 'meetu-' + this.userId_;
  491. this.localStream_ = await TRTC.createStream({
  492. audio: true,
  493. video: true,
  494. // cameraId: this.cameraId,
  495. // microphoneId: this.microphoneId,
  496. userId: _userid,
  497. });
  498. this.localStream_.setVideoProfile('480p');
  499. await this.localStream_.initialize();
  500. console.log('initialize local stream success');
  501. // publish the local stream
  502. await this.client_.publish(this.localStream_);
  503. this.index_ = this.index_ + 1;
  504. if (this.index_ < 6) {
  505. // const otheplaydiv = document.getElementById('otheplaydiv');
  506. const id_ = 'othe-video-' + this.index_;
  507. const newdata_ = { strem: this.localStream_, index: this.index_, id: id_, swichuserid: this.userId_ };
  508. this.stremMeetlist.push(newdata_);
  509. // const newdiv = '<div id="' + id_ + '" style="height: 70px, width: 20%" class="video-box col-div othe-video-left"></div>';
  510. // otheplaydiv.appendChild(newdiv);
  511. const newdata = { swichuserid: this.userId_, swichindex: this.index_ };
  512. this.swichusers.push(newdata);
  513. console.log('将用户push到列表里' + this.swichusers);
  514. this.localStream_.play(id_);
  515. }
  516. },
  517. async questSearch() {
  518. if (this.queid) {
  519. const result = await this.questfetch(this.queid);
  520. if (this.$checkRes(result)) {
  521. console.log(result.data);
  522. this.$set(this, `questInfo`, result.data);
  523. }
  524. }
  525. },
  526. async submitQuest() {
  527. let form = { roomid: this.id, userid: this.user.uid, questionnaireid: this.queid };
  528. let answers = [];
  529. for (const question of this.questInfo.question) {
  530. answers.push({ questionid: question._id, answer: JSON.stringify(question.answer) });
  531. }
  532. form.answers = answers;
  533. console.log(form);
  534. let res = await this.upcreate(form);
  535. if (res.errcode == '0') {
  536. this.showQuest = false;
  537. }
  538. },
  539. async lookuserSearch() {
  540. if (this.user.uid) {
  541. let data = {};
  542. data.roomid = this.id;
  543. data.roomname = this.roomname;
  544. data.userid = this.user.uid;
  545. data.username = this.user.name;
  546. const res = await this.lookuserFetch(data);
  547. }
  548. // 根据房间id查询房间详细信息
  549. let result = await this.fetch(this.id);
  550. if (this.$checkRes(result)) {
  551. console.log(result.data);
  552. this.$set(this, `roomInfos`, result.data);
  553. if (result.data.switchzjr) {
  554. this.swichzjrid = result.data.switchzjr;
  555. this.swichzjrstatus = true;
  556. }
  557. // 根据房间信息判断是否回答问卷
  558. if (result.data.isque === '1') {
  559. const info = { roomid: this.id, userid: this.user.uid, questionnaireid: result.data.queid };
  560. const skip = 0;
  561. const limit = 10;
  562. const upres = await this.upquery({ skip, limit, ...info });
  563. if (this.$checkRes(upres)) {
  564. if (upres.data.length === 0) {
  565. this.showQuest = true;
  566. this.queid = result.data.queid;
  567. this.questSearch();
  568. }
  569. }
  570. }
  571. // 根据是否上麦进行上麦判断
  572. }
  573. },
  574. async lookusercountsel() {
  575. // 根据房间id查询房间详细信息
  576. let result = await this.lookusercount({ roomname: this.roomname });
  577. if (this.$checkRes(result)) {
  578. console.log(result.total);
  579. this.$set(this, `total`, result.total);
  580. }
  581. },
  582. onSubmit() {
  583. console.log(this.sendmemo);
  584. },
  585. async initclient() {
  586. this.userId_ = this.user.uid;
  587. const _userid = 'meetu-' + this.userId_;
  588. const res = await this.gensignFetch({ userid: _userid });
  589. if (this.$checkRes(res)) {
  590. this.client_ = TRTC.createClient({
  591. mode: 'live',
  592. sdkAppId: this.sdkAppId_,
  593. userId: _userid,
  594. userSig: res.data,
  595. });
  596. await this.client_.join({ roomId: this.roomname, role: 'anchor' });
  597. this.client_.on('stream-subscribed', event => {
  598. const remoteStream = event.stream;
  599. // 远端流订阅成功,播放远端音视频流
  600. console.log(remoteStream);
  601. this.show = true;
  602. console.log('111' + remoteStream.getType());
  603. console.log('111' + remoteStream.getUserId());
  604. console.log('111' + remoteStream.getId());
  605. const userid_ = remoteStream.getUserId();
  606. const res_ = userid_.indexOf('-');
  607. const useridsplit_ = userid_.substring(0, 5);
  608. const userid_zs = userid_.substring(6);
  609. console.log('222--->' + useridsplit_);
  610. console.log('555--->' + userid_zs);
  611. if (useridsplit_ === 'share') {
  612. console.log('进入分享模式' + useridsplit_);
  613. const newdata_ = { strem: remoteStream, type: 'share' };
  614. this.stremlist.push(newdata_);
  615. this.lvideoid_ = 'video_' + remoteStream.getId();
  616. //this.zbfpbtn();
  617. this.swichposition();
  618. this.othedivshow = false;
  619. this.oheight = '200px';
  620. this.otheheight = '1px';
  621. console.log('进入分享模式' + this.lvideoid_);
  622. remoteStream
  623. .play('look-video-left')
  624. .then(() => {
  625. // autoplay success
  626. // 播放成功时调用css属性
  627. const _lvideoid_ = document.getElementById(this.lvideoid_);
  628. const style = 'width: 100%; height: 200px; position: absolute; transform: rotateY(0); object-fit: fill';
  629. _lvideoid_.style.cssText = style;
  630. })
  631. .catch(e => {
  632. const errorCode = e.getCode();
  633. if (errorCode === 0x4043) {
  634. // PLAY_NOT_ALLOWED,引导用户手势操作恢复音视频播放
  635. remoteStream.resume();
  636. }
  637. });
  638. } else if (useridsplit_ === 'mainr') {
  639. console.log('333');
  640. this.rvideoid_ = 'video_' + remoteStream.getId();
  641. // this.zbfullbtn();
  642. const newdata_ = { strem: remoteStream, type: 'mainr' };
  643. this.stremlist.push(newdata_);
  644. if (this.swichzjrid) {
  645. const swichstrem = _.find(this.stremOtherlist, { switchzjrid: this.swichzjrid, type: 'other' });
  646. if (swichstrem) {
  647. this.stermStop(swichstrem.strem);
  648. }
  649. }
  650. remoteStream
  651. .play('look-video-right')
  652. .then(() => {
  653. // autoplay success
  654. })
  655. .catch(e => {
  656. const errorCode = e.getCode();
  657. if (errorCode === 0x4043) {
  658. // PLAY_NOT_ALLOWED,引导用户手势操作恢复音视频播放
  659. remoteStream.resume();
  660. }
  661. });
  662. } else if (useridsplit_ === 'other') {
  663. console.log('333');
  664. this.rvideoid_ = 'video_' + remoteStream.getId();
  665. const newdata_ = { strem: remoteStream, type: 'other', switchzjrid: userid_zs };
  666. this.stremOtherlist.push(newdata_);
  667. if (this.swichzjrid) {
  668. this.swichzjrVideo(userid_zs);
  669. }
  670. } else if (useridsplit_ === 'meetu') {
  671. console.log('333');
  672. console.log('公众号进入画面' + this.index_);
  673. this.othedivshow = true;
  674. this.oheight = '270px';
  675. this.otheheight = '70px';
  676. this.iscamera = true;
  677. this.index_ = this.index_ + 1;
  678. if (this.index_ < 6) {
  679. const id_ = 'othe-video-' + this.index_;
  680. const newdata_ = { strem: remoteStream, index: this.index_, id: id_, swichuserid: userid_zs };
  681. this.stremMeetlist.push(newdata_);
  682. console.log(id_);
  683. const newdata = { swichuserid: userid_zs, swichindex: this.index_ };
  684. this.swichusers.push(newdata);
  685. console.log('将用户push到列表里' + newdata);
  686. remoteStream.play(id_);
  687. }
  688. } else if (useridsplit_ === 'wxxcx') {
  689. console.log('小程序进入画面' + this.index_);
  690. this.index_ = this.index_ + 1;
  691. if (this.index_ < 6) {
  692. const id_ = 'othe-video-' + this.index_;
  693. console.log(id_);
  694. remoteStream.play(id_);
  695. }
  696. }
  697. });
  698. // 监听远端流增加事件
  699. this.client_.on('stream-added', event => {
  700. const remoteStream = event.stream;
  701. console.log('222' + remoteStream.getType());
  702. // 订阅远端音频和视频流
  703. this.client_.subscribe(remoteStream, { audio: true, video: true }).catch(e => {
  704. console.error('failed to subscribe remoteStream');
  705. });
  706. });
  707. this.client_.on('stream-removed', event => {
  708. const remoteStream = event.stream;
  709. console.log('stop----');
  710. if (remoteStream) {
  711. const userid_ = remoteStream.getUserId();
  712. const useridsplit_ = userid_.substring(0, 5);
  713. if (useridsplit_ === 'wxxcx' || useridsplit_ === 'meetu') {
  714. console.log('退出userid_' + useridsplit_);
  715. // 订阅远端音频和视频流
  716. if (this.index_ > 0) {
  717. this.index_ = this.index_ - 1;
  718. }
  719. }
  720. }
  721. remoteStream.stop();
  722. });
  723. this.client_.on('mute-video', event => {
  724. const remoteStream = event.stream;
  725. console.log('退出');
  726. console.log('退出remoteStream' + remoteStream);
  727. if (remoteStream) {
  728. const userid_ = remoteStream.getUserId();
  729. const useridsplit_ = userid_.substring(0, 5);
  730. console.log('退出userid_' + userid_);
  731. if (useridsplit_ === 'wxxcx' || useridsplit_ === 'meetu') {
  732. console.log('退出userid_' + useridsplit_);
  733. // 订阅远端音频和视频流
  734. if (this.index_ > 0) {
  735. this.index_ = this.index_ - 1;
  736. }
  737. }
  738. }
  739. console.log('333--index---->' + this.index);
  740. });
  741. }
  742. },
  743. imgclick(url) {
  744. location.href = url;
  745. },
  746. full() {
  747. this.show = true;
  748. const width = document.documentElement.clientWidth;
  749. const height = document.documentElement.clientHeight;
  750. if (!this.isscreen) {
  751. console.log('全屏');
  752. this.isscreen = true;
  753. this.oheight = height;
  754. const transformid_ = document.getElementById('transformid');
  755. let style = 'width:' + height + 'px;';
  756. style += 'height:' + width + 'px;';
  757. style += '-webkit-transform: rotate(90deg); transform: rotate(90deg);';
  758. // 注意旋转中点的处理
  759. style += '-webkit-transform-origin: ' + width / 2 + 'px ' + width / 2 + 'px;';
  760. style += 'transform-origin: ' + width / 2 + 'px ' + width / 2 + 'px;';
  761. transformid_.style.cssText = style;
  762. this.transform = 'rotate(90deg)';
  763. // this.vwidth = height;
  764. console.log(height);
  765. if (this.othedivshow) {
  766. this.vheight = `${width - 70}px`;
  767. this.vwidth = `${height}px`;
  768. this.lheight = `${width - 70}px`;
  769. this.rheight = `${width - 70}px`;
  770. } else {
  771. this.vheight = `${width}px`;
  772. this.vwidth = `${height}px`;
  773. this.lheight = `${width}px`;
  774. this.rheight = `${width}px`;
  775. }
  776. this.btop = `${height - 40}px`;
  777. this.bright = `${width - 50}px`;
  778. if (this.othedivshow) {
  779. const othediv_ = document.getElementById('othediv');
  780. let styleothe = 'width:' + height + 'px;';
  781. styleothe += 'height:' + 70 + 'px;';
  782. styleothe += '-webkit-transform: rotate(90deg); transform: rotate(90deg);';
  783. // // 注意旋转中点的处理
  784. styleothe += '-webkit-transform-origin: ' + width / 2 + 'px ' + width / 2 + 'px;';
  785. styleothe += 'transform-origin: ' + width / 2 + 'px ' + width / 2 + 'px;';
  786. othediv_.style.cssText = styleothe;
  787. this.otheheight = '70px';
  788. this.othewidth = '20%';
  789. const ppp_ = `${width - 70}px`;
  790. this.othepadding = `${width - 70}px 0 0 0`;
  791. }
  792. } else {
  793. console.log('退出全屏');
  794. this.isscreen = false;
  795. if (this.othedivshow) {
  796. this.oheight = '270px';
  797. } else {
  798. this.oheight = '200px';
  799. }
  800. const transformid_ = document.getElementById('transformid');
  801. let style = 'width:' + width + 'px;';
  802. style += 'height: 200px;';
  803. transformid_.style.cssText = style;
  804. this.transform = 'rotate(0deg)';
  805. // this.vwidth = height;
  806. console.log(height);
  807. this.vheight = `200px`;
  808. this.vwidth = `${width}px`;
  809. this.lheight = `200px`;
  810. this.rheight = `200px`;
  811. this.btop = `167px`;
  812. this.bright = `10px`;
  813. if (this.othedivshow) {
  814. const othediv_ = document.getElementById('othediv');
  815. let styleothe = 'width:' + width + 'px;';
  816. styleothe += 'height:' + 70 + 'px;';
  817. // // 注意旋转中点的处理
  818. othediv_.style.cssText = styleothe;
  819. this.otheheight = '70px';
  820. this.othewidth = '20%';
  821. const ppp_ = `${width - 70}px`;
  822. this.othepadding = '200px 0 0 0';
  823. }
  824. }
  825. },
  826. },
  827. computed: {
  828. ...mapState(['user']),
  829. id() {
  830. return this.$route.query.id;
  831. },
  832. roomname() {
  833. return this.$route.query.roomname;
  834. },
  835. pageTitle() {
  836. return `${this.$route.meta.title}`;
  837. },
  838. },
  839. metaInfo() {
  840. return { title: this.$route.meta.title };
  841. },
  842. };
  843. </script>
  844. <style lang="less" scoped>
  845. .video {
  846. top: 0;
  847. left: 0;
  848. width: 100%;
  849. }
  850. .content {
  851. padding: 10px;
  852. }
  853. .info {
  854. .title {
  855. text-align: center;
  856. padding: 10px 0;
  857. font-size: 16px;
  858. font-weight: bold;
  859. }
  860. .num {
  861. padding: 10px 0;
  862. font-size: 16px;
  863. }
  864. .advert {
  865. background: #fff;
  866. padding: 10px;
  867. }
  868. .chat {
  869. min-height: 280px;
  870. max-height: 300px;
  871. overflow-y: auto;
  872. padding: 0 0 50px 0;
  873. .chatInfo {
  874. .list {
  875. margin: 10px 0 10px 0;
  876. span:first-child {
  877. float: left;
  878. width: 17%;
  879. text-align: center;
  880. overflow: hidden;
  881. text-overflow: ellipsis;
  882. white-space: nowrap;
  883. // font-weight: bold;
  884. }
  885. span:last-child {
  886. float: right;
  887. width: 82%;
  888. }
  889. }
  890. }
  891. }
  892. .submit {
  893. width: 100%;
  894. position: absolute;
  895. bottom: 0px;
  896. .el-button {
  897. width: 100%;
  898. padding: 20px 0;
  899. }
  900. }
  901. }
  902. .my-swipe .van-swipe-item {
  903. color: #fff;
  904. font-size: 20px;
  905. line-height: 120px;
  906. text-align: center;
  907. background-color: #39a9ed;
  908. }
  909. /deep/.video-js {
  910. height: 190px !important;
  911. border-radius: 10px;
  912. }
  913. .look-video-left {
  914. float: left;
  915. background: #000;
  916. grid-area: 1/1/3/4;
  917. justify-content: flex-end;
  918. }
  919. .look-video-right {
  920. float: right;
  921. background: #000;
  922. grid-area: 1/1/3/4;
  923. justify-content: flex-end;
  924. }
  925. .othe-video-left {
  926. float: left;
  927. background: #000;
  928. grid-area: 1/1/3/4;
  929. justify-content: flex-end;
  930. }
  931. .wrapper {
  932. background: #000;
  933. position: absolute;
  934. width: 100%;
  935. }
  936. .van-overlay {
  937. position: fixed;
  938. top: 0;
  939. left: 0;
  940. z-index: 1;
  941. width: 100%;
  942. height: 200px;
  943. background-color: rgba(0, 0, 0, 0.7);
  944. }
  945. .videoBtn {
  946. z-index: 999;
  947. position: absolute;
  948. }
  949. .userList {
  950. height: 300px;
  951. min-height: 300px;
  952. overflow-y: auto;
  953. padding: 0 10px;
  954. margin: 0 0 10px 0;
  955. }
  956. .questpopup {
  957. padding: 10px 10px;
  958. }
  959. .questpopup div {
  960. padding: 8px 0 0 5px;
  961. }
  962. .questtitle {
  963. padding: 8px 0 0 5px;
  964. text-align: center;
  965. font-size: 18px;
  966. font-weight: bold;
  967. }
  968. .questbtn {
  969. text-align: center;
  970. padding: 10px 0 15px 0;
  971. }
  972. /deep/.van-cell {
  973. padding: 25px 16px;
  974. font-size: 16px;
  975. }
  976. </style>