204 lines
9.5 KiB
Vue
204 lines
9.5 KiB
Vue
<template>
|
||
<section class="content">
|
||
<div class="box box-primary">
|
||
<div class="box-body">
|
||
<section class="content-header">
|
||
<h1 id="itemTitle"></h1>
|
||
</section>
|
||
<!-- .content -->
|
||
<section class="content">
|
||
<div id="table"></div>
|
||
<div id="toolbar">
|
||
<button id="btnAdd" class="btn btn-sm btn-danger">生成</button>
|
||
<!--兑换码:<input type="text"name="code" id="code" class="input-sm" placeholder="兑换码">
|
||
兑换人UID:<input type="text" name="uid" id="uid" class="input-sm" >
|
||
状态:<select name="status" id="status" class="input-sm">
|
||
<option value=>--全部--</option>
|
||
<option value=1>未兑换</option>
|
||
<option value=2>已兑换</option>
|
||
</select>
|
||
|
||
<button id="btnSearch" class="btn btn-sm btn-primary">查询</button>-->
|
||
</div>
|
||
</section>
|
||
<!-- .content -->
|
||
<div class="modal fade" id="roleModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
|
||
<div class="modal-dialog" role="document">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
|
||
aria-hidden="true">×</span></button>
|
||
<h4 class="modal-title" id="modalLabel">生成兑换码</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form class="form-horizontal" id="roleForm">
|
||
<input type="hidden" name="id" id="id" />
|
||
<div class="form-group">
|
||
<label for="num" class="col-sm-3 control-label">生成数量:</label>
|
||
<div class="col-sm-8">
|
||
<input type="text" class="form-control validate[required]" name="num" id="num"
|
||
value=10>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="amount" class="col-sm-3 control-label">钻石大小:</label>
|
||
<div class="col-sm-8">
|
||
<input type="text" class="form-control validate[required]" name="amount"
|
||
id="amount" value=10>
|
||
</div>
|
||
</div>
|
||
<div class="form-group" style="display: none;">
|
||
<label for="len" class="col-sm-3 control-label">兑换码长度:</label>
|
||
<div class="col-sm-8">
|
||
<input type="text" class="form-control" name="len" id="len" value=16>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||
<button type="button" class="btn btn-primary" id="btnGener">生成</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</template>
|
||
|
||
<script>
|
||
import TableHelper from '@/utils/bootstrap-table-helper';
|
||
|
||
export default {
|
||
name: "RedeemcodeAdminView",
|
||
setup() {
|
||
return {};
|
||
},
|
||
created() {
|
||
this.$nextTick(function () {
|
||
this.initData();
|
||
});
|
||
},
|
||
methods: {
|
||
initData() {
|
||
|
||
$(function () {
|
||
$('#table').bootstrapTable('destroy');
|
||
$('#table').bootstrapTable({
|
||
columns: [
|
||
{ field: 'code', title: '兑换码', align: 'center', width: '10%' },
|
||
{
|
||
field: 'amount', title: '金额', align: 'center', width: '10%',
|
||
formatter: function (val, row, index) {
|
||
return val + "钻石";
|
||
}
|
||
},
|
||
{
|
||
field: 'createTime', title: '生成时间', align: 'center', width: '20%',
|
||
formatter: function (val, row, index) {
|
||
if (val) {
|
||
var date = new Date(val)
|
||
return date.format("yyyy-MM-dd hh:mm:ss");
|
||
} else {
|
||
return "-";
|
||
}
|
||
}
|
||
},
|
||
{
|
||
field: 'useStatus', title: '状态', align: 'center', width: '10%',
|
||
formatter: function (val, row, index) {
|
||
if (val == 1) {
|
||
return "未兑换";
|
||
} else {
|
||
return "已兑换";
|
||
}
|
||
}
|
||
},
|
||
{ field: 'useUid', title: '兑换人UID', align: 'center', width: '10%' },
|
||
{ field: 'useIp', title: '兑换人IP', align: 'center', width: '10%' },
|
||
{ field: 'useImei', title: '兑换人设备ID', align: 'center', width: '10%' },
|
||
{
|
||
field: 'useTime', title: '兑换时间', align: 'center', width: '20%',
|
||
formatter: function (val, row, index) {
|
||
if (val) {
|
||
var date = new Date(val)
|
||
return date.format("yyyy-MM-dd hh:mm:ss");
|
||
} else {
|
||
return "-";
|
||
}
|
||
}
|
||
}
|
||
],
|
||
cache: false,
|
||
striped: true,
|
||
showRefresh: false,
|
||
pageSize: 10,
|
||
pagination: true,
|
||
pageList: [10, 20, 30, 50],
|
||
search: false,
|
||
sidePagination: "server", //表示服务端请求
|
||
//设置为undefined可以获取pageNumber,pageSize,searchText,sortName,sortOrder
|
||
//设置为limit可以获取limit, offset, search, sort, order
|
||
queryParamsType: "undefined",
|
||
queryParams: function queryParams(params) { //设置查询参数
|
||
var param = {
|
||
pageNumber: params.pageNumber,
|
||
pageSize: params.pageSize,
|
||
code: $('#code').val(),
|
||
uid: $('#uid').val(),
|
||
status: $('#status').val()
|
||
};
|
||
return param;
|
||
},
|
||
uniqueId: 'code',
|
||
toolbar: '#toolbar',
|
||
url: '/admin/redeemcode/getlist',
|
||
onLoadSuccess: function () { //加载成功时执行
|
||
console.log("load success");
|
||
},
|
||
onLoadError: function () { //加载失败时执行
|
||
console.log("load fail");
|
||
}
|
||
});
|
||
|
||
|
||
$('#btnAdd').click(function () {
|
||
$("#roleModal").modal('show');
|
||
});
|
||
|
||
$('#btnSearch').click(function () {
|
||
TableHelper.doRefresh("#table");
|
||
});
|
||
|
||
$('#btnGener').click(function () {
|
||
if ($("#roleForm").validationEngine('validate')) {
|
||
$.ajax({
|
||
type: "post",
|
||
url: "/admin/redeemcode/gener",
|
||
data: $('#roleForm').serialize(),
|
||
dataType: "json",
|
||
success: function (json) {
|
||
if (json.code == 200) {
|
||
$("#roleModal").modal('hide');
|
||
$("#tipMsg").text("兑换码正在生成,请稍候刷新查看");
|
||
$("#tipModal").modal('show');
|
||
TableHelper.doRefresh("#table");
|
||
} else {
|
||
$("#tipMsg").text("生成失败,错误码:" + json.code);
|
||
$("#tipModal").modal('show');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
});
|
||
|
||
});
|
||
}
|
||
},
|
||
|
||
};
|
||
</script>
|
||
|
||
<style scoped></style> |