Skip to content

Commit

Permalink
WA代码:代码整理
Browse files Browse the repository at this point in the history
  • Loading branch information
amio committed Mar 24, 2014
1 parent f84fd50 commit 893c284
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 103 deletions.
124 changes: 62 additions & 62 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,83 +61,83 @@ angular.module('toHELL', [
: 'http://wxddb1.qa.nt.ctripcorp.com/tohell/',
errDesc: {
// 用户登陆接口 /login/
1001: "请求方式错误",
1002: "用户名或密码不正确",
1003: "邮箱为空",
1004: "密码为空",
1001: '请求方式错误',
1002: '用户名或密码不正确',
1003: '邮箱为空',
1004: '密码为空',
// 用户注册接口 /register/
2001: "请求方式错误",
2002: "用户已存在",
2003: "服务器内部错误",
2004: "用户名为空",
2005: "密码为空",
2006: "邮箱格式错误",
2001: '请求方式错误',
2002: '用户已存在',
2003: '服务器内部错误',
2004: '用户名为空',
2005: '密码为空',
2006: '邮箱格式错误',
// 修改密码接口 //
3001: "请求方式错误",
3002: "Token无效需要重新登录",
3003: "密码为空",
3004: "旧密码错误",
3005: "服务器内部错误",
3001: '请求方式错误',
3002: 'Token无效需要重新登录',
3003: '密码为空',
3004: '旧密码错误',
3005: '服务器内部错误',
// 获取用户信息接口 /usrinfo/
4001: "token为空",
4002: "token无效",
4003: "服务器内部错误",
4001: 'token为空',
4002: 'token无效',
4003: '服务器内部错误',
// 更新用户信息接口 /updateuser/
5001: "token为空",
5002: "token无效",
5003: "服务器内部错误",
5001: 'token为空',
5002: 'token无效',
5003: '服务器内部错误',
// 创建工程接口 /createProject/
6001: "请求方式错误",
6002: "token无效",
6003: "服务器内部错误",
6001: '请求方式错误',
6002: 'token无效',
6003: '服务器内部错误',
// 删除工程接口 /deleteProject/
7001: "请求方式错误",
7002: "token为空",
7003: "appid为空",
7004: "token无效",
7005: "服务器内部错误",
7001: '请求方式错误',
7002: 'token为空',
7003: 'appid为空',
7004: 'token无效',
7005: '服务器内部错误',
// 保存工程接口 //
8001: "请求方式错误",
8002: "用户名为空",
8003: "用户名不存在",
8001: '请求方式错误',
8002: '用户名为空',
8003: '用户名不存在',
// 获取工程接口 //
9001: "请求方式错误",
9002: "token无效",
9003: "服务器内部异常",
9001: '请求方式错误',
9002: 'token无效',
9003: '服务器内部异常',
// 获取工程列表接口
10001: "token为空",
10002: "token认证失败",
10003: "服务器内部错误",
10001: 'token为空',
10002: 'token认证失败',
10003: '服务器内部错误',
// 分享工程接口 /share/
11001: "分享工程接口:请求方式错误",
11002: "分享工程接口:token为空或appid为空或user为空或option为空",
11003: "分享工程接口:token失效",
11004: "分享工程接口:分享的用户不存在",
11005: "分享工程接口:已经分享过了",
11006: "分享工程接口:未知操作(option为非12)",
11001: '分享工程接口:请求方式错误',
11002: '分享工程接口:token为空或appid为空或user为空或option为空',
11003: '分享工程接口:token失效',
11004: '分享工程接口:分享的用户不存在',
11005: '分享工程接口:已经分享过了',
11006: '分享工程接口:未知操作(option为非12)',
// 获取分享用户列表
12001: "请求方式错误",
12002: "token为空",
12003: "token失效",
12001: '请求方式错误',
12002: 'token为空',
12003: 'token失效',
// 意见反馈
13001: "请求方式错误",
13002: "邮箱为空",
13003: "反馈内容为空",
13004: "反馈来源为空",
13005: "服务器内部错误",
13001: '请求方式错误',
13002: '邮箱为空',
13003: '反馈内容为空',
13004: '反馈来源为空',
13005: '服务器内部错误',
// iOS 注册推送token
14001: "请求方式错误",
14002: "token为空",
14003: "服务器内部错误",
14001: '请求方式错误',
14002: 'token为空',
14003: '服务器内部错误',
// 生成ZIP包
15001: "请求方式错误",
15002: "服务器IO操作错误",
15003: "Lua解析错误",
15004: "Lua解析异常",
15005: "token失效",
15001: '请求方式错误',
15002: '服务器IO操作错误',
15003: 'Lua解析错误',
15004: 'Lua解析异常',
15005: 'token失效',
// 上传图片接口
0: "上传失败",
1: "上传成功"
0: '上传失败',
1: '上传成功'
},
errLogger: function (data, status, headers, config) {
console.log('Status:', status, '\nData :', data, '\nConfig:', config);
Expand Down
18 changes: 9 additions & 9 deletions app/scripts/controllers/package-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ angular.module('toHELL')
} else {
token = loginService.getLoggedInUser().token;
}

$scope.fileRoot = GLOBAL.pkgHost + '/' + $routeParams.pkgId + '/';

/**
Expand Down Expand Up @@ -82,8 +82,8 @@ angular.module('toHELL')
$scope.onActorItemClick = function (element) {
editService.selectElement(element);
};
function uploadDataFormater(args){

function uploadDataFormater(args) {
args.url = GLOBAL.apiHost + 'uploadImage/';
args.transformRequest = formDataObject;
args.data = {
Expand All @@ -92,20 +92,20 @@ angular.module('toHELL')
};
return args;
}

$scope.iconUploadHandlers = {
before: uploadDataFormater,
after: function(data){
if(data.status === '1'){
after: function (data) {
if (data.status === '1') {
$scope.package.icon = data.fileName;
}
}
};

$scope.sceneBgUploadHandlers = {
before: uploadDataFormater,
after: function(data){
if(data.status == '1'){
after: function (data) {
if (data.status === '1') {
$scope.editStat.selectedScene.background = $scope.fileRoot + data.fileName;
}
}
Expand Down
8 changes: 4 additions & 4 deletions app/scripts/controllers/register.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

angular.module('toHELL')
.controller('RegisterCTRL', ['$scope', '$location', '$http', 'GLOBAL', 'loginService',
function ($scope, $location, $http, GLOBAL, loginService) {
.controller('RegisterCTRL', ['$scope', '$location', '$http', 'GLOBAL', 'loginService', 'notifyService',
function ($scope, $location, $http, GLOBAL, loginService, notifyService) {
$scope.doSignup = function () {

// 将密码做 MD5 转换
Expand All @@ -24,11 +24,11 @@ angular.module('toHELL')
break;
default:
var errDesc = GLOBAL.errDesc[res.error_code] || '未知错误';
alert(errDesc);
notifyService.error(errDesc);
console.log('Signup Error: ', errDesc, res);
}
})
.error(GLOBAL.errLogger);
}
};
}
]);
4 changes: 3 additions & 1 deletion app/scripts/directives/navbar.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

angular.module('toHELL')

/**
Expand Down Expand Up @@ -52,5 +54,5 @@ angular.module('toHELL')
$rootScope.$broadcast('package.save');
};
}
}
};
}]);
10 changes: 6 additions & 4 deletions app/scripts/directives/uploader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

angular.module('toHELL')
.directive('uploader', ['$http', 'GLOBAL', 'formDataObject', function ($http, GLOBAL, formDataObject) {
.directive('uploader', ['$http', 'GLOBAL', 'formDataObject', function ($http, GLOBAL) {
return {
restrict: 'A',
link: function (scope, el, attrs) {
Expand All @@ -8,14 +10,14 @@ angular.module('toHELL')
el.bind('change', function (ev) {

// handlers 对象包含两个方法:可选 before(postArgs), 必选 after(response)
var handlers = scope[attrs['handlers']];
var handlers = scope[attrs.handlers];

if (handlers) {

// 创建 POST 参数对象
var postArgs = {
method: 'POST',
url: attrs['url'] || '',
url: attrs.url || '',
headers: {
'Content-Type': 'multipart/form-data'
},
Expand All @@ -25,7 +27,7 @@ angular.module('toHELL')
};

// handlers.before() 应该返回经过整理的 postArgs.
if(handlers.before){
if (handlers.before) {
postArgs = handlers.before(postArgs);
}

Expand Down
39 changes: 19 additions & 20 deletions app/scripts/services/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,24 @@ angular.module('toHELL').factory('loginService', [ '$http', 'GLOBAL', '$location

// Login
$http.post(GLOBAL.apiHost + 'login/', account)
.success(function (res) {
switch (res.status) {

case '1':
// Success
loggedInUser = res.result;
localStorage.setItem('loggedInUser', JSON.stringify(loggedInUser));
callback && callback(res.result);
break;

default:
// Else
var errDesc = GLOBAL.errDesc[res.error_code] || '未知错误';
alert(errDesc);
console.log('Login Error: ', errDesc, res);
errCallback && errCallback(res);
}
})
.error(GLOBAL.errLogger);
.success(function (res) {
switch (res.status) {

case '1':
// Success
loggedInUser = res.result;
localStorage.setItem('loggedInUser', JSON.stringify(loggedInUser));
callback && callback(res.result);
break;

default:
// Else
var errDesc = GLOBAL.errDesc[res.error_code] || '未知错误';
console.log('Login Error: ', errDesc, res);
errCallback && errCallback(res);
}
})
.error(GLOBAL.errLogger);
},

doLogout: function (callback) {
Expand All @@ -49,5 +48,5 @@ angular.module('toHELL').factory('loginService', [ '$http', 'GLOBAL', '$location
$location.path('/');
callback && callback();
}
}
};
}]);
2 changes: 1 addition & 1 deletion app/scripts/services/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ angular.module('toHELL')
controller: 'DialogShareCtrl',
controllerAs: 'modal',
templateUrl: 'partials/dialog-share.html'
})
});
}])
.controller('DialogShareCtrl', [
'dialogShare',
Expand Down
7 changes: 5 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ gulp.task('server:dist', ['build'], function () {
* =====================================
*/

gulp.task('lint', function(){
return gulp.src(SOURCE_ROOT + '/scripts/**/*.js')
gulp.task('lint', function () {
return gulp.src([
SOURCE_ROOT + '/scripts/**/*.js',
'!' + SOURCE_ROOT + '/scripts/libs/**/*.js'
])
.pipe($.jshint('.jshintrc'))
.pipe($.jshint.reporter('jshint-stylish'))
.pipe($.size());
Expand Down

0 comments on commit 893c284

Please sign in to comment.