diff --git a/public/img/icon-hot.png b/public/img/icon-hot.png index 702a80c..1691775 100644 Binary files a/public/img/icon-hot.png and b/public/img/icon-hot.png differ diff --git a/src/components/BaseList.vue b/src/components/BaseList.vue index 5b2282e..4912404 100644 --- a/src/components/BaseList.vue +++ b/src/components/BaseList.vue @@ -99,7 +99,8 @@ export default { this._skipWatch = true this.loadMore() this.$emit('refresh', this.list) - this._skipWatch = false + // 等 params 的 deep watcher 排队回调跑完再解锁,避免同一轮 tick 里被再触发一次 + this.$nextTick(() => { 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 @@
- 当前余额 + 当前余额