From 1f98c287cd23563d53ddd05d7325ea1030b713a2 Mon Sep 17 00:00:00 2001 From: chenhao Date: Thu, 23 Jul 2026 08:57:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8=E6=94=B9?= =?UTF-8?q?=E6=8C=89=E9=9C=80=E8=AF=B7=E6=B1=82=E3=80=81=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E7=88=86=E6=AC=BE=E6=94=B9=E8=8C=B6=E5=93=81=E9=A3=98=E9=A6=99?= =?UTF-8?q?=E8=BD=AE=E6=92=AD=E3=80=81=E5=88=86=E7=B1=BB=E9=A1=B5=E6=94=AF?= =?UTF-8?q?=E6=8C=81=20pid=20=E5=AE=9A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- public/img/icon-hot.png | Bin 1221 -> 1086 bytes src/components/BaseList.vue | 3 +- src/main.js | 10 ++-- src/stores/datadic.js | 50 +++----------------- src/styles/ch.less | 73 ++++++++++++++++++------------ src/views/Account/Login.vue | 16 +++++-- src/views/Goods/Category.vue | 51 ++++++++++++++++++++- src/views/Tabbars/Mall.vue | 40 ++++++++++++---- src/views/User/Wallet/Balance.vue | 8 ++-- 9 files changed, 158 insertions(+), 93 deletions(-) diff --git a/public/img/icon-hot.png b/public/img/icon-hot.png index 702a80ca7e1e1ce457552e947085576f55439faf..169177544feaefe250d2903f573a29c1aa992b00 100644 GIT binary patch delta 1080 zcmV-81jqZu3BCv+iBL{Q4GJ0x0000DNk~Le0000a0000e2nGNE0G7g785e}aL&MZy)$>_-n+a1FEeM( z|2*@%=bq=8GgGQmDgY>>X9I5nf7_kdub3u9iSsLg)j(Mp{gN{J-022dmN7>=y-Ze|`;cCvZJ5 zA2=UBG5-LgrOvfo=K+5Jjs6X5oY;4BfGh!efjhE%5pY=(FaSf!==F7Ao(A^Sg8{}P zd9l{q?L+&zz*Pa;#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@@}m!M2GE4if0>q^PBZrL$*Q zIC2E7sEG1V2!O@Yr?CeHQmGc#%?Gq#kb*;pQq(DQ({yJwF#)#i3cGd7wfp_(wY5Yi zC(+8wlfFtzGf{+f+#Qe+PAJ5q6DJ6tJc*j0k9pFFPEG=#f14&+iF;%F8X8=E%gaP( zW)fl&@cA-Pg#5rCX)`Y?bDf35*uA{~l$<}GAhHJrP?m*e7?kz&5V>}Zf}=+Pu)Diq zb=CEwCr^5REb=#-oIE;Kh286HNjsY#HpUb#ZJy*)7| z`rrZ4hY#KHe>ZPt63`XD3x { this._skipWatch = false }) }, }, } diff --git a/src/main.js b/src/main.js index e3cfa16..7fba203 100644 --- a/src/main.js +++ b/src/main.js @@ -68,12 +68,11 @@ window.__currentPath = () => currentPath; app.use(router); import pinia from './stores'; -import { useDatadicStore, dictCache } from './stores/datadic'; +import { useDatadicStore } from './stores/datadic'; import { useUserStore } from './stores/user'; app.use(pinia); const datadicStore = useDatadicStore() -datadicStore.init() const userStore = useUserStore() @@ -90,8 +89,11 @@ const userStore = useUserStore() // }); app.config.globalProperties.$datadic = { - get: (code) => dictCache[code] || null, - getContent: (code) => dictCache[code] ? dictCache[code].contents : '', + get: (code) => datadicStore.fetch(code), + getContent: async (code) => { + const item = await datadicStore.fetch(code) + return item ? item.contents : '' + }, } app.config.globalProperties.$userInfo = userStore.getUserInfo; diff --git a/src/stores/datadic.js b/src/stores/datadic.js index ee3677a..5a76933 100644 --- a/src/stores/datadic.js +++ b/src/stores/datadic.js @@ -1,53 +1,17 @@ import { defineStore } from 'pinia' import { get } from '@/api/http' -export let dictCache = {} - -const SESSION_KEY = 'dict_cache' - +// 按需请求:调用时才拉,不做本地缓存 export const useDatadicStore = defineStore('datadic', { - state: () => ({ - dicts: {}, - loaded: false - }), - getters: { - getByCode: (state) => (code) => { - return dictCache[code] || null - }, - getContent: (code) => { - const item = dictCache[code] - return item ? item.contents : '' - } - }, actions: { - async init() { - // 优先从 sessionStorage 读取缓存 - const cached = sessionStorage.getItem(SESSION_KEY) - if (cached) { - try { - dictCache = JSON.parse(cached) - this.dicts = dictCache - this.loaded = true - return - } catch (e) { - sessionStorage.removeItem(SESSION_KEY) - } - } - if (this.loaded) return + async fetch(code) { try { - // 使用持久请求,防止被路由切换时的 abortAll() 取消 - const res = await get('/v1/client/CDatadicsClient', undefined, undefined, undefined, true) - if (res.status === 200 && res.data) { - res.data.forEach(item => { - dictCache[item.code] = item - }) - this.dicts = dictCache - this.loaded = true - sessionStorage.setItem(SESSION_KEY, JSON.stringify(dictCache)) - } + const res = await get(`/v1/client/CDatadicsClient/${code}`) + return res?.data || null } catch (e) { - console.error('数据字典加载失败', e) + console.error('数据字典加载失败', code, e) + return null } } } -}) \ No newline at end of file +}) diff --git a/src/styles/ch.less b/src/styles/ch.less index e6d1116..bfcd61d 100644 --- a/src/styles/ch.less +++ b/src/styles/ch.less @@ -1134,53 +1134,74 @@ } .mall_page__hot { - background: #fff; border-radius: 2vw; overflow: hidden; margin-top: 4vw; margin-bottom: 4vw; + background-image: linear-gradient(0deg, + #ffffff 0%, + #d5ecd6 100%); + border-radius: 2.67vw; .mall_page__hot_header { .box; .box-align-center; - height: 10vw; - padding: 0vw 2.8vw; - background-color: #ffb43d; - color: #a86906; + height: 12.53vw; + padding: 2.93vw; + + color: #2e5d31; img { - width: 4.27vw; + width: 4.8vw; } b { font-size: 4.8vw; - color: #ffffff; + color: #000000; margin: 0 3.6vw 0 1.47vw; } p { - color: #a86906; + color: #2e5d31; } } + .van-swipe { + width: calc(100% - 5.86vw); + } + + .mall_page__hot_list { - .box; - // margin-bottom: 3vw; - padding: 4vw 3.33vw; - overflow-x: auto + background-color: #ffffff; + border-radius: 2.67vw; + // padding: 4vw 3.73vw; + padding: 4vw 0; + margin: 0 2.93vw; + + .van-swipe-item { + display: grid; + grid-template-columns: repeat(3, 1fr); + row-gap: 3.2vw; + column-gap: 4vw; + box-sizing: border-box; + padding: 0 3.73vw; + } + + .van-swipe__indicators { + bottom: 1.6vw; + } } .mall_page__hot_item { .box; .box-tb; - margin-right: 2.67vw; - width: 34.67vw; + .box-align-start; + width: max-content; img { object-fit: contain; - width: 34.67vw; - height: 34.67vw; - background-color: #e5e5e5; + width: 24vw; + height: 24vw; border-radius: 1.33vw; } @@ -1188,23 +1209,17 @@ font-size: 3.2vw; font-weight: bold; line-height: 4vw; + min-height: 4vw; + max-width: 24.27vw; color: #333333; - min-height: 8vw; - .text-hide(2); - margin-top: 2.8vw; - } - - .mall_page__hot_price--original { - font-size: 3.2vw; - text-decoration: line-through; - // line-height: 4.8vw; - color: #b1b1b1; - margin-top: 1.67vw; + .text-hide(1); + margin-top: 1.6vw; } .mall_page__hot_price { - font-size: 4vw; + font-size: 3.47vw; font-weight: bold; + line-height: 4.8vw; color: #ea3e23; } } diff --git a/src/views/Account/Login.vue b/src/views/Account/Login.vue index 6859b84..c390e4a 100644 --- a/src/views/Account/Login.vue +++ b/src/views/Account/Login.vue @@ -84,7 +84,7 @@ @@ -106,13 +106,13 @@ -
+
-
+
@@ -137,6 +137,8 @@ export default { showConfirmPassword: false, showContract: false, showPolicy: false, + contractHtml: '', + policyHtml: '', loading: false, smsCode: '', // 接口返回的验证码 countdown: { @@ -147,6 +149,14 @@ export default { } }, methods: { + async openContract() { + this.showContract = true + this.contractHtml = await this.$datadic.getContent('code_yhxy') + }, + async openPolicy() { + this.showPolicy = true + this.policyHtml = await this.$datadic.getContent('code_yszc') + }, init() { // 防止刷新重复处理微信 code if (sessionStorage.getItem('wx_code_processed') === '1') { diff --git a/src/views/Goods/Category.vue b/src/views/Goods/Category.vue index d301df6..ccef234 100644 --- a/src/views/Goods/Category.vue +++ b/src/views/Goods/Category.vue @@ -74,7 +74,7 @@ {{ item.saleprice?.toFixed(2) }} 销量{{ item.salenums - }} + }} @@ -186,6 +186,9 @@ export default { if (this.$route.query.id) { this.changeMainById(Number(this.$route.query.id)); } + if (this.$route.query.pid) { + this.selectByPid(Number(this.$route.query.pid)); + } if (this.$route.query.SortType == 2) { this.searchParams.orderby = 'salenumdown'; } @@ -263,6 +266,52 @@ export default { this.changeMain(item); } }, + // 根据 pid 定位到对应层级并激活选中态 + selectByPid(pid) { + const third = this.thirdCategories.find(x => x.id === pid); + if (third) { + const first = this.firstCategories.find(x => x.id === third.rootId); + if (first) { + this.mainCategory = first.id; + this.typeName = first.name; + this.selectedSecond = this.secondCategories.filter(x => x.parentId === first.id); + } + this.selectedThird = this.thirdCategories.filter(x => x.parentId === third.parentId); + this.goodsCategoryIndex = this.selectedThird.findIndex(x => x.id === pid) + 1; + this.currentThirdId = pid; + this.queryParams.pid = pid; + this.refreshProductList(); + this.$nextTick(() => { + this.secondCategory = third.parentId; + }); + return; + } + const second = this.secondCategories.find(x => x.id === pid); + if (second) { + const first = this.firstCategories.find(x => x.id === second.parentId); + if (first) { + this.mainCategory = first.id; + this.typeName = first.name; + this.selectedSecond = this.secondCategories.filter(x => x.parentId === first.id); + } + this.selectedThird = this.thirdCategories.filter(x => x.parentId === pid); + this.goodsCategoryIndex = 0; + this.currentThirdId = ''; + this.queryParams.pid = pid; + this.refreshProductList(); + this.$nextTick(() => { + this.secondCategory = pid; + }); + return; + } + const first = this.firstCategories.find(x => x.id === pid); + if (first) { + this.changeMain(first); + return; + } + this.queryParams.pid = pid; + this.refreshProductList(); + }, changeSecond(e) { if (e) { this.queryParams.pid = e; diff --git a/src/views/Tabbars/Mall.vue b/src/views/Tabbars/Mall.vue index 9b3669a..2074d9c 100644 --- a/src/views/Tabbars/Mall.vue +++ b/src/views/Tabbars/Mall.vue @@ -9,8 +9,8 @@
- +
@@ -41,18 +41,33 @@ -
+
- 爆款好物 -

超多会员已购买

- + 茶品飘香 +

精选茶叶礼盒

+ 查看更多
-
+ + +
+ + + {{ list.name }} + + + ¥{{ list.saleprice?.toFixed(2) }} + +
+
+
+ +
@@ -148,7 +163,7 @@ export default { this.data.Carousel = res.data this.bgcolor = res.data?.[0]?.bgcolor || '' }), - this.$get('/v1/client/EProsClient?recommend=true').then(res => { + this.$get('/v1/client/EProsClient?pid=1044&pageSize=100').then(res => { this.hotData = res.data.items || [] }), this.$get('/v1/client/EProcatesClient/3').then(res => { @@ -175,6 +190,13 @@ export default { btnStyle() { return this.bgcolor ? { background: this.bgcolor } : {} }, + comHotData() { + const groups = [] + for (let i = 0; i < this.hotData.length; i += 9) { + groups.push(this.hotData.slice(i, i + 9)) + } + return groups + } }, } diff --git a/src/views/User/Wallet/Balance.vue b/src/views/User/Wallet/Balance.vue index 0b78b5b..9329981 100644 --- a/src/views/User/Wallet/Balance.vue +++ b/src/views/User/Wallet/Balance.vue @@ -4,7 +4,7 @@
- 当前余额 + 当前余额