From 25f9813687f9c421d2815afd0cdf77ae38669c26 Mon Sep 17 00:00:00 2001 From: zc <2064281269@qq.com> Date: Sun, 19 Oct 2025 08:24:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=8B=E5=8D=95=E5=AE=8C=E6=88=90?= =?UTF-8?q?=EF=BC=88=E4=B8=8B=E4=B8=80=E6=AD=A5=EF=BC=9A=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/extensions.json | 10 +- components.d.ts | 11 +- src/api/index.ts | 2 +- src/api/{commodity.ts => shop.ts} | 5 + src/assets/variables.scss | 1 + src/utils/page.ts | 6 + .../components/address-list.vue | 48 +++++--- .../components/all-review.vue | 6 +- .../components/review-single.vue | 11 +- .../components/​​shopping-cart​.vue | 114 +++++++++++++++--- src/views/commodity-detail/index.vue | 81 ++++++++++--- src/views/demo/index.vue | 4 +- src/views/order/index.vue | 17 +++ src/views/search-container/index.vue | 39 +++++- 14 files changed, 281 insertions(+), 74 deletions(-) rename src/api/{commodity.ts => shop.ts} (60%) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index c92168f..0e1afa7 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,6 +3,14 @@ "Vue.volar", "dbaeumer.vscode-eslint", "EditorConfig.EditorConfig", - "esbenp.prettier-vscode" + "esbenp.prettier-vscode", + "zhuangtongfa.Material-theme", + "PKief.material-icon-theme", + "ms-vscode.vscode-typescript-next", + "pranaygp.vscode-css-peek", + "ecmel.vscode-html-css", + "formulahendry.auto-rename-tag", + "bradlc.vscode-tailwindcss", + "unocss.unocss" ] } diff --git a/components.d.ts b/components.d.ts index c822f55..7ef8bc4 100644 --- a/components.d.ts +++ b/components.d.ts @@ -10,15 +10,22 @@ declare module 'vue' { export interface GlobalComponents { RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] + VanArea: typeof import('vant/es')['Area'] VanButton: typeof import('vant/es')['Button'] VanCell: typeof import('vant/es')['Cell'] VanCellGroup: typeof import('vant/es')['CellGroup'] VanField: typeof import('vant/es')['Field'] + VanForm: typeof import('vant/es')['Form'] VanIcon: typeof import('vant/es')['Icon'] - VanRate: typeof import('vant/es')['Rate'] + VanNoticeBar: typeof import('vant/es')['NoticeBar'] + VanPopover: typeof import('vant/es')['Popover'] + VanPopup: typeof import('vant/es')['Popup'] VanSearch: typeof import('vant/es')['Search'] + VanStepper: typeof import('vant/es')['Stepper'] + VanSwipe: typeof import('vant/es')['Swipe'] + VanSwipeItem: typeof import('vant/es')['SwipeItem'] + VanSwitch: typeof import('vant/es')['Switch'] VanTab: typeof import('vant/es')['Tab'] VanTabs: typeof import('vant/es')['Tabs'] - VanUploader: typeof import('vant/es')['Uploader'] } } diff --git a/src/api/index.ts b/src/api/index.ts index 46cc6fd..e6595f8 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,6 +1,6 @@ import axios from '@/utils/axios' import user from './user' -import shop from './commodity' +import shop from './shop' import common from './common' const totalApiConfig = { user, shop, common } diff --git a/src/api/commodity.ts b/src/api/shop.ts similarity index 60% rename from src/api/commodity.ts rename to src/api/shop.ts index 2582ba1..ad8928e 100644 --- a/src/api/commodity.ts +++ b/src/api/shop.ts @@ -1,8 +1,13 @@ // 商品维度接口 const shop = { + // 商品 searchCommodityList: ['/index/page/list'], // 获取商品列表接口 getCommodityDetail: ['/index/product/detail'], // 获取商品详情 getReviewList: ['/comment/list'], // 获取评价接口 + addCart: ['/shipping/cart/addOrUpdate'], // 添加购物车接口 + order: ['/order/add'], // 下单 + // 订单 + orderList: ['/order/list'], // 订单列表 } export default shop diff --git a/src/assets/variables.scss b/src/assets/variables.scss index fa5b16a..41d9873 100644 --- a/src/assets/variables.scss +++ b/src/assets/variables.scss @@ -1,4 +1,5 @@ $theme-color: #01cf24; +$theme-light-color: #e4fdea; $theme-disabled-color: #cefad5; .theme-bg-color { diff --git a/src/utils/page.ts b/src/utils/page.ts index e9f9476..fac102e 100644 --- a/src/utils/page.ts +++ b/src/utils/page.ts @@ -1,3 +1,4 @@ +import api from '@/api' import { closeToast, showLoadingToast, type ToastWrapperInstance } from 'vant' interface ApiType { @@ -61,3 +62,8 @@ window.useTipDialog = ( tipDialogData.show = true tipDialogData.callback = callback } + +// 添加购物车 +export const handleAddCart = async (skuId: number, num: number = 1) => { + await api.shop.addCart.post({ num, skuId }) +} diff --git a/src/views/commodity-detail/components/address-list.vue b/src/views/commodity-detail/components/address-list.vue index aa2dc4f..c69ed08 100644 --- a/src/views/commodity-detail/components/address-list.vue +++ b/src/views/commodity-detail/components/address-list.vue @@ -11,24 +11,24 @@
- +
- +
@@ -42,12 +42,15 @@ const model = defineModel() const addressFormType = defineModel<'add' | 'edit'>('addressFormType') const showAddAddressFormDialog = defineModel('showAddAddressFormDialog') const isUpDateAddressList = defineModel('isUpDateAddressList') +const props = defineProps<{ curAddressData: Recordable }>() const addressList = ref([]) +const chooseAddressData = ref({}) const emits = defineEmits(['edit', 'confirm']) watch(model, (val) => { val && handleGetAddressData() + val && (chooseAddressData.value = { ...props.curAddressData }) }) // 是否需要更新地址列表 @@ -68,20 +71,26 @@ const onAddOrEditAddress = (type: 'edit' | 'add', data?: any) => { const handleGetAddressData = () => { api.user.getAddressList.post().then((res) => { - addressList.value = res.data.rows.map((item) => { - const originData = { ...item } - return { - id: item.id, - name: item.buyerName, - tel: item.buyerPhone, - area: item.contry + item.province + item.city + item.district, - detail: item.detail, - isDefault: item.status === 'default', - originData, - } - }) + addressList.value = res.data.rows + .filter((item) => item.status !== 'delete') + .map((item) => { + const originData = { ...item } + return { + isDefault: item.status === 'default', + ...originData, + } + }) }) } + +const onDeleteAddress = async (id: number) => { + await api.user.updateAddress.post({ id, status: 'delete' }) + handleGetAddressData() +} +const onSubmit = () => { + model.value = false + emits('confirm', chooseAddressData.value) +} diff --git a/src/views/commodity-detail/components/​​shopping-cart​.vue b/src/views/commodity-detail/components/​​shopping-cart​.vue index 251e0bd..43cac53 100644 --- a/src/views/commodity-detail/components/​​shopping-cart​.vue +++ b/src/views/commodity-detail/components/​​shopping-cart​.vue @@ -5,44 +5,113 @@

- 张四 我的详细地址是什么东西的地方的好的么 + {{ curAddressData.buyerName }} + {{ curAddressData.province + curAddressData.city + curAddressData.district + curAddressData.detail }}

- -

¥29.9

+ +
+

+ ¥{{ curPageData.price }} +

+

+ +

+
-

更多系列

-
-

手表系列

-

手表系列水

-

手表

-

手表123

-

手表12

-
-

颜色

-
-

手表系列

-

手表系列水

-

手表

-

手表123

-

手表12

-
+
- +