(function (app) {
    app.config(["$stateProvider", "$urlRouterProvider", function ($stateProvider, $urlRouterProvider) {
        $stateProvider
          .state('login', {
              url: '/account/login',
              cache:"false",
              templateUrl: 'templates/account/login.html',
              controller: 'wechatLoginCtrl'
          })
            .state('loginAccount', {
                url: '/account/loginAccount',
                params:{wechat:null},
                templateUrl: 'templates/account/loginAccount.html',
                controller: 'loginCtrl'
            })
          .state('app', {
              url: '/app',
              abstract: true,
              templateUrl: "templates/tabs.html",
              controller: 'tabsCtrl'
          })
            .state('app.home', {
                url: '/home',
                //cache:false,
                views: {
                    'app-home': {
                        templateUrl: 'templates/home/index.html',
                        controller: 'homeCtrl'
                    }
                }
            })
            .state('app.my_dreamdetail', {
                url: '/my/dreamdetail?id=',
                params:{id:null},
                views: {
                    'app-my': {
                        templateUrl: 'templates/home/dream-detail.html',
                        controller: 'dreamDetailCtrl'
                    }
                }
            })
            .state('app.home_dreamdetail', {
                url: '/home/dreamdetail?id=',
                params:{id:null,dream_user_id:null,type:null},
                views: {
                    'app-home': {
                        templateUrl: 'templates/home/dream-detail.html',
                        controller: 'dreamDetailCtrl'
                    }
                }
            })
            .state('app.home_userDetail', {
                url: '/home/userDetail',
                params:{
                    id:null,
                    items:null
                },
                views: {
                    'app-home': {
                        templateUrl: 'templates/home/userDetail.html',
                        controller: 'userDetailCtrl'
                    }
                }
            })
            .state('app.attention_Detail', {
                url: '/my/attention/userDetail',
                params:{
                    id:null,
                    items:null
                },
                views: {
                    'app-my': {
                        templateUrl: 'templates/home/userDetail.html',
                        controller: 'userDetailCtrl'
                    }
                }
            })
            .state('app.oldDream', {
                url: '/home/oldDream',
                params:{user_id:null},
                views: {
                    'app-home': {
                        templateUrl: 'templates/home/oldDream.html',
                        controller: 'oldDreamCtrl'
                    }
                }
            })
            .state('app.myOldDream', {
                url: '/my/oldDream',
                params:{user_id:null},
                views: {
                    'app-my': {
                        templateUrl: 'templates/home/oldDream.html',
                        controller: 'myOldDreamCtrl'
                    }
                }
            })
            .state('app.supportDream', {
                url: '/home/supportDream',
                params:{
                    user_id:null
                },
                views: {
                    'app-home': {
                        templateUrl: 'templates/home/supportDream.html',
                        controller: 'supportDreamCtrl'
                    }
                }
            })
            .state('app.mySupportDream', {
                url: '/my/supportDream',
                params:{
                    user_id:null
                },
                views: {
                    'app-my': {
                        templateUrl: 'templates/home/supportDream.html',
                        controller: 'mySupportDreamCtrl'
                    }
                }
            })
            .state('app.home_search', {
                url: '/home/search',
                views: {
                    'app-home': {
                        templateUrl: 'templates/home/search.html',
                        controller: 'searchCtrl'
                    }
                }
            })
        .state('app.home_collect', {
            url: '/home/collect',
            views: {
                'app-home': {
                    templateUrl: 'templates/my/my-collect.html',
                    controller: 'homeCollectCtrl'
                }
            }
        })
           .state('app.home_add', {
               url: '/home/add',
               views: {
                   'app-home': {
                       templateUrl: 'templates/add/index.html',
                       controller: 'addCtrl'
                   }
               }
           })
           .state('app.add', {
               url: '/add',
               views: {
                   'app-add': {
                       templateUrl: 'templates/add/index.html',
                       controller: 'addCtrl'
                   }
               }
           })
            .state('app.addExplain', {
                url: '/home/add/explain',
                views: {
                    'app-home': {
                        templateUrl: 'templates/add/addExplain.html',
                        controller: 'addExplainCtrl'
                    }
                }
            })
        .state('app.my', {
            url: '/my',
            views: {
                'app-my': {
                    templateUrl: 'templates/my/index.html',
                    controller: 'myCtrl'
                }
            }
        })
           .state('app.my_add', {
               url: '/my/add',
               cache:"false",
               views: {
                   'app-my': {
                       templateUrl: 'templates/add/index.html',
                       controller: 'addCtrl'
                   }
               }
           })
          .state('app.my_profile', {
              url: '/my/profile',
              views: {
                  'app-my': {
                      templateUrl: 'templates/my/my-profile.html',
                      controller: 'profileCtrl'
                  }
              }
          })
        .state('app.my_collect', {
            url: '/my/collect',
            views: {
                'app-my': {
                    templateUrl: 'templates/my/my-collect.html',
                    controller: 'collectCtrl'
                }
            }
        })
            .state('app.attention', {
                url: '/my/attention',
                views: {
                    'app-my': {
                        templateUrl: 'templates/my/attention.html',
                        controller: 'attentionCtrl'
                    }
                }
            })
        .state('app.my_dream', {
            url: '/my/dream',
            views: {
                'app-my': {
                    templateUrl: 'templates/my/my-dream.html',
                    controller: 'dreamCtrl'
                }
            }
        })
        .state('app.my_message', {
            url: '/my/message',
            views: {
                'app-my': {
                    templateUrl: 'templates/my/my-message.html',
                    controller: 'messageCtrl'
                }
            }
        })
            .state('app.my_account', {
                url: '/my/account',
                views: {
                    'app-my': {
                        templateUrl: 'templates/my/my-account.html',
                        controller: 'accountCtrl'
                    }
                }
            })
            .state('app.my_account_add', {
                url: '/my/account/add',
                views: {
                    'app-my': {
                        templateUrl: 'templates/my/my-account-add.html',
                        controller: 'my_account_addCtrl'
                    }
                }
            })
            .state('app.message', {
                url: '/home/message',
                views: {
                    'app-home': {
                        templateUrl: 'templates/my/my-message.html',
                        controller: 'homeMessageCtrl'
                    }
                }
            })
            .state('app.dream_message', {
                url: '/my/message',
                views: {
                    'app-my': {
                        templateUrl: 'templates/my/my-message.html',
                        controller: 'messageCtrl'
                    }
                }
            })
        .state('app.my_message_sys', {
                url: '/my/message/sys',
                views: {
                    'app-my': {
                        templateUrl: 'templates/my/my-message-sys.html',
                        controller: 'messageSysCtrl'
                    }
                }
        })
            .state('app.message_sys', {
                url: '/home/message/sys',
                views: {
                    'app-home': {
                        templateUrl: 'templates/my/my-message-sys.html',
                        controller: 'messageSysCtrl'
                    }
                }
            })
        .state('app.my_message_reply', {
            url: '/my/message/reply',
            views: {
                'app-my': {
                    templateUrl: 'templates/my/my-message-reply.html',
                    controller: 'messageReplyCtrl'
                }
            }
        })
            .state('app.message_reply', {
                url: '/home/message/reply',
                views: {
                    'app-home': {
                        templateUrl: 'templates/my/my-message-reply.html',
                        controller: 'messageReplyCtrl'
                    }
                }
            })

            .state('app.personalLetter', {
                url: '/my/message/personalLetter',
                views: {
                    'app-my': {
                        templateUrl: 'templates/my/personalLetter.html',
                        controller: 'personalLetterCtrl'
                    }
                }
            })
            .state('app.letter', {
                url: '/home/message/letter',
                views: {
                    'app-home': {
                        templateUrl: 'templates/my/personalLetter.html',
                        controller: 'personalLetterCtrl'
                    }
                }
            })
        .state('app.my_recharge', {
            url: '/my/recharge',
            views: {
                'app-my': {
                    templateUrl: 'templates/my/my-recharge.html',
                    controller: 'rechargeCtrl'
                }
            }
        })
            .state('app.recharge', {
                url: '/home/recharge',
                views: {
                    'app-home': {
                        templateUrl: 'templates/my/my-recharge.html',
                        controller: 'payCtrl'
                    }
                }
            })
        .state('app.my_setting', {
            url: '/my/setting',
            views: {
                'app-my': {
                    templateUrl: 'templates/my/my-setting.html',
                    controller: 'settingCtrl'
                }
            }
        })
            .state('app.aboutMiao', {
                url: '/my/aboutMiao',
                views: {
                    'app-my': {
                        templateUrl: 'templates/my/aboutMiao.html',
                        controller: 'aboutMiaoCtrl'
                    }
                }
            })
            .state('app.payExplain', {
                url: '/my/payExplain',
                views: {
                    'app-my': {
                        templateUrl: 'templates/my/payExplain.html',
                        controller: 'payExplainCtrl'
                    }
                }
            })
            .state('app.explain', {
                url: '/home/explain',
                views: {
                    'app-home': {
                        templateUrl: 'templates/my/payExplain.html',
                        controller: 'explainCtrl'
                    }
                }
            })
            .state('app.withdraw', {
                url: '/my/withdraw',
                views: {
                    'app-my': {
                        templateUrl: 'templates/my/withdraw.html',
                        controller: 'withdrawCtrl'
                    }
                }
            })
            .state('app.payout', {
                url: '/home/payout',
                views: {
                    'app-home': {
                        templateUrl: 'templates/my/withdraw.html',
                        controller: 'payoutCtrl'
                    }
                }
            })
            .state('app.contact', {
                url: '/my/contact',
                views: {
                    'app-my': {
                        templateUrl: 'templates/my/contact.html',
                        controller: 'contactCtrl'
                    }
                }
            })
            .state('app.shareDream', {
                url: '/home/shareDream',
                params:{
                  item:null
                },
                views: {
                    'app-home': {
                        templateUrl: 'templates/home/shareDream.html',
                        controller: 'shareDreamCtrl'
                    }
                }
            })
            .state('app.my_shareDream', {
                url: '/my/attention/shareDream',
                params:{
                    item:null
                },
                views: {
                    'app-my': {
                        templateUrl: 'templates/home/shareDream.html',
                        controller: 'shareDreamCtrl'
                    }
                }
            });
        if (localStorage['token']) {
            $urlRouterProvider.otherwise('/app/home');
        } else {
            $urlRouterProvider.otherwise('/account/login');
        }
    }]);
})(angular.module('app'));