作者 何书鹏
1 个管道 的构建 通过 耗费 3 秒

合并分支 'heshupeng' 到 'master'

课程兑换码优化



查看合并请求 !267
... ... @@ -84,8 +84,12 @@ class CourseCode extends Backend
{
if(request()->isAjax()){
$course_id = $this->request->request('course_id');
$number = $this->request->request('number');
empty($number) && $this->error('请输入生成数量');
!is_numeric($number) && $this->error('请输入数字');
($number <= 0) && $this->error('请输入大于0的数字');
$saveData = [];
for($i=0;$i<100;$i++){
for($i=0;$i<$number;$i++){
$saveData[] = [
'course_id' => $course_id,
'code' => $this->randStr(),
... ...
... ... @@ -18,7 +18,7 @@
<div id="toolbar" class="toolbar">
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
<a href="javascript:;" class="btn btn-success create-code {:$auth->check('mobile/course/courseCode/createCode')?'':'hide'}" title="{:__('生成兑换码')}" ><i class="fa fa-plus"></i> {:__('生成兑换码')}</a>
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('mobile/course/courseCode/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="false"
... ...
... ... @@ -40,14 +40,28 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 生成兑换码
$(document).on('click', ".create-code", function () {
Layer.confirm('确认生成兑换码吗', {
btn: ['确认','取消'] //按钮
}, function(index){
// Layer.confirm('确认生成兑换码吗', {
// btn: ['确认','取消'] //按钮
// }, function(index){
// Backend.api.ajax({
// url: $.fn.bootstrapTable.defaults.extend.create_code_url,
// }, function () {
// table.bootstrapTable('refresh');
// Layer.close(index);
// });
// });
Layer.prompt({title: __('请输入生成数量'), formType: 0}, function (value, index) {
Backend.api.ajax({
url: $.fn.bootstrapTable.defaults.extend.create_code_url,
data: {
number:value
},
}, function () {
table.bootstrapTable('refresh');
Layer.close(index);
}, function (data, ret) {
Layer.msg(ret.msg);
return false;
});
});
});
... ...