|
@@ -1,5 +1,13 @@
|
|
|
<template>
|
|
|
<div class="PushMenu">
|
|
|
+ <el-input
|
|
|
+ placeholder="请输入密码"
|
|
|
+ v-model="input"
|
|
|
+ style="width: 220px"
|
|
|
+ show-password
|
|
|
+ ></el-input>
|
|
|
+ <br />
|
|
|
+ <br />
|
|
|
<el-date-picker
|
|
|
v-model="dt"
|
|
|
value-format="yyyyMMdd"
|
|
@@ -13,9 +21,11 @@
|
|
|
<el-upload
|
|
|
class="upload-demo"
|
|
|
drag
|
|
|
- :data="{dt}"
|
|
|
+ :data="reqData"
|
|
|
:action="baseURl + '/menu/upload'"
|
|
|
:before-upload="beforeUpload"
|
|
|
+ :on-success="onSuccess"
|
|
|
+ :on-error="onError"
|
|
|
multiple
|
|
|
>
|
|
|
<i class="el-icon-upload"></i>
|
|
@@ -29,26 +39,36 @@
|
|
|
// @ is an alias to /src
|
|
|
|
|
|
import config from "../config/index.js";
|
|
|
+import sha256 from "sha256";
|
|
|
export default {
|
|
|
name: "PushMenu",
|
|
|
data() {
|
|
|
return {
|
|
|
dt: "",
|
|
|
- baseURl: config.base.menuURL
|
|
|
+ input: "",
|
|
|
+ baseURl: config.base.menuURL,
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
|
let dt = new Date();
|
|
|
let y = dt.getFullYear(),
|
|
|
- m = dt.getMonth() + 1,
|
|
|
- d = dt.getDate();
|
|
|
- y > 9 ? '' : y = '0' + y;
|
|
|
- m > 9 ? '' : m = '0' + m;
|
|
|
- d > 9 ? '' : d = '0' + d;
|
|
|
- this.dt = [y,m,d].join("")
|
|
|
+ m = dt.getMonth() + 1,
|
|
|
+ d = dt.getDate();
|
|
|
+ y > 9 ? "" : (y = "0" + y);
|
|
|
+ m > 9 ? "" : (m = "0" + m);
|
|
|
+ d > 9 ? "" : (d = "0" + d);
|
|
|
+ this.dt = [y, m, d].join("");
|
|
|
document.title = "上传菜单";
|
|
|
+ this.input = localStorage.inputName || "";
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ reqData() {
|
|
|
+ return {
|
|
|
+ dt: this.dt,
|
|
|
+ password: sha256(this.input),
|
|
|
+ };
|
|
|
+ },
|
|
|
},
|
|
|
- computed: {},
|
|
|
methods: {
|
|
|
beforeUpload(file) {
|
|
|
if (
|
|
@@ -60,6 +80,14 @@ export default {
|
|
|
}
|
|
|
this.$message.error("所选文件格式错误");
|
|
|
},
|
|
|
+ onSuccess() {
|
|
|
+ localStorage.inputName = this.input || "";
|
|
|
+ },
|
|
|
+ onError(err) {
|
|
|
+ let e = err.toString().split(": ")[1] || "{}";
|
|
|
+ e = JSON.parse(e);
|
|
|
+ this.$message.error(e.message || '请求失败');
|
|
|
+ },
|
|
|
},
|
|
|
beforeUnmount: function () {
|
|
|
localStorage.token = "";
|