Commit b7768e2e authored by ganjingcun's avatar ganjingcun

deck demo

parent bc44545b
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
"element-ui": "^1.2.8", "element-ui": "^1.2.8",
"moment": "^2.18.1", "moment": "^2.18.1",
"shelljs": "^0.7.7", "shelljs": "^0.7.7",
"swiper": "^3.4.2",
"vue": "^2.2.2", "vue": "^2.2.2",
"vue-resource": "^1.3.1", "vue-resource": "^1.3.1",
"vue-router": "^2.2.0", "vue-router": "^2.2.0",
......
...@@ -10,6 +10,14 @@ const URL = "https://api.mycard.moe/ygopro/arena" ...@@ -10,6 +10,14 @@ const URL = "https://api.mycard.moe/ygopro/arena"
export default class Api { export default class Api {
static uploadUrl = `${URL}/upload`
static getDownloadUrl(url) {
url = url.slice(7)
var downloadUrl = `${URL}/download/${url}`
return downloadUrl
}
static getCount(opt) { static getCount(opt) {
var request = query.stringify(opt); var request = query.stringify(opt);
const url = `${config.COUNTER_URL}?${request}`; const url = `${config.COUNTER_URL}?${request}`;
...@@ -47,14 +55,17 @@ export default class Api { ...@@ -47,14 +55,17 @@ export default class Api {
} }
static getDeckInfo(opt) { static getDeckInfo(opt) {
var tmp = "http://localhost:3000/api"
return Vue.http.get(`${URL}/deckinfo`, { 'params': opt }); return Vue.http.get(`${URL}/deckinfo`, { 'params': opt });
} }
static saveDeck(opt) { static saveDeck(opt) {
var tmp = "http://localhost:3000/api"
const url = `${URL}/deckinfo` const url = `${URL}/deckinfo`
return Vue.http.post(url, opt, { 'emulateJSON': true }); return Vue.http.post(url, opt, { 'emulateJSON': true });
} }
static saveDeckDemo(opt) {
const url = `${URL}/deckdemo`
return Vue.http.post(url, opt, { 'emulateJSON': true });
}
} }
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
<h4 class="color-blue"><i class="glyphicon glyphicon-list-alt"></i> 编辑历史 </h4> <h4 class="color-blue"><i class="glyphicon glyphicon-list-alt"></i> 编辑历史 </h4>
<!--<div class="panel panel-default"> <!--<div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title">编辑历史 </h3> <h3 class="panel-title">编辑历史 </h3>
...@@ -76,6 +77,64 @@ ...@@ -76,6 +77,64 @@
<table id="athletic_rank" class="table table-striped table-bordered table-hover example" :class="{ scroll: isMobile }"></table> <table id="athletic_rank" class="table table-striped table-bordered table-hover example" :class="{ scroll: isMobile }"></table>
</div> </div>
<h4 class="color-blue"><i class="glyphicon glyphicon-list-alt"></i> 卡组范例&下载 </h4>
<div v-if="user.isLogin">
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<span v-if="!isNew">您可以上传卡组范例。</span>
<span v-if="isNew">还没有卡组范例。</span>
<i class="el-icon-edit hand" @click.prevent="showDialog2">我要上传</i>
</div>
</div>
<div v-else>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<span>登录后才可上传卡组范例。</span>
<a class="hand" @click.prevent="login" href="#">登录</a>
</div>
</div>
<el-row>
<el-col :span="7" v-for="(o, index) in demo1" :key="o" :offset="index > 0 ? 1 : 0">
<el-card :body-style="{ padding: '0px' }">
<img :src="o.url" class="image">
<div style="padding: 6px;">
<span style="font-size: 10px">标题: {{o.title}}</span>
<br>
<span style="font-size: 10px">上传者: {{o.author}}</span>
<div class="bottom clearfix">
<time class="time">{{o.create_time}}</time>
<el-button v-if="o.file" type="text" class="button" @click="downloadFile(o.file)">下载</el-button>
</div>
</div>
</el-card>
</el-col>
</el-row>
<br>
<el-row>
<el-col :span="7" v-for="(o, index) in demo2" :key="o" :offset="index > 0 ? 1 : 0">
<el-card :body-style="{ padding: '0px' }">
<img :src="o.url" class="image">
<div style="padding: 6px;">
<span style="font-size: 10px">标题: {{o.title}}</span>
<br>
<span style="font-size: 10px">上传者: {{o.author}}</span>
<div class="bottom clearfix">
<time class="time">{{o.create_time}}</time>
<el-button v-if="o.file" type="text" class="button" @click="downloadFile(o.file)">下载</el-button>
</div>
</div>
</el-card>
</el-col>
</el-row>
<br>
<el-dialog :title="username" size="large" v-model="dialogFormVisible"> <el-dialog :title="username" size="large" v-model="dialogFormVisible">
<el-form :model="form"> <el-form :model="form">
<el-form-item label="标题" :label-width="formLabelWidth"> <el-form-item label="标题" :label-width="formLabelWidth">
...@@ -104,6 +163,65 @@ ...@@ -104,6 +163,65 @@
</div> </div>
</el-dialog> </el-dialog>
<!--上传卡组范例-->
<el-dialog title="上传卡组范例" size="large" v-model="dialogFormVisible2">
<el-form :model="form">
<el-form-item label="标题" :label-width="formLabelWidth">
<el-input v-model="demo_title" placeholder="请输入标题" auto-complete="off"></el-input>
</el-form-item>
<el-form-item label="图片URL" :label-width="formLabelWidth">
<el-input v-model="demo_url" placeholder="请输入您希望展示的图片的地址" auto-complete="off"></el-input>
</el-form-item>
<!--<el-form-item label="类型" :label-width="formLabelWidth">
<el-select v-model="form.region" placeholder="请选择类型">
<el-option label="一" value="shanghai"></el-option>
<el-option label="二" value="beijing"></el-option>
</el-select>
</el-form-item>-->
<!--<el-form-item label="描述" :label-width="formLabelWidth">
<el-input type="textarea" :autosize="{ minRows: 2, maxRows: 6}" placeholder="请输入您对此卡组的描述" v-model="form.desc_new">
</el-input>
</el-form-item>-->
<el-form-item label="文件" :label-width="formLabelWidth">
<!--<el-upload
class="avatar-uploader"
:action="uploadUrl"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload">
<img v-if="imageUrl" :src="imageUrl" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
<div class="el-upload__tip" slot="tip">上传卡组文件,大小不能超过500kb</div>
</el-upload>-->
<el-upload
class="upload-demo"
:action="uploadUrl"
:on-change="handleChange"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
:file-list="fileList3">
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">上传卡组文件,大小不能超过2M</div>
</el-upload>
</el-form-item>
<!--<button v-if="downloadPath" @click.prevent="download" >下载</button>-->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelModify2">取 消</el-button>
<el-button type="primary" @click="submitModify2">确 定</el-button>
</div>
</el-dialog>
</div> </div>
</div> </div>
</div> </div>
...@@ -119,12 +237,15 @@ ...@@ -119,12 +237,15 @@
import moment from 'moment' import moment from 'moment'
import tb_language from './tb_lang.js' import tb_language from './tb_lang.js'
var rankTable; var rankTable;
var rankTable2; var rankTable2;
export default { export default {
data() { data() {
return { return {
currentDate: new Date(),
fileList3: [],
isMobile: false, isMobile: false,
searchText: "", searchText: "",
hasError: false, hasError: false,
...@@ -134,7 +255,7 @@ ...@@ -134,7 +255,7 @@
avatar_url: "assets/img/unknow.jpeg", avatar_url: "assets/img/unknow.jpeg",
avatar_url_new: "", avatar_url_new: "",
input3: 'asdasd', input3: 'asdasd',
dialogTableVisible: false, dialogFormVisible2: false,
dialogFormVisible: false, dialogFormVisible: false,
form: { form: {
name: '', name: '',
...@@ -151,7 +272,14 @@ ...@@ -151,7 +272,14 @@
formLabelWidth: '40px', formLabelWidth: '40px',
isNew: true, isNew: true,
isClick: false, isClick: false,
todayCount: 0 todayCount: 0,
uploadUrl: API.uploadUrl,
imageUrl:"",
downloadPath:"",
demo_title: "",
demo_url:"",
demo1: [],
demo2: []
} }
}, },
created: function () { created: function () {
...@@ -168,6 +296,7 @@ ...@@ -168,6 +296,7 @@
} }
}, },
mounted: function () { mounted: function () {
var queryObj = querystring.parse(location.search.slice(1)) var queryObj = querystring.parse(location.search.slice(1))
var name = queryObj.name var name = queryObj.name
var version = queryObj.version var version = queryObj.version
...@@ -196,6 +325,8 @@ ...@@ -196,6 +325,8 @@
this.avatar_url_new = dataPbj.url this.avatar_url_new = dataPbj.url
this.form.desc = dataPbj.desc this.form.desc = dataPbj.desc
this.form.desc_new = dataPbj.desc this.form.desc_new = dataPbj.desc
this.demo1 = res.data.demo.slice(0,3)
this.demo2 = res.data.demo.slice(3,6)
if (rankTable) { if (rankTable) {
rankTable.destroy(); rankTable.destroy();
...@@ -206,6 +337,8 @@ ...@@ -206,6 +337,8 @@
this.hasError = true this.hasError = true
console.log(res) console.log(res)
}); });
}, },
computed: { computed: {
...mapGetters({ ...mapGetters({
...@@ -223,6 +356,35 @@ ...@@ -223,6 +356,35 @@
}, },
handleChange(file, fileList) {
this.fileList3 = fileList.slice(-1);
},
handleAvatarSuccess(res, file) {
this.downloadPath = file.response.path
this.imageUrl = URL.createObjectURL(file.raw);
},
beforeAvatarUpload(file) {
// const isJPG = file.type === 'image/jpeg';
const isLt2M = file.size / 1024 / 1024 < 2;
// if (!isJPG) {
// this.$message.error('上传头像图片只能是 JPG 格式!');
// }
if (!isLt2M) {
this.$message.error('上传文件大小不能超过 2MB!');
}
return isLt2M;
},
download: function(){
window.location.href = API.getDownloadUrl(this.downloadPath)
},
downloadFile: function(path){
window.location.href = API.getDownloadUrl(path)
},
onSubmit: function () { onSubmit: function () {
var name = this.searchText var name = this.searchText
...@@ -272,9 +434,60 @@ ...@@ -272,9 +434,60 @@
location.href = "https://ygobbs.com/session/sso_provider?" + request; location.href = "https://ygobbs.com/session/sso_provider?" + request;
}, },
showDialog2: function(){
this.dialogFormVisible2 = true
setTimeout(function(){
console.log($(".el-upload__input"))
$(".el-upload__input").hide()
},100)
},
cancelModify: function () { cancelModify: function () {
this.dialogFormVisible = false this.dialogFormVisible = false
}, },
cancelModify2: function () {
this.dialogFormVisible2 = false
},
submitModify2: function () {
this.dialogFormVisible2 = false
if (this.isClick) {
this.$notify({
title: '警告',
message: '您操作得太快了!',
type: 'error'
})
} else {
this.isClick = true;
var param = {
user: this.user.username,
name: this.username,
title: this.demo_title,
url: this.demo_url,
file: this.downloadPath
}
var _this = this;
API.saveDeckDemo(param).then((res) => {
this.dialogFormVisible2 = false
this.$notify({
title: '操作成功',
message: '感谢您的提交!',
type: 'success'
})
setTimeout(function () {
_this.isClick = false;
}, 3000)
}, (res) => {
setTimeout(function () {
_this.isClick = false;
}, 3000)
this.hasError = true
console.log(res)
});
}
},
submitModify: function () { submitModify: function () {
if (!this.title_new || !this.title_new.trim()) { if (!this.title_new || !this.title_new.trim()) {
...@@ -420,4 +633,66 @@ ...@@ -420,4 +633,66 @@
margin-bottom: 20px; margin-bottom: 20px;
margin-top: -30px; margin-top: -30px;
} }
</style>
\ No newline at end of file .el-upload__input {
}
.el-upload__tip{
}
.avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #20a0ff;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
line-height: 178px;
text-align: center;
}
.avatar {
width: 178px;
height: 178px;
display: block;
}
.time {
font-size: 13px;
color: #999;
}
.bottom {
margin-top: 13px;
line-height: 12px;
}
.button {
padding: 0;
float: right;
}
.image {
width: 100%;
display: block;
}
.clearfix:before,
.clearfix:after {
display: table;
content: "";
}
.clearfix:after {
clear: both
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment