roomDetail.vue 34 KB

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