This commit is contained in:
Daniel Camargo 2013-10-01 10:45:58 -03:00
parent 4e60bfd2f1
commit 10026ec807
3 changed files with 14 additions and 3 deletions

View File

@ -43,7 +43,7 @@ class Controller_api_referral extends Crunchbutton_Controller_Rest {
$invites = Crunchbutton_Referral::getInvitesPerCode( $invite_code );
$limit = Crunchbutton_Referral::getInvitesLimit();
$enabled = Crunchbutton_Referral::isReferralEnable();
$url = 'http://' . $_SERVER['HTTP_HOST'] . '/invite/' . $invite_code;
$url = 'http://' . $_SERVER['HTTP_HOST'] . '?invite=' . $invite_code;
$value = Crunchbutton_Referral::getInviterCreditValue();
echo json_encode(['invites' => intval( $invites ), 'limit' => intval( $limit ), 'invite_url' => $url, 'value' => intval( $value ), 'enabled' => $enabled ]);
} else {

View File

@ -181,7 +181,7 @@ NGApp.config(['$routeProvider', '$locationProvider', function($routeProvider, $l
}]);
// global route change items
NGApp.controller('AppController', function ($scope, $route, $routeParams, $rootScope, $location, $window, AccountService, MainNavigationService, AccountSignOut, CartService) {
NGApp.controller('AppController', function ($scope, $route, $routeParams, $rootScope, $location, $window, AccountService, MainNavigationService, AccountSignOut, CartService, ReferralService) {
// define external pointers
App.rootScope = $rootScope;
@ -327,6 +327,8 @@ NGApp.controller('AppController', function ($scope, $route, $routeParams, $rootS
AccountService.checkUser();
ReferralService.check();
});
App.alert = function(txt, title) {

View File

@ -1,8 +1,17 @@
// ReferralService service
NGApp.factory( 'ReferralService', function( $http, $rootScope ){
NGApp.factory( 'ReferralService', function( $http, $rootScope, $location ){
var service = { invite_url : null, value : 0, invites : 0, limit : 0 };
service.check = function(){
var param = $location.search();
if( param.invite ){
$.cookie( 'referral', param.invite );
// Remove the invite from url
$location.url( $location.path() );
}
}
service.getInviteCode = function(){
var url = App.service + 'referral/code';
$http( {