| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- layui.use(['table', 'jquery', 'madmin', 'mhttp', 'layer', 'form', 'common'], function () {
- let table = layui.table;
- let $ = layui.jquery;
- let admin = layui.madmin;
- let layer = layui.layer;
- let form = layui.form;
- let common = layui.common;
- let mhttp = layui.mhttp;
- admin.getConfig();
- getStorageServersConfig();
- //搜索条件
- let uid = GetQueryString('uid') ?? null;
- let agent_uid = GetQueryString('agent_uid') ?? null;
- let mom_app_uid = GetQueryString('mom_app_uid') ?? null;
- let agent_username = GetQueryString('agent_username') ?? null;
- $('.uid').val(uid);
- $('.agent_uid').val(agent_uid);
- $('.mom_app_uid').val(mom_app_uid);
- $('.agent_username').val(agent_username);
- let appArray = {};
- let appArrayInfo = {};
- // 获取app
- let ret = mhttp.ajax({
- url: '/app/all'
- });
- ret.then((data) => {
- if (data.code === 200) {
- let html = '<option value=""></option>';
- for (var i in data.data) {
- appArray[data.data[i].uid] = data.data[i].name;
- appArrayInfo[data.data[i].uid] = data.data[i];
- html += '<option class="se_' + data.data[i].uid + '" value="' + data.data[i].uid + '">' + data.data[i].name + '</option>';
- }
- $('.mom_app_uid').append(html);
- $('.mom_app_uid .se_' + mom_app_uid).attr('selected', 'selected');
- form.render();
- let cols = [
- [
- {
- title: 'UID',
- field: 'uid',
- align: 'center',
- },
- {
- title: '渠道名字',
- field: 'name',
- align: 'center'
- },
- {
- title: '代理UID',
- field: 'agent_uid',
- align: 'center',
- },
- {
- title: '代理名称',
- field: 'nick',
- align: 'center',
- templet: function (d) {
- if (!d.agent_name) {
- return '未知';
- }
- return d.agent_name.nick;
- }
- },
- {
- title: '渠道链接',
- field: 'share_url',
- align: 'center',
- templet: function (d) {
- if (d.share_url) {
- return '<button class="pear-btn pear-btn-sm" lay-event="cp_link">推广链接</button>';
- } else {
- return '';
- }
- }
- },
- {
- title: '应用名称',
- field: 'mom_app_uid',
- align: 'center',
- templet: function (d) {
- return appArray[d.mom_app_uid];
- }
- },
- {
- title: '更新时间',
- field: 'updated_at',
- align: 'center'
- },
- {
- title: '操作',
- field: 'updated_at',
- align: 'center',
- width: '200',
- templet(d) {
- if (d.channel_row) {
- // 判断版本号是否相同
- if (appArrayInfo[d.mom_app_uid].android_version === d.channel_row.mom_app_version) {
- if (d.channel_row.status === 1) {
- return '<div class="pack_btn-box_uid_' + d.uid + '"><button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="pack">重新打包</button><button class="pear-btn pear-btn-sm" lay-event="cp">查看地址</button></div>';
- } else if ((d.channel_row.status === 2)) {
- return '<div class="pack_btn-box_uid_' + d.uid + '"><button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="pack">重新打包(失败)</button></div>';
- } else if ((d.channel_row.status === 3)) {
- return '<div class="pack_btn-box_uid_' + d.uid + '"><button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="pack">重新打包(打包中)</button></div>';
- }
- } else {
- return '<div class="pack_btn-box_uid_' + d.uid + '"><button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="pack">重新打包(版本过低)</button></div>';
- }
- } else {
- return '<div class="pack_btn-box_uid_' + d.uid + '"><button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="pack">渠道打包</button></div>';
- }
- }
- },
- ]
- ];
- let search = httpRequestPostData({
- uid: uid,
- agent_uid: agent_uid,
- mom_app_uid: mom_app_uid,
- agent_username: agent_username
- });
- table.render({
- elem: '#channel-table',
- method: 'POST',
- request: {
- pageName: 'page',
- limitName: 'page_size'
- },
- async: false,
- headers: {
- "AUTH-TOKEN": localStorage.getItem('XSRF-TOKEN') ?? ''
- },
- contentType: 'application/json',
- where: search,
- url: getMyApiUrl('/agent/channel/list'),
- limit: 20,
- limits: [20, 30, 40, 50, 80, 100],
- parseData: function (res) {
- return httpRequestPagesParseData(res);
- },
- response: {
- "statusCode": 200,
- },
- done: function (data, page, total) {
- var intCode = parseInt(data.code);
- if (intCode === 403) {
- cbRespnseRedirectLogin(data);
- } else if (intCode === 401) {
- // 仅仅是过期了,这里可以有其他逻辑补偿.
- // 暂时跳到登陆页面
- cbRespnse401(data);
- }
- onloadRender();
- },
- error: function (obj, message) {
- cbRespnseReloadPage(obj, message);
- },
- page: true,
- cols: cols,
- skin: 'line',
- defaultToolbar: [{
- title: '刷新',
- layEvent: 'refresh',
- icon: 'layui-icon-refresh',
- }, 'filter', 'print', 'exports']
- });
- } else {
- layer.msg(data.message, {icon: 2, time: 1000});
- }
- });
- form.render();
- // 表单内
- table.on('tool(channel-table)', function (obj) {
- if (obj.event === 'pack') {
- let createLoading = layer.load();
- // 打包
- let ret = mhttp.ajax({
- url: '/agent/channel/pack',
- data: {uid: obj.data.uid}
- });
- 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);
- // parent.layui.table.reload("channel-table");
- // table.reload('channel-table');
- let p_uid = obj.data.uid;
- let pack_bth = $('.pack_btn-box_uid_' + p_uid);
- pack_bth.html('<div class="pack_btn-box_uid_' + p_uid + '"><button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="pack">重新打包(打包中)</button></div>');
- });
- } else {
- layer.msg(data.message, {icon: 2, time: 1000});
- }
- });
- return false;
- } else if (obj.event === 'cp') {
- // 复制
- layer.open({
- id: 'qrcode',
- type: 2,
- title: '获取链接',
- shade: 0.1,
- offset: '200px',
- area: ['400px', '200px'],
- maxWidth: 500,
- maxHeight: 500,
- scrollbar: true,
- content: 'copy_link.html?|||' + obj.data.channel_row.app_download,
- });
- } else if (obj.event === 'cp_link') {
- console.debug(obj.data)
- // 复制
- layer.open({
- id: 'qrcode',
- type: 2,
- title: '获取链接',
- shade: 0.1,
- offset: '200px',
- area: ['400px', '200px'],
- maxWidth: 500,
- maxHeight: 500,
- scrollbar: true,
- content: 'copy_link.html?|||' + obj.data.share_url,
- });
- }
- });
- $('#reset').click(function () {
- window.location.href = './channel_list.html';
- });
- window.refresh = function (param) {
- table.reload('channel-table');
- }
- })
|