text: angular.module("app").controller("UserlistCtrl",["$scope","CommonFunction","DataLoad","toaster","divpage","$modal",function(e,a,t,n,i,l){e.haveData=!0,e.loading=!0,e.query="",e.page=1,e.totalPage=1,e.perPage=10,e.dataList=[],e.init=!0,e.selectAll=!1,e.all_delete_disabled=!0,e.all_delete_html="删除",e.submit=!1,e.radioModel=99,e.init_loading=!0,e.is_manager=!1,e.is_company=!1,e.$watch("is_manager",function(a,t){a!=t&&(e.page=1,e.getAllData())}),e.$watch("is_company",function(a,t){a!=t&&(e.page=1,e.getAllData())}),e.$watch("radioModel",function(a,t){a!=t&&(e.init_loading||(e.page=1,e.getAllData()))}),e.dateSelectSingle={start:moment(new Date).utc().startOf("day"),end:""},e.$watch("dateSelectSingle.start",function(a,t){a!=t&&(e.init=!1,e.page=1,e.getAllData())},!0),e.getAllData=function(){e.loading=!0;var a=t.getMemberPageData({searchkey:e.query,level:e.radioModel,manager:e.is_manager?1:0,company:e.is_company?1:0,time:e.init?"":e.dateSelectSingle.end.format("YYYY-MM-DD"),offset:(e.page-1)*e.perPage,num:e.perPage});return a.then(function(a){if(a&&0==a.code)if(0!=a.data.data.length){e.haveData=!0,e.dataList=a.data.data,angular.forEach(e.dataList,function(e,a){1==e.is_manager?e.manager=!0:e.manager=!1,1==e.is_company?e.company=!0:e.company=!1,1==e.is_message?e.message=!0:e.message=!1}),e.totalPage=Math.ceil(a.data.count/e.perPage);var t=$("#divpage-page");i.getready(t,e.totalPage,e.page)}else e.dataList=[],n.pop("success","会员列表","没有数据！"),e.haveData=!1;else e.dataList=[],e.haveData=!1,n.pop("error","会员列表",a.message);e.loading=!1,e.init_loading=!1},function(){e.dataList=[],e.haveData=!1,e.loading=!1,e.init_loading=!1,n.pop("error","会员列表","获取数据出错！")})},e.getAllData(),e.isFirst=function(e){return 1==e},e.isDisable=function(a){return 1==a&&1==e.totalPage?!0:!(a<e.totalPage)},e.getInfoPage=function(a){a<=e.totalPage&&a>0&&(e.page=a,e.getAllData())},e.divpageByPage=function(a){var t=$(a.currentTarget).html(),n=Number(t);angular.isNumber(n)&&n>0&&e.getInfoPage(n)},e.searchData=function(){e.page=1,e.getAllData()},e.$watch("dataList",function(a,t){a!=t&&e.dataList.length>0&&(e.num=0,e.all=0,angular.forEach(e.dataList,function(a,t){a.selected&&e.num++,e.all++}),e.num>0?e.all_delete_disabled=!1:e.all_delete_disabled=!0,e.num==e.all?e.selectAll=!0:e.selectAll=!1)},!0),e.$watch("selectAll",function(a,t){a!=t&&e.dataList.length>0&&(a?angular.forEach(e.dataList,function(e,a){e.selected=!0}):(e.count=0,e.all=0,angular.forEach(e.dataList,function(a,t){a.selected&&e.count++,e.all++}),e.count==e.all&&angular.forEach(e.dataList,function(e,a){e.selected=!1})))}),e.deleteBatch=function(){if(1==confirm("确定要删除吗?")&&0==e.submit){e.submit=!0,e.idlist=[],angular.forEach(e.dataList,function(a,t){1==a.selected&&e.idlist.push(a.id)});var a=t.deleteUserBatch({idlist:JSON.stringify(e.idlist)});return a.then(function(a){e.all_disagree_disabled=!1,e.all_delete_html="删除",a&&0==a.code?(n.pop("success","会员列表",a.message),location.reload()):(e.submit=!1,n.pop("error","会员列表",a.message))},function(){e.submit=!1,e.all_disagree_disabled=!1,e.all_delete_html="删除",n.pop("error","会员列表","操作出错！")})}},e.open=function(a,t){var n=l.open({templateUrl:"userModalContent",controller:"userModalInstanceCtrl",size:t,resolve:{item:function(){return a}}});n.result.then(function(a){angular.isDefined(a)&&angular.isDefined(a.type)&&"update"==a.type?e.getAllData():angular.isDefined(a)&&angular.isDefined(a.type)&&"student"==a.type&&e.student(a.item,"lg")},function(){})},e.student=function(e,a){var t=l.open({templateUrl:"studentModalContent",controller:"studentModalInstanceCtrl",size:a,resolve:{item:function(){return e}}});t.result.then(function(e){},function(){})}}]),angular.module("app").controller("userModalInstanceCtrl",["$rootScope","$scope","$modalInstance","toaster","item","$timeout","DataLoad","$window",function(e,a,t,n,i,l,o,r){a.item=angular.copy(i),a.item.new_level="",a.item.pay_mobile="",a.item.pay_consume_rate="",a.submit=!1,a.submitBtnHtml="提交",a.upgrade=[],a.item.manager=1==a.item.is_manager,a.item.company=1==a.item.is_company,0==a.item.level||1==a.item.level||2==a.item.level?(a.upgrade=[{level:11,name:"初级服务中心"},{level:12,name:"中级服务中心"},{level:13,name:"高级服务中心"}],a.item.new_level=11):11==a.item.level?(a.upgrade=[{level:12,name:"中级服务中心"},{level:13,name:"高级服务中心"}],a.item.new_level=12):12==a.item.level&&(a.upgrade=[{level:13,name:"高级服务中心"}],a.item.new_level=13),a.cancle=function(){var e={type:"cancel"};t.close(e)},a.update=function(){var e={type:"update"};t.close(e)},a.student=function(){var e={type:"student",item:a.item};t.close(e)},a.detail=function(e){t.close(e),"charge"!=e&&"declaration"!=e?r.location.href="/admin/#/app/"+e+"?userid="+a.item.id:"charge"==e?r.location.href="/admin/#/app/declaration?userid="+a.item.id+"&type=charge":"declaration"==e&&(r.location.href="/admin/#/app/declaration?userid="+a.item.id+"&type=declaration")},a.update_html="提交修改",a.updateRecommend=function(){if(0==a.submit){a.submit=!0,a.update_html="提交中…";var e=o.changeRecommend({id:a.item.id,mobile:a.item.parent_mobile});return e.then(function(e){a.update_html="提交修改",e&&0==e.code?(n.pop("success","会员管理",e.message),a.update()):(a.submit=!1,n.pop("error","会员管理",e.message))},function(){a.submit=!1,a.update_html="提交修改",n.pop("error","会员管理","操作出错！")})}},a.upgrade_html="提交升级",a.upgradeLevel=function(){if(""==a.item.pay_mobile)return n.pop("error","会员管理","兑充人手机号码不能为空"),!1;if(""!=a.item.pay_consume_rate&&(a.item.pay_consume_rate<0||a.item.pay_consume_rate>100))return n.pop("error","会员管理","抵扣消费积分比例必须在0-100之间"),!1;if(1==confirm("确定要升级吗?")&&0==a.submit){a.submit=!0,a.upgrade_html="提交中…";var e=o.upgradeLevel({id:a.item.id,old_level:a.item.level,new_level:a.item.new_level,pay_mobile:a.item.pay_mobile,pay_consume_rate:""!=a.item.pay_consume_rate?a.item.pay_consume_rate:0});return e.then(function(e){a.upgrade_html="提交升级",e&&0==e.code?(n.pop("success","会员管理",e.message),a.update()):(a.submit=!1,n.pop("error","会员管理",e.message))},function(){a.submit=!1,a.upgrade_html="提交升级",n.pop("error","会员管理","操作出错！")})}},a.manager_status=function(e){if(e.manager)var t=1;else var t=0;var i=o.manager_status({id:e.id,value:t});return i.then(function(e){e&&0==e.code?(n.pop("success","会员管理",e.message),l(function(){a.update()},1e3)):n.pop("error","会员管理",e.message)},function(){n.pop("error","会员管理","修改出错")})},a.company_status=function(e){if(e.company)var t=1;else var t=0;var i=o.company_status({id:e.id,value:t});return i.then(function(e){e&&0==e.code?(n.pop("success","会员管理",e.message),l(function(){a.update()},1e3)):n.pop("error","会员管理",e.message)},function(){n.pop("error","会员管理","修改出错")})},a.message_status=function(e){if(e.message)var t=1;else var t=0;var i=o.message_status({id:e.id,value:t});return i.then(function(e){e&&0==e.code?(n.pop("success","会员管理",e.message),l(function(){a.update()},1e3)):n.pop("error","会员管理",e.message)},function(){n.pop("error","会员管理","修改出错")})}}]),angular.module("app").controller("studentModalInstanceCtrl",["$rootScope","$scope","$modalInstance","toaster","item","$rootScope","DataLoad","divpage",function(e,a,t,n,i,e,l,o){a.item=angular.copy(i),a.cancle=function(){t.close()},a.haveData=!0,a.page=1,a.totalPage=1,a.perPage=10,a.dataList=[],a.loading=!0,a.isFirst=function(e){return 1==e},a.isDisable=function(e){return 1==e&&1==a.totalPage?!0:!(e<a.totalPage)},a.getInfoPage=function(e){e<=a.totalPage&&e>0&&(a.page=e,a.getAllData())},a.divpageByPage=function(e){var t=$(e.currentTarget).html(),n=Number(t);angular.isNumber(n)&&n>0&&a.getInfoPage(n)},a.getAllData=function(){a.loading=!0;var e=l.getStudentPageData({page:a.page,num:a.perPage,parent_id:a.item.id});return e.then(function(e){if(e&&0==e.code)if(0!=e.data.data.length){a.haveData=!0,a.dataList=e.data.data,a.totalPage=Math.ceil(e.data.count/a.perPage);var t=$("#student-page");o.getready(t,a.totalPage,a.page)}else a.dataList=[],n.pop("success","会员列表","没有数据！"),a.haveData=!1;else a.dataList=[],a.haveData=!1,n.pop("error","会员列表",e.message);a.loading=!1,a.init_loading=!1},function(){a.dataList=[],a.haveData=!1,a.loading=!1,a.init_loading=!1,n.pop("error","会员列表","获取数据出错！")})},a.getAllData()}]);