-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
sdc
committed
Sep 13, 2017
0 parents
commit 545407d
Showing
97 changed files
with
829 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>test</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.aptana.ide.core.unifiedBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.aptana.projects.webnature</nature> | ||
</natures> | ||
<filteredResources> | ||
<filter> | ||
<id>1479866373171</id> | ||
<name></name> | ||
<type>26</type> | ||
<matcher> | ||
<id>org.eclipse.ui.ide.multiFilter</id> | ||
<arguments>1.0-name-matches-false-false-node_modules</arguments> | ||
</matcher> | ||
</filter> | ||
<filter> | ||
<id>1505179373333</id> | ||
<name></name> | ||
<type>26</type> | ||
<matcher> | ||
<id>org.eclipse.ui.ide.multiFilter</id> | ||
<arguments>1.0-name-matches-false-false-node_modules</arguments> | ||
</matcher> | ||
</filter> | ||
</filteredResources> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// value值 类型是一个 对象 | ||
function setCookie(key,value,days){ | ||
var now = new Date(); | ||
now.setTime(now.getTime() + days*24*60*60*1000 ) | ||
document.cookie=key+"="+value + ";expires="+now; | ||
} | ||
function getCookie(key){ | ||
//如果cookie中有数据 才可以获取数据 | ||
if(document.cookie){ | ||
var cookieInfo = document.cookie; | ||
//cookie中可能会包含一些 额外的数据,这些数据特点是由 分号和空格间隔的 | ||
//所以 先将 分号和空格 替换掉 替换成 ; | ||
var arr = cookieInfo.replace(/;\s/g,';').split(";"); | ||
for(var i=0;i<arr.length;i++){ | ||
item = arr[i].split("="); | ||
if(item[0] == key){ | ||
brr = item[1]; | ||
return JSON.parse(brr);//如果找到 我们想要的键,将值转成数组返回 | ||
} | ||
} | ||
//如果cookie中 没有我们想获取的键值,直接返回一个空数组 | ||
return []; | ||
} | ||
//如果cookie中没有数据,直接返回一个空数组 | ||
return []; | ||
} | ||
function removeCookie(key){ | ||
setCookie(key,"",-1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
{ | ||
"classify001":{ | ||
"name" : "小米手机", | ||
"list" : [ | ||
{ | ||
"id" : "shop01", | ||
"name" : "小米1", | ||
"src" : "9.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop02", | ||
"name" : "小米2", | ||
"src" : "2.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop03", | ||
"name" : "小米3", | ||
"src" : "3.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop04", | ||
"name" : "小米4", | ||
"src" : "4.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop05", | ||
"name" : "小米5", | ||
"src" : "5.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop06", | ||
"name" : "小米6", | ||
"src" : "6.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop07", | ||
"name" : "小米7", | ||
"src" : "7.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop08", | ||
"name" : "小米8", | ||
"src" : "8.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop09", | ||
"name" : "小米9", | ||
"src" : "9.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop10", | ||
"name" : "小米10", | ||
"src" : "10.jpg", | ||
"price" : "999" | ||
} | ||
] | ||
}, | ||
"classify002":{ | ||
"name" : "三星", | ||
"list" : [ | ||
{ | ||
"id" : "shop11", | ||
"name" : "三星11", | ||
"src" : "11.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop02", | ||
"name" : "三星12", | ||
"src" : "12.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop13", | ||
"name" : "小米13", | ||
"src" : "13.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop04", | ||
"name" : "小米14", | ||
"src" : "14.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop15", | ||
"name" : "小米15", | ||
"src" : "15.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop16", | ||
"name" : "小米16", | ||
"src" : "16.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop17", | ||
"name" : "小米17", | ||
"src" : "17.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop18", | ||
"name" : "小米18", | ||
"src" : "18.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop19", | ||
"name" : "小米9", | ||
"src" : "9.jpg", | ||
"price" : "999" | ||
}, | ||
{ | ||
"id" : "shop20", | ||
"name" : "小米20", | ||
"src" : "20.jpg", | ||
"price" : "999" | ||
} | ||
] | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title></title> | ||
<link rel="stylesheet" href="main.css" /> | ||
<script src="jquery.min.js"></script> | ||
<script src="cookie.js"></script> | ||
<style> | ||
.header{ | ||
height: 40px; | ||
width: 900px; | ||
margin: 0 auto 50px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="header"> | ||
<span id="s"><a href="login.html">登录 / 注册</a></span> | ||
<span id="s1"> | ||
|
||
</span> | ||
</div> | ||
<div class="nav clearfix"> | ||
<!--<span>小米手机</span>--> | ||
</div> | ||
|
||
<ul class="shoplist clearfix"> | ||
<!--<li> | ||
<a href="page.html"> | ||
<img src="img/1.jpg" alt="" /> | ||
<p>小米1</p> | ||
<p>890</p> | ||
</a> | ||
<button>加入购物车</button> | ||
</li>--> | ||
</ul> | ||
</body> | ||
</html> | ||
<script type="text/javascript"> | ||
|
||
$(function(){ | ||
$.ajax({ | ||
type:"get", | ||
url:"http://127.0.0.1/shopCart_sh1705/data.json", | ||
success : function(res){ | ||
var html = ""; | ||
for (var i in res) { | ||
//console.log(i); | ||
$(".nav").append(`<span>${res[i].name}</span>`);//加载标题 | ||
for(var j in res[i].list){ | ||
var ch = res[i].list[j];//{} | ||
html += `<li> | ||
<a href="page.html?pid=${ch.id}&cname=${i}"> | ||
<img src="img/${ch.src}" alt="" /> | ||
<p>${ch.name}</p> | ||
<p>${ch.price}</p> | ||
</a> | ||
<span data-id=${ch.id} data-name=${ch.name} data-src=${ch.src} data-price=${ch.price} style="display:none"></span> | ||
<button>加入购物车</button> | ||
</li>`; | ||
} | ||
} | ||
$(".shoplist").html( html ); | ||
|
||
} | ||
}); | ||
}) | ||
|
||
$(".shoplist").on("click","button",function(){ | ||
var arr = []; | ||
var flag = true;//可以向数组中添加数据 | ||
var _json = { | ||
id:$(this).prev().data("id"), | ||
name:$(this).prev().data("name"), | ||
src:$(this).prev().data("src"), | ||
price:$(this).prev().data("price"), | ||
count:1 | ||
} | ||
//当再次点击按钮时,cookie信息被覆盖 解决 : 先取出cookie数据 存入到数组中,然后在把新增的商品存入到数组中 | ||
var cookieInfo = getCookie("shoplist"); | ||
if( cookieInfo.length != 0 ){//表示cookie中有数据 | ||
arr = cookieInfo; | ||
//点击相同商品时,需要做商品数量的累加 用当前点击的商品编号id 和 取出来的cookie的 数据中商品id做比较 发现有相等的,count++ | ||
for(var i in arr){ | ||
if(_json.id == arr[i].id && _json.name == arr[i].name){ | ||
arr[i].count++; | ||
flag = false; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
if(flag){ | ||
arr.push(_json); | ||
} | ||
|
||
setCookie("shoplist",JSON.stringify(arr)); | ||
var f = confirm("是否继续购买?确定--继续购买,取消---去购物车结算"); | ||
if( !f ){ | ||
location.href = "shopcar.html"; | ||
} | ||
console.log( document.cookie ); | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title></title> | ||
<style> | ||
input{ | ||
padding: 5px; | ||
width: 200px; | ||
height: 30px; | ||
border: 1px solid #d1d1d1; | ||
} | ||
</style> | ||
|
||
<script src="jquery.min.js"></script> | ||
<script src="cookie.js"></script> | ||
</head> | ||
<body> | ||
<div id="register"> | ||
<input class="username" type="text" value="" id="uname" placeholder="请输入用户名" /> | ||
<br/> | ||
<input class="userpassword" type="password" id="upwd" value="" placeholder="请输入密码" /> | ||
<br/> | ||
<button id="regis">注册</button> | ||
</div> | ||
<br /> | ||
<div id="login"> | ||
<input class="username" id="hname" type="text" value="" placeholder="请输入用户名" /> | ||
<br/> | ||
<input class="userpassword" id="hpwd" type="password" value="" placeholder="请输入密码" /> | ||
<br/> | ||
<button id="log">登录</button> | ||
<script> | ||
|
||
</script> | ||
</div> | ||
</body> | ||
</html> | ||
<script type="text/javascript"> | ||
|
||
</script> |
Oops, something went wrong.