channel.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. $('#c-pay_method').change(function(){
  3. var sval = $(this).val();
  4. if (sval<3){ //银行卡
  5. $('.c-card_bank').show();
  6. $('.c-card_holder').html('* 收款人:');
  7. $('.c-card_num').html('* 收款账号:');
  8. if(sval == 1){
  9. $('.c-idcard_no').hide();
  10. $('#c-idcard_no').attr("disabled",true);
  11. }else{
  12. $('.c-idcard_no').show();
  13. $('#c-idcard_no').attr("disabled",false);
  14. }
  15. }else if(sval==3){ //微信
  16. $('.c-card_bank').hide();
  17. $('.c-card_holder').html('* 姓名:');
  18. $('.c-card_num').html('* 微信账号:');
  19. $('#c-card_bank').val('');
  20. }else if(sval==4){ //支付宝
  21. $('.c-card_bank').hide();
  22. $('.c-card_holder').html('* 姓名:');
  23. $('.c-card_num').html('* 支付宝账号:');
  24. $('#c-card_bank').val('');
  25. }
  26. })
  27. //book_but
  28. $(document).on('click','.book_but',function () {
  29. Fast.api.open($(this).attr('href'), '查看数据', {});
  30. return false;
  31. });
  32. $(document).on('click','.btn-re',function () {
  33. var uid = $(this).data('uid');
  34. layer.confirm("请确认你要进行重置服务号,重置后将会导致、数据清空、老用户无法访问、等等一系列你无法想象的超级严重的问题", { title: "重置服务号确认" }, function (index) {
  35. layer.close(index);
  36. $.post('/admin/auth/channel/re?admin_id='+uid,{},function(data){
  37. if(data.code != 0){
  38. Toastr.success(data.msg);
  39. setTimeout(function() {
  40. window.location.reload();
  41. },2000);
  42. }else{
  43. Toastr.error(data.msg);
  44. }
  45. })
  46. });
  47. });
  48. $(document).on('click','.btn-sync',function () {
  49. var uid = $(this).data('uid');
  50. layer.confirm("请确认你要进行微信用户同步确认", { title: "微信用户同步确认" }, function (index) {
  51. layer.close(index);
  52. $.post('/admin/auth/channel/sync?admin_id='+uid,{},function(data){
  53. if(data.code != 0){
  54. Toastr.success(data.msg);
  55. setTimeout(function() {
  56. window.location.reload();
  57. },2000);
  58. }else{
  59. Toastr.error(data.msg);
  60. }
  61. })
  62. });
  63. });
  64. //推送开关全选 add by liues@dianzhong.com at 2018-09-05 11:01:18
  65. Form.events.selecttips = function (form) {
  66. var all_tip = $("#c-all_tip", form);
  67. var other_tips = $(":checkbox[id$='_tip']:not('#c-all_tip')", form);
  68. var all_tip_checked = function () {
  69. var checked = (other_tips.length == other_tips.filter(":checked").length);
  70. all_tip.prop("checked", checked);
  71. };
  72. var other_tips_checked = function () {
  73. var checked = all_tip.prop("checked");
  74. other_tips.prop("checked", checked);
  75. };
  76. all_tip.change(other_tips_checked);
  77. other_tips.change(all_tip_checked);
  78. all_tip_checked();
  79. }
  80. var Controller = {
  81. index: function () {
  82. // 初始化表格参数配置
  83. Table.api.init({
  84. extend: {
  85. index_url: 'auth/channel/index',
  86. add_url: 'auth/channel/add',
  87. edit_url: 'auth/channel/edit',
  88. del_url: 'auth/channel/del',
  89. multi_url: 'auth/channel/multi',
  90. },
  91. });
  92. var table = $("#table");
  93. if (Config.is_index == 1 || Config.isassociated == '2') {
  94. // 勾选,关联渠道
  95. $('.js_assosite').on('click', function (e, data) {
  96. var ids = Table.api.selectedids(table);
  97. Layer.confirm(
  98. __('已选中条数:%s', ids.length),
  99. {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
  100. function (index) {
  101. var strids = ($.isArray(ids) ? ids.join(",") : ids);
  102. if (Config.is_index == 1) {
  103. Fast.api.close(strids);
  104. } else {
  105. var url = 'kl/rulemanage/batchAssociate';
  106. var options = {url: url, data: { ids: strids, kl_id:Config.kl_id, isassociated: 2, params: ''}};
  107. Fast.api.ajax(options, function (data, ret) {
  108. table.bootstrapTable('refresh');
  109. parent.layer.close(this);
  110. }, function (data, ret) {
  111. });
  112. }
  113. Layer.close(index);
  114. }
  115. );
  116. });
  117. $('.js_assosite_all').on('click', function (e, data) {
  118. var kl_id = $(this).data('kl_id');
  119. Layer.confirm(
  120. '确定要关联所有渠道吗',
  121. {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
  122. function (index) {
  123. if (Config.is_index == 1) {
  124. Fast.api.close('*');
  125. } else {
  126. $.post('/admin/kl/rulemanage/ajaxsingeassociateall',
  127. {
  128. 'kl_id': kl_id,
  129. },
  130. function (result) {
  131. if (result.code) {
  132. layer.msg(result.msg,{icon:1,time:1000});
  133. //layer.alert(result.msg);
  134. setTimeout(function () {
  135. var index=parent.layer.getFrameIndex(window.name);
  136. window.parent.location.reload();//刷新父页面
  137. }, 1500)
  138. }
  139. });
  140. }
  141. Layer.close(index);
  142. }
  143. );
  144. });
  145. // 初始化表格
  146. table.bootstrapTable({
  147. url: $.fn.bootstrapTable.defaults.extend.index_url + '?kl_id=' + Config.kl_id + '&isassociated=' + Config.isassociated + '&operate=' +Config.operate+ '&channel_ids='+ Config.channel_ids,
  148. searchFormVisible: true,
  149. search:false,
  150. columns: [
  151. [
  152. {field: 'state', checkbox: true, },
  153. {field: 'admin.id', title: 'ID',operate: '=',visible:false},
  154. {field: 'id', title: 'ID',operate: false},
  155. {field: 'username', title: __('账号'),operate: 'LIKE %...%'},
  156. {field: 'nickname', title: __('Nickname'),operate: 'LIKE %...%'},
  157. {field: 'ac.appid', title: __('Appid'),visible:false,operate: 'LIKE %...%'},
  158. {field: 'appid', title: __('Appid'),operate:false},
  159. {field: 'admin_extend.benefit', title: __('佣金比例'), operate: false},
  160. {field: 'admin_extend.benefit_app', title: __('APP佣金比例'), operate: false},
  161. {field: 'admin_extend.create_by', title: __('开户人'), operate: '=', searchList:{}},
  162. {
  163. field: 'operate',
  164. title: __('Operate'),
  165. table: table,
  166. events: Table.api.events.operate,
  167. formatter: function (value, row, index) {
  168. html = "";
  169. html += "<a href='javascript:;' class='qd-doassociate' data-channel_id='"+row.id+"' data-kl_id='"+Config.kl_id+"'>关联</a>";
  170. return html;
  171. }
  172. },
  173. ]
  174. ],
  175. onLoadSuccess: function (data) {
  176. //配置搜索栏"开户人"下拉列表
  177. var formControlCreateBy = $(".form-control[name='admin_extend.create_by']");
  178. if(formControlCreateBy.children("option").length<=1){
  179. $.each(data.create_list, function (index, row) {
  180. formControlCreateBy.append('<option value="'+ row.id +'">'+ row.username +' | '+ row.nickname +'</option>');
  181. });
  182. }
  183. }
  184. });
  185. // 单个关联操作
  186. $(document).on('click', '.qd-doassociate', function () {
  187. var kl_id = $(this).data("kl_id");
  188. var channel_id = $(this).data("channel_id");
  189. var qd_this= $(this);
  190. if (Config.is_index == 1) {
  191. Fast.api.close(channel_id);
  192. } else {
  193. $.post('/admin/kl/rulemanage/ajaxsingeassociate',
  194. {
  195. 'kl_id': kl_id,
  196. 'channel_id': channel_id
  197. },
  198. function (result) {
  199. if (result.code) {
  200. //layer.alert(result.msg);
  201. qd_this.removeClass('qd-doassociate').html('已关联');
  202. //table.bootstrapTable('refresh');
  203. }
  204. });
  205. }
  206. });
  207. } else if (Config.is_index == 2 || Config.isassociated == '3') {
  208. // 勾选,查看 删除渠道
  209. $('.js_assosite_del').on('click', function (e, data) {
  210. var ids = Table.api.selectedids(table);
  211. Layer.confirm(
  212. __('已选中条数:%s', ids.length),
  213. {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
  214. function (index) {
  215. var strids = ($.isArray(ids) ? ids.join(",") : ids);
  216. if (Config.is_index == 2) {
  217. Fast.api.close(strids);
  218. } else {
  219. var url = 'kl/rulemanage/batchassociatedel';
  220. var options = {url: url, data: { ids: strids, kl_id:Config.kl_id, isassociated: 3, params: ''}};
  221. Fast.api.ajax(options, function (data, ret) {
  222. table.bootstrapTable('refresh');
  223. parent.layer.close(this);
  224. }, function (data, ret) {
  225. });
  226. }
  227. Layer.close(index);
  228. }
  229. );
  230. });
  231. // 初始化表格
  232. table.bootstrapTable({
  233. url: $.fn.bootstrapTable.defaults.extend.index_url + '?kl_id=' + Config.kl_id + '&isassociated=' + Config.isassociated+ '&operate=' +Config.operate+ '&channel_ids='+ Config.channel_ids,
  234. searchFormVisible: true,
  235. search:false,
  236. columns: [
  237. [
  238. {field: 'state', checkbox: true, },
  239. {field: 'admin.id', title: 'ID',operate: '=',visible:false},
  240. {field: 'id', title: 'ID',operate: false},
  241. {field: 'username', title: __('账号'),operate: 'LIKE %...%'},
  242. {field: 'nickname', title: __('Nickname'),operate: 'LIKE %...%'},
  243. {field: 'ac.appid', title: __('Appid'),visible:false,operate: 'LIKE %...%'},
  244. {field: 'appid', title: __('Appid'),operate:false},
  245. {field: 'admin_extend.benefit', title: __('佣金比例'), operate: false},
  246. {field: 'admin_extend.benefit_app', title: __('APP佣金比例'), operate: false},
  247. {field: 'admin_extend.create_by', title: __('开户人'), operate: '=', searchList:{}},
  248. {
  249. field: 'operate',
  250. title: __('Operate'),
  251. table: table,
  252. events: Table.api.events.operate,
  253. formatter: function (value, row, index) {
  254. return "<a href='javascript:;' class='qd-doassociate-del' data-channel_id='"+row.id+"' data-kl_id='"+Config.kl_id+"'>删除</a>";
  255. }
  256. },
  257. ]
  258. ],
  259. onLoadSuccess: function (data) {
  260. //配置搜索栏"开户人"下拉列表
  261. var formControlCreateBy = $(".form-control[name='admin_extend.create_by']");
  262. if(formControlCreateBy.children("option").length<=1){
  263. $.each(data.create_list, function (index, row) {
  264. formControlCreateBy.append('<option value="'+ row.id +'">'+ row.username +' | '+ row.nickname +'</option>');
  265. });
  266. }
  267. }
  268. });
  269. // 单个关联操作
  270. $(document).on('click', '.qd-doassociate-del', function () {
  271. var kl_id = $(this).data("kl_id");
  272. var channel_id = $(this).data("channel_id");
  273. var qd_this= $(this);
  274. if (Config.is_index == 2) {
  275. Fast.api.close(channel_id);
  276. } else {
  277. $.post('/admin/kl/rulemanage/ajaxsingeassociatedel',
  278. {
  279. 'kl_id': kl_id,
  280. 'channel_id': channel_id
  281. },
  282. function (result) {
  283. if (result.code) {
  284. //layer.alert(result.msg);
  285. //qd_this.removeClass('qd-doassociate-del').html('已删除');
  286. table.bootstrapTable('refresh');
  287. }
  288. });
  289. }
  290. });
  291. } else {
  292. // 初始化表格
  293. table.bootstrapTable({
  294. url: $.fn.bootstrapTable.defaults.extend.index_url,
  295. searchFormVisible: true,
  296. columns: [
  297. [
  298. {field: 'admin.id', title: 'ID',operate: '=',visible:false},
  299. {field: 'id', title: 'ID',operate: false},
  300. {field: 'username', title: __('账号'),operate: 'LIKE %...%'},
  301. {field: 'nickname', title: __('Nickname'),operate: 'LIKE %...%'},
  302. {field: 'ac.appid', title: __('Appid'),visible:false,operate: 'LIKE %...%'},
  303. {field: 'appid', title: __('Appid'),operate:false},
  304. {field: 'admin_extend.benefit', title: __('佣金比例'), operate: false},
  305. {field: 'admin_extend.benefit_app', title: __('APP佣金比例'), operate: false},
  306. {field: 'admin_extend.create_by', title: __('开户人'), operate: '=', searchList:{}},
  307. {field: 'today_recharge_money', title: __('今日充值'), operate: false},
  308. {field: 'yesterday_recharge_money', title: __('昨日充值'), operate: false},
  309. {field: 'recharge_money', title: __('总充值金额(不含当日)'), operate: false},
  310. {field: 'benefit_money', title: __('结算单总额(包含当日)'), operate: false},
  311. {field: 'no_cash_money', title: __('未提现总额(包含当日)'), operate: false},
  312. {field: 'status', title: __("Status"), formatter: Table.api.formatter.status,searchList: {'normal': '正常', 'hidden':'隐藏'}},
  313. {field: 'is_fouce', title: __("是否强制授权"), operate: false,formatter: function(value,row,index){return value==1?"强制":"不强制";}},
  314. {field: 'platforms', title: __("域名系统"), operate: false,formatter: function(value,row,index){return $('<div/>').html(value).text();}},
  315. {field: 'ac.platform_id', title: __("默认平台"), visible:false, searchList:Controller.api.formatter.platforms()},
  316. {field: 'ophost', title: __("业务域名(主)"), operate: '=', searchList: Controller.api.formatter.ophosts()},
  317. {field: 'wxpay', title: __("支付服务号(主)"), operate: '=', searchList: Controller.api.formatter.wxpays()},
  318. {field: 'menuophost', title: __("业务域名(菜单)"), operate: '=', searchList: Controller.api.formatter.ophosts()},
  319. {field: 'menuwxpay_host', title: __("支付服务号(菜单)"), operate: '=', searchList: Controller.api.formatter.wxpays()},
  320. {field: 'admin_extend.can_distribute', title: __("配号状态"), searchList: {'0': '关闭', '1':'开启'},formatter: function(value,row,index){return value==1?"开启":"关闭";}},
  321. {field: 'short_relation_count', title: __('短链域名数'),operate:false},
  322. {field: 'guide_relation_count', title: __('导粉域名数'),operate:false},
  323. {field: 'guide_domain', title: __('导粉短链状态'), searchList: {'0': '关闭', '1':'开启'},formatter:function(value,row,index){return value==1?"<span style='color: green;'>开启</span>":"<span style='color: red;'>关闭</span>";}},
  324. {field: 'admin_extend.reward_state', title: __('赏金开关'),formatter:function(value,row,index){return value==1?"已开启":"未开启";}, searchList: {'0': '未开启', '1':'已开启'}},
  325. {
  326. field: 'admin_extend.createtime',
  327. title: __('注册时间'),
  328. formatter: Table.api.formatter.datetime,
  329. operate: false
  330. },
  331. {
  332. field: 'tongji', visible:([2, 9].indexOf(Config.group) > -1), title: __("统计"), operate: false, formatter: function (value, row, index) {
  333. return '<a style="display:inline-block; margin:4px 5px;vertical-align: middle;" href="/admin/collect/index?channel_id=' + row.id + '" class="book_but"><button type="button" class="btn dropdown-toggle" style="background-color:#ddd;">订单统计</button></a>' +
  334. '<div class="dropdown" style="display:inline-block; margin:4px 5px;vertical-align: middle;"> <button type="button" style="background-color:#ddd;" class="btn dropdown-toggle" id="dropdownMenu1"data-toggle="dropdown">更多' +
  335. '<span class="caret"></span>' +
  336. '</button>' +
  337. '<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1" style="min-width: 5px;">' +
  338. '<li role="presentation">' +
  339. '<a role="menuitem" tabindex="-1" href="/admin/user/collect/index?ids=' + row.id + '" class="book_but">用户统计</a>' +
  340. '</li>' +
  341. '<li role="presentation">' +
  342. '<a role="menuitem" tabindex="-1" href="/admin/orders/index?channel_id=' + row.id + '" class="book_but">订单明细</a>' +
  343. '</li>' +
  344. '<li role="presentation">' +
  345. '<a role="menuitem" tabindex="-1" href="/admin/referral/referral/index?ids=' + row.id + '" class="book_but">推广链接</a>' +
  346. '</li>' +
  347. '</ul>' +
  348. '</div>';
  349. }
  350. },
  351. {
  352. field: 'operate',
  353. title: __('Operate'),
  354. table: table,
  355. events: Table.api.events.operate,
  356. formatter: function (value, row, index) {
  357. if (row.id == Config.admin.id) {
  358. return '';
  359. }
  360. return Table.api.formatter.operate.call(this, value, row, index);
  361. }
  362. },
  363. ]
  364. ],
  365. onLoadSuccess: function (data) {
  366. //配置搜索栏"开户人"下拉列表
  367. var formControlCreateBy = $(".form-control[name='admin_extend.create_by']");
  368. if(formControlCreateBy.children("option").length<=1){
  369. $.each(data.create_list, function (index, row) {
  370. formControlCreateBy.append('<option value="'+ row.id +'">'+ row.username +' | '+ row.nickname +'</option>');
  371. });
  372. }
  373. }
  374. });
  375. }
  376. // 为表格绑定事件
  377. Table.api.bindevent(table);
  378. },
  379. add: function () {
  380. Form.api.bindevent($("form[role=form]"));
  381. Form.events.selecttips("form[role=form]");
  382. //选择平台
  383. $('.checkbox_plat input').change(function () {
  384. var platform_id = $(this).attr('value');
  385. if($(this).is(":checked")){
  386. Controller.api.addOphostList(platform_id);
  387. }else{
  388. Controller.api.delPlatformList(platform_id);
  389. }
  390. });
  391. },
  392. edit: function () {
  393. Form.api.bindevent($("form[role=form]"));
  394. Form.events.selecttips("form[role=form]");
  395. $('.checkbox_plat input').change(function () {
  396. var platform_id = $(this).attr('value');
  397. if($(this).is(":checked")){
  398. if(Controller.api.checkedPlatformAuth(platform_id,Config.admin_id)){
  399. Controller.api.addOphostList(platform_id);
  400. }
  401. }else{
  402. Controller.api.delPlatformList(platform_id);
  403. }
  404. });
  405. },
  406. select:function(){
  407. // 初始化表格参数配置
  408. Table.api.init({
  409. extend: {
  410. index_url: 'auth/channel/select'
  411. },
  412. searchFormVisible: true,
  413. search:false,
  414. });
  415. var table = $("#table");
  416. // 初始化表格
  417. table.bootstrapTable({
  418. url: $.fn.bootstrapTable.defaults.extend.index_url + '?type='+Config.type+'&operate='+Config.operate+'&source_id='+Config.source_id+'&group_ids='+Config.group_ids,
  419. pk: 'id',
  420. sortName: 'id desc',
  421. sortOrder: '',
  422. columns: [Controller.api.showColumns()],
  423. });
  424. // 为表格绑定事件
  425. Table.api.bindevent(table);
  426. // 单个关联操作
  427. $(document).on('click', '.qd-doassociate', function () {
  428. var kl_id = $(this).data("kl_id");
  429. var channel_id = $(this).data("channel_id");
  430. var qd_this= $(this);
  431. Fast.api.close(channel_id);
  432. });
  433. // 勾选,关联渠道
  434. $('.js_assosite').on('click', function (e, data) {
  435. var ids = Table.api.selectedids(table);
  436. Layer.confirm(
  437. __('已选中条数:%s', ids.length),
  438. {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
  439. function (index) {
  440. var strids = ($.isArray(ids) ? ids.join(",") : ids);
  441. Fast.api.close(strids);
  442. }
  443. );
  444. });
  445. $('.js_assosite_all').on('click', function (e, data) {
  446. var kl_id = $(this).data('kl_id');
  447. Layer.confirm(
  448. '确定要关联所有渠道吗',
  449. {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
  450. function (index) {
  451. Fast.api.close('*');
  452. }
  453. );
  454. });
  455. // 勾选,查看 删除渠道
  456. $('.js_assosite_del').on('click', function (e, data) {
  457. var ids = Table.api.selectedids(table);
  458. Layer.confirm(
  459. __('已选中条数:%s', ids.length),
  460. {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
  461. function (index) {
  462. var strids = ($.isArray(ids) ? ids.join(",") : ids);
  463. Fast.api.close(strids);
  464. Layer.close(index);
  465. }
  466. );
  467. });
  468. // 单个关联操作
  469. $(document).on('click', '.qd-doassociate-del', function () {
  470. var kl_id = $(this).data("kl_id");
  471. var channel_id = $(this).data("channel_id");
  472. var qd_this= $(this);
  473. Fast.api.close(channel_id);
  474. });
  475. },
  476. api:{
  477. showColumns:function(){
  478. var cols = new Array();
  479. cols.push({checkbox: true});
  480. cols.push({field: 'id', title: 'ID'});
  481. cols.push({field: 'username', title: __('Username'), operate: 'LIKE %...%'});
  482. cols.push({field: 'nickname', title: __('Nickname'), operate: 'LIKE %...%'});
  483. cols.push({field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label});
  484. if(Config.operate == 'add'){
  485. cols.push({
  486. field: 'operate',
  487. title: __('Operate'),
  488. table: table,
  489. formatter: function (value, row, index) {
  490. html = "";
  491. html += "<a href='javascript:;' class='qd-doassociate' data-channel_id='"+row.id+"' data-kl_id='"+Config.kl_id+"'>关联</a>";
  492. return html;
  493. }
  494. });
  495. } else {
  496. cols.push({
  497. field: 'operate',
  498. title: __('Operate'),
  499. table: table,
  500. formatter: function (value, row, index) {
  501. return "<a href='javascript:;' class='qd-doassociate-del' data-channel_id='"+row.id+"' data-kl_id='"+Config.kl_id+"'>删除</a>";
  502. }
  503. });
  504. }
  505. return cols;
  506. },
  507. //检查平台,检查用户是否已授权过,检查平台是否已授权过
  508. checkedPlatformAuth:function(platform_id,channel_id){
  509. var is_auth = false;
  510. if(Config.channel_is_auth){
  511. $.ajaxSettings.async = false;
  512. $.get("auth/channel/checkplatformauth?platform_id=" + platform_id +'&channel_id='+channel_id,function(data){
  513. if(data.code){
  514. is_auth = true;
  515. }else{
  516. is_auth = false;
  517. }
  518. });
  519. $.ajaxSettings.async = true;
  520. }else{
  521. is_auth = true;
  522. }
  523. return is_auth;
  524. },
  525. //添加业务域名列表
  526. addOphostList:function(platform_id){
  527. $.get("auth/channel/ajaxgetophostlistbyplatformid?platform_id=" + platform_id, function (data) {
  528. if (data.code) {
  529. var ophost_list = data.data;
  530. for (var key in ophost_list) {
  531. $("#c-ophost_id").append("<option data-platform_id='"+ platform_id +"' value='" + ophost_list[key]['id'] + "' >" + ophost_list[key]['text']+ "</option><br>");
  532. $("#c-menuophost_id").append("<option data-platform_id='"+ platform_id +"' value='" + ophost_list[key]['id'] + "' >" + ophost_list[key]['text'] + "</option><br>");
  533. }
  534. }else{
  535. Toastr.error(data.msg);
  536. }
  537. });
  538. },
  539. //添加支付域名列表
  540. addOphostPayList:function(platform_id,ophost_id,wxpayName){
  541. $.get("auth/channel/ajaxgetwxpaylistbyplatformid?platform_id=" + platform_id+'&ophost_id='+ophost_id, function (data) {
  542. if (data.code) {
  543. var pay_list = data.data;
  544. for (var key in pay_list) {
  545. $('#'+wxpayName).append("<option data-platform_id='"+ platform_id +"' value='" + pay_list[key]['id'] + "' >" + pay_list[key]['text'] + "</option><br>");
  546. }
  547. }else{
  548. Toastr.error(data.msg);
  549. }
  550. });
  551. },
  552. //删除平台列表
  553. delPlatformList:function(platform_id){
  554. $("#c-ophost_id option[data-platform_id='"+platform_id+"']").remove();
  555. $("#c-menuophost_id option[data-platform_id='"+platform_id+"']").remove();
  556. },
  557. delWxpayList:function(wxpayName){
  558. $("#"+wxpayName+" option").remove();
  559. $("#"+wxpayName).append("<option value='' selected>请选择</option><br>");
  560. },
  561. formatter: {
  562. tongji: function (value, row, index) {
  563. return '<a class="btn btn-xs btn-browser">' + row.useragent.split(" ")[0] + '</a>';
  564. },
  565. platforms: function(){
  566. var list = {};
  567. for(var val in Config.platforms){
  568. list[Config.platforms[val].id] = Config.platforms[val].name;
  569. }
  570. return list;
  571. },
  572. ophosts: function () {
  573. var list = {};
  574. for(var val in Config.ophosts){
  575. list[val] = Config.ophosts[val];
  576. }
  577. return list;
  578. },
  579. wxpays: function () {
  580. var list = {};
  581. for(var val in Config.wxpays){
  582. list[val] = Config.wxpays[val];
  583. }
  584. return list;
  585. }
  586. },
  587. }
  588. };
  589. return Controller;
  590. });