|
|
@@ -120,10 +120,15 @@ define(['app/app'], function(app) {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- $scope.condition = {
|
|
|
- startDateOpen: false,
|
|
|
- endDateOpen: false
|
|
|
+ $scope.condition = [];
|
|
|
+ var start = {
|
|
|
+ open : false
|
|
|
};
|
|
|
+ var end = {
|
|
|
+ open : false
|
|
|
+ };
|
|
|
+ $scope.condition.push(start);
|
|
|
+ $scope.condition.push(end);
|
|
|
|
|
|
// 打开日期选择框
|
|
|
$scope.openDatePicker = function($event, item, openParam, status) {
|
|
|
@@ -141,7 +146,81 @@ define(['app/app'], function(app) {
|
|
|
}
|
|
|
$event.preventDefault();
|
|
|
$event.stopPropagation();
|
|
|
- item[openParam] = !item[openParam];
|
|
|
+ openParam == 0 ? $scope.condition[1].open = false : $scope.condition[0].open = false;
|
|
|
+ item[openParam].open = !item[openParam].open;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.onDateCondition = function (bool) {
|
|
|
+ var text = '';
|
|
|
+ var datePattern = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
|
+ if (bool == 1){
|
|
|
+ text = document.getElementById("start").value;
|
|
|
+ if (text != '' && !datePattern.test(text)){
|
|
|
+ // $scope.startDate = text;
|
|
|
+ toaster.pop("info", "请输入正确开始时间格式");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (text != '' && !validateDate(text)){
|
|
|
+ // $scope.startDate = text;
|
|
|
+ toaster.pop("info", "请输入正确开始时间格式");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!$scope.startDate && text != ''){
|
|
|
+ $scope.startDate = convertTextToDate(text);
|
|
|
+ }
|
|
|
+ if ($scope.startDate && !$scope.endDate){
|
|
|
+ var nowTime = new Date();
|
|
|
+ $scope.endDate = new Date(nowTime.getFullYear(), nowTime.getMonth(), nowTime.getDate());
|
|
|
+ }
|
|
|
+ if ($scope.endDate && $scope.startDate.getTime() > $scope.endDate.getTime()){
|
|
|
+ $scope.endDate = new Date($scope.startDate.getTime() + 86400000);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ text = document.getElementById("end").value;
|
|
|
+ if (text != '' && !datePattern.test(text)){
|
|
|
+ // $scope.endDate = text;
|
|
|
+ toaster.pop("info", "请输入正确结束时间格式");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!validateDate(text)){
|
|
|
+ // $scope.endDate = text;
|
|
|
+ toaster.pop("info", "请输入正确结束时间格式");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!$scope.endDate && text != ''){
|
|
|
+ $scope.endDate = convertTextToDate(text);
|
|
|
+ }
|
|
|
+ if ($scope.startDate && $scope.startDate.getTime() > $scope.endDate.getTime()){
|
|
|
+ $scope.startDate = new Date($scope.endDate.getTime() - 86400000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将文本转化为日期
|
|
|
+ * @param value
|
|
|
+ * @returns {Date}
|
|
|
+ */
|
|
|
+ var convertTextToDate = function (value) {
|
|
|
+ var date = value;
|
|
|
+ var result = date.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
|
|
|
+
|
|
|
+ return new Date(result[1], result[3] - 1, result[4]);
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证日期格式是否正确
|
|
|
+ * @param value
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
+ var validateDate = function (value) {
|
|
|
+ var date = value;
|
|
|
+ var result = date.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
|
|
|
+
|
|
|
+ if (result == null)
|
|
|
+ return false;
|
|
|
+ var d = new Date(result[1], result[3] - 1, result[4]);
|
|
|
+ return (d.getFullYear() == result[1] && (d.getMonth() + 1) == result[3] && d.getDate() == result[4]);
|
|
|
};
|
|
|
|
|
|
var loadAccountData = function() {
|
|
|
@@ -503,7 +582,7 @@ define(['app/app'], function(app) {
|
|
|
};
|
|
|
|
|
|
$rootScope.$on('$stateChangeStart',function(event,toState,toParams,fromState,fromParams){
|
|
|
- if(fromState.name == 'pay_center'){
|
|
|
+ if(fromState.name == 'pay_center' || toState.name == 'pay_center'){
|
|
|
SessionService.removeCookie("buyCenter");
|
|
|
}
|
|
|
});
|