购物车完成,解决计算精度问题
This commit is contained in:
parent
983276be5c
commit
9246a0686c
81
package-lock.json
generated
81
package-lock.json
generated
|
@ -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=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"mathjs": "^14.0.1",
|
||||
"mitt": "^3.0.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
console.log('失败原因-->', res.data);
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
title: "请求失败"
|
||||
title: res.data.message
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -14,10 +14,11 @@
|
|||
<view class="flex-row items-center group_4">
|
||||
<text class="font_2 text_5">所在地区</text>
|
||||
<view class="flex-col justify-start flex-1 relative group_5 ml-13">
|
||||
<input class="text-wrapper_3" v-model="addressParam.region" placeholder="请输入地区" />
|
||||
<!-- <input class="text-wrapper_3" v-model="addressParam.region" placeholder="请输入地区" /> -->
|
||||
<view class="zujian"><addSelected></addSelected></view>
|
||||
<image
|
||||
class="image pos"
|
||||
:src="dingwei"
|
||||
src="https://carbon2.obs.cn-north-4.myhuaweicloud.com:443/feiyi%2Ftest%2F0%2FkYDyjpPh-dingwei.png"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -47,24 +48,34 @@
|
|||
<script setup>
|
||||
import {ref , onMounted} from 'vue'
|
||||
import { testUrl , baseUrl , suiUrl } from '../../../api/request';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
const userInfo = ref({})
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import addSelected from '../../../pages/order/component/addSelected.vue'
|
||||
import emitter from '../../../utils/emitter';
|
||||
const addressParam = ref({
|
||||
userId: 0,
|
||||
name: "",
|
||||
phone: "",
|
||||
region: "",
|
||||
detailAddress: "",
|
||||
isDefault: 0
|
||||
})
|
||||
const isAdd = ref(false)
|
||||
//接受编辑按钮传来的地址信息
|
||||
onLoad((options)=>{
|
||||
addressParam.value = JSON.parse(options.editInfo) //将原来的地址信息赋值给原来的addressParam
|
||||
// console.log('待编辑地址--->',addressParam.value);
|
||||
if(JSON.stringify(options) != '{}') {
|
||||
addressParam.value = JSON.parse(options.editInfo) //将原来的地址信息赋值给原来的addressParam
|
||||
} else {
|
||||
isAdd.value = true
|
||||
}
|
||||
// console.log(options);
|
||||
})
|
||||
onShow(()=>{
|
||||
})
|
||||
onMounted(()=>{
|
||||
userInfo.value = uni.getStorageSync("userInfo")
|
||||
// console.log('userInfo-->', userInfo.value.id);
|
||||
emitter.on('region',(val)=>{ //将地址弹窗的值传到当前页面
|
||||
addressParam.value.region = val
|
||||
// console.log('val--->',val);
|
||||
})
|
||||
if(!isAdd.value) emitter.emit('addRegion', addressParam.value.region)
|
||||
})
|
||||
//勾选默认地址的选项
|
||||
const defaultAddress =(event)=>{
|
||||
|
@ -72,8 +83,8 @@ const defaultAddress =(event)=>{
|
|||
}
|
||||
//发送添加新增地址的请求
|
||||
const newAddress = async () =>{
|
||||
console.log(addressParam.value);
|
||||
addressParam.value.userId = userInfo.value.id
|
||||
// console.log(addressParam.value);
|
||||
// addressParam.value.userId = userInfo.value.id
|
||||
const values = Object.values(addressParam.value);
|
||||
// 使用some()方法来检查是否有任何值为空
|
||||
if (values.some(value => value === null || value === undefined || value === '')) {
|
||||
|
@ -83,34 +94,60 @@ const newAddress = async () =>{
|
|||
})
|
||||
return;
|
||||
}
|
||||
const res = await uni.request({
|
||||
url: baseUrl + '/address/add',
|
||||
method: 'POST',
|
||||
header: {
|
||||
'cookie': wx.getStorageSync('cookie')
|
||||
},
|
||||
data: {...addressParam.value}
|
||||
})
|
||||
console.log('res==>',res.data);
|
||||
if(res.data.code === 1) {
|
||||
console.log(addressParam.value);
|
||||
if(addressParam.value.id != undefined) {
|
||||
const res = await uni.request({
|
||||
url: baseUrl + '/address/update',
|
||||
method: 'POST',
|
||||
header: {
|
||||
'cookie': wx.getStorageSync('cookie')
|
||||
},
|
||||
data: { ...addressParam.value }
|
||||
})
|
||||
console.log('res1==>',res.data);
|
||||
sucRes(res.data.code)
|
||||
} else {
|
||||
const res = await uni.request({
|
||||
url: baseUrl + '/address/add',
|
||||
method: 'POST',
|
||||
header: {
|
||||
'cookie': wx.getStorageSync('cookie')
|
||||
},
|
||||
data: {...addressParam.value}
|
||||
})
|
||||
console.log('res2==>',res.data);
|
||||
sucRes(res.data.code)
|
||||
}
|
||||
// if(res.data.code === 1) {
|
||||
// uni.navigateBack({ //返回上一页
|
||||
// })
|
||||
// } else {
|
||||
// uni.showToast({
|
||||
// icon: 'error',
|
||||
// title: "新增地址失败"
|
||||
// })
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
const sucRes =(res)=>{ //请求成功执行的方法
|
||||
if(res === 1) {
|
||||
uni.navigateBack({ //返回上一页
|
||||
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'error',
|
||||
title: "新增地址失败"
|
||||
title: '新增地址失败'
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
//跳转回订单页面
|
||||
const jump =()=> {
|
||||
uni.navigateTo({
|
||||
url: '../../../pages/Shopping-cart/address/address'
|
||||
})
|
||||
}
|
||||
// const jump =()=> {
|
||||
// uni.navigateTo({
|
||||
// url: '../../../pages/Shopping-cart/address/address'
|
||||
// })
|
||||
// }
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -238,6 +275,11 @@ const jump =()=> {
|
|||
font-size: 30rpx;
|
||||
font-family: Open Sans;
|
||||
line-height: 27.9rpx;
|
||||
}
|
||||
.zujian{ //地址组件样式
|
||||
height: 100rpx;
|
||||
width: 450rpx;
|
||||
margin-left: 50rpx;
|
||||
}
|
||||
@import url(../../../common/css/global.css);
|
||||
</style>
|
|
@ -21,16 +21,16 @@
|
|||
<image
|
||||
class="shrink-0 image"
|
||||
:src="item.cartGoodVO.goodImg"
|
||||
@click="jump_product"
|
||||
@click="jump_product(item.goodId)"
|
||||
/>
|
||||
<view class="flex-col flex-1 group_3 ml-12">
|
||||
<view class="flex-row group_4">
|
||||
<text class="font_2" @click="jump_product">{{ item.cartGoodVO.name }}</text>
|
||||
<text class="font_2 ml-4" @click="jump_product">【{{ item.cartGoodVO.type }}】</text>
|
||||
<text class="font_2" @click="jump_product(item.goodId)">{{ item.cartGoodVO.name }}</text>
|
||||
<text class="font_2 ml-4" @click="jump_product(item.goodId)">【{{ item.cartGoodVO.type }}】</text>
|
||||
</view>
|
||||
<view class="flex-row items-center mt-47">
|
||||
<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(item.goodId)"><text class="font_4">¥</text>{{ item.cartGoodVO.price }}</text>
|
||||
<!-- <image
|
||||
class="image_6"
|
||||
src="https://carbon2.obs.cn-north-4.myhuaweicloud.com:443/feiyi%2Ftest%2F0%2FJipaVPoQ-storeRmb.png"
|
||||
|
@ -132,12 +132,13 @@
|
|||
import { ref , onMounted , toRaw} from 'vue'
|
||||
import { onShow } from "@dcloudio/uni-app";
|
||||
import { baseUrl , testUrl ,suiUrl} from '../../../api/request';
|
||||
import * as math from 'mathjs'
|
||||
const products = ref([])
|
||||
const current = ref(1) //用于判断是实体类商品还是服务类商品
|
||||
const allCheck = ref(false) //全选
|
||||
const checkedData = ref([]) //选择的暂存保存数组
|
||||
const totalPrice = ref(0)
|
||||
const userInfo = wx.getStorageSync('userInfo')
|
||||
// const userInfo = wx.getStorageSync('userInfo')
|
||||
const stateText = ref({
|
||||
topBtn: '编辑',
|
||||
bottomBtn: '去结算'
|
||||
|
@ -163,6 +164,21 @@ const getProductCart = async ()=>{
|
|||
}
|
||||
console.log('products-->',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 =()=>{ //修改购物车订单方法
|
||||
|
|
|
@ -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("删除地址成功");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
<template>
|
||||
<view class="flex-col page">
|
||||
<image
|
||||
<!-- <image
|
||||
mode="aspectFit"
|
||||
class="self-stretch image"
|
||||
:src="goodObject.goodImg"
|
||||
/>
|
||||
/> -->
|
||||
<swiper class="swiper-box">
|
||||
<swiper-item v-for="(item,index) in imgArr" :key="index" >
|
||||
<image mode="aspectFit" class="self-stretch image" :src="item" ></image>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
<view class="flex-col self-stretch section_2">
|
||||
<view class="self-start group">
|
||||
<text class="font text_2">¥</text>
|
||||
|
@ -83,21 +88,13 @@ import emitter from '../../../utils/emitter'
|
|||
import addProduct from '../../Shopping-cart/component/addProduct.vue';
|
||||
const popup = ref(null) //弹窗对象
|
||||
const goodObject = ref({}) //商品对象
|
||||
// const checkedData = ref([{}]) //对齐批量购买
|
||||
const idInfo = ref([]) //数量 + 商品id
|
||||
const userInfo = ref({}) //用户信息
|
||||
const labelList = ref([]) //标签
|
||||
const imgArr = ref([])
|
||||
//转换上一页面传来的商品
|
||||
onLoad((options) => {
|
||||
goodObject.value = JSON.parse(options.info) //将string转为objec赋值给商品对象
|
||||
idInfo.value = [{
|
||||
goodId: goodObject.value.id,
|
||||
quantity: 1 //暂时为1
|
||||
}]
|
||||
labelList.value = goodObject.value.label.split(";") //分割字符串,生成标签数组
|
||||
labelList.value = labelList.value.filter((s)=>{ //使用filter将最后一个空值去掉
|
||||
return s
|
||||
})
|
||||
getProduct(JSON.parse(options.gid)) //页面加载的时候获取商品信息
|
||||
})
|
||||
onShow(()=>{
|
||||
userInfo.value = wx.getStorageSync('userInfo') //获取用户信息
|
||||
|
@ -109,6 +106,30 @@ onMounted(()=>{
|
|||
})
|
||||
getFonts()
|
||||
})
|
||||
const getProduct = async (gid) =>{ //根据商品获取商品信息
|
||||
const res = await uni.request({
|
||||
url: baseUrl + '/goods/getById',
|
||||
method: 'POST',
|
||||
data: { id: gid },
|
||||
header: {
|
||||
cookie: wx.getStorageSync('cookie')
|
||||
}
|
||||
})
|
||||
// console.log('请求请求--->',res.data);
|
||||
if(res.data.code === 1) {
|
||||
goodObject.value = res.data.data
|
||||
imgArr.value = res.data.data.goodImg.split(';') //将后端传来的图片字符串转为图片数组
|
||||
// console.log(imgArr.value);
|
||||
labelList.value = goodObject.value.label.split(';') //分割字符串,生成标签数组
|
||||
labelList.value = labelList.value.filter((s)=>{ //使用filter将最后一个空值去掉
|
||||
return s
|
||||
})
|
||||
idInfo.value = [{
|
||||
goodId: goodObject.value.id,
|
||||
quantity: 1 //暂时为1
|
||||
}]
|
||||
}
|
||||
}
|
||||
const loadPop =()=>{
|
||||
popup.value.open('bottom') //从底部弹出
|
||||
emitter.emit('product',goodObject.value)
|
||||
|
@ -158,11 +179,11 @@ const getFonts =()=>{
|
|||
overflow-x: hidden;
|
||||
}
|
||||
.image {
|
||||
width: 100vw;
|
||||
height: 72vw;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.section_2 {
|
||||
margin-top: 20.63rpx;
|
||||
// margin-top: 20.63rpx;
|
||||
padding-left: 18.75rpx;
|
||||
padding-top: 19.2rpx;
|
||||
background-color: #ffffff;
|
||||
|
@ -367,5 +388,9 @@ const getFonts =()=>{
|
|||
.text_18 {
|
||||
line-height: 27.77rpx;
|
||||
}
|
||||
.swiper-box {
|
||||
width: 100%;
|
||||
height: calc(150vw * 9 / 16);
|
||||
}
|
||||
@import url(../../../common/css/global.css);
|
||||
</style>
|
|
@ -10,7 +10,7 @@
|
|||
</view>
|
||||
<view class="flex-col justify-start items-center image-wrapper pos_1">
|
||||
<image class="shrink-0 image_2"
|
||||
src="" />
|
||||
src="https://carbon2.obs.cn-north-4.myhuaweicloud.com:443/feiyi%2Ftest%2F0%2FloZarLZD-%E6%B5%8B%E8%AF%95%E6%8F%92%E5%85%A5.jpg" />
|
||||
</view>
|
||||
<!-- 类别列表 -->
|
||||
<view class="flex-col justify-start section_3 pos_9">
|
||||
|
@ -40,7 +40,7 @@
|
|||
<scroll-view scroll-y class="scrollable-content">
|
||||
<view class="flex-row section_9 list-item_2 mt-5" v-for="(item, index) in productList" :key="index" @click="goToProduct(item)">
|
||||
<image class="self-center image_4"
|
||||
:src="item.goodImg" />
|
||||
:src="item.goodImg.split(';')[0]" />
|
||||
<view style="width: 220rpx;" class="flex-col items-start self-center group_3">
|
||||
<text class="font_2 text_5">{{ item.name }}</text>
|
||||
<text class="font_3 mt-13">{{ item.intro }}</text>
|
||||
|
@ -55,9 +55,7 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref,onMounted, toRaw
|
||||
} from 'vue';
|
||||
import { ref,onMounted, toRaw } from 'vue';
|
||||
import { baseUrl, testUrl , suiUrl} from '@/api/request';
|
||||
const currentColor = ref(0);
|
||||
const sort =ref([{}]) //商品类别对象数组
|
||||
|
@ -135,7 +133,7 @@ const getBoxStyle = (index) => ({
|
|||
|
||||
const goToProduct = (item) => {
|
||||
uni.navigateTo({
|
||||
url: '../../../pages/store-home/ProductDetails/ProductDetails?info=' + JSON.stringify(item)
|
||||
url: '../../../pages/store-home/ProductDetails/ProductDetails?gid=' + JSON.stringify(item.id)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue
Block a user