Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
wtdmw committed Dec 27, 2018
1 parent 915513f commit 48ffe55
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 25 deletions.
32 changes: 32 additions & 0 deletions api/xqy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
if($_GET['qqlx']=="jz"){
$xqy_id=$_GET['xqy_id'];
//服务器地址
$severname="10.3.143.81";
//登陆用户名
$username="mgj_com";
//登陆密码
$password="63PWznc6a5pi7NFD";
//数据库名字
$dbname="mgj_com";

//创建链接
$con=new mysqli($severname,$username,$password,$dbname);
//检擦是否链接成功
if($con->connect_error){
exit("链接失败:".$con->connect_error);
}
$cqsql="select * from sp where id='".$xqy_id."'";
$result = $con->query($cqsql);
//判读集中是否有数据
if ($result->num_rows > 0) {
// 输出数据
while($row = $result->fetch_assoc()) {
echo json_encode($row,JSON_UNESCAPED_UNICODE);
}
}

//关闭数据库链接
$con->close();
}
?>
26 changes: 7 additions & 19 deletions html/xqy.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,48 +216,36 @@ <h3>流行话题</h3>
<div class="xqy_body_sx_zt">
<div class="xqy_body_sx_zt_bigimg">
<div class="xqy_body_sx_zt_bigimg_smk"></div>
<img src="https://s11.mogucdn.com/mlcdn/c45406/181217_6e1blljf8fbdc51hc4gk0kge2629f_640x960.jpg_468x468.jpg"
<img src=""
alt="" id="xqy_body_sx_zt_bigimg">
</div>

<div class="xqy_body_sx_zt_faj">
<img src="https://s11.mogucdn.com/mlcdn/c45406/181217_6e1blljf8fbdc51hc4gk0kge2629f_640x960.jpg_468x468.jpg" alt="">
<img src="" alt="">
</div>

<div class="xqy_body_sx_zt_kz">
<div class="xqy_body_sx_zt_kz_zj"></div>
<div class="xqy_body_sx_zt_kz_lb" id="xqy_body_sx_zt_kz_lb">
<ul>
<li><img src="https://s11.mogucdn.com/mlcdn/c45406/181217_6e1blljf8fbdc51hc4gk0kge2629f_640x960.jpg_468x468.jpg"
alt=""></li>
<li><img src="https://s11.mogucdn.com/mlcdn/c45406/181217_3c1fb7a5ab4kig7bb8ga84ei15d4i_800x800.jpg_100x100.jpg"
alt=""></li>
<li><img src="https://s3.mogucdn.com/mlcdn/c45406/181217_1ifjd811fgc7eb84effh6jj9dg0f6_800x800.jpg_100x100.jpg"
alt=""></li>
<li><img src="https://s11.mogucdn.com/mlcdn/c45406/181217_310fe4dka364chll90g9918125191_800x800.jpg_100x100.jpg"
alt=""></li>
<li><img src="https://s3.mogucdn.com/mlcdn/c45406/181217_44f76874d4bc5fk311i8e0dfi150f_800x800.jpg_100x100.jpg"
alt=""></li>
<li><img src="https://s11.mogucdn.com/mlcdn/c45406/181217_10cg36bk8b6cjc015j6ad0lg10933_746x743.jpg_100x100.jpg"
alt=""></li>
<li><img src="https://s11.mogucdn.com/mlcdn/c45406/181217_6e1blljf8fbdc51hc4gk0kge2629f_640x960.jpg_468x468.jpg"
alt=""></li>
<!-- <li><img src="https://s11.mogucdn.com/mlcdn/c45406/181217_6e1blljf8fbdc51hc4gk0kge2629f_640x960.jpg_468x468.jpg"
alt=""></li> -->
</ul>
</div>
<div class="xqy_body_sx_zt_kz_yj"></div>
</div>
</div>

<div class="xqy_body_sx_xz">
<h1>加厚加绒chic卫衣女长袖韩版宽松秋冬带帽中长款渐变箭头潮牌慵懒风加厚港风ins外套冬</h1>
<h1></h1>
<div class="xqy_body_sx_xz_xx">
<div class="xqy_body_sx_xz_xx_jg">
<span>价格:</span><span>¥100</span><span>¥120</span><span>累计销量:10</span><span>评价:1</span>
<span>价格:</span><span id="xqy_jg">¥100</span><span id="xqy_yj">¥120</span><span id="xqy_xl">累计销量:10</span><span id="xqy_pj">评价:1</span>
</div>
<div class="xqy_body_sx_xz_xx_yh">
<span>店铺优惠:</span>
<div>满199立减10元 <span>领取</span></div>
<div>满199立减10元 <span>领取</span></div>
<div>满299立减30元 <span>领取</span></div>
</div>
<div class="xqy_body_sx_xz_xx_kf">
<span>客服:</span>
Expand Down
2 changes: 1 addition & 1 deletion js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ var Cooke = {
},
//删除cookie文件
ccsc: function (cname) {
document.cookie = cname + "=" + ";" + 'expires=Thu, 01 Jan 1970 00:00:00 GMT';
document.cookie = cname + "=" + ";" + 'expires=Thu, 01 Jan 1970 00:00:00 GMT'+"; path=/";
return '删除成功';
},
//读取cookie文件
Expand Down
4 changes: 3 additions & 1 deletion js/top.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ if (JSON.parse(Cooke.ccdq('dlzt')) == "ydl") {
Cooke.ccsc("dlzt");
Cooke.ccsc("dlyh");
location.reload();
})
});

}

