|
|
define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootSwitch'], function (angular) {
|
|
|
'use strict';
|
|
|
|
|
|
var app = angular.module('customManagement', ['ui.bootstrap', 'ui.router', 'frapontillo.bootstrap-switch']);
|
|
|
app.config(['$stateProvider', function ($stateProvider) {
|
|
|
$stateProvider.state('custom', {
|
|
|
url: '/custom',
|
|
|
templateUrl: '/static/payment/custom/templates/custom.html',
|
|
|
controller: 'customCtrl'
|
|
|
})
|
|
|
}]);
|
|
|
app.controller('customCtrl', ['$scope', '$http', 'commonDialog','$filter','orderService', function ($scope, $http, commonDialog,$filter,orderService) {
|
|
|
$scope.pagination = {};
|
|
|
$scope.params = {};
|
|
|
$scope.new_bill = {};
|
|
|
$scope.minDate = new Date();
|
|
|
var maxDate = new Date();
|
|
|
$scope.maxDate = maxDate.setDate(maxDate.getDate() + 14);
|
|
|
|
|
|
|
|
|
$scope.loadBills = function (page) {
|
|
|
var params = angular.copy($scope.params);
|
|
|
params.page = page || $scope.pagination.page || 1;
|
|
|
$http.get('/partner/qrcode', {params: params}).then(function (resp) {
|
|
|
$scope.bills = resp.data;
|
|
|
$scope.pagination = resp.data.pagination;
|
|
|
});
|
|
|
};
|
|
|
$scope.loadBills(1);
|
|
|
$scope.generateBill = function () {
|
|
|
var params = angular.copy($scope.new_bill);
|
|
|
if(!params.client_order_id){
|
|
|
alert("client order id为空,是否后台自动生成?");
|
|
|
}
|
|
|
if(!params.order_amount){
|
|
|
alert("order amount不可为空!");
|
|
|
return;
|
|
|
}
|
|
|
if(params.cancle_time){
|
|
|
params.cancle_time = $filter('date')(params.cancle_time, 'yyyy-MM-dd HH:mm:ss')
|
|
|
}else {
|
|
|
alert("Expire Date 不可为空!");
|
|
|
}
|
|
|
$http.post('/partner/qrcode/bills',params).then(function (resp) {
|
|
|
commonDialog.alert({title: 'Success', content: 'Success', type: 'success'});
|
|
|
$scope.code_url = resp.data;
|
|
|
$scope.loadBills(1);
|
|
|
},function (resp) {
|
|
|
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
|
|
|
});
|
|
|
};
|
|
|
$scope.disableBill = function (bill) {
|
|
|
commonDialog.confirm(
|
|
|
{
|
|
|
title: 'Delete Bill',
|
|
|
content: 'Are you sure to delete this bill?'
|
|
|
}).then(function () {
|
|
|
$http.delete('/partner/qrcode/'+bill.bill_code_id).then(function(){
|
|
|
$scope.loadBills(1);
|
|
|
});
|
|
|
})
|
|
|
};
|
|
|
$scope.clearBill = function () {
|
|
|
$scope.new_bill = {};
|
|
|
$scope.code_url = "";
|
|
|
};
|
|
|
|
|
|
$scope.showTradeDetail = function (order) {
|
|
|
orderService.clientOrderDetail(order)
|
|
|
};
|
|
|
}]);
|
|
|
|
|
|
app.filter('billStatus', function () {
|
|
|
return function (status) {
|
|
|
switch (status + '') {
|
|
|
case '1':
|
|
|
return 'wait for payment';
|
|
|
case '2':
|
|
|
return 'disabled';
|
|
|
case '3':
|
|
|
return 'payment success'
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
app.filter('remarkCut', function () {
|
|
|
return function (value, wordwise, max, tail) {
|
|
|
if (!value) return '';
|
|
|
|
|
|
max = parseInt(max, 10);
|
|
|
if (!max) return value;
|
|
|
if (value.length <= max) return value;
|
|
|
|
|
|
value = value.substr(0, max);
|
|
|
if (wordwise) {
|
|
|
var lastspace = value.lastIndexOf(' ');
|
|
|
if (lastspace != -1) {
|
|
|
value = value.substr(0, lastspace);
|
|
|
}
|
|
|
}
|
|
|
return value + (tail || ' …');
|
|
|
};
|
|
|
});
|
|
|
|
|
|
|
|
|
return app;
|
|
|
}); |