123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- angular.module('push')
- .controller('psMoneyConsumeCtrl', function ($scope, $stateParams, $ionicModal, UserService, UtilService, $ionicPopup, CommentService) {
- $scope.keyPsMoney = "";
- $scope.totalcurrency = $stateParams.totalcurrency;
- var item = 0;//服务对应item
- //获取兑换服务列表
- var getServices = function () {
- $scope.showLoadingToast();
- CommentService.getServices().then(function (response) {
- // console.log(response);
- $scope.servicelist = response;
- $scope.hideLoadingToast();
- }, function () {
- $scope.hideLoadingToast();
- })
- };
- getServices();
- $ionicModal.fromTemplateUrl('my-payBoard.html', {
- scope: $scope,
- animation: 'slide-in-up'
- }).then(function (modal) {
- $scope.modal = modal;
- });
- //打开支付弹窗
- $scope.openPasModal = function (tempitem, tempitemvalue) {
- item = tempitem;
- if (UserService.ishaspaypassword == 0) {
- $ionicPopup.show({
- title: '提示',
- template: '<span style="width: 100%;display: block;text-align: center;">您的支付密码还未设置</span>',
- buttons: [
- {
- text: '<span class="ionicAction_span">去设置</span>',
- type: "button-positive",
- onTap: function (e) {
- $scope.go("payPsMoneyPassword");
- }
- }
- ]
- });
- return;
- }
- if ($scope.totalcurrency < tempitemvalue) {
- 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;
- 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);
- };
- //检测密码并兑换服务
- var checkPas = function () {
- CommentService.checkPaymentPassword($scope.keyPsMoney).then(function (response) {
- if (response == 1) {
- CommentService.exchangeService(item).then(function (response) {
- //0 支付密码错误 1 兑换成功 2 普适币不足 3 支付密码成功,兑换失败
- // console.log(response);
- if (response == 1) {
- UtilService.showMess("兑换成功");
- } else if (response == 2) {
- notPsEnough();
- } else {
- UtilService.showMess("兑换失败,请重试");
- }
- $scope.keyPsMoney = "";
- $scope.hideLoadingToast();
- }, function () {
- $scope.keyPsMoney = "";
- $scope.hideLoadingToast();
- })
- } else {
- UtilService.showMess("支付密码错误,请重试");
- $scope.hideLoadingToast();
- }
- $scope.closePasModal();
- }, function () {
- $scope.closePasModal();
- $scope.hideLoadingToast();
- });
- };
- //账户余额不足
- var notPsEnough = function () {
- $ionicPopup.show({
- template: "<span style='display: block;width:90%;margin: 0 auto 10px;height: 55px;'>您的账号余额不足,无法兑换服务!</span>",
- title: "普适币账号余额不足",
- scope: $scope,
- buttons: [
- {
- text: "取消"
- },
- {
- text: '<span class="pop_right_button">确认</span>',
- type: "button-positive",
- onTap: function (e) {
- }
- }
- ]
- })
- };
- });
|