You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
197 lines
6.7 KiB
197 lines
6.7 KiB
5 years ago
|
<template>
|
||
|
<div class="publish-container">
|
||
|
<div>
|
||
4 years ago
|
<div v-if="!publishStatus" class="publish-btn-view">
|
||
5 years ago
|
<el-button
|
||
|
class="publish-btn"
|
||
4 years ago
|
size="medium"
|
||
|
type="primary"
|
||
|
@click="publishProject"
|
||
|
>
|
||
|
<i class="el-icon-document-checked el-icon--right">开始发布</i>
|
||
|
</el-button>
|
||
5 years ago
|
</div>
|
||
4 years ago
|
<div v-if="publishStatus" class="publish-finish-view">
|
||
|
<el-row align="middle" type="flex">
|
||
|
<el-col :span="20">
|
||
|
<div style="display: flex; justify-content: center;">
|
||
5 years ago
|
<div class="icon-view">
|
||
4 years ago
|
<i class="el-icon-check success-icon" />
|
||
5 years ago
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<p class="success-title">恭喜您,发布成功!</p>
|
||
|
</div>
|
||
|
<div>
|
||
|
<p class="link-text"> {{ writeLink }}</p>
|
||
|
</div>
|
||
|
<el-row>
|
||
4 years ago
|
<el-col :offset="3" :span="6">
|
||
5 years ago
|
<el-button v-clipboard:copy="writeLink"
|
||
4 years ago
|
v-clipboard:error="()=>{this.msgError('复制失败')}"
|
||
|
v-clipboard:success="()=>{this.msgSuccess('复制成功')}" type="primary"
|
||
|
>
|
||
|
复制链接
|
||
5 years ago
|
</el-button>
|
||
|
</el-col>
|
||
4 years ago
|
<el-col :span="6">
|
||
4 years ago
|
<el-button
|
||
4 years ago
|
type="danger"
|
||
4 years ago
|
@click="stopPublishProject"
|
||
4 years ago
|
>
|
||
|
停止发布
|
||
4 years ago
|
</el-button>
|
||
|
</el-col>
|
||
5 years ago
|
<el-col :span="6">
|
||
5 years ago
|
<el-button
|
||
4 years ago
|
type="warning"
|
||
5 years ago
|
@click="toFeedbackPageHandle"
|
||
4 years ago
|
>
|
||
|
查看反馈
|
||
5 years ago
|
</el-button>
|
||
5 years ago
|
</el-col>
|
||
|
</el-row>
|
||
|
</el-col>
|
||
|
<el-col :span="6">
|
||
|
<div>
|
||
4 years ago
|
<vue-qr v-if="writeLink" :callback="qrCodeGenSuccess" :size="194"
|
||
|
:text="writeLink"
|
||
|
/>
|
||
5 years ago
|
</div>
|
||
4 years ago
|
<div style="text-align: center;">
|
||
5 years ago
|
<el-link type="primary" @click="()=>{
|
||
|
this.downloadFile('qrcode.png',this.qrCodeUrl)
|
||
4 years ago
|
}"
|
||
|
>
|
||
|
下载分享二维码
|
||
5 years ago
|
</el-link>
|
||
5 years ago
|
</div>
|
||
|
</el-col>
|
||
|
</el-row>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import VueQr from 'vue-qr'
|
||
|
|
||
|
export default {
|
||
4 years ago
|
name: 'ProjectPublish',
|
||
5 years ago
|
components: {
|
||
|
VueQr
|
||
|
},
|
||
|
data() {
|
||
|
return {
|
||
|
publishStatus: false,
|
||
4 years ago
|
projectKey: null,
|
||
5 years ago
|
writeLink: '',
|
||
|
qrCodeUrl: ''
|
||
|
}
|
||
4 years ago
|
},
|
||
|
mounted() {
|
||
4 years ago
|
this.projectKey = this.$route.query.key
|
||
4 years ago
|
let url = window.location.protocol + '//' + window.location.host
|
||
|
this.writeLink = `${url}/s/${this.projectKey}`
|
||
|
this.getProjectStatus()
|
||
5 years ago
|
}, methods: {
|
||
5 years ago
|
getProjectStatus() {
|
||
|
this.$api.get(`/user/project/${this.projectKey}`).then(res => {
|
||
4 years ago
|
if (res.data.status == 2) {
|
||
5 years ago
|
this.publishStatus = true
|
||
4 years ago
|
} else {
|
||
4 years ago
|
this.publishStatus = false
|
||
5 years ago
|
}
|
||
|
})
|
||
|
},
|
||
5 years ago
|
publishProject() {
|
||
4 years ago
|
this.$api.post('/user/project/publish', {key: this.projectKey}).then(() => {
|
||
5 years ago
|
this.publishStatus = true
|
||
|
this.msgSuccess('发布成功')
|
||
|
})
|
||
|
},
|
||
4 years ago
|
stopPublishProject() {
|
||
|
this.$api.post('/user/project/stop', {'key': this.projectKey}).then(res => {
|
||
|
if (res.data) {
|
||
|
this.msgSuccess('停止成功')
|
||
|
this.getProjectStatus()
|
||
|
}
|
||
|
})
|
||
|
},
|
||
4 years ago
|
qrCodeGenSuccess(dataUrl) {
|
||
5 years ago
|
this.qrCodeUrl = dataUrl
|
||
|
},
|
||
|
downloadFile(fileName, content) {
|
||
5 years ago
|
let aLink = document.createElement('a')
|
||
4 years ago
|
let blob = this.base64ToBlob(content) // new Blob([content]);
|
||
5 years ago
|
let evt = document.createEvent('HTMLEvents')
|
||
4 years ago
|
evt.initEvent('click', true, true)// initEvent 不加后两个参数在FF下会报错 事件类型,是否冒泡,是否阻止浏览器的默认行为
|
||
5 years ago
|
aLink.download = fileName
|
||
|
aLink.href = URL.createObjectURL(blob)
|
||
5 years ago
|
// aLink.dispatchEvent(evt);
|
||
|
aLink.click()
|
||
|
},
|
||
4 years ago
|
// base64转blob
|
||
5 years ago
|
base64ToBlob(code) {
|
||
|
let parts = code.split(';base64,')
|
||
|
let contentType = parts[0].split(':')[1]
|
||
|
let raw = window.atob(parts[1])
|
||
|
let rawLength = raw.length
|
||
|
let uInt8Array = new Uint8Array(rawLength)
|
||
|
for (let i = 0; i < rawLength; ++i) {
|
||
|
uInt8Array[i] = raw.charCodeAt(i)
|
||
|
}
|
||
|
return new Blob([uInt8Array], {type: contentType})
|
||
5 years ago
|
},
|
||
|
toFeedbackPageHandle() {
|
||
4 years ago
|
this.$router.replace({path: '/project/form/statistics', query: {key: this.projectKey}})
|
||
5 years ago
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style lang="scss" scoped>
|
||
|
.publish-container {
|
||
|
width: 100%;
|
||
|
height: 100%;
|
||
4 years ago
|
padding: 0;
|
||
5 years ago
|
margin: 0;
|
||
4 years ago
|
background-color: #f7f7f7;
|
||
5 years ago
|
min-height: 84vh;
|
||
|
display: flex;
|
||
|
align-items: center;
|
||
|
justify-content: center;
|
||
|
}
|
||
|
.publish-finish-view {
|
||
|
width: 500px;
|
||
|
height: 200px;
|
||
|
text-align: center;
|
||
|
.icon-view {
|
||
|
width: 59px;
|
||
|
height: 59px;
|
||
|
border-radius: 100px;
|
||
4 years ago
|
background-color: #0076ff;
|
||
5 years ago
|
display: flex;
|
||
|
align-items: center;
|
||
|
align-content: center;
|
||
|
justify-items: center;
|
||
|
justify-content: center;
|
||
|
}
|
||
|
.success-icon {
|
||
|
text-align: center;
|
||
|
color: white;
|
||
|
font-size: 30px;
|
||
|
}
|
||
|
.success-title {
|
||
|
color: rgba(16, 16, 16, 100);
|
||
|
font-size: 28px;
|
||
|
}
|
||
|
.link-text {
|
||
|
color: rgba(16, 16, 16, 100);
|
||
|
font-size: 14px;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
</style>
|