-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
166 lines (163 loc) · 3.83 KB
/
script.js
File metadata and controls
166 lines (163 loc) · 3.83 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// JavaScript
var rooms = [
{
"name": "經濟雙人房",
"eng": "Economy Double Room",
"price": 7000,
"amount": 0,
"cover": "http://bosscode.monoame.com/20170323_vue_comp/img/room%20(1).jpg",
"discount": 0.9,
"equipment": {
"wifi": false,
"bathtub": true,
"breakfast": true
}
},
{
"name": "海景三人房",
"eng": "Sea view triple Room",
"price": 7800,
"amount": 0,
"cover": "http://bosscode.monoame.com/20170323_vue_comp/img/room%20(2).jpg",
"discount": 0.8,
"equipment": {
"wifi": true,
"bathtub": true,
"breakfast": false
}
},
{
"name": "典雅景觀房",
"eng": "Elegant landscape Room",
"price": 5400,
"amount": 0,
"cover": "http://bosscode.monoame.com/20170323_vue_comp/img/room%20(3).jpg",
"discount": 0.85,
"equipment": {
"wifi": false,
"bathtub": true,
"breakfast": true
}
},
{
"name": "尊享豪華房",
"eng": "Exclusive Deluxe Room",
"price": 9800,
"amount": 0,
"cover": "http://bosscode.monoame.com/20170323_vue_comp/img/room%20(4).jpg",
"discount": 0.8,
"equipment": {
"wifi": true,
"bathtub": false,
"breakfast": true
}
},
{
"name": "商務雙人房",
"eng": "Business Double Room",
"price": 5600,
"amount": 0,
"cover": "http://bosscode.monoame.com/20170323_vue_comp/img/room (5).jpg",
"discount": 0.9,
"equipment": {
"wifi": true,
"bathtub": false,
"breakfast": false
}
},
{
"name": "溫泉雙人房",
"eng": "Hot spring double Room",
"price": 8400,
"amount": 0,
"cover": "http://bosscode.monoame.com/20170323_vue_comp/img/room (6).jpg",
"discount": 0.6,
"equipment": {
"wifi": true,
"bathtub": true,
"breakfast": true
}
},
{
"name": "總統套房",
"eng": "Presidential Suite",
"price": 23000,
"amount": 0,
"cover": "http://bosscode.monoame.com/20170323_vue_comp/img/room (7).jpg",
"discount": 0.75,
"equipment": {
"wifi": true,
"bathtub": true,
"breakfast": true
}
},
{
"name": "奢華四人房",
"eng": "Luxury four Room",
"price": 8500,
"amount": 0,
"cover": "http://bosscode.monoame.com/20170323_vue_comp/img/room (8).jpg",
"discount": 0.7,
"equipment": {
"wifi": true,
"bathtub": true,
"breakfast": false
}
}
];
Vue.component("room", {
template: "#room",
props: ["room_data", "hotel_discount", "hotel_fee", "delete_room", "id"],
computed: {
final_discount: function(){
return this.room_data.discount * this.hotel_discount;
},
final_discount_show: function(){
return parseInt(this.final_discount * 100);
},
final_price: function(){
return parseInt(this.room_data.price * this.final_discount) + this.hotel_fee * 1.0;
},
bg_css: function(){
return {
"background-image": "url('" + this.room_data.cover + " ')"
};
}
}
});
var vm = new Vue({
el: "#app",
data: {
rooms: rooms,
discount: 0.9,
service_fee: 200,
edit_id: -1
},
methods:{
addroom: function(){
this.rooms.push({
name:"新房間",
eng: "new Room",
price: 0,
amount: 0,
cover: "",
discount: 0,
equipment:{
wifi: true,
bathtub: true,
breakfast: false
}
});
this.edit_id = this.rooms.length - 1;},
delete_room: function(id) {
if (this.rooms.length > 1) {
this.rooms.splice(id, 1);
if (this.edit_id >= this.rooms.length) {
this.edit_id = this.rooms.length - 1; // 確保 edit_id 不超出範圍
}
} else {
alert("至少需要保留一間房間");
}
}
}
});