1. Talking
One day, the class monitor said that the students wanted me to develop a address book that could share the location, so they simply designed the function themselves. Including user roles, posting on Weibo, sharing locations, etc. This time I was a bit selfish. In order to exercise my recently watched angularjs, I decisively chose the Node.js + MongoDB + angular.js solution. Of course, the experience of developing Node.js is becoming more and more profound. Remember, last year the leader told me that I should try to make each service of node support only one business function, so that it can be more convenient to maintain. At that time, I really wanted to make a Node service very powerful. Now it seems that the leader's approach is correct, and I prefer to single out the node service functions...
2. Directly upload the dry goods
The database service is deployed on Alibaba Cloud; the static file server uses Github page.
Github project address: https://github.com/vczero/OurTimes
Online experience address: http://vczero.github.io/tuban/main.html#/
I don't have a picture to say a ball, let me show you two screenshots:
(1) Home Page
(2) Address Book
......More experience online...
III. Project
Total project: https://github.com/vczero/OurTimes
Developed the required services: https://github.com/vczero/OurTimes/tree/master/server
Open the web pc client: https://github.com/vczero/OurTimes/tree/master/client-web
A simple backend management system has been developed: https://github.com/vczero/OurTimes/tree/master/client-admin
Everyone is welcome to fork, follow and share code to work together to build the front-end.
4. Attach the entry file code of the web-pc terminal Angular
The code copy is as follows:
var app = angular.module('app', ['ui.router', 'ngCookies']);
var SERVER_BASE_URL = 'http://127.0.0.1:3000/';
//Initialize the configuration
app.run(['$rootScope', function($rootScope) {
$rootScope.appName = 'Tuban.com';
$rootScope.desc = 'location-based address book';
$rootScope.author = 'Ghost Rumor';
$rootScope._email = '[email protected]';
}]);
//Checked service list
app.constant('ServiceConfig', {
wei_content: SERVER_BASE_URL + 'wei/get',
wei_zan: SERVER_BASE_URL + 'wei/zan',
wei_comment: SERVER_BASE_URL + 'wei/comment',
wei_create: SERVER_BASE_URL + 'wei/create',
user_get: SERVER_BASE_URL + 'user/get',
user_login: SERVER_BASE_URL + 'user/login',
user_register: SERVER_BASE_URL + 'user/register',
user_common: SERVER_BASE_URL + 'user/getCommon',
user_ben: SERVER_BASE_URL + 'user/getBen',
user_self: SERVER_BASE_URL + 'user/getSelf',
user_common_update: SERVER_BASE_URL + 'user/updateCommon',
user_ben_update: SERVER_BASE_URL + 'user/updateBen',
user_ben_get_name: SERVER_BASE_URL + 'user/singleBen/name',
user_common_get_nickname: SERVER_BASE_URL + 'user/getCommon/name',
user_ben_get_realname: SERVER_BASE_URL + 'user/singleBen/name',
wei_get_token_page: SERVER_BASE_URL + 'wei/getByToken',
wei_delete: SERVER_BASE_URL + 'wei/delete',
user_update_password: SERVER_BASE_URL + 'user/updatePassword',
article_get: SERVER_BASE_URL + 'article/get',
article_detail: SERVER_BASE_URL + 'article/get/id',
amap_url: 'http://webapi.amap.com/maps?v=1.3&key=ad925c5003760094713775d64748d872&callback=init'
});
//JSON parse
app.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
$httpProvider.defaults.headers.put['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8';
$httpProvider.defaults.transformRequest = [function(data) {
var obj = [];
for (var key in data) {
obj.push(key + '=' + data[key]);
}
return obj.join('&');
}];
}]);
//Routing configuration
app.config(['$stateProvider', '$urlRouterProvider',
function($stateProvider, $urlRouterProvider) {
/*URL Routing*/
$urlRouterProvider.otherwise("/");
/*Status Configuration*/
$stateProvider
//front page
.state('index', {
url: '/',
views: {
'': {
templateUrl: 'views/index/index.html',
},
'header@index': {
templateUrl: 'views/header.html',
controller: 'HeaderController'
},
'footer@index': {
templateUrl: 'views/footer.html',
controller: ''
},
'weibo@index': {
templateUrl: 'views/index/weibo.html',
controller: 'WeiboController'
},
'article@index': {
templateUrl: 'views/index/article.html',
controller: 'ArticleController'
},
'post@index': {
templateUrl: 'views/index/post.html',
controller: 'PostWeiboController'
}
}
})
.state('login', {
url: '/login',
views: {
'': {
templateUrl: 'views/login/login.html',
controller: 'LoginController'
}
}
})
.state('register', {
url: '/register',
views: {
'': {
templateUrl: 'views/register/register.html',
controller: 'RegisterController'
}
}
})
.state('contacts', {
url: '/contacts',
views: {
'': {
templateUrl: 'views/contacts/contacts.html',
controller: ''
},
'header@contacts': {
templateUrl: 'views/header.html',
controller: 'HeaderController'
},
'userinfo@contacts': {
templateUrl: 'views/contacts/userinfo.html',
controller: 'UserInfoController'
},
'map@contacts': {
templateUrl: 'views/contacts/map.html',
controller: 'MapController'
},
'search@contacts': {
templateUrl: 'views/contacts/search.html',
controller: 'SearchUserController'
}
}
})
.state('ucenter', {
url: '/ucenter',
views: {
'': {
templateUrl: 'views/ucenter/ucenter.html',
controller: ''
},
'header@ucenter': {
templateUrl: 'views/header.html',
controller: 'HeaderController'
},
'userWeibo@ucenter': {
templateUrl: 'views/ucenter/weibo.html',
controller: 'UcWeiboController'
},
'userDetailInfo@ucenter': {
templateUrl: 'views/ucenter/user.html',
controller: 'UcUserController'
},
'footer@ucenter': {
templateUrl: 'views/footer.html',
controller: ''
}
}
})
.state('article', {
url: '/article/:id',
views: {
'': {
templateUrl: 'views/article/article.html',
controller: ''
},
'header@article': {
templateUrl: 'views/header.html',
controller: 'HeaderController'
},
'article_content@article': {
templateUrl: 'views/article/article_content.html',
controller: 'ArticleDetailController'
},
'footer@article': {
templateUrl: 'views/footer.html',
controller: ''
}
}
})
.state('article_index', {
url: '/article',
views: {
'': {
templateUrl: 'views/article/article.html',
controller: ''
},
'header@article_index': {
templateUrl: 'views/header.html',
controller: 'HeaderController'
},
'article_content@article_index': {
templateUrl: 'views/article/article_content.html',
controller: 'ArticleDetailController'
},
'footer@article_index': {
templateUrl: 'views/footer.html',
controller: ''
}
}
});
}]);