Grid.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317
  1. <template>
  2. <div class="pb_content g_body">
  3. <div>
  4. <el-image class="coin coin1" :src="require('../../assets/grid/coin1.png')" fit="cover"></el-image>
  5. <el-image class="coin coin2" :src="require('../../assets/grid/coin2.png')" fit="cover"></el-image>
  6. <el-image class="coin coin3" :src="require('../../assets/grid/coin3.png')" fit="cover"></el-image>
  7. <el-image class="coin coin4" :src="require('../../assets/grid/coin4.png')" fit="cover"></el-image>
  8. </div>
  9. <div class="grid_member">
  10. <!-- <div class="member_imgbox">
  11. <el-image
  12. v-for="item in 4"
  13. :key="item"
  14. class="member_img"
  15. :src="require('../../assets/grid/portal.png')"
  16. fit="cover"
  17. ></el-image>
  18. </div>-->
  19. <el-button type="text" @click="dialogVisible2 = true">邀请成员</el-button>
  20. <!-- <el-button type="text">成员</el-button> -->
  21. <el-button type="text" v-if="RoomInfo.userid == userid" @click="dismiss">解散房间</el-button>
  22. </div>
  23. <draggable
  24. element="div"
  25. v-model="data"
  26. class="g_body"
  27. @change="handleDraggableFormItemChange"
  28. @end="dragEnd"
  29. :move="checkMove"
  30. >
  31. <div
  32. v-for="(item,index) in data"
  33. :key="index"
  34. class="g_box"
  35. @mouseover="pIndex = index"
  36. @mouseleave="pIndex = ''"
  37. @dragstart="handleDragStart($event, index)"
  38. @dragover.prevent="handleDragOver($event, index)"
  39. @dragenter="handleDragEnter($event, index)"
  40. @dragend="handleDragEnd($event, index)"
  41. >
  42. <div
  43. :class="{'left-popover':index<3,'right-popover':index==3,'top-popover':index>3,'visibleO':pIndex === index && item && (item.video || item.photo)}"
  44. >
  45. <div class="pChild" @click="check(index)">
  46. <el-image :src="require('../../assets/grid/upload.png')" fit="cover"></el-image>
  47. <span>修改</span>
  48. </div>
  49. <div class="pChild" @click="deleteGrid(index)">
  50. <el-image :src="require('../../assets/grid/deleteT.png')" fit="cover"></el-image>
  51. <span>删除</span>
  52. </div>
  53. <div class="pChild" @click="check(index,2)">
  54. <el-image :src="require('../../assets/grid/edit.png')" fit="cover"></el-image>
  55. <span>添加备注</span>
  56. </div>
  57. </div>
  58. <div
  59. v-if="item && item.remarks"
  60. :class="{'remark-right-popover':index>11 && index!=15,'remark-left-popover':index==15,'remark-bottom-popover':index<12,'visibleO':pIndex === index && item && item.remarks}"
  61. >
  62. <div class="Rbox" v-for="(x,y) in item.remarks" :key="y">
  63. <div v-if="x.remarks!=''" style="display:flex">
  64. <el-image class="Rportal" :src="require('../../assets/grid/portal.png')" fit="cover"></el-image>
  65. <div class="RContent">
  66. <div>{{x.username}}</div>
  67. <div>{{x.remarks}}</div>
  68. </div>
  69. </div>
  70. <div v-else-if="x.remarks==''&& y==0">{{x.username}}暂无备注</div>
  71. </div>
  72. </div>
  73. <el-image
  74. v-if="item && item.photo"
  75. v-viewer
  76. class="photo_img"
  77. :src="item.photo"
  78. fit="cover"
  79. ></el-image>
  80. <video-player
  81. v-else-if="item && item.video"
  82. class="video-player vjs-custom-skin"
  83. ref="videoPlayer"
  84. :playsinline="true"
  85. :options="item.video"
  86. style="width: 85%;"
  87. ></video-player>
  88. <el-image
  89. v-else
  90. class="add_img"
  91. :src="require('../../assets/grid/add.png')"
  92. fit="cover"
  93. @click="check(index,3)"
  94. ></el-image>
  95. </div>
  96. </draggable>
  97. <el-dialog
  98. title="上传文件"
  99. :visible.sync="dialogVisible"
  100. :append-to-body="true"
  101. width="800px"
  102. :before-close="handleClose"
  103. class="look_notice"
  104. >
  105. <div slot="title" class="header-title">
  106. <div class="title_add_student">上传文件</div>
  107. </div>
  108. <div>
  109. <div class="upload_box" v-show="!file.userid || file.userid == userid">
  110. <el-image class="list_img" :src="require('../../assets/grid/list.png')" fit="cover"></el-image>
  111. <div class="upload_content">
  112. <div
  113. @click="addEvent($event)"
  114. @mouseover="file.photo ? deleteVisible1 = true:''"
  115. @mouseleave="file.photo ? deleteVisible1 = false:''"
  116. >
  117. <el-image
  118. class="delete_img"
  119. :src="require('../../assets/grid/delete.png')"
  120. fit="cover"
  121. v-if="deleteVisible1"
  122. @click.stop="deleteFile(1)"
  123. ></el-image>
  124. <el-image
  125. class="upload_img"
  126. :src="file.photo ? file.photo : require('../../assets/grid/image.png')"
  127. fit="cover"
  128. ></el-image>
  129. <input
  130. type="file"
  131. accept="image/*"
  132. style="display: none"
  133. ref="pathClear1"
  134. @change="beforeUpload($event, 1)"
  135. />
  136. </div>
  137. <div
  138. style="margin-left: 20px;"
  139. @click="addEvent($event)"
  140. @mouseover="file.video ? deleteVisible2 = true:''"
  141. @mouseleave="file.video ? deleteVisible2 = false:''"
  142. >
  143. <el-image
  144. class="delete_img"
  145. :src="require('../../assets/grid/delete.png')"
  146. fit="cover"
  147. v-if="deleteVisible2"
  148. @click.stop="deleteFile(2)"
  149. ></el-image>
  150. <el-image
  151. class="upload_img"
  152. :src="file.video ? require('../../assets/grid/videoH.png') : require('../../assets/grid/video.png')"
  153. fit="cover"
  154. ></el-image>
  155. <input
  156. type="file"
  157. accept="video/mp4, video/quicktime, video/x-msvideo"
  158. style="display: none"
  159. ref="pathClear2"
  160. @change="beforeUpload($event, 2)"
  161. />
  162. </div>
  163. </div>
  164. </div>
  165. <div class="textarea_box">
  166. <div class="textarea_title">添加描述</div>
  167. <el-input
  168. type="textarea"
  169. v-model="remarks"
  170. placeholder="请输入描述..."
  171. class="textarea_content"
  172. :rows="5"
  173. resize="none"
  174. ></el-input>
  175. </div>
  176. </div>
  177. <span slot="footer" class="dialog-footer">
  178. <el-button class="close" @click="addGrid()" type="primary">确定</el-button>
  179. </span>
  180. </el-dialog>
  181. <el-dialog
  182. title="邀请成员"
  183. :visible.sync="dialogVisible2"
  184. :append-to-body="true"
  185. width="400px"
  186. :before-close="handleClose"
  187. class="look_notice invite_dialog"
  188. >
  189. <div slot="title" class="header-title">
  190. <div class="title_add_student">邀请成员</div>
  191. </div>
  192. <div>
  193. <div class="invite_box">
  194. <div class="invite_title" ref="inviteT">{{userinfo ? this.userinfo.name: "用户"}}邀请您参加思维网格</div>
  195. <div class="line"></div>
  196. <div class="invite_link">
  197. <div ref="invite1">复制链接加入房间:</div>
  198. <div ref="invite2">https://baidu.com</div>
  199. </div>
  200. <div class="invite_num" ref="invite3">
  201. 房间号:
  202. <span>{{RoomInfo.num}}</span>
  203. </div>
  204. <div class="invite_num" ref="invite4">复制房间号信息,打开思维网格输入即可加入。</div>
  205. </div>
  206. </div>
  207. <span slot="footer" class="dialog-footer">
  208. <el-button
  209. class="close tag-read"
  210. @click="copy"
  211. type="primary"
  212. :data-clipboard-text="copyText"
  213. >一键复制信息</el-button>
  214. </span>
  215. </el-dialog>
  216. <el-dialog
  217. title="创建/加入房间"
  218. :visible.sync="dialogVisible3"
  219. :append-to-body="true"
  220. width="400px"
  221. :before-close="handleClose2"
  222. class="look_notice invite_dialog room_dialog"
  223. >
  224. <div slot="title" class="header-title">
  225. <div class="title_add_student">创建/加入房间</div>
  226. </div>
  227. <div class="addRoom_box">
  228. <div>
  229. <el-input v-model="goNum" placeholder="请输入要加入的房间号"></el-input>
  230. <div class="room_b">备注:输入房间号点击加入房间或点击创建房间直接创建房间</div>
  231. <div class="room_btn">
  232. <el-button class="roomBtn" type="primary" @click="goRoom(goNum)">加入房间</el-button>
  233. <el-button class="roomBtn" type="primary" @click="checkNum">创建房间</el-button>
  234. </div>
  235. </div>
  236. </div>
  237. </el-dialog>
  238. <div v-if="proVisible" class="mask">
  239. <div class="progressBox">
  240. <div class="lbox">
  241. <img :src="require('../../assets/loading.gif')" />上传中,请稍后
  242. </div>
  243. <el-progress
  244. :text-inside="true"
  245. :stroke-width="20"
  246. :percentage="progress"
  247. style="width:80%"
  248. ></el-progress>
  249. </div>
  250. </div>
  251. </div>
  252. </template>
  253. <script>
  254. import Clipboard from "clipboard";
  255. import draggable from "vuedraggable";
  256. export default {
  257. components: {
  258. //调用组件
  259. draggable,
  260. },
  261. data() {
  262. return {
  263. timer: null,
  264. userinfo: [],
  265. RoomInfo: [],
  266. copyText: "",
  267. userid: this.$route.query.userid,
  268. data: [],
  269. dialogVisible: false,
  270. dialogVisible2: false,
  271. dialogVisible3: true,
  272. deleteVisible1: false,
  273. deleteVisible2: false,
  274. dialogImgVisible: false,
  275. dialogImageUrl: "",
  276. remarks: "",
  277. goNum: "",
  278. numNum: "",
  279. file: {},
  280. gIndex: "",
  281. pIndex: "",
  282. proVisible: false,
  283. progress: 0,
  284. playerOptions: {
  285. playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
  286. autoplay: false, //如果true,浏览器准备好时开始回放。
  287. muted: false, // 默认情况下将会消除任何音频。
  288. loop: false, // 导致视频一结束就重新开始。
  289. preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频(如果浏览器支持)
  290. language: "zh-CN",
  291. aspectRatio: "16:9", // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  292. fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
  293. sources: [
  294. {
  295. type: "video/mp4", //这里的种类支持很多种:基本视频格式、直播、流媒体等,具体可以参看git网址项目 || "video/ogg"|| "video/webm"
  296. src: "", //url地址require("../../assets/media/aaa.mp4")
  297. },
  298. ],
  299. // poster: require("../../assets/tu31.png"), //你的封面地址
  300. // poster: dataRes.imgUrl, //你的封面地址
  301. notSupportedMessage: "此视频暂无法播放,请稍后再试", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
  302. controlBar: {
  303. timeDivider: true, //当前时间和持续时间的分隔符
  304. durationDisplay: true, //显示持续时间
  305. remainingTimeDisplay: false, //是否显示剩余时间功能
  306. fullscreenToggle: true, //全屏按钮
  307. },
  308. },
  309. playerO: {},
  310. dragging: null,
  311. draggingE: null,
  312. };
  313. },
  314. methods: {
  315. handleDragStart(e, items) {
  316. this.dragging = items; //开始拖动时,暂时保存当前拖动的数据。
  317. if (!this.data[items]) {
  318. return;
  319. }
  320. },
  321. handleDragEnd(e, items) {
  322. if (!this.data[this.dragging]) {
  323. return;
  324. }
  325. e.dataTransfer.effectAllowed = "move"; //为需要移动的元素设置dragstart事件
  326. if (this.draggingE == this.dragging) return;
  327. var newItems = [...JSON.parse(JSON.stringify(this.data))]; //拷贝一份数据进行交换操作。
  328. var src = newItems[this.dragging]; //获取数组下标
  329. var dst = newItems[this.draggingE];
  330. newItems[this.dragging] = dst;
  331. newItems[this.draggingE] = src;
  332. // newItems2.splice(dst, 0, ...newItems.splice(src, 1)); //交换位置
  333. this.data = newItems;
  334. this.updateRoomData();
  335. this.dragging = null; //拖动结束后,清除数据
  336. this.draggingE = null;
  337. },
  338. handleDragOver(e) {
  339. e.dataTransfer.dropEffect = "move"; //在dragenter中针对放置目标来设置!
  340. },
  341. handleDragEnter(e, items) {
  342. this.draggingE = items;
  343. e.dataTransfer.effectAllowed = "move"; //为需要移动的元素设置dragstart事件
  344. // if (items == this.dragging) return;
  345. // var newItems = [...JSON.parse(JSON.stringify(this.data))]; //拷贝一份数据进行交换操作。
  346. // var src = this.dragging; //获取数组下标
  347. // var dst = items;
  348. // newItems.splice(dst, 0, ...newItems.splice(src, 1)); //交换位置
  349. // this.data = newItems;
  350. // this.updateRoomData();
  351. },
  352. handleDraggableFormItemChange(val) {
  353. // console.log(val);
  354. // console.log(this.data[val.moved.newIndex]);
  355. // console.log(this.data[val.moved.oldIndex]);
  356. },
  357. dragEnd(val) {
  358. // if (this.data[val.newIndex].userid != this.userinfo.userid) {
  359. // this.$message.error("不是您上传的作品不能拖动哦");
  360. // return;
  361. // }
  362. // this.updateRoomData();
  363. },
  364. checkMove(evt) {
  365. // console.log(evt);
  366. // if (evt.draggedContext.element.userid != this.userinfo.userid) {
  367. // return false;
  368. // } else {
  369. // return true;
  370. // }
  371. return false;
  372. },
  373. copy() {
  374. this.copyText =
  375. this.$refs.inviteT.innerHTML +
  376. "\n" +
  377. this.$refs.invite1.innerHTML +
  378. "\n" +
  379. this.$refs.invite2.innerHTML +
  380. "\n" +
  381. this.$refs.invite3.innerText +
  382. "\n" +
  383. this.$refs.invite4.innerHTML;
  384. var clipboard = new Clipboard(".tag-read");
  385. clipboard.on("success", (e) => {
  386. this.$message.success("复制成功");
  387. console.log("复制成功");
  388. clipboard.destroy(); // 释放内存
  389. });
  390. clipboard.on("error", (e) => {
  391. console.log("不支持复制,该浏览器不支持自动复制");
  392. clipboard.destroy(); // 释放内存
  393. });
  394. },
  395. handleClose(done) {
  396. this.restart();
  397. done();
  398. },
  399. handleClose2(done) {
  400. // done();
  401. },
  402. restart() {
  403. this.file = {};
  404. this.gIndex = "";
  405. this.remarks = "";
  406. if (this.$refs.pathClear1) {
  407. this.$refs.pathClear1.value = "";
  408. this.$refs.pathClear2.value = "";
  409. }
  410. },
  411. deleteGrid(index) {
  412. if (this.data[index].userid != this.userid) {
  413. this.$message.error("你不是上传人无权限删除");
  414. return;
  415. }
  416. this.$confirm("确定删除吗?", "提示", {
  417. confirmButtonText: "确定",
  418. cancelButtonText: "取消",
  419. type: "warning",
  420. })
  421. .then(() => {
  422. this.data[index] = "";
  423. this.updateRoomData();
  424. this.$forceUpdate();
  425. })
  426. .catch(() => {});
  427. },
  428. updateRoomData() {
  429. let params = [
  430. {
  431. data: JSON.stringify(this.data),
  432. idL: this.RoomInfo.id,
  433. },
  434. ];
  435. this.ajax
  436. .post(this.$store.state.api + "updateRoomData", params)
  437. .then((res) => {})
  438. .catch((err) => {});
  439. },
  440. check(index, type) {
  441. this.gIndex = index;
  442. if (this.data[index].userid != this.userid && type != 2 && type != 3) {
  443. this.$message.error("你不是上传人无权限修改");
  444. return;
  445. }
  446. if (this.data[index] && this.data[index].userid == this.userid) {
  447. if (this.data[index].userid != this.userid) {
  448. this.$message.error("你不是上传人无权限修改");
  449. return;
  450. }
  451. this.file = {
  452. photo: this.data[index].photo,
  453. userid: this.data[index].userid,
  454. video:
  455. this.data[index].video &&
  456. this.data[index].video.sources &&
  457. this.data[index].video.sources[0].src,
  458. };
  459. this.remarks = this.data[index].remarks[0].remarks;
  460. } else if (this.data[index] && type == 2) {
  461. this.file = {
  462. userid: this.data[index].userid,
  463. };
  464. for (var i = 0; i < this.data[index].remarks.length; i++) {
  465. if (this.data[index].remarks[i].userid == this.userid) {
  466. this.remarks = this.data[index].remarks[i].remarks;
  467. break;
  468. }
  469. }
  470. this.remarks = this.remarks ? this.remarks : "";
  471. }
  472. this.dialogVisible = true;
  473. },
  474. addEvent(e) {
  475. var el = e.currentTarget;
  476. el.getElementsByTagName("input")[0].click();
  477. },
  478. deleteFile(type) {
  479. if (type == 1) {
  480. this.file.photo = "";
  481. this.deleteVisible1 = false;
  482. this.$refs.pathClear1.value = "";
  483. } else {
  484. this.file.video = "";
  485. this.deleteVisible2 = false;
  486. this.$refs.pathClear2.value = "";
  487. }
  488. this.$forceUpdate();
  489. },
  490. addGrid() {
  491. if (!this.file.userid || this.file.userid == this.userid) {
  492. if (!this.file.video && !this.file.photo) {
  493. this.$message.error("至少上传一个视频或者一张图片");
  494. return;
  495. }
  496. if (!this.data[this.gIndex]) {
  497. this.data[this.gIndex] = {};
  498. }
  499. if (this.file.photo) {
  500. this.data[this.gIndex].photo = this.file.photo;
  501. } else {
  502. // this.playerOptions.sources[0].src = ""
  503. var video = JSON.parse(JSON.stringify(this.playerOptions));
  504. video.sources[0].src = this.file.video;
  505. this.data[this.gIndex].video = video;
  506. }
  507. if (this.data[this.gIndex].remarks) {
  508. this.data[this.gIndex].remarks[0] = {
  509. remarks: this.remarks,
  510. userid: this.userinfo ? this.userinfo.userid : this.userid,
  511. username: this.userinfo ? this.userinfo.name : "用户",
  512. };
  513. } else {
  514. this.data[this.gIndex].remarks = [
  515. {
  516. remarks: this.remarks,
  517. userid: this.userinfo ? this.userinfo.userid : this.userid,
  518. username: this.userinfo ? this.userinfo.name : "用户",
  519. },
  520. ];
  521. }
  522. this.data[this.gIndex].userid = this.userinfo
  523. ? this.userinfo.userid
  524. : this.userid;
  525. } else {
  526. if (!this.remarks) {
  527. this.$message.error("备注不能为空");
  528. return;
  529. }
  530. var a = 0;
  531. for (var i = 0; i < this.data[this.gIndex].remarks.length; i++) {
  532. if (this.data[this.gIndex].remarks[i].userid == this.userid) {
  533. a++;
  534. this.data[this.gIndex].remarks[i] = {
  535. remarks: this.remarks,
  536. userid: this.userinfo ? this.userinfo.userid : this.userid,
  537. username: this.userinfo ? this.userinfo.name : "用户",
  538. };
  539. break;
  540. }
  541. }
  542. if (a < 1) {
  543. this.data[this.gIndex].remarks.push({
  544. remarks: this.remarks,
  545. userid: this.userinfo ? this.userinfo.userid : this.userid,
  546. username: this.userinfo ? this.userinfo.name : "用户",
  547. });
  548. }
  549. }
  550. this.updateRoomData();
  551. this.dialogVisible = false;
  552. this.$forceUpdate();
  553. this.restart();
  554. },
  555. beforeUpload(event, type) {
  556. // debugger;
  557. if (this.file.photo && type != 1) {
  558. this.$message.error("只能上传一个视频或者一张图片");
  559. this.$refs.pathClear2.value = "";
  560. return;
  561. } else if (this.file.video && type != 2) {
  562. this.$message.error("只能上传一个视频或者一张图片");
  563. this.$refs.pathClear1.value = "";
  564. return;
  565. }
  566. var file = event.target.files[0];
  567. var credentials = {
  568. accessKeyId: "AKIATLPEDU37QV5CHLMH",
  569. secretAccessKey: "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",
  570. }; //秘钥形式的登录上传
  571. window.AWS.config.update(credentials);
  572. window.AWS.config.region = "cn-northwest-1"; //设置区域
  573. var bucket = new window.AWS.S3({ params: { Bucket: "ccrb" } }); //选择桶
  574. var _this = this;
  575. if (type == 1) {
  576. var mediaFormatList = ["png", "jpg", "jpeg"];
  577. if (
  578. mediaFormatList.indexOf(
  579. file.name
  580. .split(".")
  581. [file.name.split(".").length - 1].toLocaleLowerCase()
  582. ) == "-1"
  583. ) {
  584. _this.$message.error("请上传jpg或者png的图片格式文件");
  585. return;
  586. }
  587. } else {
  588. var mediaFormatList = ["mp4"];
  589. if (
  590. mediaFormatList.indexOf(
  591. file.name
  592. .split(".")
  593. [file.name.split(".").length - 1].toLocaleLowerCase()
  594. ) == "-1"
  595. ) {
  596. _this.$message.error("请上传mp4视频格式文件");
  597. return;
  598. }
  599. }
  600. _this.progress = 0;
  601. _this.proVisible = true;
  602. if (file) {
  603. var params = {
  604. Key:
  605. file.name.split(".")[0] +
  606. new Date().getTime() +
  607. "." +
  608. file.name.split(".")[1],
  609. ContentType: file.type,
  610. Body: file,
  611. "Access-Control-Allow-Credentials": "*",
  612. ACL: "public-read",
  613. }; //key可以设置为桶的相抵路径,Body为文件, ACL最好要设置
  614. var options = {
  615. partSize: 2048 * 1024 * 1024,
  616. queueSize: 2,
  617. leavePartsOnError: true,
  618. };
  619. bucket
  620. .upload(params, options)
  621. .on("httpUploadProgress", function (evt) {
  622. //这里可以写进度条
  623. // console.log("Uploaded : " + parseInt((evt.loaded * 80) / evt.total) + '%');
  624. _this.progress = parseInt((evt.loaded * 80) / evt.total);
  625. })
  626. .send(function (err, data) {
  627. this.progress = 100;
  628. setTimeout(() => {
  629. _this.proVisible = false;
  630. }, 1000);
  631. if (err) {
  632. _this.$message.error("上传失败");
  633. } else {
  634. if (type == 1) {
  635. _this.file.photo = data.Location;
  636. } else {
  637. _this.file.video = data.Location;
  638. }
  639. _this.$forceUpdate();
  640. console.log(data.Location);
  641. }
  642. });
  643. }
  644. },
  645. getUser() {
  646. let params = { uid: this.userid };
  647. this.ajax
  648. .get(this.$store.state.api + "getUser", params)
  649. .then((res) => {
  650. this.userinfo = res.data[0][0];
  651. console.log(res.data[0][0]);
  652. })
  653. .catch((err) => {
  654. console.error(err);
  655. });
  656. },
  657. MathRand() {
  658. var Num = "";
  659. for (var i = 0; i < 6; i++) {
  660. Num += Math.floor(Math.random() * 10);
  661. }
  662. return Num;
  663. },
  664. checkNum() {
  665. this.numNum = this.MathRand();
  666. let params = {
  667. num: this.numNum,
  668. };
  669. this.ajax
  670. .get(this.$store.state.api + "checkRoomNum", params)
  671. .then((res) => {
  672. console.log(res.data[0].length);
  673. if (res.data[0].length) {
  674. this.checkNum();
  675. } else {
  676. this.addRoom();
  677. }
  678. })
  679. .catch((err) => {
  680. console.error(err);
  681. });
  682. },
  683. addRoom() {
  684. let params = [
  685. {
  686. uid: this.userid,
  687. n: this.numNum,
  688. d: JSON.stringify(this.data),
  689. },
  690. ];
  691. this.ajax
  692. .post(this.$store.state.api + "insertRoom", params)
  693. .then((res) => {
  694. this.$message.success("创建成功");
  695. this.selectRoom(this.userid);
  696. })
  697. .catch((err) => {
  698. this.$message.error("创建失败");
  699. console.error(err);
  700. });
  701. },
  702. selectRoom(uid) {
  703. let params = {
  704. uid: uid,
  705. };
  706. this.ajax
  707. .get(this.$store.state.api + "selectRoom", params)
  708. .then((res) => {
  709. if (res.data[0].length) {
  710. this.RoomInfo = res.data[0][0];
  711. this.data = JSON.parse(res.data[0][0].data);
  712. this.dialogVisible3 = false;
  713. this.dialogVisible2 = true;
  714. // this.data.splice(0,1)
  715. // this.updateRoomData()
  716. this.timer = setInterval(() => {
  717. this.selectRoom2(uid);
  718. }, 5000);
  719. } else {
  720. // this.$message.error("此房间不存在或已被解散");
  721. }
  722. })
  723. .catch((err) => {
  724. console.error(err);
  725. });
  726. },
  727. goRoom(uid) {
  728. let params = {
  729. uid: uid,
  730. };
  731. this.ajax
  732. .get(this.$store.state.api + "selectRoom", params)
  733. .then((res) => {
  734. if (res.data[0].length) {
  735. this.$message.success("加入成功");
  736. this.RoomInfo = res.data[0][0];
  737. this.data = JSON.parse(res.data[0][0].data);
  738. this.dialogVisible3 = false;
  739. this.dialogVisible2 = true;
  740. this.timer = setInterval(() => {
  741. this.selectRoom2(uid);
  742. }, 5000);
  743. } else {
  744. this.$message.error("此房间不存在或已被解散");
  745. }
  746. })
  747. .catch((err) => {
  748. console.error(err);
  749. });
  750. },
  751. selectRoom2(uid) {
  752. let params = {
  753. uid: uid,
  754. };
  755. this.ajax
  756. .get(this.$store.state.api + "selectRoom", params)
  757. .then((res) => {
  758. this.RoomInfo = res.data[0][0];
  759. this.data = JSON.parse(res.data[0][0].data);
  760. })
  761. .catch((err) => {
  762. console.error(err);
  763. });
  764. },
  765. dismiss() {
  766. this.$confirm("确定解散房间吗?", "提示", {
  767. confirmButtonText: "确定",
  768. cancelButtonText: "取消",
  769. type: "warning",
  770. })
  771. .then(() => {
  772. let params = [
  773. {
  774. id: this.RoomInfo.id,
  775. },
  776. ];
  777. this.ajax
  778. .post(this.$store.state.api + "dismiss", params)
  779. .then((res) => {
  780. this.$message.success("解散成功");
  781. this.$router.go(0);
  782. })
  783. .catch((err) => {
  784. console.error(err);
  785. });
  786. })
  787. .catch(() => {});
  788. },
  789. },
  790. beforeDestroy() {
  791. clearInterval(this.timer);
  792. },
  793. created() {
  794. for (var i = 0; i < 16; i++) {
  795. this.data.push("");
  796. }
  797. this.data.push("");
  798. this.getUser();
  799. // this.selectRoom(this.userid);
  800. },
  801. };
  802. </script>
  803. <style scoped>
  804. .g_body {
  805. width: 100%;
  806. height: 100%;
  807. background: #fff;
  808. border-radius: 5px;
  809. display: flex;
  810. align-items: center;
  811. justify-content: center;
  812. flex-wrap: wrap;
  813. position: relative;
  814. min-height: 750px;
  815. }
  816. .coin {
  817. position: absolute;
  818. width: 50px;
  819. z-index: 1;
  820. user-select: none;
  821. }
  822. .coin1 {
  823. top: 10px;
  824. left: 20px;
  825. }
  826. .coin2 {
  827. top: 10px;
  828. right: 20px;
  829. }
  830. .coin3 {
  831. bottom: 10px;
  832. left: 20px;
  833. }
  834. .coin4 {
  835. bottom: 10px;
  836. right: 20px;
  837. }
  838. .g_box {
  839. background: rgb(227 228 232);
  840. width: calc(100% / 4 - 15px);
  841. height: calc(100% / 4 - 15px);
  842. margin: 5px;
  843. border-radius: 5px;
  844. cursor: pointer;
  845. display: flex;
  846. align-items: center;
  847. justify-content: center;
  848. /* overflow: hidden; */
  849. position: relative;
  850. user-select: none;
  851. }
  852. .photo_img {
  853. width: 100%;
  854. height: 100%;
  855. border-radius: 5px;
  856. }
  857. .g_box .add_img {
  858. width: 100px;
  859. display: none;
  860. }
  861. .g_box:hover .add_img {
  862. display: block;
  863. }
  864. .look_notice >>> .el-dialog__header {
  865. padding: 10px 20px;
  866. text-align: center;
  867. background: #32455b;
  868. }
  869. .look_notice >>> .el-dialog__title {
  870. font-size: 14px !important;
  871. color: #fff !important;
  872. }
  873. .look_notice >>> .el-dialog__headerbtn {
  874. font-size: 20px !important;
  875. top: 10px;
  876. }
  877. .look_notice >>> .el-form-item__label {
  878. margin-left: 65px;
  879. }
  880. .look_notice >>> .el-form-item {
  881. display: flex;
  882. }
  883. .look_notice >>> .el-form-item__content {
  884. margin: 0 !important;
  885. }
  886. .look_notice >>> .el-dialog__footer {
  887. text-align: center !important;
  888. }
  889. .look_notice >>> .el-dialog {
  890. min-width: 450px;
  891. background: #f3f3f3;
  892. }
  893. .notice_content {
  894. width: 100%;
  895. word-wrap: break-word;
  896. word-break: break-all;
  897. overflow: hidden;
  898. font-size: 18px;
  899. line-height: 35px;
  900. text-indent: 35px;
  901. min-width: 385px;
  902. }
  903. .roomBtn {
  904. background: rgb(112 183 79);
  905. /* padding: 0 !important; */
  906. border: none;
  907. }
  908. .close {
  909. width: 150px;
  910. height: 40px;
  911. border-radius: 30px;
  912. line-height: 30px;
  913. font-size: 14px;
  914. background: rgb(112 183 79);
  915. padding: 0 !important;
  916. border: none;
  917. }
  918. .header-title {
  919. display: flex;
  920. }
  921. .logoImg {
  922. width: 30px;
  923. }
  924. .logoImg > img {
  925. width: 100%;
  926. height: 100%;
  927. }
  928. .title_add_student {
  929. /* margin: 0 auto; */
  930. color: #fff;
  931. }
  932. .grid_member {
  933. position: absolute;
  934. background: #fff;
  935. right: 70px;
  936. top: 18px;
  937. /* min-width: 320px; */
  938. height: 50px;
  939. border-radius: 5px;
  940. padding: 0 10px;
  941. display: flex;
  942. align-items: center;
  943. z-index: 1;
  944. user-select: none;
  945. }
  946. .member_imgbox {
  947. display: flex;
  948. align-items: center;
  949. margin: 0 10px;
  950. width: 185px;
  951. }
  952. .member_img {
  953. height: 40px;
  954. width: 40px;
  955. border-radius: 50px;
  956. overflow: hidden;
  957. display: block;
  958. background: aliceblue;
  959. }
  960. .member_img + .member_img {
  961. margin-left: 8px;
  962. }
  963. .upload_box {
  964. border-radius: 5px;
  965. background: #fff;
  966. position: relative;
  967. }
  968. .upload_box .list_img {
  969. position: absolute;
  970. top: 10px;
  971. left: 10px;
  972. }
  973. .upload_box .upload_content {
  974. display: flex;
  975. align-items: center;
  976. justify-content: center;
  977. padding: 50px 0 20px;
  978. }
  979. .upload_box .upload_content div {
  980. display: flex;
  981. align-items: center;
  982. justify-content: center;
  983. cursor: pointer;
  984. position: relative;
  985. }
  986. .delete_img {
  987. position: absolute !important;
  988. width: 25px;
  989. transform: translate(50%, -50%);
  990. top: 0;
  991. z-index: 1;
  992. right: 0;
  993. }
  994. .upload_img {
  995. width: 306px;
  996. height: 206px;
  997. }
  998. .textarea_box {
  999. background: #fff;
  1000. margin-top: 20px;
  1001. display: flex;
  1002. flex-direction: column;
  1003. align-items: center;
  1004. padding: 20px 0;
  1005. }
  1006. .textarea_title {
  1007. width: 95%;
  1008. margin: 0 auto;
  1009. font-size: 16px;
  1010. }
  1011. .textarea_content {
  1012. width: 95%;
  1013. margin: 10px auto 0;
  1014. border-radius: 10px;
  1015. }
  1016. .textarea_content >>> .el-textarea__inner {
  1017. background: rgb(243, 243, 243);
  1018. border: none;
  1019. }
  1020. .invite_dialog >>> .el-dialog__body {
  1021. padding: 15px 20px;
  1022. }
  1023. .room_dialog >>> .el-dialog {
  1024. margin-top: 50vh !important;
  1025. transform: translateY(-50%);
  1026. min-width: unset;
  1027. }
  1028. .invite_box {
  1029. font-size: 16px;
  1030. background: #fff;
  1031. border-radius: 5px;
  1032. padding: 30px 0 150px;
  1033. }
  1034. .invite_title {
  1035. width: 90%;
  1036. margin: 0 auto 20px;
  1037. }
  1038. .line {
  1039. width: 95%;
  1040. border-top: 1px solid rgb(230, 230, 230);
  1041. margin: 0 auto;
  1042. }
  1043. .invite_link {
  1044. width: 90%;
  1045. margin: 20px auto 30px;
  1046. }
  1047. .invite_link div + div {
  1048. margin-top: 15px;
  1049. }
  1050. .invite_num {
  1051. width: 90%;
  1052. margin: 0 auto 50px;
  1053. }
  1054. .invite_num span {
  1055. color: rgb(112 183 79);
  1056. font-size: 28px;
  1057. }
  1058. .addRoom_box {
  1059. background: #fff;
  1060. padding: 30px 20px;
  1061. border-radius: 5px;
  1062. }
  1063. .room_b {
  1064. margin: 5px 0 30px;
  1065. /* width:300px; */
  1066. }
  1067. .room_btn {
  1068. display: flex;
  1069. justify-content: space-around;
  1070. }
  1071. .mask {
  1072. background-color: rgba(0, 0, 0, 0);
  1073. position: fixed;
  1074. top: 0;
  1075. left: 0;
  1076. width: 100%;
  1077. height: 100%;
  1078. z-index: 20000;
  1079. display: flex;
  1080. align-items: center;
  1081. justify-content: center;
  1082. }
  1083. .progressBox {
  1084. width: 500px;
  1085. height: 180px;
  1086. background: #fff;
  1087. border-radius: 10px;
  1088. box-shadow: 0 0 6px 1px #bfbfbf;
  1089. display: flex;
  1090. align-items: center;
  1091. justify-content: center;
  1092. flex-direction: column;
  1093. }
  1094. .progressBox .lbox {
  1095. height: 100px;
  1096. font-size: 19px;
  1097. display: flex;
  1098. align-items: center;
  1099. }
  1100. .progressBox .lbox img {
  1101. width: 40px;
  1102. margin-right: 20px;
  1103. }
  1104. .progressBox >>> .el-progress-bar__outer {
  1105. background-color: #d1dfff !important;
  1106. }
  1107. .top-popover {
  1108. position: absolute;
  1109. top: -50px;
  1110. left: 0;
  1111. background: #fff;
  1112. display: flex;
  1113. height: 45px;
  1114. align-items: center;
  1115. padding: 0px 10px 0 20px;
  1116. border-radius: 5px;
  1117. box-shadow: 0 1px 3px 1px rgb(202, 202, 202);
  1118. z-index: 10;
  1119. transition: 0.5s all;
  1120. opacity: 0;
  1121. visibility: hidden;
  1122. }
  1123. .top-popover .pChild {
  1124. display: flex;
  1125. align-items: center;
  1126. }
  1127. .top-popover .pChild + .pChild {
  1128. margin-left: 10px;
  1129. }
  1130. .left-popover {
  1131. position: absolute;
  1132. top: 0px;
  1133. right: -65px;
  1134. background: #fff;
  1135. display: flex;
  1136. width: 45px;
  1137. align-items: center;
  1138. padding: 10px 5px 20px;
  1139. border-radius: 5px;
  1140. box-shadow: 0 1px 3px 1px rgb(202, 202, 202);
  1141. z-index: 10;
  1142. flex-direction: column;
  1143. justify-content: center;
  1144. transition: 0.5s all;
  1145. opacity: 0;
  1146. visibility: hidden;
  1147. }
  1148. .left-popover .pChild {
  1149. display: flex;
  1150. align-items: center;
  1151. flex-direction: column;
  1152. }
  1153. .left-popover .pChild span {
  1154. display: flex;
  1155. align-items: center;
  1156. flex-direction: column;
  1157. text-align: center;
  1158. }
  1159. .left-popover .pChild + .pChild {
  1160. margin-top: 10px;
  1161. }
  1162. .right-popover {
  1163. position: absolute;
  1164. top: 0px;
  1165. left: -65px;
  1166. background: #fff;
  1167. display: flex;
  1168. width: 45px;
  1169. align-items: center;
  1170. padding: 10px 5px 20px;
  1171. border-radius: 5px;
  1172. box-shadow: 0 1px 3px 1px rgb(202, 202, 202);
  1173. z-index: 10;
  1174. flex-direction: column;
  1175. justify-content: center;
  1176. transition: 0.5s all;
  1177. opacity: 0;
  1178. visibility: hidden;
  1179. }
  1180. .right-popover .pChild {
  1181. display: flex;
  1182. align-items: center;
  1183. flex-direction: column;
  1184. }
  1185. .right-popover .pChild span {
  1186. display: flex;
  1187. align-items: center;
  1188. flex-direction: column;
  1189. text-align: center;
  1190. }
  1191. .right-popover .pChild + .pChild {
  1192. margin-top: 10px;
  1193. }
  1194. .visibleO {
  1195. opacity: 1 !important;
  1196. visibility: visible !important;
  1197. }
  1198. .remark-bottom-popover {
  1199. position: absolute;
  1200. bottom: 0px;
  1201. left: 0;
  1202. background: #fff;
  1203. max-height: 150px;
  1204. width: 100%;
  1205. padding: 10px 20px;
  1206. border-radius: 5px;
  1207. box-shadow: 0 1px 3px 1px rgb(202, 202, 202);
  1208. z-index: 10;
  1209. transition: 0.5s all;
  1210. box-sizing: border-box;
  1211. transform: translateY(calc(100% + 5px));
  1212. overflow: auto;
  1213. opacity: 0;
  1214. visibility: hidden;
  1215. }
  1216. .Rbox {
  1217. display: flex;
  1218. word-break: break-all;
  1219. }
  1220. .Rbox + .Rbox {
  1221. border-top: 1px solid rgb(233, 233, 233);
  1222. margin-top: 10px;
  1223. padding-top: 10px;
  1224. }
  1225. .Rportal {
  1226. height: 45px;
  1227. min-width: 45px;
  1228. border-radius: 50px;
  1229. overflow: hidden;
  1230. display: block;
  1231. background: aliceblue;
  1232. user-select: none;
  1233. }
  1234. .RContent {
  1235. margin-left: 10px;
  1236. }
  1237. .RContent div:nth-child(1) {
  1238. user-select: none;
  1239. color: rgb(80, 80, 80);
  1240. margin-bottom: 5px;
  1241. font-size: 14px;
  1242. }
  1243. .RContent div:nth-child(2) {
  1244. font-family: "微软雅黑";
  1245. font-size: 15px;
  1246. }
  1247. .remark-right-popover {
  1248. position: absolute;
  1249. top: 0;
  1250. right: 0;
  1251. background: #fff;
  1252. max-height: 100%;
  1253. width: 300px;
  1254. padding: 10px 20px;
  1255. border-radius: 5px;
  1256. box-shadow: 0 1px 3px 1px rgb(202, 202, 202);
  1257. z-index: 10;
  1258. transition: 0.5s all;
  1259. box-sizing: border-box;
  1260. transform: translateX(calc(100% + 5px));
  1261. overflow: auto;
  1262. opacity: 0;
  1263. visibility: hidden;
  1264. }
  1265. .remark-left-popover {
  1266. position: absolute;
  1267. top: 0;
  1268. left: 0;
  1269. background: #fff;
  1270. max-height: 100%;
  1271. width: 300px;
  1272. padding: 10px 20px;
  1273. border-radius: 5px;
  1274. box-shadow: 0 1px 3px 1px rgb(202, 202, 202);
  1275. z-index: 10;
  1276. transition: 0.5s all;
  1277. box-sizing: border-box;
  1278. transform: translateX(calc(-100% - 5px));
  1279. overflow: auto;
  1280. opacity: 0;
  1281. visibility: hidden;
  1282. }
  1283. </style>