prepayController.js 1.69 KB
angular.module('myApp')
	.controller('prepayController',['$scope','$rootScope','dingdaService','$state','globalService','wechatPayment',function($scope,$rootScope,dingdaService,$state,globalService,wechatPayment){
		
		$scope.account = "";
		$scope.way = 101;
		
		var init = function() {
//			globalService.init();
		}
		
//		mui.init();
		init();
		var ispay = false;
		$scope.prepay = function() {
			if(ispay) return;
			if($scope.account == ""){
                layer.open({
                    content: '请输入充值金额',
                    time:1
                });
			    return;
			};
			
			if($scope.account < 1) {
                layer.open({
                    content: '充值金额至少为1元',
                    time:1
                });
			    return;
			}
			ispay = true;
			// alert($scope.way)
            wechatPayment.callBalanceRecharge($scope.account, $scope.way)
                .then(function(result){
                	
					ispay = false;
                    //支付成功
//                    $state.go('wallet',{},{reload:true});
                    window.history.back();
                }, function(errMsg){
                	
					ispay = false;
                   //支付失败
                })

//			alert("充值 : " + $scope.account + "元")
		}

        $scope.payway = function() {
            if($scope.way == 101){
            	$('#wxpay').show();
                $('#alipay').hide();
                $('#alipayform').hide();
                $('#wxpayform').show();
            } else{
                $('#alipay').show();
                $('#wxpay').hide();
                $('#alipayform').show();
                $('#wxpayform').hide();
			}
			// alert('xxx')
		}
}]);