MemberController.js 3.7 KB
"use strict";
var memberController = angular.module('memberController',[]);


memberController.controller('memberController', [
    '$rootScope',
    '$scope',
    'MemberService',
    function($rootScope, $scope, MemberService) {
        $scope.currentPage = 1;
        $scope.numPages = 1;
        $scope.pageSize = 20;
        $scope.totalRecord = 0;
        $scope.pages = [];
        $scope.members=[];
        $scope.cardStatus='';
        $scope.status=[
            {name:'未认证', idCardStatus:'0'},
            {name:'待审核', idCardStatus:'1'},
            {name:'认证失败', idCardStatus:'2'},
            {name:'认证成功', idCardStatus:'100'}
        ];
        $scope.memberQuery={
            keyword:'',
            phone:'',
            trueName:'',
            wechat:'',
            idCard:'',
            pageNow:1,
            pageSize:20
        };
        if(($scope.memberQuery.keyword!=null&&$scope.memberQuery.keyword!="")||($scope.memberQuery.phone!=null&&$scope.memberQuery.phone!="")
        || ($scope.memberQuery.trueName!=null&&$scope.memberQuery.trueName!="")|| ($scope.memberQuery.wechat!=null&&$scope.memberQuery.wechat!="")
        ||($scope.memberQuery.idCard!=null&&$scope.memberQuery.idCard!="")){
            MemberService.memberPager($scope.memberQuery);
        }
        $scope.$on('member.list',function(){
            $scope.members=MemberService.members.datas;
            $scope.numPages=MemberService.members.totalPage;
            $scope.totalRecord=MemberService.members.totalRecord;
        });
        //选当前页
        $scope.onSelectPage = function(page) {
            $scope.memberQuery.pageNow=page;
            $scope.currentPage=page;
            MemberService.memberPager($scope.memberQuery);
        };
        $scope.searchMember=function(){
            $scope.memberQuery.pageNow=1;
            MemberService.memberPager($scope.memberQuery);
        };
        $scope.changervar=function(){
            $scope.memberQuery.idCard=$scope.cardStatus.idCardStatus;
        }



    }]
);

memberController.controller('memberDetailController',[
    '$rootScope',
    '$scope',
    'MemberService',
    function($rootScope, $scope, MemberService) {
        var id =  $rootScope.$stateParams.id;
        $scope.editMemberInfo={
            id:id,
            phone:''
        }
        $scope.onSubmitMember=function(){
            MemberService.updateMember($scope.editMemberInfo);
        }

        if(id) {
            MemberService.getMemberDetail(id, function (data) {
                $scope.editMemberInfo = data.data;
                console.log(data.data)
            });
        }
    }
]);


memberController.controller('memberAuditController',[
    '$rootScope',
    '$scope',
    'MemberService',
    '$state',
    function($rootScope, $scope, MemberService,$state) {
        var id =  $rootScope.$stateParams.id;
        $scope.memberDetail=[];
        $scope.memberQuery={
            keyword:'',
            phone:'',
            wechat:'',
            pageNow:1,
            pageSize:20
        };
        if(id) {
            MemberService.getMemberDetail(id, function (data) {
                $scope.memberDetail = data.data;
            });
        }
        $scope.onSubmitMember=function(value){
            $scope.memberDetail.idCardAuditStatus=value;
            if(confirm("您确认要审核该用户吗")) {
                MemberService.updateAuditIdCard($scope.memberDetail,function(res){
                    if(res.code == 0){
                        $state.go('listMember', $scope.memberQuery);
                    }else{
                        alert("小主,审核异常!!");
                    }
                });
            }
        }


    }
]);