Compare commits

..

No commits in common. "983276be5c3edb042c54fbda160175aacba3c628" and "7f3f7e14fbb732b6deb27483399a604bcd1198e5" have entirely different histories.

4 changed files with 51 additions and 72 deletions

View File

@ -2,4 +2,4 @@ export const Url = 'http://localhost:9092/api' //后端接口文档
export const testUrl = 'http://123.249.108.160:8888/api' //自己组的服务器接口地址 export const testUrl = 'http://123.249.108.160:8888/api' //自己组的服务器接口地址
export const suiUrl = 'http://154.8.193.216:9092/api' //隋宇霏的接口地址 export const suiUrl = 'http://154.8.193.216:9092/api' //隋宇霏的接口地址
export const baseUrl = Url export const baseUrl = testUrl

View File

@ -205,6 +205,13 @@
{ {
"navigationBarTitleText" : "" "navigationBarTitleText" : ""
} }
},
{
"path" : "pages/syy",
"style" :
{
"navigationBarTitleText" : ""
}
} }
], ],
"globalStyle": { "globalStyle": {

View File

@ -82,8 +82,11 @@
cookie: wx.getStorageSync('cookie') cookie: wx.getStorageSync('cookie')
}, },
data: { data: {
userId: userInfo.value.id,
goodId: productBrief.value.id, goodId: productBrief.value.id,
quantity: quantity.value quantity: quantity.value,
subtotal: productBrief.value.price * quantity.value,
isGoodType: productBrief.value.isGoodType
} }
}) })
if (res.data.code === 1) { if (res.data.code === 1) {
@ -104,7 +107,7 @@
// //
const decrease = () => { const decrease = () => {
// console.log('index-->',index); // console.log('index-->',index);
if (quantity.value != 1) { if (quantity.value > 0) {
quantity.value -= 1 quantity.value -= 1
} }
} }

View File

@ -2,7 +2,7 @@
<template> <template>
<view class="flex-col page"> <view class="flex-col page">
<view class="flex-col"> <view class="flex-col">
<view class="flex-col justify-start items-end text-wrapper"><text class="font text" @click="changeState">{{ stateText.topBtn }}</text></view> <view class="flex-col justify-start items-end text-wrapper"><text class="font text">编辑</text></view>
<!-- <view class="flex-col justify-start items-end text-wrapper"><text class="font text">完成</text></view> --> <!-- <view class="flex-col justify-start items-end text-wrapper"><text class="font text">完成</text></view> -->
<view class="flex-col section"> <view class="flex-col section">
<view class="flex-row justify-between self-stretch group"> <view class="flex-row justify-between self-stretch group">
@ -20,22 +20,23 @@
<view class="flex-row flex-1 self-center group_2"> <view class="flex-row flex-1 self-center group_2">
<image <image
class="shrink-0 image" class="shrink-0 image"
:src="item.cartGoodVO.goodImg" :src="item.goodVO.goodImg"
@click="jump_product" @click="jump_product"
/> />
<view class="flex-col flex-1 group_3 ml-12"> <view class="flex-col flex-1 group_3 ml-12">
<view class="flex-row group_4"> <view class="flex-row group_4">
<text class="font_2" @click="jump_product">{{ item.cartGoodVO.name }}</text> <text class="font_2" @click="jump_product">{{ item.goodVO.name }}</text>
<text class="font_2 ml-4" @click="jump_product">{{ item.cartGoodVO.type }}</text> <text class="font_2 ml-4" @click="jump_product">{{ item.goodVO.type }}</text>
</view> </view>
<view class="flex-row items-center mt-47"> <view class="flex-row items-center mt-47">
<view class="flex-row items-center self-stretch group_5"> <view class="flex-row items-center self-stretch group_5">
<text class="font_3 text_3" @click="jump_product"><text class="font_4"></text>{{ item.cartGoodVO.price }}</text> <text class="font_3 text_3" @click="jump_product"><text class="font_4"></text>{{ item.goodVO.price }}.<text class="font_4">00</text></text>
<!-- <image <!-- <image
class="image_6" class="image_6"
src="https://carbon2.obs.cn-north-4.myhuaweicloud.com:443/feiyi%2Ftest%2F0%2FJipaVPoQ-storeRmb.png" src="https://carbon2.obs.cn-north-4.myhuaweicloud.com:443/feiyi%2Ftest%2F0%2FJipaVPoQ-storeRmb.png"
/> --> /> -->
</view> </view>
</view> </view>
</view> </view>
</view> </view>
@ -121,7 +122,7 @@
src="https://carbon2.obs.cn-north-4.myhuaweicloud.com:443/feiyi%2Ftest%2F0%2FJipaVPoQ-storeRmb.png" src="https://carbon2.obs.cn-north-4.myhuaweicloud.com:443/feiyi%2Ftest%2F0%2FJipaVPoQ-storeRmb.png"
/> />
<text class="font text_12">{{ totalPrice }}</text> <text class="font text_12">{{ totalPrice }}</text>
<view class="flex-col justify-start items-center shrink-0 text-wrapper_3" @click="editOrSettle"><text class="text_11">{{ stateText.bottomBtn }}</text></view> <view class="flex-col justify-start items-center shrink-0 text-wrapper_3" @click="goToBuy"><text class="text_11">去结算</text></view>
<!-- <view class="flex-col justify-start items-center shrink-0 text-wrapper_3"><text class="text_11">删除</text></view> --> <!-- <view class="flex-col justify-start items-center shrink-0 text-wrapper_3"><text class="text_11">删除</text></view> -->
</view> </view>
</view> </view>
@ -129,7 +130,7 @@
</template> </template>
<script setup> <script setup>
import { ref , onMounted , toRaw} from 'vue' import { ref , onMounted} from 'vue'
import { onShow } from "@dcloudio/uni-app"; import { onShow } from "@dcloudio/uni-app";
import { baseUrl , testUrl ,suiUrl} from '../../../api/request'; import { baseUrl , testUrl ,suiUrl} from '../../../api/request';
const products = ref([]) const products = ref([])
@ -138,12 +139,12 @@ const allCheck = ref(false) //全选
const checkedData = ref([]) // const checkedData = ref([]) //
const totalPrice = ref(0) const totalPrice = ref(0)
const userInfo = wx.getStorageSync('userInfo') const userInfo = wx.getStorageSync('userInfo')
const stateText = ref({ onMounted(()=>{
topBtn: '编辑',
bottomBtn: '去结算'
}) })
onShow(()=>{ onShow(()=>{
getProductCart() // getProductCart() //
// getServiceCart()
}) })
//id //id
const getProductCart = async ()=>{ const getProductCart = async ()=>{
@ -154,13 +155,14 @@ const getProductCart = async ()=>{
'cookie': wx.getStorageSync('cookie') 'cookie': wx.getStorageSync('cookie')
} }
}) })
// console.log('res--->',res.data); // console.log(res.data);
if(res.data.code === 1) { if(res.data.code === 1) {
products.value = res.data.data products.value = res.data.data
products.value.forEach((item)=>{ products.value.forEach((item)=>{
item.checked = false item.checked = false
}) })
} }
console.log('res--->',res);
console.log('products-->',products.value); console.log('products-->',products.value);
} }
const getServiceCart =()=>{ const getServiceCart =()=>{
@ -179,32 +181,27 @@ const getTextStyle = (num) => ({
}); });
// //
const checkBoxChange =(event)=>{ const checkBoxChange =(event)=>{
console.log('方法被触发');
//checkboxvalue allChecktrue //checkboxvalue allChecktrue
console.log('length---->',event.detail.value.length); console.log('length---->',event.detail.value.length);
// console.log('product--->',products.value);
if(event.detail.value.length == products.value.length) { if(event.detail.value.length == products.value.length) {
allCheck.value = true allCheck.value = true
} else { } else {
allCheck.value = false allCheck.value = false
} }
checkedData.value = [] // checkedData.value = [{}] //
totalPrice.value = 0; totalPrice.value = 0;
let count = 0; //checkedDatanull let count = 0; //checkedDatanull
console.log('event--->',event.detail); console.log('event--->',event.detail);
if(event.detail.value.length) {
products.value[parseInt(event.detail.value)].checked = true; // products.value[parseInt(event.detail.value)].checked = true; //
} else {
products.value.forEach((item)=>{
item.checked = false
})
}
// //
for(let key in event.detail.value) { for(let key in event.detail.value) {
let temp = parseInt(event.detail.value[parseInt(key)]) // let temp = parseInt(event.detail.value[parseInt(key)]) //
computed(products.value[temp].cartGoodVO.price , products.value[temp].quantity) computed(products.value[temp].goodVO.price , products.value[temp].quantity)
} }
event.detail.value.forEach((item)=>{ event.detail.value.forEach((item)=>{
products.value[parseInt(item)].checked = true products.value[parseInt(item)].checked = true
// allCheck.value = false
}) })
//checkboxGroup detail.valueidcheckedtrue() //checkboxGroup detail.valueidcheckedtrue()
products.value.forEach((x)=>{ products.value.forEach((x)=>{
@ -218,11 +215,10 @@ const checkBoxChange =(event)=>{
console.log('products.value[parseInt(item)].goodId',products.value[parseInt(item)].goodId); console.log('products.value[parseInt(item)].goodId',products.value[parseInt(item)].goodId);
if(products.value[parseInt(item)] !== null) { if(products.value[parseInt(item)] !== null) {
// console.log('item--->',item); // console.log('item--->',item);
// checkedData.value[count] = { checkedData.value[count] = {
// goodId: products.value[parseInt(item)].goodId, goodId: products.value[parseInt(item)].goodId,
// quantity: products.value[parseInt(item)].quantity, quantity: products.value[parseInt(item)].quantity,
// } }
checkedData.value.push(products.value[parseInt(item)].id)
// console.log(products.value[parseInt(item)].goodId); // console.log(products.value[parseInt(item)].goodId);
count += 1 count += 1
} }
@ -239,13 +235,13 @@ const allChecked = ()=>{
if ( allCheck.value == true ) { if ( allCheck.value == true ) {
products.value.forEach((item)=>{ products.value.forEach((item)=>{
item.checked = true // item.checked = true //
computed(item.cartGoodVO.price , item.quantity) // console.log('item--->',item);
computed(item.goodVO.price , item.quantity)
}) })
// checkedData.value = products.value.map((item)=>({ checkedData.value = products.value.map((item)=>({
// goodId: item.goodId, goodId: item.goodId,
// quantity: item.quantity quantity: item.quantity
// })) //checkedData })) //checkedData
checkedData.value = products.value.map((item)=>( item.id ))
console.log('checkedData--->',checkedData.value); console.log('checkedData--->',checkedData.value);
} else { } else {
products.value.forEach((item)=>{ products.value.forEach((item)=>{
@ -255,24 +251,22 @@ const allChecked = ()=>{
} }
// //
const decrease =(index , item)=>{ //item const decrease =(index , item)=>{ //item
console.log('decrease,index-->',index); // console.log('index-->',index);
console.log('decrease,item-->',item); // console.log('item-->',item);
if(products.value[index].quantity > 1) { if(products.value[index].quantity > 1) {
products.value[index].quantity -= 1 products.value[index].quantity -= 1
if(item && products.value[index].quantity >= 1) { if(item && products.value[index].quantity >= 1) {
computed(-products.value[index].cartGoodVO.price, 1) computed(-products.value[index].goodVO.price, 1)
} }
} }
} }
// // 11.8
const increase =(index , item) =>{ //item const increase =(index , item) =>{ //item
console.log('increase,index-->',index);
console.log('increase,item-->',item);
if(products.value[index].quantity <= 99) { if(products.value[index].quantity <= 99) {
products.value[index].quantity += 1 products.value[index].quantity += 1
} }
if(item) { if(item) {
computed(products.value[index].cartGoodVO.price, 1) computed(products.value[index].goodVO.price, 1)
} }
} }
// //
@ -285,36 +279,11 @@ const jump_product =()=>{
url:'../../../pages/store-home/ProductDetails/ProductDetails' url:'../../../pages/store-home/ProductDetails/ProductDetails'
}) })
} }
const editOrSettle = async ()=>{ const goToBuy =()=>{
// console.log('checked--->',checkedData.value); console.log('要传到订单详情页面的checked--->',checkedData.value);
if(stateText.value.bottomBtn === '去结算') {
uni.navigateTo({ uni.navigateTo({
url: '/pages/order/product-waitpay/product-waitpay?cartInfo=' + JSON.stringify(checkedData.value) url: '/pages/order/product-waitpay/product-waitpay?cartInfo=' + JSON.stringify(checkedData.value)
}) })
} else {
const res = await uni.request({
url: baseUrl + '/cart/delete',
method: 'POST',
data: checkedData.value ,
header: {
'cookie': wx.getStorageSync('cookie')
}
})
console.log(res.data);
if(res.data.code === 1) {
getProductCart() //
totalPrice.value = 0
}
}
}
const changeState =()=>{ //
if(stateText.value.topBtn === '编辑') {
stateText.value.topBtn = '完成',
stateText.value.bottomBtn = '删除'
} else {
stateText.value.topBtn = '编辑',
stateText.value.bottomBtn = '去结算'
}
} }
</script> </script>