setSms.js 1.55 KB
(function (angular) {
    function setSms($scope,aiNicheService,DTOptionsBuilder, $uibModal,$uibModalInstance,$sce,SweetAlertX) {
        $scope.cnotifySwitch='';
        $scope.cnotifySwitch = 2;
        $scope.collisionPhone = '';
        function getCurrentUserInfo() {
            aiNicheService.getCurrentUserMerchantConfig(function(response) {
            	if(response.data) {
            		$scope.cnotifySwitch = response.data.cnotifySwitch;
                    $scope.collisionPhone = response.data.collisionPhone;
            	}
            });
        }
        getCurrentUserInfo();
        
        
    	//保存
        $scope.ok = function () {
        	if($scope.smsSetForm.$valid) {
        		var obj = {
	        		collisionPhone:$scope.collisionPhone,
	                cnotifySwitch:$scope.cnotifySwitch
	            };
	        	aiNicheService.saveOrUpdateConfig(obj, function(result){
	    			if (result.returnCode == '0') {
	                    SweetAlertX.alert('', '设置成功', 'success');
	                    $uibModalInstance.close(result);
	
	                } else {
	                    SweetAlertX.alert(result.message || '', '设置失败', 'error');
	                }
	    		});
        	}else{
        		$scope.smsSetForm.submitted = true;
        	}
        };

        //关闭
        $scope.cancel = function () {
            // $uibModalInstance.dismiss('cancel');
            /*关闭后返回true给前一页面*/
            $uibModalInstance.close();
        };
    }

    angular.module('AIniche').controller('setSms', setSms);
})(angular);