From 8542b437ad25c79e2e6e8d9e818efb130023fdd1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B0=8C=E5=85=88=E8=88=9C?= <2499071264@qq.com>
Date: Mon, 27 Jul 2026 18:12:29 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8?=
=?UTF-8?q?=E3=80=81=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
supplied-h5/package-lock.json | 55 +++
supplied-h5/package.json | 1 +
supplied-h5/public/index.html | 2 +-
supplied-h5/src/main.js | 5 +
supplied-h5/src/router/index.js | 3 +-
supplied-h5/src/store/cart.js | 44 ++
supplied-h5/src/view/index.vue | 2 +-
.../src/view/joyful-selection/cart/index.vue | 47 +-
.../cart/payment-success/index.vue | 3 +-
.../src/view/joyful-selection/layout.vue | 4 +-
.../joyful-selection/product-detail/index.vue | 329 ++++++++++++-
.../view/joyful-selection/products/index.vue | 455 +++++++++++++-----
12 files changed, 794 insertions(+), 156 deletions(-)
create mode 100644 supplied-h5/src/store/cart.js
diff --git a/supplied-h5/package-lock.json b/supplied-h5/package-lock.json
index 58fec2a..589a31a 100644
--- a/supplied-h5/package-lock.json
+++ b/supplied-h5/package-lock.json
@@ -9,6 +9,7 @@
"version": "1.0.0",
"dependencies": {
"core-js": "^3.37.1",
+ "pinia": "^2.3.1",
"vant": "^2.13.9",
"vue": "^2.7.16",
"vue-router": "^3.6.5"
@@ -2372,6 +2373,12 @@
"dev": true,
"license": "ISC"
},
+ "node_modules/@vue/devtools-api": {
+ "version": "6.6.4",
+ "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.6.4.tgz",
+ "integrity": "sha512-sGhTPMuXqZ1rVOk32RylztWkfXTRhuS7vgAKv0zjqk8gbsHkJ7xfFf+jbySxt7tWObEJwyKaHMikV/WGDiQm8g==",
+ "license": "MIT"
+ },
"node_modules/@vue/shared": {
"version": "3.5.39",
"dev": true,
@@ -6934,6 +6941,54 @@
"url": "https://github.com/sponsors/jonschlinkert"
}
},
+ "node_modules/pinia": {
+ "version": "2.3.1",
+ "resolved": "https://registry.npmjs.org/pinia/-/pinia-2.3.1.tgz",
+ "integrity": "sha512-khUlZSwt9xXCaTbbxFYBKDc/bWAGWJjOgvxETwkTN7KRm66EeT1ZdZj6i2ceh9sP2Pzqsbc704r2yngBrxBVug==",
+ "license": "MIT",
+ "dependencies": {
+ "@vue/devtools-api": "^6.6.3",
+ "vue-demi": "^0.14.10"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/posva"
+ },
+ "peerDependencies": {
+ "typescript": ">=4.4.4",
+ "vue": "^2.7.0 || ^3.5.11"
+ },
+ "peerDependenciesMeta": {
+ "typescript": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/pinia/node_modules/vue-demi": {
+ "version": "0.14.10",
+ "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.10.tgz",
+ "integrity": "sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==",
+ "hasInstallScript": true,
+ "license": "MIT",
+ "bin": {
+ "vue-demi-fix": "bin/vue-demi-fix.js",
+ "vue-demi-switch": "bin/vue-demi-switch.js"
+ },
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/antfu"
+ },
+ "peerDependencies": {
+ "@vue/composition-api": "^1.0.0-rc.1",
+ "vue": "^3.0.0-0 || ^2.6.0"
+ },
+ "peerDependenciesMeta": {
+ "@vue/composition-api": {
+ "optional": true
+ }
+ }
+ },
"node_modules/pkg-dir": {
"version": "4.2.0",
"dev": true,
diff --git a/supplied-h5/package.json b/supplied-h5/package.json
index 3ca6abb..52e330d 100644
--- a/supplied-h5/package.json
+++ b/supplied-h5/package.json
@@ -8,6 +8,7 @@
},
"dependencies": {
"core-js": "^3.37.1",
+ "pinia": "^2.3.1",
"vant": "^2.13.9",
"vue": "^2.7.16",
"vue-router": "^3.6.5"
diff --git a/supplied-h5/public/index.html b/supplied-h5/public/index.html
index d69b27b..99db16a 100644
--- a/supplied-h5/public/index.html
+++ b/supplied-h5/public/index.html
@@ -4,7 +4,7 @@
-
供货端
+ 积分商城
diff --git a/supplied-h5/src/main.js b/supplied-h5/src/main.js
index 7495eb3..bc23797 100644
--- a/supplied-h5/src/main.js
+++ b/supplied-h5/src/main.js
@@ -1,13 +1,18 @@
import Vue from 'vue'
import Vant from 'vant'
+import { createPinia, PiniaVuePlugin } from 'pinia'
import 'vant/lib/index.css'
import App from './App.vue'
import router from './router'
Vue.use(Vant)
+Vue.use(PiniaVuePlugin)
Vue.config.productionTip = false
+const pinia = createPinia()
+
new Vue({
router,
+ pinia,
render: h => h(App)
}).$mount('#app')
diff --git a/supplied-h5/src/router/index.js b/supplied-h5/src/router/index.js
index 5809428..0e4df03 100644
--- a/supplied-h5/src/router/index.js
+++ b/supplied-h5/src/router/index.js
@@ -28,7 +28,8 @@ export default new Router({
path: '/joyful-selection',
component: JoyfulSelectionLayout,
children: [
- { path: '', component: JoyfulSelectionHome },
+ { path: '', redirect: 'home' },
+ { path: 'home', component: JoyfulSelectionHome },
{ path: 'products', component: JoyfulSelectionProductList },
{ path: 'product-detail', component: JoyfulSelectionProductDetail },
{ path: 'cart', component: JoyfulSelectionCart },
diff --git a/supplied-h5/src/store/cart.js b/supplied-h5/src/store/cart.js
new file mode 100644
index 0000000..68ce8fc
--- /dev/null
+++ b/supplied-h5/src/store/cart.js
@@ -0,0 +1,44 @@
+import { defineStore } from 'pinia'
+
+const CART_KEY = 'joyful-selection-cart'
+
+const readCartItems = () => {
+ try {
+ return JSON.parse(localStorage.getItem(CART_KEY) || '[]')
+ } catch (error) {
+ return []
+ }
+}
+
+const saveCartItems = items => {
+ localStorage.setItem(CART_KEY, JSON.stringify(items))
+}
+
+export const useCartStore = defineStore('joyfulSelectionCart', {
+ state: () => ({
+ items: []
+ }),
+ getters: {
+ totalCount: state => state.items.reduce((total, item) => total + Number(item.count || 0), 0),
+ totalPrice: state => state.items.reduce((total, item) => total + Math.round(Number(item.price) * 100) * Number(item.count || 0), 0)
+ },
+ actions: {
+ loadCart() {
+ this.items = readCartItems()
+ },
+ persistCart() {
+ saveCartItems(this.items)
+ },
+ addItem(item) {
+ const index = this.items.findIndex(cartItem => cartItem.cartId === item.cartId)
+
+ if (index > -1) {
+ this.items[index].count += item.count
+ } else {
+ this.items.unshift(item)
+ }
+
+ this.persistCart()
+ }
+ }
+})
diff --git a/supplied-h5/src/view/index.vue b/supplied-h5/src/view/index.vue
index c78984b..710fc9c 100644
--- a/supplied-h5/src/view/index.vue
+++ b/supplied-h5/src/view/index.vue
@@ -68,7 +68,7 @@ export default {
{ id: 'daily', image: bannerDaily, alt: '精选商品每日推荐' }
],
suppliers: [
- { id: 'joy', name: '悦享优选', image: supplierJoy, description: '精选好物,悦享品质生活', tags: ['正品保障', '极速发货', '售后无忧'], productCount: 6800, sales: '18万+', backgroundColor: '#f4f7ff', tagColor: '#4e83ef', tagBackground: '#edf3ff', buttonColor: '#ff651d', path: '/joyful-selection' },
+ { id: 'joy', name: '悦享优选', image: supplierJoy, description: '精选好物,悦享品质生活', tags: ['正品保障', '极速发货', '售后无忧'], productCount: 6800, sales: '18万+', backgroundColor: '#f4f7ff', tagColor: '#4e83ef', tagBackground: '#edf3ff', buttonColor: '#ff651d', path: '/joyful-selection/home' },
{ id: 'home', name: '美家生活馆', image: supplierHome, description: '家居好物,点亮品质生活', tags: ['家居日用', '品质精选', '售后保障'], productCount: 5200, sales: '12万+', backgroundColor: '#f1fbf9', tagColor: '#18bfae', tagBackground: '#e9faf7', buttonColor: '#ff651d', path: '/home-living' },
{ id: 'happy', name: '乐购甄选', image: supplierHappy, description: '天天低价,乐享购物', tags: ['低价好物', '限时优惠', '极速配送'], productCount: 7600, sales: '22万+', backgroundColor: '#f7f4ff', tagColor: '#7b61ee', tagBackground: '#f0edff', buttonColor: '#ff651d', path: '/happy-shopping' },
{ id: 'fruit', name: '鲜果优品', image: supplierFruit, description: '新鲜直达,优选好果', tags: ['产地直采', '新鲜直达', '坏果包赔'], productCount: 3500, sales: '9万+', backgroundColor: '#fff9ed', tagColor: '#f39d16', tagBackground: '#fff5df', buttonColor: '#ff651d', path: '/fresh-fruit' },
diff --git a/supplied-h5/src/view/joyful-selection/cart/index.vue b/supplied-h5/src/view/joyful-selection/cart/index.vue
index d8f03d9..3787e61 100644
--- a/supplied-h5/src/view/joyful-selection/cart/index.vue
+++ b/supplied-h5/src/view/joyful-selection/cart/index.vue
@@ -3,33 +3,48 @@
-
- {{ item.tag }}
-
-
+
+
+
+ {{ item.tag }}
+
+
+
-
+
全选
diff --git a/supplied-h5/src/view/joyful-selection/cart/payment-success/index.vue b/supplied-h5/src/view/joyful-selection/cart/payment-success/index.vue
index c358370..8567e5b 100644
--- a/supplied-h5/src/view/joyful-selection/cart/payment-success/index.vue
+++ b/supplied-h5/src/view/joyful-selection/cart/payment-success/index.vue
@@ -1,3 +1,4 @@
-支付成功
¥ 297.90订单编号 YX2024051812345678
支付方式 微信支付
支付时间 2024-05-18 14:35:28
查看订单继续购物
+支付成功
¥ 297.90订单编号 YX2024051812345678
支付方式 微信支付
支付时间 2024-05-18 14:35:28
查看订单继续购物
+
diff --git a/supplied-h5/src/view/joyful-selection/layout.vue b/supplied-h5/src/view/joyful-selection/layout.vue
index 5c4856a..e8f787f 100644
--- a/supplied-h5/src/view/joyful-selection/layout.vue
+++ b/supplied-h5/src/view/joyful-selection/layout.vue
@@ -2,7 +2,7 @@
- 首页
+ 首页
分类
购物车
我的
@@ -15,7 +15,7 @@ export default {
name: 'JoyfulSelectionLayout',
computed: {
showTabbar() {
- return ['/joyful-selection', '/joyful-selection/products', '/joyful-selection/cart', '/joyful-selection/profile'].includes(this.$route.path)
+ return ['/joyful-selection/home', '/joyful-selection/products', '/joyful-selection/cart', '/joyful-selection/profile'].includes(this.$route.path)
}
}
}
diff --git a/supplied-h5/src/view/joyful-selection/product-detail/index.vue b/supplied-h5/src/view/joyful-selection/product-detail/index.vue
index b445803..e3ff7da 100644
--- a/supplied-h5/src/view/joyful-selection/product-detail/index.vue
+++ b/supplied-h5/src/view/joyful-selection/product-detail/index.vue
@@ -1,20 +1,62 @@
-
-
+
+
+
+
- {{ product.name }}
+ {{ product.name }}
{{ product.detail }}
- ¥{{ product.price }}¥{{ product.originPrice }}{{ product.tag }}
+
+ ¥{{ product.price }}
+ ¥{{ product.originPrice }}
+ {{ product.tag }}
+
-
-
-
-
+
+
+
+
+
- 商品详情
- {{ product.desc }}
+ 商品详情
+
+
+
+ {{ item.title }}
+ {{ item.desc }}
+
+
+
@@ -30,19 +72,268 @@ import { getJoyfulProduct } from '../product-data'
export default {
name: 'JoyfulSelectionProductDetail',
+ data: () => ({
+ count: 1,
+ features: [
+ { icon: 'music-o', title: '舒适半入耳设计', desc: '长时间佩戴更舒适' },
+ { icon: 'bar-chart-o', title: '高清音质', desc: '清晰稳定的聆听体验' },
+ { icon: 'battery-o', title: '长续航', desc: '单次可用约 5 小时' },
+ { icon: 'cluster-o', title: '蓝牙 5.0', desc: '稳定连接,低延迟' }
+ ]
+ }),
computed: {
product() { return getJoyfulProduct(this.$route.query.id) }
}
}
-
diff --git a/supplied-h5/src/view/joyful-selection/products/index.vue b/supplied-h5/src/view/joyful-selection/products/index.vue
index b30fc3d..fb41dc1 100644
--- a/supplied-h5/src/view/joyful-selection/products/index.vue
+++ b/supplied-h5/src/view/joyful-selection/products/index.vue
@@ -2,33 +2,43 @@
-
{{ item.name }}
-
{{ item.tag }}
+
+ {{ item.tag }}
+
{{ item.name }}
+
-
¥{{ item.price }}
-
已售{{ item.sales }}
-
@@ -37,91 +47,232 @@
+