$(window).scroll(function (event) {
if ($(document).scrollTop() > 100) {
$("#header").stop();
Expand Down
113 changes: 109 additions & 4 deletions js/xqy.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,116 @@ $(".xqy_body_sx_xz_xx_sl_kz_ja").on("click", function (e) {
var dv = $(".xqy_body_sx_xz_xx_sl_kz_z").attr("value");
$(".xqy_body_sx_xz_xx_sl_kz_z").attr("value", dv * 1 + 1)
// console.log($(".xqy_body_sx_xz_xx_sl_kz_z").attr("value"))
})
});
var xqy_res = (location.search).slice(1);
var xqy_id = xqy_res.split('=')[1];
// console.log(yhfx_id);
$.get("../api/xqy.php", {
xqy_id: xqy_id,
qqlx: "jz"
},
function (data) {
var arr = JSON.parse(data)
// console.log(arr);
xqy_sj(arr);
});

//输入数据
function xqy_sj(arr) {
//主图图片更新
var zt = arr.zt.split(",");
// console.log(zt);
$("#xqy_body_sx_zt_bigimg").attr("src", zt[0]);
$.each(zt, function (i, n) {
$("#xqy_body_sx_zt_kz_lb ul").append(`
<li><img src="${n}" alt=""></li>
`)
});
$("#xqy_body_sx_zt_kz_lb ul").css("width", zt.length * 68);

//生成当前商品传入购物车数据
function xqy_gwcc(){
// var
//属性信息
$(".xqy_body_sx_xz h1").text(arr.bt);

$("#xqy_jg").text("¥" + arr.jg);
$("#xqy_yj").text("¥" + arr.yj);
$("#xqy_xl").text("累计销量:" + arr.xl);
$("#xqy_pj").text("评价:" + arr.pj);
}

//购物车数据搜集 添加到数据库
function xqy_gwcc() {
if (Cooke.ccdq('dlzt') == '"ydl"') {
// console.log("已登录")

//获取用户名
var yhm = JSON.parse(Cooke.ccdq('dlyh'));
//获取商品id
var xres = (location.search).slice(1);
var spid = xqy_res.split('=')[1];
//获取颜色
var ys = $(".xqy_body_sx_xz_xx_ys_sk.xqy_body_sx_xz_xx_xz").attr("cor");
//获取尺码
var cm = $(".xqy_body_sx_xz_xx_xz.xqy_body_sx_xz_xx_cm_k").text();
//获取数量
var sl = $(".xqy_body_sx_xz_xx_sl_kz_z").attr("value");
var gwcsj = {
"yhm": yhm,
"spid": spid,
"ys": ys,
"cm": cm,
"sl": sl
}
return gwcsj;

} else {
alert("请登陆");
}
}



$(".xqy_body_sx_xz_xx_jsan_gwc").on("click", function () {
var gwjson = xqy_gwcc();
// cookie内购物车数据名为 gwcsj 值为商品购物车数据组成的数组
var gwcsj = [];

//检查cookie是否有购物车数据 没有直接写入
if (Cooke.ccdq('gwcsj') == 'non') {
//将当前商品购物车数据加入cooke购物车数据
gwcsj.push(gwjson);
//写入cookie
Cooke.ccxr('gwcsj', JSON.stringify(gwcsj), 1, '/');
// console.log('cookie中没有数据直接写入');
// console.log(JSON.parse(Cooke.ccdq('gwcsj')));
} else {
//读取购物车数据向cooke购物车数据添加当前商品购物车数据
//读取到的购物车数据
var gwcsj = JSON.parse(Cooke.ccdq('gwcsj'));

//cookie中有当前id的商品判断属性是否和当前商品购物车数据相同,默认相同
//相同只增加商品数量
//如果没有一个相同的就新push
var dqsxgg = true;

//检查cookie数据中是否有当前商品id
for (var k in gwcsj) {

if (gwcsj[k].goodsid == gwjson.goodsid) {

if (gwcsj[k].ys == gwjson.ys && gwcsj[k].cm == gwjson.cm) {
var dqslz = gwcsj[k].sl;
gwcsj[k] = gwjson;
gwcsj[k].sl = (gwcsj[k].sl * 1) + dqslz * 1 + '';
dqsxgg = false;
}
}
}

//没有当前商品数据向购物车数据内添加当前商品购物车数据
if (dqsxgg == true) {
gwcsj.push(gwjson);
}
//将修改后的cookie购物车数据写入cookie
Cooke.ccxr('gwcsj', JSON.stringify(gwcsj), 1, '/');
};
})

0 comments on commit 48ffe55

Please sign in to comment.