HomeService.js 1.2 KB
"use strict";
var homeService = angular.module('HomeService',[]);

homeService.service("HomeService", [
	'$rootScope',
	'BaseService',
	function ($rootScope,BaseService) {
		var _service = {
				onClickShopTypeId:undefined,
				userinfo:"",
				statistics:"",
				getCurrentUserInfo:function() {
					BaseService.request({
						url:BaseService.url.getCurrentUserInfo_url,
						method:'get',
						mark:true,
						fn:function(response) {
							if(response.code == 0) {
								_service.userinfo = response.data;
								$rootScope.$broadcast('user.info');
							}
						}
					});
				},
				getStatisticsInfo:function(){
					BaseService.request({
						url:BaseService.url.statistics_url,
						method:'get',
						mark:true,
						fn:function(response) {
							if(response.code == 0) {
								_service.statistics = response.data;
								$rootScope.$broadcast('statistics.info');
							}
						}
					});
				},
				getTreeMenu:function(callback) {
					BaseService.request({
						url:BaseService.url.getTreeMenu_url,
						method:'get',
						mark:true,
						fn:function(response) {
							if(response.code == 0) {
								callback.call(this,response);
							}
						}
					});
				}
		}
		return _service;
	}]);