layui.use(['form', 'jquery', 'madmin', 'mhttp', 'layer'], function () { let form = layui.form; let $ = layui.jquery; let layer = layui.layer; let admin = layui.madmin; let http = layui.mhttp; admin.getConfig(); // 查询应用 let appRet = http.ajax({ url: '/app/all' }); appRet.then((data) => { if (data.code === 200) { let html = ''; for (let i in data.data) { html += ''; } $('.app_uid').html(html); form.render(); } else { $('.app-help').append('获取应用失败,刷新重试!'); } }); form.on('submit(cps-save)', function (data) { let createLoading = layer.load(); let postData = data.field; postData.deduction_method = 1; postData.deduction_type = 'cpa'; postData.jdata = '{}'; let ret = http.ajax({ url: '/deduction/create', data: postData }); ret.then((data) => { layer.close(createLoading); if (data.code === 200) { layer.msg(data.message, {icon: 1, time: 1000}, function () { // 成功刷父页面 window.parent.location.reload(); // 成功关闭父窗口 let index = parent.layer.getFrameIndex(window.name); parent.layer.close(index); }); } else { layer.msg(data.message, {icon: 2, time: 1000}); } }); return false; }); });