Skip to content

Commit 91f74b3

Browse files
committed
立即购买的在登录情况和未登录下的处理
1 parent 266089c commit 91f74b3

File tree

3 files changed

+60
-16
lines changed

3 files changed

+60
-16
lines changed

src/main/webapp/confirmOrder.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,14 @@
334334
})
335335

336336
$(".order-ok").click(function(){
337-
let obj = {'orderDetails':orderDetails,'ids':ids,"oNum":oNum,"oPrice":oPrice,"uAddress":uAddress,"uReceiver":uReceiver,"oPhone":oPhone,"oCheaper":oCheaper.toFixed(2)}
337+
let objects = {'orderDetails':orderDetails,'ids':ids,"oNum":oNum,"oPrice":oPrice,"uAddress":uAddress,"uReceiver":uReceiver,"oPhone":oPhone,"oCheaper":oCheaper.toFixed(2)}
338338
$.ajax({
339339
url:'orders/addOrders',
340340
type:'post',
341341
contentType: "application/json; charset=utf-8",
342-
data:JSON.stringify(obj),
342+
data:JSON.stringify(objects),
343343
success:function(){
344-
window.location="mineOrders.html"
344+
window.location="mineOrders.html"
345345
}
346346
})
347347
})

src/main/webapp/js/cart.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var totalPage,currpage,limit
66
$(function(){
77
getCartList()
88
$("body").on("click",".selectSub",function(){
9-
currentName = this.getAttribute('name')
9+
currentName = this.parentNode.parentNode.getAttribute('id')
1010
if(this.checked){
1111
if(multiDeleteArr.length){
1212
for(var i=0;i<multiDeleteArr.length;i++){
@@ -30,7 +30,6 @@ $(function(){
3030
$("body").on('click','.plus',function(){
3131
//获取总价列
3232
var sum_money = this.parentNode.nextSibling;
33-
console.log(sum_money)
3433
while(sum_money.nodeName=="#text"){
3534
sum_money = sum_money.nextSibling;
3635
}
@@ -176,14 +175,12 @@ function getCartList(page,limit){
176175
"limit": limit,
177176
},
178177
success:function(data){
179-
console.log(data)
180178
totalPage = data.pageInfo.pages
181179
limit = data.pageInfo.pageSize
182180
currpage = data.pageInfo.pageNum
183181
$(".papigationPage").html("第"+currpage+"页/共"+totalPage+"页")
184182
var html = '';
185183
$.each(data.cartList,function(index,cdata){
186-
console.log(cdata)
187184
html += "<tr index="+index+" id="+cdata['cId']+"><td><input type=\"checkbox\" class=\"selectSub\" name="+cdata['bId']+"></td>"
188185
html += "<td><img class=\"table-img\" src=\"img/book_images/"+cdata['bPic']+"\" /></td>"
189186
html += "<td class='bname'>"+cdata['bName']+"</td>"
@@ -212,7 +209,7 @@ function getCartList(page,limit){
212209
if($(this).attr('name') == 'book-select'){
213210
console.log('no need 表头不需要')
214211
}else {
215-
console.log("!!!",$(this).attr('name'));
212+
let cId = $(this).parent().parent().attr('id');
216213
let bId = $(this).attr('name');
217214
let imgSrc = $(this).parent().next().find(".table-img").attr('src');
218215
let bname = $(this).parent().siblings().eq(1).html();
@@ -221,7 +218,7 @@ function getCartList(page,limit){
221218
let bNum = $(this).parent().siblings().eq(4).find(".num-text").val();
222219
let bSumdiscountprice = $(this).parent().siblings().eq(5).html();
223220
let bSumprice = bPrice * bNum
224-
obj = {"bId":bId,"imgSrc":imgSrc,"bName":bname,"bPrice":bPrice,"bDiscountprice":bDiscountprice,"bNum":bNum,"bSumdiscountprice":bSumdiscountprice,"bSumprice":bSumprice};
221+
obj = {"cId":cId,"bId":bId,"imgSrc":imgSrc,"bName":bname,"bPrice":bPrice,"bDiscountprice":bDiscountprice,"bNum":bNum,"bSumdiscountprice":bSumdiscountprice,"bSumprice":bSumprice};
225222
selectedGoods.push(obj)
226223
}
227224
})
@@ -257,7 +254,7 @@ $("#selectAll").click(function () {
257254
}
258255
}
259256
if(!flag){
260-
multiDeleteArr.push(check[i].getAttribute('name'))
257+
multiDeleteArr.push(check[i].parentNode.parentNode.getAttribute('id'))
261258
}
262259

263260
}
@@ -298,7 +295,6 @@ $("body").on('change','.selectSub',function(){
298295
getSumPrice()
299296
})
300297
function toPage(str) {
301-
console.log(str)
302298
if(str == "index"){
303299
getCartList(1,limit)
304300
}

src/main/webapp/js/details.js

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var uAddress='',uReceiver='',oPhone='',orderDetails=[];
12
$(function(){
23
function getQueryString(name) {
34
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i")
@@ -65,8 +66,8 @@ $(function(){
6566
tab2 += "<div class=\"new_prod_box\">"
6667
tab2 += " <a href=\"detail.html?bId="+ndata['bId']+"\" style=\"white-space:nowrap;text-overflow:ellipsis;overflow: hidden;width: 100px;\">"+ndata['bName']+"</a>"
6768
tab2 += " <a href=\"detail.html?bId="+ndata['bId']+"\"><img src=\"img/book_images/"+ndata['bPic']+"\" class=\"thumb\" border=\"0\" width=\"90px\" height=\"90px\"/></a>"
68-
tab2 +="</div></div>"
69-
})
69+
tab2 +="</div></div>";
70+
});
7071
$("#tab2").html(tab2)
7172
},
7273
error:function(){
@@ -130,8 +131,55 @@ $(function(){
130131
})
131132
})
132133

133-
$(".now_order").click(function(){
134-
135-
})
134+
//得默认地址
135+
$.ajax({
136+
url:'userAdress/getUserDefaultAddress',
137+
type:'get',
138+
success:function(data){
139+
if(data.defaultUserAddress ){
140+
uReceiver = data.defaultUserAddress.oReceiver;
141+
oPhone = data.defaultUserAddress.oPhone;
142+
uAddress = data.defaultUserAddress.uAddress;
143+
}
144+
145+
}
146+
})
147+
148+
$("#now_order").click(function(){
149+
bNums = $("#num_text").val();
150+
bSumprice = bNums * bPrice;
151+
bSumdiscountprice = bNums * bDiscountprice;
152+
let obj = {
153+
"bId":bookId,
154+
'bName':bName,
155+
"bNums":bNums,
156+
"bPrice":bPrice,
157+
"bDiscountprice":bDiscountprice,
158+
"bSumprice":bSumprice,
159+
"bSumdiscountprice":bSumdiscountprice
160+
};
161+
orderDetails.push(obj);
162+
let objects = {'orderDetails':orderDetails,
163+
"oNum":bNums,
164+
"oPrice":bSumdiscountprice,
165+
"uAddress":uAddress,
166+
"uReceiver":uReceiver,
167+
"oPhone":oPhone,
168+
"oCheaper":(bSumprice-bSumdiscountprice).toFixed(2)}
169+
$.ajax({
170+
url:'orders/addOrders',
171+
type:'post',
172+
contentType: "application/json; charset=utf-8",
173+
data:JSON.stringify(objects),
174+
success:function(data){
175+
176+
if(data=="userNotLogin"){
177+
window.location="login.html"
178+
}else {
179+
/* window.location="mineOrders.html" */
180+
}
181+
}
182+
})
183+
});
136184

137185
})

0 commit comments

Comments
 (0)