- 新增师傅资质审核模块及权限 - 未审核通过的师傅默认禁用接单状态 - 新增售后退款申诉功能与相关界面 - 新增用户钱包管理及充值功能 - 更新服务定价矩阵相关数据库结构 - 修复微信支付证书验证问题
110 行
5.3 KiB
JavaScript
110 行
5.3 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
function syncCouponTypeInputs() {
|
|
var $type = $('#c-type');
|
|
if (!$type.length) return;
|
|
var apply = function () {
|
|
var val = $type.val();
|
|
if (val === 'discount') {
|
|
$('#box-coupon-amount').hide();
|
|
$('#box-coupon-discount').show();
|
|
} else {
|
|
$('#box-coupon-amount').show();
|
|
$('#box-coupon-discount').hide();
|
|
}
|
|
};
|
|
$type.on('change changed.bs.select', apply);
|
|
apply();
|
|
}
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'coupon/index' + location.search,
|
|
detail_url: 'coupon/detail',
|
|
add_url: 'coupon/add',
|
|
edit_url: 'coupon/edit',
|
|
del_url: 'coupon/del',
|
|
multi_url: 'coupon/multi',
|
|
table: 'coupon',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
pk: 'id',
|
|
sortName: 'id',
|
|
sortOrder: 'desc',
|
|
fixedColumns: false,
|
|
fixedRightNumber: 0,
|
|
columns: [
|
|
[
|
|
{checkbox: true},
|
|
{field: 'index', title: '序号', operate: false, formatter: Table.api.formatter.index, width: '60px'},
|
|
{field: 'name', title: __('Name'), operate: 'LIKE'},
|
|
{field: 'type', title: __('Type'), searchList: {"cash":__('Cash'),"discount":__('Discount')}, formatter: Table.api.formatter.label, custom: {cash: 'danger', discount: 'warning'}},
|
|
{field: 'amount', title: '优惠力度', operate: false, formatter: function (v, row) {
|
|
if (row.type === 'discount') {
|
|
var d = (Number(row.discount || 1) * 10).toFixed(1).replace(/\.0$/, '');
|
|
return '<strong class="text-warning">' + d + ' 折</strong>';
|
|
}
|
|
return '<strong class="text-danger">¥' + Number(v || 0).toFixed(2) + '</strong>';
|
|
}},
|
|
{field: 'min_amount', title: '使用门槛', operate: 'BETWEEN', formatter: function (v) {
|
|
return Number(v) > 0 ? ('满 ¥' + Number(v).toFixed(2)) : '<span class="text-success">无门槛</span>';
|
|
}},
|
|
{field: 'total', title: '领取 / 总量', operate: false, formatter: function (v, row) {
|
|
var claimed = row.real_claimed !== undefined ? row.real_claimed : (row.received || 0);
|
|
return '<strong>' + claimed + '</strong> / ' + (v || 0);
|
|
}},
|
|
{field: 'used_count', title: '已核销', operate: false, formatter: function (v) {
|
|
return Number(v) > 0 ? '<span class="label label-success">' + v + ' 张</span>' : '<span class="text-muted">0 张</span>';
|
|
}},
|
|
{field: 'end_time', title: '有效期限', operate: false, formatter: function (v, row) {
|
|
var now = Math.floor(Date.now() / 1000);
|
|
var s = row.start_time ? Table.api.formatter.datetime.call({datetimeFormat: 'YYYY-MM-DD'}, row.start_time) : '-';
|
|
var e = v ? Table.api.formatter.datetime.call({datetimeFormat: 'YYYY-MM-DD'}, v) : '-';
|
|
var expired = v && Number(v) < now ? ' <span class="label label-default">已到期</span>' : '';
|
|
return '<small>' + s + ' ~ ' + e + '</small>' + expired;
|
|
}},
|
|
{field: 'status', title: __('Status'), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
|
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
|
|
buttons: [
|
|
{
|
|
name: 'detail',
|
|
text: '领用数据',
|
|
title: '卡券领取与核销详情',
|
|
classname: 'btn btn-xs btn-info btn-detailone',
|
|
extend: 'data-area=\'["880px","84%"]\''
|
|
}
|
|
],
|
|
formatter: Table.api.formatter.operate}
|
|
]
|
|
]
|
|
});
|
|
|
|
Table.api.bindevent(table);
|
|
},
|
|
detail: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
add: function () {
|
|
syncCouponTypeInputs();
|
|
Controller.api.bindevent();
|
|
},
|
|
edit: function () {
|
|
syncCouponTypeInputs();
|
|
Controller.api.bindevent();
|
|
},
|
|
api: {
|
|
bindevent: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
}
|
|
}
|
|
};
|
|
return Controller;
|
|
});
|