475 lines
12 KiB
Vue
475 lines
12 KiB
Vue
<template>
|
|
<div class="box">
|
|
<!-- 查询 -->
|
|
<!-- 时间选择器 -->
|
|
<!-- <div class="inquire">
|
|
<div class="block">
|
|
<span class="demonstration">创建时间</span>
|
|
<el-date-picker
|
|
v-model="inquire.time"
|
|
type="datetimerange"
|
|
range-separator="至"
|
|
start-placeholder="开始日期"
|
|
end-placeholder="结束日期"
|
|
></el-date-picker>
|
|
</div>
|
|
</div> -->
|
|
<div class="inquire">
|
|
<span>游戏昵称</span>
|
|
<el-input
|
|
v-model="inquire.gameName"
|
|
placeholder="请输入..."
|
|
class="input"
|
|
></el-input>
|
|
</div>
|
|
|
|
<!-- 查询按钮 -->
|
|
<el-button class="primary" type="primary" @click="getData()">
|
|
查询</el-button
|
|
>
|
|
<!-- 添加 -->
|
|
<el-button class="primary" type="primary" @click="add()"> 添加</el-button>
|
|
</div>
|
|
|
|
<!-- 表格 -->
|
|
<el-table
|
|
v-loading="loading"
|
|
:data="tableData"
|
|
border
|
|
style="width: 100%; margin-top: 25px"
|
|
>
|
|
<el-table-column prop="gameName" align="center" label="游戏名称" />
|
|
<!-- <el-table-column prop="x" align="center" label="分区" /> -->
|
|
<el-table-column align="center" prop="giftInfo" label="游戏icon">
|
|
<template v-slot="scope">
|
|
<el-image
|
|
v-if="scope.row.logo"
|
|
style="width: 100px; height: 100px"
|
|
:src="scope.row.logo"
|
|
:zoom-rate="1.1"
|
|
:preview-src-list="scope.row.logo"
|
|
fit="cover"
|
|
preview-teleported="true"
|
|
hide-on-click-modal="true"
|
|
/>
|
|
<div v-else>/</div>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column align="center" prop="giftInfo" label="游戏背景">
|
|
<template v-slot="scope">
|
|
<el-image
|
|
v-if="scope.row.background"
|
|
style="width: 100px; height: 100px"
|
|
:src="scope.row.background"
|
|
:zoom-rate="1.1"
|
|
:preview-src-list="scope.row.background"
|
|
fit="cover"
|
|
preview-teleported="true"
|
|
hide-on-click-modal="true"
|
|
/>
|
|
<div v-else>/</div>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column align="center" prop="giftInfo" label="下单弹窗背景">
|
|
<template v-slot="scope">
|
|
<el-image
|
|
v-if="scope.row.pic"
|
|
style="width: 100px; height: 100px"
|
|
:src="scope.row.pic"
|
|
:zoom-rate="1.1"
|
|
:preview-src-list="scope.row.pic"
|
|
fit="cover"
|
|
preview-teleported="true"
|
|
hide-on-click-modal="true"
|
|
/>
|
|
<div v-else>/</div>
|
|
</template>
|
|
</el-table-column>
|
|
<!-- <el-table-column prop="x" align="center" label="创建日期" />
|
|
<el-table-column prop="x" align="center" label="添加人" /> -->
|
|
<el-table-column align="center" label="操作">
|
|
<template v-slot="scope">
|
|
<el-button
|
|
@click="eir(scope.row)"
|
|
class="primary"
|
|
type="primary"
|
|
size="default"
|
|
>编辑
|
|
</el-button>
|
|
<el-button
|
|
@click="
|
|
delObj = scope.row;
|
|
delDialog = true;
|
|
"
|
|
class="danger"
|
|
type="danger"
|
|
size="default"
|
|
>删除
|
|
</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
|
|
<!-- 分页 -->
|
|
<el-pagination
|
|
style="margin-top: 10px"
|
|
class="paginationClass"
|
|
v-model:current-page="currentPage"
|
|
v-model:page-size="pageSize"
|
|
:page-sizes="[10, 20, 30, 40, 50, 100, 200, 300, 400, 500, 999999999]"
|
|
layout="sizes, prev, pager, next"
|
|
:total="total"
|
|
@size-change="handleSizeChange"
|
|
@current-change="handleCurrentChange"
|
|
/>
|
|
|
|
<!-- 二次确认 -->
|
|
<el-dialog v-model="delDialog" title="提示" width="30%" center>
|
|
<span> 确认要删除吗?</span>
|
|
<template #footer>
|
|
<span class="dialog-footer">
|
|
<el-button @click="delDialog = false">取消</el-button>
|
|
<el-button type="primary" @click="sureClick()"> 确认 </el-button>
|
|
</span>
|
|
</template>
|
|
</el-dialog>
|
|
|
|
<!-- 添加和编辑弹窗 -->
|
|
<el-dialog
|
|
v-model="operationDialog"
|
|
:title="operationTitle"
|
|
width="30%"
|
|
center
|
|
>
|
|
<!-- 地区 -->
|
|
<!-- <div class="selectBox">
|
|
<span class="left" style="margin-right: 20px">地区</span>
|
|
<el-checkbox-group v-model="operation.checkList">
|
|
<el-checkbox label="1">英语</el-checkbox>
|
|
<el-checkbox label="2">阿语</el-checkbox>
|
|
<el-checkbox label="4">华语</el-checkbox>
|
|
</el-checkbox-group>
|
|
</div> -->
|
|
<!-- 游戏昵称 -->
|
|
<div class="selectBox">
|
|
<span class="left" style="margin-right: 20px">游戏昵称</span>
|
|
<el-input
|
|
v-model="operation.gameName"
|
|
size="default"
|
|
placeholder="请输入游戏昵称..."
|
|
class="right"
|
|
style="width: 70%"
|
|
></el-input>
|
|
</div>
|
|
<!-- 游戏icon -->
|
|
<div class="selectBox selectBoxImg">
|
|
<span class="left" style="margin-right: 20px">游戏icon</span>
|
|
<!-- action="/admin/tencent/cos/upload/file" -->
|
|
<el-upload
|
|
class="avatar-uploader"
|
|
action="/admin/tencent/cos/upload/file"
|
|
:show-file-list="false"
|
|
:on-success="handleAvatarSuccess"
|
|
:before-upload="beforeAvatarUpload"
|
|
:on-error="handleAvatarError"
|
|
>
|
|
<img
|
|
v-if="operation.imageUrl1"
|
|
:src="operation.imageUrl1"
|
|
class="avatar"
|
|
/>
|
|
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
|
|
</el-upload>
|
|
</div>
|
|
<!-- 游戏背景 -->
|
|
<div class="selectBox selectBoxImg">
|
|
<span class="left" style="margin-right: 20px">游戏背景</span>
|
|
<el-upload
|
|
class="avatar-uploader"
|
|
action="/admin/tencent/cos/upload/file"
|
|
:show-file-list="false"
|
|
:on-success="handleAvatarSuccess2"
|
|
:before-upload="beforeAvatarUpload"
|
|
:on-error="handleAvatarError"
|
|
>
|
|
<img
|
|
v-if="operation.imageUrl2"
|
|
:src="operation.imageUrl2"
|
|
class="avatar"
|
|
/>
|
|
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
|
|
</el-upload>
|
|
</div>
|
|
<!-- 下单弹窗icon -->
|
|
<div class="selectBox selectBoxImg">
|
|
<span class="left" style="margin-right: 20px">下单弹窗icon</span>
|
|
<el-upload
|
|
class="avatar-uploader"
|
|
action="/admin/tencent/cos/upload/file"
|
|
:show-file-list="false"
|
|
:on-success="handleAvatarSuccess3"
|
|
:before-upload="beforeAvatarUpload"
|
|
:on-error="handleAvatarError"
|
|
>
|
|
<img
|
|
v-if="operation.imageUrl3"
|
|
:src="operation.imageUrl3"
|
|
class="avatar"
|
|
/>
|
|
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
|
|
</el-upload>
|
|
</div>
|
|
<!-- 操作 -->
|
|
<template #footer>
|
|
<span class="dialog-footer">
|
|
<el-button @click="operationDialog = false">取消</el-button>
|
|
<el-button type="primary" @click="operationClick()"> 确认 </el-button>
|
|
</span>
|
|
</template>
|
|
</el-dialog>
|
|
</template>
|
|
|
|
<script>
|
|
import { page, save, delGame } from "@/api/gameInfo/gameInfo";
|
|
import { Plus } from "@element-plus/icons-vue";
|
|
import { uploadQiNiuFile } from "@/api/common/upload";
|
|
import { dateFormat } from "@/utils/system-helper";
|
|
import { ElMessage } from "element-plus";
|
|
|
|
export default {
|
|
name: "GameInfo",
|
|
components: {
|
|
Plus,
|
|
},
|
|
data() {
|
|
return {
|
|
inquire: {
|
|
time: "",
|
|
gameName: "",
|
|
},
|
|
loading: false,
|
|
// 表格数据
|
|
tableData: [],
|
|
// 分页
|
|
total: 10, //总页数
|
|
currentPage: 1, //页码
|
|
pageSize: 10, //条数
|
|
// 二次确认
|
|
delDialog: false,
|
|
//操作和编辑
|
|
operationDialog: false,
|
|
operationType: 1, //1添加2编辑
|
|
operationTitle: "编辑&添加",
|
|
operatioObj: {},
|
|
operation: {
|
|
gameName: "",
|
|
imageUrl1: "",
|
|
imageUrl2: "",
|
|
imageUrl3: "",
|
|
},
|
|
delObj: {},
|
|
};
|
|
},
|
|
created() {
|
|
this.getData();
|
|
},
|
|
methods: {
|
|
getData() {
|
|
this.loading = true;
|
|
let startTime = "";
|
|
let endTime = "";
|
|
if (this.inquire.time && this.inquire.time.length > 0) {
|
|
startTime = dateFormat(this.inquire.time[0], "yyyy-MM-dd hh:mm:ss");
|
|
endTime = dateFormat(this.inquire.time[1], "yyyy-MM-dd hh:mm:ss");
|
|
}
|
|
page({
|
|
gameName: this.inquire.gameName,
|
|
page: this.currentPage,
|
|
pageSize: this.pageSize,
|
|
}).then((res) => {
|
|
if (res.code === 200) {
|
|
this.tableData = res.data.rows;
|
|
this.total = res.data.total;
|
|
} else {
|
|
ElMessage({
|
|
showClose: true,
|
|
message: res.message,
|
|
type: "error",
|
|
});
|
|
}
|
|
this.loading = false;
|
|
});
|
|
},
|
|
add() {
|
|
this.operationDialog = true;
|
|
this.operationType = 1;
|
|
this.operationTitle = "添加";
|
|
this.operation = {
|
|
gameName: "",
|
|
imageUrl1: "",
|
|
imageUrl2: "",
|
|
imageUrl3: "",
|
|
};
|
|
},
|
|
eir(val) {
|
|
this.operatioObj = val;
|
|
this.operationDialog = true;
|
|
this.operationType = 2;
|
|
this.operationTitle = "编辑";
|
|
this.operation = {
|
|
gameName: this.operatioObj.gameName,
|
|
imageUrl1: this.operatioObj.logo,
|
|
imageUrl2: this.operatioObj.background,
|
|
imageUrl3: this.operatioObj.pic,
|
|
};
|
|
},
|
|
operationClick() {
|
|
save({
|
|
gameId: this.operationType == 1 ? null : this.operatioObj.gameId,
|
|
gameName: this.operation.gameName,
|
|
logo: this.operation.imageUrl1,
|
|
background: this.operation.imageUrl2,
|
|
pic: this.operation.imageUrl3,
|
|
}).then((res) => {
|
|
if (res.code === 200) {
|
|
this.operationDialog = false;
|
|
this.getData();
|
|
} else {
|
|
ElMessage({
|
|
showClose: true,
|
|
message: res.message,
|
|
type: "error",
|
|
});
|
|
}
|
|
});
|
|
},
|
|
sureClick() {
|
|
delGame({ gameId: this.delObj.gameId }).then((res) => {
|
|
if (res.code === 200) {
|
|
this.delDialog = false;
|
|
this.getData();
|
|
} else {
|
|
ElMessage({
|
|
showClose: true,
|
|
message: res.message,
|
|
type: "error",
|
|
});
|
|
}
|
|
});
|
|
},
|
|
JsonFunc(val) {
|
|
var res = JSON.parse(val);
|
|
return res;
|
|
},
|
|
beforeAvatarUpload() {
|
|
ElMessage({
|
|
showClose: true,
|
|
message: "上传中~",
|
|
type: "warning",
|
|
});
|
|
},
|
|
handleAvatarError() {
|
|
ElMessage({
|
|
showClose: true,
|
|
message: "上传失败!",
|
|
type: "error",
|
|
});
|
|
},
|
|
handleAvatarSuccess(res, file) {
|
|
console.log(file);
|
|
// this.operation.imageUrl1 = URL.createObjectURL();
|
|
this.operation.imageUrl1 = file.response.data;
|
|
ElMessage({
|
|
showClose: true,
|
|
message: "上传成功!",
|
|
type: "success",
|
|
});
|
|
},
|
|
handleAvatarSuccess2(res, file) {
|
|
// this.operation.imageUrl2 = URL.createObjectURL(file.raw);
|
|
this.operation.imageUrl2 = file.response.data;
|
|
ElMessage({
|
|
showClose: true,
|
|
message: "上传成功!",
|
|
type: "success",
|
|
});
|
|
},
|
|
handleAvatarSuccess3(res, file) {
|
|
// this.operation.imageUrl3 = URL.createObjectURL(file.raw);
|
|
this.operation.imageUrl3 = file.response.data;
|
|
ElMessage({
|
|
showClose: true,
|
|
message: "上传成功!",
|
|
type: "success",
|
|
});
|
|
},
|
|
// 分页导航
|
|
handleSizeChange(size) {
|
|
this.pageSize = size;
|
|
this.getData();
|
|
},
|
|
handleCurrentChange(page) {
|
|
this.currentPage = page;
|
|
this.getData();
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="less" scoped>
|
|
.box {
|
|
padding-top: 20px;
|
|
background: #ecf0f5;
|
|
.inquire {
|
|
display: inline-block;
|
|
margin-right: 20px;
|
|
span {
|
|
margin-right: 10px;
|
|
}
|
|
.input {
|
|
width: 180px;
|
|
margin-right: 10px;
|
|
}
|
|
}
|
|
.paginationClass {
|
|
margin: 15px 0 5px 0px;
|
|
}
|
|
}
|
|
.selectBox {
|
|
display: flex;
|
|
height: 35px;
|
|
line-height: 35px;
|
|
margin-bottom: 20px;
|
|
}
|
|
.selectBoxImg {
|
|
height: 150px;
|
|
}
|
|
</style>
|
|
|
|
<style scoped>
|
|
.avatar-uploader .avatar {
|
|
width: 178px;
|
|
height: 178px;
|
|
display: block;
|
|
}
|
|
</style>
|
|
|
|
<style>
|
|
.avatar-uploader .el-upload {
|
|
border: 1px dashed var(--el-border-color);
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
position: relative;
|
|
overflow: hidden;
|
|
transition: var(--el-transition-duration-fast);
|
|
width: 150px;
|
|
height: 150px;
|
|
}
|
|
|
|
.avatar-uploader .el-upload .el-upload__input {
|
|
display: none;
|
|
}
|
|
.avatar-uploader .el-upload:hover {
|
|
border-color: var(--el-color-primary);
|
|
}
|
|
</style> |