prepayController.js
1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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')
}
}]);