Explorar el Código

处理修改订单确认界面调用配送规则信息报错的问题。

yujia hace 8 años
padre
commit
b2efd2e102

+ 13 - 3
src/main/webapp/resources/js/usercenter/controllers/forstore/order_pay_ctrl.js

@@ -332,7 +332,7 @@ define(['app/app'], function(app) {
 			$scope.calculateTotal();
 			updateStoreArray(detail);
 			$q.all([updateFare($scope.ruleMap[detail.storeid], $scope.storePrice[detail.storeName]).$promise]).then(function (data) {
-				if (data){
+				if (data && data.length > 0 && data[0]){
 					var id = $scope.deliveryList[detail.storeid].id;
 					var arr = data[0];
 					$scope.ruleMap[detail.storeid] = arr;
@@ -343,6 +343,8 @@ define(['app/app'], function(app) {
 						}
 					});
 					$scope.calculateFare();
+				}else {
+					$scope.calculateFare();
 				}
 			});
 		};
@@ -362,7 +364,7 @@ define(['app/app'], function(app) {
 			$scope.calculateTotal();
 			updateStoreArray(detail);
 			$q.all([updateFare($scope.ruleMap[detail.storeid], $scope.storePrice[detail.storeName]).$promise]).then(function (data) {
-				if (data){
+				if (data && data.length > 0 && data[0]){
 					var id = $scope.deliveryList[detail.storeid].id;
 					var arr = data[0];
 					$scope.ruleMap[detail.storeid] = arr;
@@ -373,6 +375,8 @@ define(['app/app'], function(app) {
 						}
 					});
 					$scope.calculateFare();
+				}else {
+					$scope.calculateFare();
 				}
 			});
 
@@ -396,6 +400,10 @@ define(['app/app'], function(app) {
 		 * @returns {*|{url, method, isArray}}
 		 */
 		var updateFare = function (ruleList, price) {
+			if(ruleList == null || ruleList.length < 1) {
+				toaster.pop('warning', '提示', "配送规则缺失,请联系卖家设置相应的配送规则");
+				return 0;
+			}
 			return DistributionRule.findFareOfRule({price:price}, ruleList, function (data) {
 				if (data){
 
@@ -435,7 +443,7 @@ define(['app/app'], function(app) {
 			$scope.calculateTotal();
 			updateStoreArray(detail);
 			$q.all([updateFare($scope.ruleMap[detail.storeid], $scope.storePrice[detail.storeName]).$promise]).then(function (data) {
-				if (data){
+				if (data && data.length > 0 && data[0]){
 					var id = $scope.deliveryList[detail.storeid].id;
 					var arr = data[0];
 					$scope.ruleMap[detail.storeid] = arr;
@@ -446,6 +454,8 @@ define(['app/app'], function(app) {
 						}
 					});
 					$scope.calculateFare();
+				}else {
+					$scope.calculateFare();
 				}
 			});
 		};