diff --git a/package-lock.json b/package-lock.json index ae01bac..ee2775d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,78 @@ { - "name": "jiangchengfeiyi-xiaochengxu", - "lockfileVersion": 3, "requires": true, - "packages": { - "": { - "dependencies": { - "mitt": "^3.0.1" + "lockfileVersion": 1, + "dependencies": { + "@babel/runtime": { + "version": "7.26.0", + "resolved": "https://registry.npmmirror.com/@babel/runtime/-/runtime-7.26.0.tgz", + "integrity": "sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==", + "requires": { + "regenerator-runtime": "^0.14.0" } }, - "node_modules/mitt": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz", - "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==" + "complex.js": { + "version": "2.4.2", + "resolved": "https://registry.npmmirror.com/complex.js/-/complex.js-2.4.2.tgz", + "integrity": "sha512-qtx7HRhPGSCBtGiST4/WGHuW+zeaND/6Ld+db6PbrulIB1i2Ev/2UPiqcmpQNPSyfBKraC0EOvOKCB5dGZKt3g==" + }, + "decimal.js": { + "version": "10.4.3", + "resolved": "https://registry.npmmirror.com/decimal.js/-/decimal.js-10.4.3.tgz", + "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA==" + }, + "escape-latex": { + "version": "1.2.0", + "resolved": "https://registry.npmmirror.com/escape-latex/-/escape-latex-1.2.0.tgz", + "integrity": "sha512-nV5aVWW1K0wEiUIEdZ4erkGGH8mDxGyxSeqPzRNtWP7ataw+/olFObw7hujFWlVjNsaDFw5VZ5NzVSIqRgfTiw==" + }, + "fraction.js": { + "version": "5.2.1", + "resolved": "https://registry.npmmirror.com/fraction.js/-/fraction.js-5.2.1.tgz", + "integrity": "sha512-Ah6t/7YCYjrPUFUFsOsRLMXAdnYM+aQwmojD2Ayb/Ezr82SwES0vuyQ8qZ3QO8n9j7W14VJuVZZet8U3bhSdQQ==" + }, + "javascript-natural-sort": { + "version": "0.7.1", + "resolved": "https://registry.npmmirror.com/javascript-natural-sort/-/javascript-natural-sort-0.7.1.tgz", + "integrity": "sha512-nO6jcEfZWQXDhOiBtG2KvKyEptz7RVbpGP4vTD2hLBdmNQSsCiicO2Ioinv6UI4y9ukqnBpy+XZ9H6uLNgJTlw==" + }, + "mathjs": { + "version": "14.0.1", + "resolved": "https://registry.npmmirror.com/mathjs/-/mathjs-14.0.1.tgz", + "integrity": "sha512-yyJgLwC6UXuve724np8tHRMYaTtb5UqiOGQkjwbSXgH8y1C/LcJ0pvdNDZLI2LT7r+iExh2Y5HwfAY+oZFtGIQ==", + "requires": { + "@babel/runtime": "^7.25.7", + "complex.js": "^2.2.5", + "decimal.js": "^10.4.3", + "escape-latex": "^1.2.0", + "fraction.js": "^5.2.1", + "javascript-natural-sort": "^0.7.1", + "seedrandom": "^3.0.5", + "tiny-emitter": "^2.1.0", + "typed-function": "^4.2.1" + } + }, + "mitt": { + "version": "3.0.1" + }, + "regenerator-runtime": { + "version": "0.14.1", + "resolved": "https://registry.npmmirror.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", + "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==" + }, + "seedrandom": { + "version": "3.0.5", + "resolved": "https://registry.npmmirror.com/seedrandom/-/seedrandom-3.0.5.tgz", + "integrity": "sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==" + }, + "tiny-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz", + "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==" + }, + "typed-function": { + "version": "4.2.1", + "resolved": "https://registry.npmmirror.com/typed-function/-/typed-function-4.2.1.tgz", + "integrity": "sha512-EGjWssW7Tsk4DGfE+5yluuljS1OGYWiI1J6e8puZz9nTMM51Oug8CD5Zo4gWMsOhq5BI+1bF+rWTm4Vbj3ivRA==" } } } diff --git a/package.json b/package.json index 055b94a..0df35ed 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "dependencies": { + "mathjs": "^14.0.1", "mitt": "^3.0.1" } } diff --git a/pages/Shopping-cart/component/addProduct.vue b/pages/Shopping-cart/component/addProduct.vue index 2d46cdc..c1c58c7 100644 --- a/pages/Shopping-cart/component/addProduct.vue +++ b/pages/Shopping-cart/component/addProduct.vue @@ -96,7 +96,7 @@ console.log('失败原因-->', res.data); uni.showToast({ icon: 'error', - title: "请求失败" + title: res.data.message }) return; } diff --git a/pages/Shopping-cart/newaddress_Info/newaddress_Info.vue b/pages/Shopping-cart/newaddress_Info/newaddress_Info.vue index 1029029..74f8342 100644 --- a/pages/Shopping-cart/newaddress_Info/newaddress_Info.vue +++ b/pages/Shopping-cart/newaddress_Info/newaddress_Info.vue @@ -14,10 +14,11 @@ 所在地区 - + + @@ -47,24 +48,34 @@ \ No newline at end of file diff --git a/pages/Shopping-cart/productmain/productmain.vue b/pages/Shopping-cart/productmain/productmain.vue index 9c1532d..e74d073 100644 --- a/pages/Shopping-cart/productmain/productmain.vue +++ b/pages/Shopping-cart/productmain/productmain.vue @@ -21,16 +21,16 @@ - {{ item.cartGoodVO.name }} - 【{{ item.cartGoodVO.type }}】 + {{ item.cartGoodVO.name }} + 【{{ item.cartGoodVO.type }}】 - {{ item.cartGoodVO.price }} + {{ item.cartGoodVO.price }} ',products.value); } +const deleteProduct = async (idArr) =>{ //删除商品 + const res = await uni.request({ + url: baseUrl + '/cart/delete', + method: 'POST', + data: idArr , + header: { + 'cookie': wx.getStorageSync('cookie') + } + }) + console.log(res.data); + if(res.data.code === 1) { + getProductCart() //重新获取购物车信息 + totalPrice.value = 0 + } +} const getServiceCart =()=>{ console.log('获取服务类商品方法被触发'); } @@ -241,10 +257,6 @@ const allChecked = ()=>{ item.checked = true //将全部选项选上 computed(item.cartGoodVO.price , item.quantity) }) - // checkedData.value = products.value.map((item)=>({ - // goodId: item.goodId, - // quantity: item.quantity - // })) //将商品全部信息保存到checkedData中 checkedData.value = products.value.map((item)=>( item.id )) console.log('checkedData--->',checkedData.value); } else { @@ -268,43 +280,61 @@ const decrease =(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 < products.value[index].cartGoodVO.inventory) { + if(item && products.value[index].quantity <= products.value[index].cartGoodVO.inventory) { + computed(products.value[index].cartGoodVO.price, 1) + } products.value[index].quantity += 1 } - if(item) { - computed(products.value[index].cartGoodVO.price, 1) - } } //计算方法 const computed =( price , quantity )=>{ - totalPrice.value += price * quantity + totalPrice.value = math.round(totalPrice.value+price * quantity,2) return totalPrice.value } -const jump_product =()=>{ +const jump_product =(gid)=>{ uni.navigateTo({ - url:'../../../pages/store-home/ProductDetails/ProductDetails' + url:'../../../pages/store-home/ProductDetails/ProductDetails?gid=' + JSON.stringify(gid) }) } -const editOrSettle = async ()=>{ +const editOrSettle = async ()=>{ //去结算或者删除状态方法 // console.log('要传到订单详情页面的checked--->',checkedData.value); if(stateText.value.bottomBtn === '去结算') { - uni.navigateTo({ - url: '/pages/order/product-waitpay/product-waitpay?cartInfo=' + JSON.stringify(checkedData.value) - }) - } else { const res = await uni.request({ - url: baseUrl + '/cart/delete', + url: baseUrl + '/cart/cart/list/error', method: 'POST', - data: checkedData.value , header: { 'cookie': wx.getStorageSync('cookie') } }) console.log(res.data); - if(res.data.code === 1) { - getProductCart() //重新获取购物车信息 - totalPrice.value = 0 + if(res.data.data.length != 0) { + uni.showModal({ + title: '提示', + content: '购物车商品发生改变,点击移除变化商品', + showCancel: false, + success: (e)=>{ + if(e.confirm) { + deleteProduct(res.data.data) + } + } + }) + } else { + uni.navigateTo({ + url: '/pages/order/product-waitpay/product-waitpay?cartInfo=' + JSON.stringify(checkedData.value) + }) } + } else { + uni.showModal({ + title: '提示', + content: '是否删除商品?', + success: (e) => { + if(e.confirm) + deleteProduct(checkedData.value) + else if(e.cancel) + return; + } + }) } } const changeState =()=>{ //修改购物车订单方法 diff --git a/pages/order/component/addressComponent.vue b/pages/order/component/addressComponent.vue index c88317e..bdeaa26 100644 --- a/pages/order/component/addressComponent.vue +++ b/pages/order/component/addressComponent.vue @@ -94,11 +94,15 @@ const deleteAddress = async( id ) =>{ const res = await uni.request({ url: baseUrl + '/address/delete', method: 'POST', + header: { + 'cookie': wx.getStorageSync('cookie') + }, data: { id: id } }) + // console.log(res.data); if( res.data.code === 1 ) { getAddressList() - console.log("删除地址成功"); + // console.log("删除地址成功"); } } diff --git a/pages/order/product-waitpay/product-waitpay.vue b/pages/order/product-waitpay/product-waitpay.vue index 4a7879f..93eaa5e 100644 --- a/pages/order/product-waitpay/product-waitpay.vue +++ b/pages/order/product-waitpay/product-waitpay.vue @@ -167,6 +167,7 @@ import emitter from '../../../utils/emitter' import { onLoad , onShow } from "@dcloudio/uni-app"; import { baseUrl } from '../../../api/request'; import addressComponentVue from '../component/addressComponent.vue'; //导入组件 +import { stateMap } from '../../../common/global'; //一些暂时变量 const num = ref(1) const price = ref(138) @@ -194,6 +195,7 @@ onMounted(() => { emitter.on('addressInfo', (val) =>{ addressRealInfo.value = val }) + // console.log(stateMap.get('订单已经退款')); }) onLoad((options)=>{ totalInfo.value = JSON.parse(options.cartInfo) @@ -227,8 +229,7 @@ const getDefaultAddress = async () =>{ method: 'POST', header: { cookie: wx.getStorageSync('cookie') - }, - data: { id: userInfo.value.id } + } }) //根据for循环遍历默认地址 for(let key in res.data.data) { diff --git a/pages/store-home/ProductDetails/ProductDetails.vue b/pages/store-home/ProductDetails/ProductDetails.vue index eb97a28..c499ec9 100644 --- a/pages/store-home/ProductDetails/ProductDetails.vue +++ b/pages/store-home/ProductDetails/ProductDetails.vue @@ -1,10 +1,15 @@