|
@@ -3,7 +3,10 @@
|
|
|
<div class="default-width py-5" v-if="state.goodsInfo && Object.keys(state.goodsInfo).length">
|
|
|
<div class="d-flex justify-space-between">
|
|
|
<v-btn class="mb-3" size="large" color="primary" variant="text" prepend-icon="mdi-chevron-triple-left" @click="router.go(-1)">返回上一页</v-btn>
|
|
|
- <v-btn v-if="getToken()" class="mb-3" size="large" color="primary" variant="text" prepend-icon="mdi-account-circle-outline" to="/mall/user/order">我的订单</v-btn>
|
|
|
+ <div v-if="getToken()">
|
|
|
+ <v-btn class="mb-3" size="large" color="primary" variant="text" prepend-icon="mdi-account-circle-outline" to="/mall/user/order">我的订单</v-btn>
|
|
|
+ <v-btn class="mb-3 ml-1" size="large" color="primary" variant="text" prepend-icon="mdi-cart-outline" to="/mall/cart">购物车</v-btn>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<v-card class="carousel border-radius-8 white-bgc pa-5" style="width: 100%;">
|
|
|
<div class=" d-flex">
|
|
@@ -44,6 +47,7 @@
|
|
|
:goodsInfo="state.goodsInfo"
|
|
|
@change="onSkuChange"
|
|
|
@buy="onBuy"
|
|
|
+ @addCart="onAddCart"
|
|
|
></selectSku>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -72,6 +76,7 @@
|
|
|
<script setup>
|
|
|
defineOptions({name: 'goods-details'})
|
|
|
import { getProductDetail } from '@/api/mall/product'
|
|
|
+import { addCart } from '@/api/mall/cart'
|
|
|
import selectSku from './details/s-select-sku.vue'
|
|
|
import describe from './details/describe.vue'
|
|
|
import comment from './details/detail-comment-card.vue'
|
|
@@ -146,46 +151,24 @@ const skuInfo = ref(null) // 购买商品规格信息
|
|
|
const onBuy = async (e) => {
|
|
|
if (!getToken()) return handleLogin()
|
|
|
if (!e?.id) return Snackbar.warning('请选择商品规格!')
|
|
|
- console.log('购买规格信息:', e)
|
|
|
+ // console.log('购买规格信息:', e)
|
|
|
//
|
|
|
skuInfo.value = JSON.stringify({
|
|
|
items: [{ skuId: e.id, count: e.goods_num, categoryId: state.goodsInfo.categoryId, }]
|
|
|
})
|
|
|
showPay.value = true
|
|
|
}
|
|
|
-// Snackbar.warning('购买功能暂未开放,敬请期待!')
|
|
|
|
|
|
-// onMounted(() => {
|
|
|
-// onBuy({
|
|
|
-// id: 45,
|
|
|
-// properties: [
|
|
|
-// {
|
|
|
-// propertyId: 19,
|
|
|
-// propertyName: "颜色",
|
|
|
-// valueId: 31,
|
|
|
-// valueName: "酒红色"
|
|
|
-// },
|
|
|
-// {
|
|
|
-// propertyId: 21,
|
|
|
-// propertyName: "材质",
|
|
|
-// valueId: 33,
|
|
|
-// valueName: "纯棉"
|
|
|
-// }
|
|
|
-// ],
|
|
|
-// price: 2190,
|
|
|
-// marketPrice: 2190,
|
|
|
-// vipPrice: null,
|
|
|
-// picUrl: "http://menduner.citupro.com:6868/admin-api/infra/file/24/get/84d51e3ce5c466667c8cdf4b05c432b98a845559ef81461a78677c08a0608d62.jpg",
|
|
|
-// stock: 99,
|
|
|
-// weight: 0.1,
|
|
|
-// volume: 0.1,
|
|
|
-// value_id_array: [
|
|
|
-// 31,
|
|
|
-// 33
|
|
|
-// ],
|
|
|
-// goods_num: 1
|
|
|
-// })
|
|
|
-// })
|
|
|
+// 添加购物车
|
|
|
+const onAddCart = async (e) => {
|
|
|
+ if (!e.id) {
|
|
|
+ Snackbar.warning('请选择商品规格')
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ await addCart({ skuId: e.id, count: e.goods_num })
|
|
|
+ Snackbar.success('已添加到购物车~')
|
|
|
+ // 刷新购物车列表
|
|
|
+}
|
|
|
|
|
|
const confirmRef = ref()
|
|
|
const handleSubmit = () => {
|