xiangpei
2024-03-26 dd36e59f6ef5057dc6334ebb2a8e492c9786b04c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
<template>
<!--  <div ref="jitsiContainer" style="height: 100vh; width: 100%;"></div>-->
  <div style="display: flex;height: calc(100vh - 84px);" >
    <div id="meet" style="width: 65%;height: 100%;"></div>
<!--    <el-button @click="Connect">加入</el-button>-->
<!--    <div class="table-meet">-->
<!--      <el-form :model="queryParam" ref="queryForm" :inline="true">-->
<!--        <el-form-item label="用户名:">-->
<!--          <el-input v-model="queryParam.userName"></el-input>-->
<!--        </el-form-item>-->
<!--        <el-form-item>-->
<!--          <el-button type="primary" @click="submitForm">查询</el-button>-->
<!--          <el-button type="primary" @click="addMeeting">添加至会议</el-button>-->
<!--          <el-button type="primary" @click="delMeeting">清空</el-button>-->
<!--        </el-form-item>-->
<!--      </el-form>-->
 
<!--      <el-table  v-loading="listLoading" :data="tableData" border fit highlight-current-row style="width: 100%" @selection-change="handleSelectionChange">-->
<!--        <el-table-column-->
<!--          type="selection"-->
<!--          width="55">-->
<!--        </el-table-column>-->
<!--        <el-table-column prop="userName" label="用户名"/>-->
<!--        <el-table-column prop="realName" label="真实姓名" />-->
<!--        <el-table-column prop="userLevel" label="学级"  :formatter="levelFormatter"/>-->
<!--&lt;!&ndash;        <el-table-column prop="sex" label="性别" width="60px;" :formatter="sexFormatter"/>&ndash;&gt;-->
<!--      </el-table>-->
<!--      <pagination class="meet-pagin" v-show="total>0" :total="total" :page.sync="queryParam.pageIndex" :limit.sync="queryParam.pageSize"-->
<!--                  @pagination="search"/>-->
<!--    </div>-->
  </div>
 
</template>
 
