agent.js 37 KB

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