index.vue
2.31 KB
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
<!--
* @Author: lide1202@hotmail.com
* @Date: 2021-3-13 11:04:24
* @Last Modified by: lide1202@hotmail.com
* @Last Modified time: 2021-3-13 11:04:24
!-->
<template>
<div>
<el-dialog
title="请输入分享码"
:visible.sync="dialogVisible"
width="30%"
:close-on-click-modal="false"
:before-close="handleClose"
>
<el-input v-model="password" placeholder="请输入分享码"></el-input>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false">取 消</el-button>
<el-button type="primary" @click="checkPassword()">确 定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import { reportShareDetailByCode } from "@/api/reportShare";
import { setShareToken } from "@/utils/auth";
export default {
name: "Report",
components: {},
data() {
return {
password: "",
sharePassword: "",
dialogVisible: false,
reportCode: "",
shareToken: "",
otherParam:""
};
},
created() {
this.handleOpen();
},
methods: {
async handleOpen() {
const url = window.location.href;
const shareCode = url.substring(url.lastIndexOf("/") + 1);
const { code, data } = await reportShareDetailByCode(shareCode);
if (code != "200") return;
this.reportCode = data.reportCode;
this.sharePassword = data.sharePassword;
this.shareToken = data.shareToken;
if(this.isNotBlank(data.otherParam)){
this.otherParam = "?"+data.otherParam;
}
if (this.sharePassword) {
this.dialogVisible = true;
} else {
this.pushAj();
}
},
checkPassword() {
const md5 = require("js-md5");
const inputPassword = md5(this.password);
if (inputPassword == this.sharePassword) {
this.pushAj();
} else {
this.$message.error("分享码输入不正确");
}
},
pushAj() {
console.log("ssss",this.reportCode,this.otherParam)
setShareToken(this.shareToken);
this.$router.push({
path: "/bigscreen/viewer",
query: {
reportCode: this.reportCode+this.otherParam,
}
});
},
handleClose(done) {
this.$confirm("确认关闭?")
.then(_ => {
done();
})
.catch(_ => {});
}
}
};
</script>