angular.module('push')
.controller('upGradeMangementCtrl', function ($scope, $stateParams, $ionicModal, AccountService, UtilService, UserService, $ionicPopup, $timeout) {
if($scope.app){
$scope.setStatusBar(0);
}
$scope.defaultLan = UserService.defaultLan;
$scope.keyPsMoney = "";
$scope.viplevel = UserService.viplevel;
$scope.paymoney = 29999;
var totalcurrency = $stateParams.totalcurrency;
$ionicModal.fromTemplateUrl('my-payBoard.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function (modal) {
$scope.modal = modal;
});
//打开支付弹窗
$scope.openPasModal = function () {
if (UserService.ishaspaypassword == 0) {
$ionicPopup.show({
title: '提示',
template: '您的支付密码还未设置',
buttons: [
{
text: '去设置',
type: "button-positive",
onTap: function (e) {
$scope.go("payPsMoneyPassword");
}
}
]
});
return;
}
if (totalcurrency < 29999) {
notPsEnough();
return;
}
$scope.modal.show();
};
//关闭支付弹窗
$scope.closePasModal = function () {
$scope.keyPsMoney = "";
$scope.modal.hide();
};
//输入密码
$scope.pressKey = function (num) {
$(".gradeBgWrap_Div").removeClass("gradeBgWrap_Div_delete");
if ($scope.keyPsMoney.length >= 6) {
return;
}
$scope.keyPsMoney += num;
// console.log($scope.keyPsMoney);
if ($scope.keyPsMoney.length == 6) {
checkPas();
}
};
/*回退密码*/
$scope.keyBoardDelete = function () {
if ($scope.keyPsMoney.length <= 0) {
return;
}
$scope.keyPsMoney = $scope.keyPsMoney.substring(0, $scope.keyPsMoney.length - 1);
// console.log($scope.keyPsMoney);
};
var checkPas = function () {
$scope.showLoadingToast();
AccountService.checkPayPassword($scope.keyPsMoney).then(function (response) {
//0 支付密码错误 1 升级成功 2 普适币不足 3 支付密码成功,升级失败
// console.log(response);
if (response.status == 0) {
UtilService.showMess("支付密码错误");
} else if (response.status == 1) {
$(".gradeBgWrap").fadeIn("fast");
} else if (response.status == 2) {
notPsEnough();
// UtilService.showMess("普适币不足,请充值");
} else {
UtilService.showMess("升级失败,请重试");
}
$scope.keyPsMoney = "";
$scope.hideLoadingToast();
$scope.closePasModal();
}, function () {
$scope.closePasModal();
$scope.hideLoadingToast();
$scope.keyPsMoney = "";
})
};
$scope.showUpMessage = function () {
// UtilService.showMess("联系客服");
$ionicPopup.show({
template: "客户电话:18112872030" +
"客服QQ:3421717266 2372362384",
title: "请联系客服",
scope: $scope,
buttons: [
{
text: '知道了',
type: "button-positive",
onTap: function (e) {
}
}
]
})
};
//账户余额不足
var notPsEnough = function () {
$ionicPopup.show({
template: "您的账号余额不足,无法升级,需要充值后才能升级!",
title: "普适币账号余额不足",
scope: $scope,
buttons: [
{
text: "取消"
},
{
text: '确认',
type: "button-positive",
onTap: function (e) {
}
}
]
})
};
// 删除动画提醒
$scope.grade_delete=function () {
$(".gradeBgWrap_Div").addClass("gradeBgWrap_Div_delete");
$(".gradeBgWrap").fadeOut();
$timeout(function () {
$scope.goback();
},500);
}
});