|
|
@@ -631,53 +631,58 @@ define([ 'angularAMD', 'ngLocal', 'common/services', 'common/directives', 'commo
|
|
|
$rootScope.rootPath = BaseService.getRootPath();
|
|
|
$rootScope.page = 'vendor';// 导航栏状态,'个人中心'状态激活
|
|
|
|
|
|
- $rootScope.$on('$stateChangeStart', function (event, toState) {
|
|
|
+ var getToStateName = function () {
|
|
|
+ if ($rootScope.store && (!$rootScope.store.status || $rootScope.store.status === 'OPENED')) {
|
|
|
+ return 'vendor_store_maintain';
|
|
|
+ } else if ($rootScope.store && $rootScope.store.status && $rootScope.store.status !== 'OPENED') {
|
|
|
+ return 'vendor_store_close';
|
|
|
+ } else if ($rootScope.applyStatus === 'NONE') {
|
|
|
+ return 'vendor_store_apply';
|
|
|
+ } else if ($rootScope.applyStatus === 'PREPARE') {
|
|
|
+ return 'vendor_store_wait';
|
|
|
+ } else if ($rootScope.applyStatus === 'PASS') {
|
|
|
+ return 'vendor_store_info';
|
|
|
+ } else {
|
|
|
+ return 'vendor_index';
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
- var getToStateName = function () {
|
|
|
- if ($rootScope.store && (!$rootScope.store.status || $rootScope.store.status === 'OPENED')) {
|
|
|
- return 'vendor_store_maintain';
|
|
|
- } else if ($rootScope.store && $rootScope.store.status && $rootScope.store.status !== 'OPENED') {
|
|
|
- return 'vendor_store_close';
|
|
|
- } else if ($rootScope.applyStatus === 'NONE') {
|
|
|
- return 'vendor_store_apply';
|
|
|
- } else if ($rootScope.applyStatus === 'PREPARE') {
|
|
|
- return 'vendor_store_wait';
|
|
|
- } else if ($rootScope.applyStatus === 'PASS') {
|
|
|
- return 'vendor_store_info';
|
|
|
- } else {
|
|
|
- return 'vendor_index';
|
|
|
- }
|
|
|
- };
|
|
|
+ // 创建店铺的Promise对象
|
|
|
+ var deferred = $q.defer();
|
|
|
+ StoreInfo.existStore({}, {}, function (store) {
|
|
|
+ deferred.resolve(store);
|
|
|
+ }, function (error) {
|
|
|
+ deferred.reject(error);
|
|
|
+ });
|
|
|
+ var storePromise = deferred.promise;
|
|
|
+ $rootScope.storePromise = storePromise;
|
|
|
|
|
|
- // 创建店铺的Promise对象
|
|
|
- var deferred = $q.defer();
|
|
|
- StoreInfo.existStore({}, {}, function (store) {
|
|
|
- deferred.resolve(store);
|
|
|
- }, function (error) {
|
|
|
- deferred.reject(error);
|
|
|
- });
|
|
|
- var storePromise = deferred.promise;
|
|
|
- $rootScope.storePromise = storePromise;
|
|
|
+ // 创建开店申请的Promise对象
|
|
|
+ var deferred1 = $q.defer();
|
|
|
+ StoreInfo.findShopOwnerApplyByNormalStatus({}, {}, function (result) {
|
|
|
+ deferred1.resolve(result);
|
|
|
+ }, function (error) {
|
|
|
+ deferred1.reject(error);
|
|
|
+ });
|
|
|
+ var applyPromise = deferred1.promise;
|
|
|
|
|
|
- // 创建开店申请的Promise对象
|
|
|
- var deferred1 = $q.defer();
|
|
|
- StoreInfo.findShopOwnerApplyByNormalStatus({}, {}, function (result) {
|
|
|
- deferred1.resolve(result);
|
|
|
- }, function (error) {
|
|
|
- deferred1.reject(error);
|
|
|
- });
|
|
|
- var applyPromise = deferred1.promise;
|
|
|
+ // 合并多个Promise对象
|
|
|
+ $q.all([storePromise, applyPromise]).then(function (result) {
|
|
|
+ $rootScope.store = result[0] && result[0].uuid ? result[0] : null;
|
|
|
+ $rootScope.applyInfo = null;
|
|
|
+ if (result[1] && result[1].success) {
|
|
|
+ $rootScope.applyInfo = result[1].data;
|
|
|
+ $rootScope.applyStatus = result[1].data ? result[1].data.status : 'NONE';
|
|
|
+ } else {
|
|
|
+ $rootScope.applyStatus = 'NONE';
|
|
|
+ }
|
|
|
|
|
|
- // 合并多个Promise对象
|
|
|
- $q.all([storePromise, applyPromise]).then(function (result) {
|
|
|
- $rootScope.store = result[0] && result[0].uuid ? result[0] : null;
|
|
|
- $rootScope.applyInfo = null;
|
|
|
- if (result[1] && result[1].success) {
|
|
|
- $rootScope.applyInfo = result[1].data;
|
|
|
- $rootScope.applyStatus = result[1].data ? result[1].data.status : 'NONE';
|
|
|
- } else {
|
|
|
- $rootScope.applyStatus = 'NONE';
|
|
|
- }
|
|
|
+
|
|
|
+ if ($rootScope.applyStatus === 'NONE') {
|
|
|
+ $state.go('vendor_store_apply');
|
|
|
+ }
|
|
|
+
|
|
|
+ $rootScope.$on('$stateChangeStart', function (event, toState) {
|
|
|
|
|
|
if (toState.name === 'vendor_store_apply' && $rootScope.applyStatus !== 'NONE') {
|
|
|
event.preventDefault();
|
|
|
@@ -714,14 +719,15 @@ define([ 'angularAMD', 'ngLocal', 'common/services', 'common/directives', 'commo
|
|
|
return ;
|
|
|
}
|
|
|
console.log('route', toState.name);
|
|
|
- })['catch'](function () {
|
|
|
- $rootScope.store = null;
|
|
|
- $rootScope.applyInfo = null;
|
|
|
- $rootScope.applyStatus = 'NONE';
|
|
|
- event.preventDefault();
|
|
|
- console.log('route', toState.name, 'vendor_index');
|
|
|
- $state.go('vendor_index');
|
|
|
+
|
|
|
});
|
|
|
+
|
|
|
+ })['catch'](function () {
|
|
|
+ $rootScope.store = null;
|
|
|
+ $rootScope.applyInfo = null;
|
|
|
+ $rootScope.applyStatus = 'NONE';
|
|
|
+ event.preventDefault();
|
|
|
+ $state.go('vendor_index');
|
|
|
});
|
|
|
}]);
|
|
|
|