user.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'user/user/index',
  8. add_url: 'user/user/add',
  9. edit_url: 'user/user/edit',
  10. del_url: 'user/user/del',
  11. multi_url: 'user/user/multi',
  12. table: 'user',
  13. },
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'user.id',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'id', title: __('Id'), sortable: true, operate: false},
  25. {field: 'username', title: __('Username'), operate: 'LIKE',formatter: Controller.api.formatter.user},
  26. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  27. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  28. {field: 'bonus', title: __('Bonus'), operate: 'LIKE'},
  29. {field: 'referee_name', title: __('Referee'), operate: false},
  30. {field: 'referee_number', title: __('Referee number'), operate: false},
  31. {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {2: __('Status2'),1: __('Status1'), 0: __('Status0')}, operate:false},
  32. {field: 'ishost', title: __('是否房主'), formatter: Table.api.formatter.status, searchList: {1: __('是'),'0': __('否')}, operate: false},
  33. {field: 'operate', title: __('Operate'),
  34. buttons: [
  35. {
  36. name: 'chongzhi',
  37. text: '充值',
  38. title: '充值',
  39. icon: 'fa fa-plus',
  40. classname: 'btn btn-xs btn-primary btn-dialog',
  41. url: 'user/user/chongzhi',
  42. },
  43. {
  44. name: 'koufei',
  45. text: '扣费',
  46. title: '扣费',
  47. icon: 'fa fa-minus',
  48. classname: 'btn btn-xs btn-info btn-dialog',
  49. url: 'user/user/koufei',
  50. },
  51. {
  52. name: 'setStatus2',
  53. text: '冻结',
  54. title: '冻结',
  55. icon: 'fa fa-circle',
  56. classname: 'btn btn-xs btn-success btn-ajax',
  57. url: 'user/user/setStatus/status/2',
  58. },
  59. {
  60. name: 'setStatus1',
  61. text: '解冻',
  62. title: '解冻',
  63. icon: 'fa fa-circle',
  64. classname: 'btn btn-xs btn-danger btn-ajax',
  65. url: 'user/user/setStatus/status/1',
  66. },
  67. {
  68. name: 'updatepwd',
  69. text: '密码重置',
  70. title: '密码重置',
  71. icon: 'fa fa-circle',
  72. classname: 'btn btn-xs btn-success btn-dialog',
  73. url: 'user/user/updatepwd',
  74. }
  75. ],table: table, events: Table.api.events.operate,
  76. formatter:function (value, row, index) {
  77. var that = $.extend({}, this);
  78. var table = $(that.table).clone(true);
  79. $(table).data("operate-del", null);
  80. if(row.status == 1)
  81. {
  82. $(table).data("operate-setStatus1", null);
  83. }else if(row.status == 2){
  84. $(table).data("operate-setStatus2", null);
  85. }
  86. that.table = table;
  87. return Table.api.formatter.operate.call(that, value, row, index);
  88. }}
  89. ]
  90. ]
  91. });
  92. // 为表格绑定事件
  93. Table.api.bindevent(table);
  94. },
  95. reallist: function () {
  96. // 初始化表格参数配置
  97. Table.api.init({
  98. extend: {
  99. index_url: 'user/user/reallist',
  100. add_url: '',
  101. del_url: '',
  102. table: 'user',
  103. },
  104. });
  105. var table = $("#table");
  106. // 初始化表格
  107. table.bootstrapTable({
  108. url: $.fn.bootstrapTable.defaults.extend.index_url,
  109. pk: 'id',
  110. sortName: 'id',
  111. columns: [
  112. [
  113. {checkbox: true},
  114. {field: 'id', title: __('Id'), sortable: true, operate: false},
  115. {field: 'username', title: __('Username'), operate: 'LIKE'},
  116. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  117. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  118. {field: 'idcard', title: __('身份证号'), operate: false},
  119. {field: 'realname', title: __('真实姓名'), operate: false},
  120. {field: 'idprc1', title: __('正面照'), formatter: Table.api.formatter.image, operate: false},
  121. {field: 'idprc2', title: __('反面照'), formatter: Table.api.formatter.image, operate: false},
  122. {field: 'isreal', title: __('Status'), formatter: Table.api.formatter.status, searchList: {1: __('审核中'), 2: __('已通过')}, operate:false},
  123. {field: 'operate', title: __('Operate'),
  124. buttons: [
  125. {
  126. name: 'viewauto',
  127. text: '审核',
  128. title: '审核',
  129. icon: 'fa fa-list',
  130. classname: 'btn btn-xs btn-primary btn-ajax',
  131. url: 'user/user/viewauto/status/1',
  132. success: function (data) {
  133. window.location.reload();
  134. }
  135. },{
  136. name: 'viewauto',
  137. text: '拒绝',
  138. title: '审核',
  139. icon: 'fa fa-list',
  140. classname: 'btn btn-xs btn-primary btn-ajax',
  141. url: 'user/user/viewauto/status/-1',
  142. success: function (data) {
  143. window.location.reload();
  144. }
  145. },{
  146. name: 'showprc',
  147. text: '查看图片',
  148. title: '查看图片',
  149. icon: 'fa fa-list',
  150. classname: 'btn btn-xs btn-primary btn-dialog',
  151. url: 'user/user/showprc',
  152. }
  153. ], table: table, events: Table.api.events.operate,
  154. formatter:function (value, row, index) {
  155. var that = $.extend({}, this);
  156. var table = $(that.table).clone(true);
  157. if(row.isreal != 1)
  158. {
  159. $(table).data("operate-viewauto", null);
  160. }
  161. that.table = table;
  162. return Table.api.formatter.operate.call(that, value, row, index);
  163. }}
  164. ]
  165. ]
  166. });
  167. // 为表格绑定事件
  168. Table.api.bindevent(table);
  169. },
  170. noactivelist: function () {
  171. // 初始化表格参数配置
  172. Table.api.init({
  173. extend: {
  174. index_url: 'user/user/noactivelist',
  175. add_url: 'user/user/add',
  176. del_url: 'user/user/del',
  177. table: 'user',
  178. },
  179. });
  180. var table = $("#table");
  181. // 初始化表格
  182. table.bootstrapTable({
  183. url: $.fn.bootstrapTable.defaults.extend.index_url,
  184. pk: 'id',
  185. sortName: 'id',
  186. columns: [
  187. [
  188. {checkbox: true},
  189. {field: 'id', title: __('Id'), sortable: true, operate: false},
  190. {field: 'username', title: __('Username'), operate: 'LIKE'},
  191. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  192. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  193. {field: 'referee_name', title: __('Referee'), operate: false},
  194. {field: 'parent_name', title: __('Parent'), operate: false},
  195. {field: 'createtime', title: __('Create time'), operate: 'LIKE', formatter: Table.api.formatter.datetime},
  196. {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {1: __('Status1'), 0: __('Status0')}, operate:false},
  197. // {field: 'custom', title: '激活', operate: false, formatter: Controller.api.formatter.jihuo},
  198. {field: 'operate', title: __('Operate'),
  199. buttons: [
  200. {
  201. name: 'jihuo',
  202. text: '激活',
  203. title: '激活',
  204. icon: 'fa fa-list',
  205. classname: 'btn btn-xs btn-primary btn-ajax',
  206. url: 'user/user/jihuo',
  207. success: function (data) {
  208. window.location.reload();
  209. }
  210. }
  211. ], table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  212. ]
  213. ]
  214. });
  215. // 为表格绑定事件
  216. Table.api.bindevent(table);
  217. },
  218. usermessage: function () {
  219. // 初始化表格参数配置
  220. Table.api.init({
  221. extend: {
  222. index_url: 'user/user/usermessage',
  223. add_url: 'user/user/add',
  224. del_url: 'user/user/del',
  225. table: 'user',
  226. },
  227. });
  228. var table = $("#table");
  229. // 初始化表格
  230. table.bootstrapTable({
  231. url: $.fn.bootstrapTable.defaults.extend.index_url,
  232. pk: 'id',
  233. sortName: 'id',
  234. columns: [
  235. [
  236. {checkbox: true},
  237. {field: 'id', title: __('Id'), sortable: true, operate: false},
  238. {field: 'username', title: __('Username'), operate: 'LIKE'},
  239. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  240. {field: 'operate', title: __('Operate'),
  241. buttons: [
  242. {
  243. name: 'viewmsg',
  244. text: '查看留言',
  245. title: '查看留言',
  246. icon: 'fa fa-list',
  247. classname: 'btn btn-xs btn-success btn-dialog',
  248. url: 'user/user/viewmsg',
  249. callback: function (data) {
  250. Layer.alert("接收到回传数据:" + JSON.stringify(data), { title: "回传数据" });
  251. }
  252. }
  253. ], table: table, events: Table.api.events.operate,
  254. formatter:function (value, row, index) {
  255. var that = $.extend({}, this);
  256. var table = $(that.table).clone(true);
  257. $(table).data("operate-del", null);
  258. that.table = table;
  259. return Table.api.formatter.operate.call(that, value, row, index);
  260. }
  261. }
  262. ]
  263. ]
  264. });
  265. // 为表格绑定事件
  266. Table.api.bindevent(table);
  267. },
  268. add: function () {
  269. Controller.api.bindevent();
  270. },
  271. edit: function () {
  272. Controller.api.bindevent();
  273. },
  274. api: {
  275. bindevent: function () {
  276. Form.api.bindevent($("form[role=form]"));
  277. $(document).on('click', ".switchname", function () {
  278. $.get("/index.php/api/index/switchname", function (ret) {
  279. $('#c-username').val(ret.msg);
  280. });
  281. });
  282. $(document).on('click', ".checkname", function () {
  283. $.getJSON("/index.php/api/index/checkusername",{username:$('#c-username').val()},function(json){
  284. layer.msg(json.msg);
  285. });
  286. });
  287. $(document).on('change', "#c-referee", function () {
  288. $.getJSON("/index.php/api/index/getnickname",{username:$('#c-referee').val()},function(json){
  289. if(json.code == 0)
  290. {
  291. layer.msg(json.msg);
  292. }else{
  293. $('.c-referee').html(json.msg);
  294. }
  295. });
  296. });
  297. $(document).on('change', "#c-parent", function () {
  298. $.getJSON("/index.php/api/index/getnickname",{username:$('#c-parent').val()},function(json){
  299. if(json.code == 0)
  300. {
  301. layer.msg(json.msg);
  302. }else{
  303. $('.c-parent').html(json.msg);
  304. }
  305. });
  306. $.getJSON("/index.php/api/index/getpos",{username:$('#c-parent').val()},function(json){
  307. if(json.code == 0)
  308. {
  309. layer.msg(json.msg);
  310. }else{
  311. $('#pos').html(json.msg);
  312. }
  313. });
  314. });
  315. $(document).on('change', "#pos", function () {
  316. $('.pos').val($('#pos').val());
  317. });
  318. },
  319. formatter: {
  320. user: function (value, row, index) {
  321. return '<a href="/index/user/syslogin/uid/'+row.id+'#" target="_blank" class="btn btn-xs btn-ip bg-success"> ' + value + '</a>';
  322. },
  323. }
  324. }
  325. };
  326. return Controller;
  327. });