<script>
import { JitsiMeet } from "@/utils/jitsi_meet";
import $ from 'jquery';
import Pagination from '@/components/Pagination/index.vue'
import userApi from '@/api/user'
import { mapGetters, mapState } from 'vuex'
window.$ = $;
export default {
  components: { Pagination },
  // props: {
  //   domain: {
  //     type: String,
  //     default: '124.222.18.104:8443'
  //   },
  //   options: {
  //     type: Object,
  //     default: () => ({}),
  //   },
  // },
  data () {
    return {
      multipleSelection:[],
      userInfo:null,
      queryParam: {
        userName: '',
        role: 1,
        pageIndex: 1,
        pageSize: 10
      },
      listLoading: true,
      tableData: [],
      total: 0,
 
      jitsiApi: null,
      userName:'张三',
      roomName:'李四',
      meet: {
        clients: [],
      },
    };
  },
  async mounted () {
    // this.search()
    this.roomName = this.$route.query.roomName
    await userApi.getCurrentUser().then(re => {
      this.userInfo = re.response
      // this.roomName = re.response.userName
      this.userName = re.response.userName
      console.log(this.userInfo, this.roomName, this.userName)
    })
 
    const domain = '101.35.247.188:8443';
    const options = {
      roomName: this.roomName,
      width: '100%',
      height: '100%',
      lang: 'zh_CN',
      parentNode: document.querySelector('#meet'),
      userInfo: { displayName: this.userName }
    };
    // const connection = new JitsiMeetJS.JitsiConnection('123', null, options);
 
    const api = new JitsiMeetExternalAPI(domain, options);
 
    // this.meet = new JitsiMeet(
    //   //这里是服务端的XMPP地址
    //   "https://124.222.18.104:8443/http-bind",
    //   this.name
    // );
    api.addEventListeners({
      participantJoined: handleParticipantJoined,
      participantLeft: handleParticipantLeft
    });
 
    function handleParticipantJoined (event) {
      console.log(`Participant joined: ${event.id}`);
      console.log(event)
    }
 
    function handleParticipantLeft (event) {
      console.log(`Participant left: ${event.id}`);
      console.log(event)
    }
 
    // function onConnectionSuccess() {
    //   console.log("onConnectionSuccess", arguments);
    // }
    // function onConnectionFailed() {
    //   console.log("onConnectionFailed", arguments);
    // }
    // function disconnect() {
    //   console.log("disconnect", arguments);
    // }
    //
    // connection.addEventListener(JitsiMeetJS.events.connection.CONNECTION_ESTABLISHED, onConnectionSuccess);
    // connection.addEventListener(JitsiMeetJS.events.connection.CONNECTION_FAILED, onConnectionFailed);
    // connection.addEventListener(JitsiMeetJS.events.connection.CONNECTION_DISCONNECTED, disconnect);
    //
    // connection.connect(undefined);
 
    // this.loadScript(`https://${this.domain}/external_api.js`, () => {
    //   if (!window.JitsiMeetExternalAPI) throw new Error('Jitsi Meet External API not loaded');
    //   this.embedJitsiWidget();
    // });
  },
  beforeDestroy () {
    // this.Disconnect()
    this.removeJitsiWidget();
 
  },
  computed: {
    // ...mapGetters('enumItem', [
    //   'enumFormat'
    // ]),
    // ...mapState('enumItem', {
    //   sexEnum: state => state.user.sexEnum,
    //   statusEnum: state => state.user.statusEnum,
    //   statusTag: state => state.user.statusTag,
    //   statusBtn: state => state.user.statusBtn,
    //   levelEnum: state => state.user.levelEnum
    // })
  },
  created () {
    let _this = this
 
 
  },
  methods: {
    submitForm () {
      this.queryParam.pageIndex = 1
      this.search()
    },
    handleSelectionChange(val){
      console.log(val)
      this.multipleSelection = val;
    },
    addMeeting(){
      //添加会议
      let obj={}
        let arr= []
      this.multipleSelection.forEach(item=>{
        arr.push(item.id)
      })
      obj.roomName=this.roomName
      obj.stuIds = arr
      userApi.addMeetin(obj).then(res=>{
        console.log(res)
        if (res.code ==1){
          this.$message.success('添加成功')
        }
      })
 
    },
    delMeeting(){
      // 清除会议
      userApi.delMeetin().then(res=>{
        console.log(res)
        if (res.code==1){
          this.$message.success('清除成功')
        }
 
      })
 
    },
    // search () {
    //   this.listLoading = true
    //   userApi.getUserPageList(this.queryParam).then(data => {
    //     const re = data.response
    //     this.tableData = re.list
    //     this.total = re.total
    //     this.queryParam.pageIndex = re.pageNum
    //     this.listLoading = false
    //   })
    // },
    levelFormatter  (row, column, cellValue, index) {
      return this.enumFormat(this.levelEnum, cellValue)
    },
    sexFormatter  (row, column, cellValue, index) {
      return this.enumFormat(this.sexEnum, cellValue)
    },
    statusFormatter (status) {
      return this.enumFormat(this.statusEnum, status)
    },
    statusTagFormatter (status) {
      return this.enumFormat(this.statusTag, status)
    },
    statusBtnFormatter (status) {
      return this.enumFormat(this.statusBtn, status)
    },
    Connect() {
      // 加入名称为xxx的房间(这一步会创建连接与房间对象)
      this.meet.joinRoom("xxxx");
      // this.beInRoom = true;
    },
    // Disconnect() {
    //   // 离开房间(这一步会断开连接)
    //   this.meet.leveRoom();
    //   // this.beInRoom = false;
    // },
    loadScript (src, cb) {
      const scriptEl = document.createElement('script');
      scriptEl.src = src;
      scriptEl.async = 1;
      document.querySelector('head').appendChild(scriptEl);
      scriptEl.addEventListener('load', cb);
    },
    embedJitsiWidget () {
      const options = {
        ...this.options,
        parentNode: this.$refs.jitsiContainer,
      };
      this.jitsiApi = new window.JitsiMeetExternalAPI(this.domain, options);
    },
    executeCommand (command, ...value) {
      this.jitsiApi.executeCommand(command, ...value);
    },
    addEventListener (event, fn) {
      this.jitsiApi.on(event, fn);
    },
    // Misc
    removeJitsiWidget () {
      if (this.jitsiApi) this.jitsiApi.dispose();
    },
  }
};
</script>
<style scoped lang="scss">
    .table-meet{
      padding: 5px;
    }
    .meet-pagin{
      position: absolute;
      bottom: 5px;
    }
</style>