| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'user/user/index',
- add_url: 'user/user/add',
- edit_url: 'user/user/edit',
- del_url: 'user/user/del',
- multi_url: 'user/user/multi',
- table: 'user',
- },
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'user.id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id'), sortable: true, operate: false},
- {field: 'username', title: __('Username'), operate: 'LIKE',formatter: Controller.api.formatter.user},
- {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
- {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
- {field: 'bonus', title: __('Bonus'), operate: 'LIKE'},
- {field: 'referee_name', title: __('Referee'), operate: false},
- {field: 'referee_number', title: __('Referee number'), operate: false},
- {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {2: __('Status2'),1: __('Status1'), 0: __('Status0')}, operate:false},
- {field: 'ishost', title: __('是否房主'), formatter: Table.api.formatter.status, searchList: {1: __('是'),'0': __('否')}, operate: false},
- {field: 'operate', title: __('Operate'),
- buttons: [
- {
- name: 'chongzhi',
- text: '充值',
- title: '充值',
- icon: 'fa fa-plus',
- classname: 'btn btn-xs btn-primary btn-dialog',
- url: 'user/user/chongzhi',
- },
- {
- name: 'koufei',
- text: '扣费',
- title: '扣费',
- icon: 'fa fa-minus',
- classname: 'btn btn-xs btn-info btn-dialog',
- url: 'user/user/koufei',
- },
- {
- name: 'setStatus2',
- text: '冻结',
- title: '冻结',
- icon: 'fa fa-circle',
- classname: 'btn btn-xs btn-success btn-ajax',
- url: 'user/user/setStatus/status/2',
- },
- {
- name: 'setStatus1',
- text: '解冻',
- title: '解冻',
- icon: 'fa fa-circle',
- classname: 'btn btn-xs btn-danger btn-ajax',
- url: 'user/user/setStatus/status/1',
- },
- {
- name: 'updatepwd',
- text: '密码重置',
- title: '密码重置',
- icon: 'fa fa-circle',
- classname: 'btn btn-xs btn-success btn-dialog',
- url: 'user/user/updatepwd',
- }
- ],table: table, events: Table.api.events.operate,
- formatter:function (value, row, index) {
- var that = $.extend({}, this);
- var table = $(that.table).clone(true);
- $(table).data("operate-del", null);
- if(row.status == 1)
- {
- $(table).data("operate-setStatus1", null);
- }else if(row.status == 2){
- $(table).data("operate-setStatus2", null);
- }
- that.table = table;
- return Table.api.formatter.operate.call(that, value, row, index);
- }}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- reallist: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'user/user/reallist',
- add_url: '',
- del_url: '',
- table: 'user',
- },
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id'), sortable: true, operate: false},
- {field: 'username', title: __('Username'), operate: 'LIKE'},
- {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
- {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
- {field: 'idcard', title: __('身份证号'), operate: false},
- {field: 'realname', title: __('真实姓名'), operate: false},
- {field: 'idprc1', title: __('正面照'), formatter: Table.api.formatter.image, operate: false},
- {field: 'idprc2', title: __('反面照'), formatter: Table.api.formatter.image, operate: false},
- {field: 'isreal', title: __('Status'), formatter: Table.api.formatter.status, searchList: {1: __('审核中'), 2: __('已通过')}, operate:false},
- {field: 'operate', title: __('Operate'),
- buttons: [
- {
- name: 'viewauto',
- text: '审核',
- title: '审核',
- icon: 'fa fa-list',
- classname: 'btn btn-xs btn-primary btn-ajax',
- url: 'user/user/viewauto/status/1',
- success: function (data) {
- window.location.reload();
- }
- },{
- name: 'viewauto',
- text: '拒绝',
- title: '审核',
- icon: 'fa fa-list',
- classname: 'btn btn-xs btn-primary btn-ajax',
- url: 'user/user/viewauto/status/-1',
- success: function (data) {
- window.location.reload();
- }
- },{
- name: 'showprc',
- text: '查看图片',
- title: '查看图片',
- icon: 'fa fa-list',
- classname: 'btn btn-xs btn-primary btn-dialog',
- url: 'user/user/showprc',
-
- }
- ], table: table, events: Table.api.events.operate,
- formatter:function (value, row, index) {
- var that = $.extend({}, this);
- var table = $(that.table).clone(true);
- if(row.isreal != 1)
- {
- $(table).data("operate-viewauto", null);
- }
- that.table = table;
- return Table.api.formatter.operate.call(that, value, row, index);
- }}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- noactivelist: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'user/user/noactivelist',
- add_url: 'user/user/add',
- del_url: 'user/user/del',
- table: 'user',
- },
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id'), sortable: true, operate: false},
- {field: 'username', title: __('Username'), operate: 'LIKE'},
- {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
- {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
- {field: 'referee_name', title: __('Referee'), operate: false},
- {field: 'parent_name', title: __('Parent'), operate: false},
- {field: 'createtime', title: __('Create time'), operate: 'LIKE', formatter: Table.api.formatter.datetime},
- {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {1: __('Status1'), 0: __('Status0')}, operate:false},
- // {field: 'custom', title: '激活', operate: false, formatter: Controller.api.formatter.jihuo},
- {field: 'operate', title: __('Operate'),
- buttons: [
- {
- name: 'jihuo',
- text: '激活',
- title: '激活',
- icon: 'fa fa-list',
- classname: 'btn btn-xs btn-primary btn-ajax',
- url: 'user/user/jihuo',
- success: function (data) {
- window.location.reload();
- }
-
- }
- ], table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- usermessage: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'user/user/usermessage',
- add_url: 'user/user/add',
- del_url: 'user/user/del',
- table: 'user',
- },
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id'), sortable: true, operate: false},
- {field: 'username', title: __('Username'), operate: 'LIKE'},
- {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
- {field: 'operate', title: __('Operate'),
- buttons: [
- {
- name: 'viewmsg',
- text: '查看留言',
- title: '查看留言',
- icon: 'fa fa-list',
- classname: 'btn btn-xs btn-success btn-dialog',
- url: 'user/user/viewmsg',
- callback: function (data) {
- Layer.alert("接收到回传数据:" + JSON.stringify(data), { title: "回传数据" });
- }
-
- }
- ], table: table, events: Table.api.events.operate,
- formatter:function (value, row, index) {
- var that = $.extend({}, this);
- var table = $(that.table).clone(true);
- $(table).data("operate-del", null);
-
- that.table = table;
- return Table.api.formatter.operate.call(that, value, row, index);
- }
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- $(document).on('click', ".switchname", function () {
- $.get("/index.php/api/index/switchname", function (ret) {
- $('#c-username').val(ret.msg);
- });
- });
- $(document).on('click', ".checkname", function () {
- $.getJSON("/index.php/api/index/checkusername",{username:$('#c-username').val()},function(json){
- layer.msg(json.msg);
- });
- });
-
- $(document).on('change', "#c-referee", function () {
- $.getJSON("/index.php/api/index/getnickname",{username:$('#c-referee').val()},function(json){
- if(json.code == 0)
- {
- layer.msg(json.msg);
- }else{
- $('.c-referee').html(json.msg);
- }
-
- });
- });
- $(document).on('change', "#c-parent", function () {
- $.getJSON("/index.php/api/index/getnickname",{username:$('#c-parent').val()},function(json){
- if(json.code == 0)
- {
- layer.msg(json.msg);
- }else{
- $('.c-parent').html(json.msg);
- }
- });
- $.getJSON("/index.php/api/index/getpos",{username:$('#c-parent').val()},function(json){
- if(json.code == 0)
- {
- layer.msg(json.msg);
- }else{
- $('#pos').html(json.msg);
- }
- });
- });
- $(document).on('change', "#pos", function () {
- $('.pos').val($('#pos').val());
- });
-
- },
- formatter: {
- user: function (value, row, index) {
- return '<a href="/index/user/syslogin/uid/'+row.id+'#" target="_blank" class="btn btn-xs btn-ip bg-success"> ' + value + '</a>';
- },
- }
- }
- };
- return Controller;
- });
|