diff --git a/pages.json b/pages.json index e343ff2..6e7893b 100644 --- a/pages.json +++ b/pages.json @@ -149,11 +149,14 @@ } }, { -<<<<<<< HEAD "path" : "pages/Shopping-cart/component/addProduct", -======= + "style" : + { + "navigationBarTitleText" : "" + } + }, + { "path" : "pages/mine/OrderDetails/OrderDetails", ->>>>>>> c9237d26d1ae81ae719b02c06a049bdb594622bd "style" : { "navigationBarTitleText" : "" diff --git a/pages/Shopping-cart/component/addProduct.vue b/pages/Shopping-cart/component/addProduct.vue new file mode 100644 index 0000000..bec9f68 --- /dev/null +++ b/pages/Shopping-cart/component/addProduct.vue @@ -0,0 +1,232 @@ + + + + + diff --git a/pages/Shopping-cart/newaddress_Info/newaddress_Info.vue b/pages/Shopping-cart/newaddress_Info/newaddress_Info.vue index 282a8df..f77ae3a 100644 --- a/pages/Shopping-cart/newaddress_Info/newaddress_Info.vue +++ b/pages/Shopping-cart/newaddress_Info/newaddress_Info.vue @@ -131,7 +131,7 @@ const jump =()=> { width: 100%; overflow-y: auto; overflow-x: hidden; - height: 100vh; + // height: 100vh; overflow: hidden; } .group { diff --git a/pages/Shopping-cart/productmain/productmain.vue b/pages/Shopping-cart/productmain/productmain.vue index 85e4d18..0622294 100644 --- a/pages/Shopping-cart/productmain/productmain.vue +++ b/pages/Shopping-cart/productmain/productmain.vue @@ -122,7 +122,7 @@ src="https://carbon2.obs.cn-north-4.myhuaweicloud.com:443/feiyi%2Ftest%2F0%2FJipaVPoQ-storeRmb.png" /> {{ totalPrice }} - 去结算 + 去结算 @@ -142,7 +142,6 @@ import pull from '@/pages/Shopping-cart/productmain/img/pull.png'; import rmb from '@/pages/Shopping-cart/productmain/img/rmb.png'; import short from '@/pages/Shopping-cart/productmain/img/short.png'; const products = ref([]) -let checkedArr = [] //变量 const current = ref(1) const allCheck = ref(false) //全选 const checkedData = ref([]) //选择的暂存保存数组 @@ -153,7 +152,6 @@ onMounted(()=>{ }) onShow(()=>{ getProductCart() //获取商品类 - // getServiceCart() }) //小程序刷新根据用户id获取购物车信息 @@ -163,6 +161,7 @@ const getProductCart = async ()=>{ method: 'POST', data: { id: userInfo.id } }) + // console.log(res.data); if(res.data.code === 1) { products.value = res.data.data products.value.forEach((item)=>{ @@ -187,17 +186,16 @@ const getTextStyle = (num) => ({ }); //复选框绑定方法 const checkBoxChange =(event)=>{ + checkedData.value = [{}] //每次都要重置一下 totalPrice.value = 0; - // products.value[parseInt(event.detail.value)].checked = true; + let count = 0; //用于记录checkedData不为null的个数 console.log('event--->',event.detail); - products.value[parseInt(event.detail.value)].checked = true; + products.value[parseInt(event.detail.value)].checked = true; //勾选 //计算一下总金额 for(let key in event.detail.value) { - let temp = parseInt(event.detail.value[parseInt(key)]) //相当于商品数组下标 // totalPrice.value += products.value[temp].goodVO.price * products.value[temp].quantity computed(products.value[temp].goodVO.price , products.value[temp].quantity) - // console.log('--->',event.detail.value[parseInt(key)]); } // products.value.forEach((item)=>{ // item.checked = false @@ -220,8 +218,22 @@ const checkBoxChange =(event)=>{ if(event.detail.value.length == products.value.length) { allCheck.value = true } + event.detail.value.forEach((item)=>{ //将选中的商品信息赋值给checkedData + console.log('products.value[parseInt(item)].goodId',products.value[parseInt(item)].goodId); + if(products.value[parseInt(item)] !== null) { + // console.log('item--->',item); + checkedData.value[count] = { + goodId: products.value[parseInt(item)].goodId, + quantity: products.value[parseInt(item)].quantity, + } + // console.log(products.value[parseInt(item)].goodId); + count += 1 + } + }) + console.log('checkedData--->',checkedData.value); //将选中的数组保存在某一个ref中 - checkedData.value = event.detail.value + // checkedData.value = event.detail.value + // console.log('checkedData--->',checkedData.value); } //全选方法 const allChecked = ()=>{ @@ -231,10 +243,13 @@ const allChecked = ()=>{ products.value.forEach((item)=>{ item.checked = true //将全部选项选上 // console.log('item--->',item); - // totalPrice.value += item.goodVO.price * item.quantity computed(item.goodVO.price , item.quantity) }) - // checkedData.value = products.value.map((item)=>{ return item.value }) + checkedData.value = products.value.map((item)=>({ + goodId: item.goodId, + quantity: item.quantity + })) //将商品全部信息保存到checkedData中 + console.log('checkedData--->',checkedData.value); } else { products.value.forEach((item)=>{ item.checked = false //将全部都取消选择 @@ -243,8 +258,8 @@ const allChecked = ()=>{ } //减少商品 const decrease =(index , item)=>{ //item用于监测是否选中 - console.log('index-->',index); - console.log('item-->',item); + // console.log('index-->',index); + // console.log('item-->',item); if(products.value[index].quantity > 1) { products.value[index].quantity -= 1 if(item && products.value[index].quantity >= 1) { @@ -254,8 +269,6 @@ const decrease =(index , item)=>{ //item用于监测是否选中 } //这里应该结合库存有多少 11.8 const increase =(index , item) =>{ //item用于监测是否选中 - console.log('index-->',index); - console.log('item-->',item); if(products.value[index].quantity <= 99) { products.value[index].quantity += 1 } @@ -273,6 +286,12 @@ const jump_product =()=>{ url:'../../../pages/store-home/ProductDetails/ProductDetails' }) } +const goToBuy =()=>{ + console.log('要传到订单详情页面的checked--->',checkedData.value); + uni.navigateTo({ + url: '/pages/order/product-waitpay/product-waitpay?cartInfo=' + JSON.stringify(checkedData.value) + }) +}