|
@@ -1,19 +1,20 @@
|
|
|
-import { defineComponent } from 'vue'
|
|
|
-import { ElButton, ElFormItem, ElForm, ElRadio,ElMessage } from 'element-plus'
|
|
|
+import { defineComponent, DefineComponent, ref, Ref } from 'vue'
|
|
|
+import { ElButton, ElFormItem, ElForm, ElRadio, ElMessage } from 'element-plus'
|
|
|
import runtime, * as RuntimeUtils from './runtime'
|
|
|
import styles from './share.module.less'
|
|
|
import request from "/src/helpers/request";
|
|
|
import { vaildStudentUrl } from "/src/helpers/validate";
|
|
|
import { toPng } from "html-to-image";
|
|
|
import copy from "copy-to-clipboard";
|
|
|
-// import groupChat from './'
|
|
|
+import GroupChat from './groupChat'
|
|
|
import Preview from './preview'
|
|
|
+const GroupChatRef: Ref<DefineComponent<{}, {}, any> | null> = ref(null)
|
|
|
export default defineComponent({
|
|
|
name: 'LiveBroadcastShare',
|
|
|
- props:{
|
|
|
- onClose:{
|
|
|
+ props: {
|
|
|
+ onClose: {
|
|
|
type: Function,
|
|
|
- default: () => {}
|
|
|
+ default: () => { }
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
@@ -23,7 +24,7 @@ export default defineComponent({
|
|
|
roomTitle: '',
|
|
|
liveStartTime: '',
|
|
|
liveRemark: '',
|
|
|
- roomUid:''
|
|
|
+ roomUid: ''
|
|
|
},
|
|
|
url: ''
|
|
|
}
|
|
@@ -57,24 +58,49 @@ export default defineComponent({
|
|
|
},
|
|
|
shareImage() {
|
|
|
var node = document.getElementById("preview");
|
|
|
- toPng(node)
|
|
|
- .then((dataUrl) => {
|
|
|
- var img = new Image();
|
|
|
- img.src = dataUrl;
|
|
|
- // 在这里下载
|
|
|
- let link = document.createElement("a");
|
|
|
- let fname = this.detail.roomTitle || "分享图片文件.png"; //下载文件的名字
|
|
|
- link.href = dataUrl;
|
|
|
- link.setAttribute("download", fname);
|
|
|
- document.body.appendChild(link);
|
|
|
- link.click();
|
|
|
- this.$emit('close')
|
|
|
- })
|
|
|
- .catch(function (error) {
|
|
|
- console.error("oops, something went wrong!", error);
|
|
|
- });
|
|
|
+ if (node) {
|
|
|
+ toPng(node)
|
|
|
+ .then((dataUrl) => {
|
|
|
+ var img = new Image();
|
|
|
+ img.src = dataUrl;
|
|
|
+ // 在这里下载
|
|
|
+ let link = document.createElement("a");
|
|
|
+ let fname = this.detail.roomTitle || "分享图片文件.png"; //下载文件的名字
|
|
|
+ link.href = dataUrl;
|
|
|
+ link.setAttribute("download", fname);
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ this.onClose()
|
|
|
+ })
|
|
|
+ .catch(function (error) {
|
|
|
+ console.error("oops, something went wrong!", error);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ async shareChat() {
|
|
|
+
|
|
|
+ let checkList = GroupChatRef.value?.checkList || [];
|
|
|
+ if (!(checkList.length > 0)) {
|
|
|
+ ElMessage.error("请至少选择一个群聊");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ let obj = {
|
|
|
+ groupIds: checkList.join(","),
|
|
|
+ roomUid: this.detail.roomUid,
|
|
|
+ }
|
|
|
+ const res = await request.get('/api-web/imLiveBroadcastRoom/shareGroup', {
|
|
|
+ params: {
|
|
|
+ ...obj
|
|
|
+ }
|
|
|
+ });
|
|
|
+ ElMessage.success('分享成功')
|
|
|
+ this.onClose()
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
},
|
|
|
- shareChat() { },
|
|
|
changeRafdio(value: string) {
|
|
|
this.form.shareType = value;
|
|
|
}
|
|
@@ -104,14 +130,14 @@ export default defineComponent({
|
|
|
</div >
|
|
|
{this.form.shareType === '2' ? <div class={styles.codeWrap} >
|
|
|
<div class={styles.shareWrap}>
|
|
|
- <Preview form={this.detail} url={ this.url}/>
|
|
|
+ <Preview form={this.detail} url={this.url} />
|
|
|
</div>
|
|
|
<div class={styles.shareBtn} onClick={this.shareImage}>复制分享内容</div>
|
|
|
</div> : null
|
|
|
}
|
|
|
{this.form.shareType == '3' ? <div class={styles.shareWrap}>
|
|
|
<div class={styles.groupWrap} >
|
|
|
- {/* <GroupChat /> */}
|
|
|
+ <GroupChat ref={GroupChatRef} />
|
|
|
</div>
|
|
|
<div class={styles.shareBtn} onClick={this.shareChat}>发送分享信息</div>
|
|
|
</div> : null
|