-
Notifications
You must be signed in to change notification settings - Fork 33
/
base.js
91 lines (89 loc) · 2.1 KB
/
base.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
var app = angular.module('wsscat', ['ngRoute']);
app.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/index', {
templateUrl: 'template/index.html',
controller: 'indexCtrl'
}).when('/home', {
templateUrl: 'template/home.html',
controller: 'homeCtrl'
}).otherwise({
redirectTo: '/index'
})
}])
app.run([function($rootScope) {
/*http.get('isLogin.php',{
params:{
cookie:'123'
}}).success(function(data){
if(data.isLogin){
}else{
window.location.href = '#/login'
}
})*/
//自执行函数
(function(doc, win) {
var docEl = doc.documentElement,
recalc = function() {
var clientWidth = docEl.clientWidth;
if(!clientWidth) return;
if(clientWidth >= 740) {
clientWidth = 740;
}
if(clientWidth <= 320) {
clientWidth = 320;
}
docEl.style.fontSize = 100 * (clientWidth / 320) + 'px';
};
if(!doc.addEventListener) return;
win.addEventListener('resize', recalc, false);
doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
console.log("进入路由前先执行");
}])
app.controller('indexCtrl', function($scope, swipe, $http) {
swipe.me()
$http.jsonp('http://localhost:8888/', {
params: {
name: 'abc',
callback: "JSON_CALLBACK"
}
}).success(function(data) {
console.log(data)
$scope.hotels = data.hotel
})
})
app.controller('homeCtrl', function($scope, swipe, $http) {
swipe.me()
$scope.name = "wsscat";
$http.jsonp('http://localhost:8888/', {
params: {
name: 'abc',
callback: "JSON_CALLBACK"
}
}).success(function(data) {
console.log(data)
})
})
app.directive('xcheader', function() {
return {
templateUrl: 'directive/xcheader.html',
}
})
app.service('swipe', function() {
return {
me: function() {
var myswiper = new Swiper('.swiper-container', {
// direction: 'vertical', // 一个垂直方向的
loop: true, // 一个循环的滑动
pagination: '.swiper-pagination', // 分页器
prevButton: '.swiper-button-prev',
autoplay: '1000',
});
}
}
})
app.filter('wsscat', function() {
return function(input) {
return input + "你经过处理"
}
})