mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-11-07 09:28:52 +08:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1411f15679 | ||
|
|
af7bd78614 | ||
|
|
0170c92f9a | ||
|
|
5e59f2cd3c | ||
|
|
6b59ae3d6e | ||
|
|
b589c551bf | ||
|
|
b8a60a9369 | ||
|
|
1032b6e34d |
24
App.vue
24
App.vue
@@ -3,13 +3,18 @@ import config from '@/config/config'
|
|||||||
import { getClipboardData } from '@/js_sdk/h5-copy/h5-copy.js'
|
import { getClipboardData } from '@/js_sdk/h5-copy/h5-copy.js'
|
||||||
import APPUpdate from '@/plugins/APPUpdate'
|
import APPUpdate from '@/plugins/APPUpdate'
|
||||||
import storage from '@/utils/storage'
|
import storage from '@/utils/storage'
|
||||||
import { getThemeSetting } from '@/api/common.js'
|
import { getThemeSetting, getCategoryPageSetting } from '@/api/common.js'
|
||||||
import {
|
import {
|
||||||
applyTabBarStyle,
|
applyTabBarStyle,
|
||||||
cacheTheme,
|
cacheTheme,
|
||||||
loadCachedTheme,
|
loadCachedTheme,
|
||||||
normalizeTheme,
|
normalizeTheme,
|
||||||
} from '@/utils/theme'
|
} from '@/utils/theme'
|
||||||
|
import {
|
||||||
|
cacheCategoryPageSetting,
|
||||||
|
loadCachedCategoryPageSetting,
|
||||||
|
normalizeCategoryPageSetting,
|
||||||
|
} from '@/utils/categoryPageSetting'
|
||||||
import { onLaunch, onShow } from '@dcloudio/uni-app'
|
import { onLaunch, onShow } from '@dcloudio/uni-app'
|
||||||
import { useStore } from '@/store'
|
import { useStore } from '@/store'
|
||||||
import { handleAppLaunchScene } from '@/utils/distributionBind.js'
|
import { handleAppLaunchScene } from '@/utils/distributionBind.js'
|
||||||
@@ -24,6 +29,7 @@ wx.onAppRoute((res) => {
|
|||||||
|
|
||||||
onLaunch((val) => {
|
onLaunch((val) => {
|
||||||
initTheme()
|
initTheme()
|
||||||
|
initCategoryPageSetting()
|
||||||
handleAppLaunchScene(val)
|
handleAppLaunchScene(val)
|
||||||
if (val?.query?.inviter) {
|
if (val?.query?.inviter) {
|
||||||
storage.setInviter(val.query.inviter)
|
storage.setInviter(val.query.inviter)
|
||||||
@@ -81,6 +87,22 @@ function initTheme() {
|
|||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initCategoryPageSetting() {
|
||||||
|
const cached = loadCachedCategoryPageSetting()
|
||||||
|
if (cached) {
|
||||||
|
store.commit('SET_CATEGORY_PAGE_SETTING', cached)
|
||||||
|
}
|
||||||
|
getCategoryPageSetting()
|
||||||
|
.then((res) => {
|
||||||
|
if (res.data?.success) {
|
||||||
|
const setting = normalizeCategoryPageSetting(res.data.result)
|
||||||
|
store.commit('SET_CATEGORY_PAGE_SETTING', setting)
|
||||||
|
cacheCategoryPageSetting(setting)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
}
|
||||||
|
|
||||||
function applyUpdateWeChat() {
|
function applyUpdateWeChat() {
|
||||||
const updateManager = uni.getUpdateManager()
|
const updateManager = uni.getUpdateManager()
|
||||||
|
|
||||||
|
|||||||
@@ -41,3 +41,14 @@ export function getThemeSetting() {
|
|||||||
message: false,
|
message: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取分类页配置
|
||||||
|
*/
|
||||||
|
export function getCategoryPageSetting() {
|
||||||
|
return http.request({
|
||||||
|
url: `${api.buyer}/common/site/category-page`,
|
||||||
|
method: Method.GET,
|
||||||
|
message: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
133
components/category/category-scroller.vue
Normal file
133
components/category/category-scroller.vue
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
<template>
|
||||||
|
<scroll-view scroll-x scroll-with-animation class="cate-scroller" :scroll-into-view="intoView">
|
||||||
|
<view
|
||||||
|
v-for="item in list"
|
||||||
|
:key="item.id"
|
||||||
|
:id="'cs-' + item.id"
|
||||||
|
class="cs-item"
|
||||||
|
:class="{ active: item.id === currentId, 'cs-item--text': mode === 'text' }"
|
||||||
|
@click="$emit('change', item)"
|
||||||
|
>
|
||||||
|
<template v-if="mode === 'icon'">
|
||||||
|
<view class="cs-icon-box">
|
||||||
|
<view class="cs-icon">
|
||||||
|
<u-image width="80rpx" height="80rpx" shape="circle" :src="item.image" mode="aspectFill">
|
||||||
|
<template #loading><u-loading-icon></u-loading-icon></template>
|
||||||
|
</u-image>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<text class="cs-name">{{ item.name }}</text>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<text class="cs-text-name">{{ item.name }}</text>
|
||||||
|
<view class="cs-text-line" v-if="item.id === currentId"></view>
|
||||||
|
</template>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
list?: any[]
|
||||||
|
currentId?: string | number | null
|
||||||
|
mode?: 'icon' | 'text'
|
||||||
|
}>(), {
|
||||||
|
list: () => [],
|
||||||
|
currentId: null,
|
||||||
|
mode: 'icon'
|
||||||
|
})
|
||||||
|
|
||||||
|
defineEmits(['change'])
|
||||||
|
|
||||||
|
const intoView = computed(() =>
|
||||||
|
props.currentId != null ? 'cs-' + props.currentId : ''
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.cate-scroller {
|
||||||
|
white-space: nowrap;
|
||||||
|
width: 100%;
|
||||||
|
background: #ffffff;
|
||||||
|
border-bottom: 1rpx solid #f2f3f5;
|
||||||
|
box-sizing: border-box;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.cs-item {
|
||||||
|
display: inline-flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 130rpx;
|
||||||
|
padding: 16rpx 6rpx 14rpx;
|
||||||
|
vertical-align: top;
|
||||||
|
box-sizing: border-box;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
.cs-icon-box {
|
||||||
|
width: 92rpx;
|
||||||
|
height: 92rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border: 3rpx solid transparent;
|
||||||
|
box-sizing: border-box;
|
||||||
|
background: #ffffff;
|
||||||
|
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
||||||
|
}
|
||||||
|
.cs-item.active .cs-icon-box {
|
||||||
|
border-color: $light-color;
|
||||||
|
box-shadow: 0 4rpx 12rpx rgba(255, 102, 0, 0.15);
|
||||||
|
}
|
||||||
|
.cs-icon {
|
||||||
|
width: 80rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #f6f7f9;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.cs-name {
|
||||||
|
margin-top: 10rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #555;
|
||||||
|
max-width: 120rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
.cs-item.active .cs-name {
|
||||||
|
color: $light-color;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.cs-item--text {
|
||||||
|
width: auto;
|
||||||
|
padding: 18rpx 28rpx;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.cs-text-name {
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #666;
|
||||||
|
transition: color 0.2s ease;
|
||||||
|
}
|
||||||
|
.cs-item--text.active .cs-text-name {
|
||||||
|
color: $light-color;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.cs-text-line {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 6rpx;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
width: 32rpx;
|
||||||
|
height: 4rpx;
|
||||||
|
border-radius: 2rpx;
|
||||||
|
background: $light-color;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
75
components/category/category-side-list.vue
Normal file
75
components/category/category-side-list.vue
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
<template>
|
||||||
|
<scroll-view scroll-y scroll-with-animation class="side-list">
|
||||||
|
<view
|
||||||
|
v-for="item in list"
|
||||||
|
:key="item.id"
|
||||||
|
class="side-item"
|
||||||
|
:class="{ active: item.id === currentId }"
|
||||||
|
@click="$emit('change', item)"
|
||||||
|
>
|
||||||
|
<view class="active-indicator" v-if="item.id === currentId"></view>
|
||||||
|
<text class="side-item-text">{{ item.name }}</text>
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
withDefaults(defineProps<{
|
||||||
|
list?: any[]
|
||||||
|
currentId?: string | number | null
|
||||||
|
}>(), {
|
||||||
|
list: () => [],
|
||||||
|
currentId: null
|
||||||
|
})
|
||||||
|
|
||||||
|
defineEmits(['change'])
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.side-list {
|
||||||
|
width: 176rpx;
|
||||||
|
flex-shrink: 0;
|
||||||
|
height: 100%;
|
||||||
|
background-color: #f6f7f9;
|
||||||
|
border-right: 1rpx solid #ebebeb;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
.side-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 96rpx;
|
||||||
|
padding: 16rpx 14rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #666;
|
||||||
|
text-align: center;
|
||||||
|
position: relative;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
font-weight: 600;
|
||||||
|
color: $light-color;
|
||||||
|
background: #ffffff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.side-item-text {
|
||||||
|
line-height: 1.35;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
.active-indicator {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
width: 6rpx;
|
||||||
|
height: 36rpx;
|
||||||
|
border-radius: 0 4rpx 4rpx 0;
|
||||||
|
background: $light-color;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
94
components/category/sort-bar.vue
Normal file
94
components/category/sort-bar.vue
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
<template>
|
||||||
|
<view class="sort-bar">
|
||||||
|
<view
|
||||||
|
class="sort-item"
|
||||||
|
:class="{ active: sort === 'releaseTime' }"
|
||||||
|
@click="onClick('releaseTime')"
|
||||||
|
>
|
||||||
|
<text class="sort-label">综合</text>
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
class="sort-item"
|
||||||
|
:class="{ active: sort === 'buyCount' }"
|
||||||
|
@click="onClick('buyCount')"
|
||||||
|
>
|
||||||
|
<text class="sort-label">销量</text>
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
class="sort-item"
|
||||||
|
:class="{ active: sort === 'price' }"
|
||||||
|
@click="onClick('price')"
|
||||||
|
>
|
||||||
|
<text class="sort-label">价格</text>
|
||||||
|
<view class="arrows">
|
||||||
|
<u-icon
|
||||||
|
name="arrow-up-fill"
|
||||||
|
size="7"
|
||||||
|
:color="sort === 'price' && order === 'asc' ? '#ff6700' : '#bbbbbb'"
|
||||||
|
></u-icon>
|
||||||
|
<u-icon
|
||||||
|
name="arrow-down-fill"
|
||||||
|
size="7"
|
||||||
|
:color="sort === 'price' && order === 'desc' ? '#ff6700' : '#bbbbbb'"
|
||||||
|
></u-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
sort?: string
|
||||||
|
order?: string
|
||||||
|
}>(), {
|
||||||
|
sort: 'releaseTime',
|
||||||
|
order: 'desc'
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(['change'])
|
||||||
|
|
||||||
|
function onClick(type: string) {
|
||||||
|
let nextOrder = 'desc'
|
||||||
|
if (type === 'price') {
|
||||||
|
nextOrder = props.sort === 'price' && props.order === 'desc' ? 'asc' : 'desc'
|
||||||
|
}
|
||||||
|
emit('change', { sort: type, order: nextOrder })
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.sort-bar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 68rpx;
|
||||||
|
background: #ffffff;
|
||||||
|
padding: 0 20rpx;
|
||||||
|
border-bottom: 1rpx solid #f6f6f6;
|
||||||
|
box-sizing: border-box;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.sort-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-right: 44rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #666;
|
||||||
|
height: 100%;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: color 0.2s ease;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
color: $light-color;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.sort-label {
|
||||||
|
font-size: 26rpx;
|
||||||
|
}
|
||||||
|
.arrows {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin-left: 8rpx;
|
||||||
|
gap: 2rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
61
components/category/sub-tag-bar.vue
Normal file
61
components/category/sub-tag-bar.vue
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<template>
|
||||||
|
<scroll-view scroll-x scroll-with-animation class="tag-bar" :scroll-into-view="intoView">
|
||||||
|
<view
|
||||||
|
v-for="item in list"
|
||||||
|
:key="item.id"
|
||||||
|
:id="'tb-' + item.id"
|
||||||
|
class="tag-item"
|
||||||
|
:class="{ active: item.id === currentId }"
|
||||||
|
@click="$emit('change', item)"
|
||||||
|
>
|
||||||
|
{{ item.name }}
|
||||||
|
</view>
|
||||||
|
</scroll-view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
list?: any[]
|
||||||
|
currentId?: string | number | null
|
||||||
|
}>(), {
|
||||||
|
list: () => [],
|
||||||
|
currentId: null
|
||||||
|
})
|
||||||
|
|
||||||
|
defineEmits(['change'])
|
||||||
|
|
||||||
|
const intoView = computed(() =>
|
||||||
|
props.currentId != null ? 'tb-' + props.currentId : ''
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.tag-bar {
|
||||||
|
white-space: nowrap;
|
||||||
|
width: 100%;
|
||||||
|
background: #ffffff;
|
||||||
|
padding: 12rpx 16rpx 10rpx;
|
||||||
|
border-bottom: 1rpx solid #f6f6f6;
|
||||||
|
box-sizing: border-box;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.tag-item {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 6rpx 22rpx;
|
||||||
|
margin-right: 12rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #666;
|
||||||
|
background: #f5f6f8;
|
||||||
|
border-radius: 24rpx;
|
||||||
|
line-height: 1.35;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
color: #ffffff;
|
||||||
|
background: $light-color;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
297
components/category/tpl-category-goods.vue
Normal file
297
components/category/tpl-category-goods.vue
Normal file
@@ -0,0 +1,297 @@
|
|||||||
|
<template>
|
||||||
|
<view class="tpl-goods">
|
||||||
|
<!-- 模板2/3:顶部一级分类图标横滑 -->
|
||||||
|
<category-scroller
|
||||||
|
v-if="template !== 4"
|
||||||
|
:list="categoryList"
|
||||||
|
:current-id="currentL1 && currentL1.id"
|
||||||
|
mode="icon"
|
||||||
|
@change="onL1Change"
|
||||||
|
/>
|
||||||
|
<view class="tpl-main">
|
||||||
|
<!-- 左侧:模板2/3 为二级分类,模板4 为一级分类 -->
|
||||||
|
<category-side-list
|
||||||
|
:list="sideList"
|
||||||
|
:current-id="sideCurrentId"
|
||||||
|
@change="onSideChange"
|
||||||
|
/>
|
||||||
|
<view class="tpl-right">
|
||||||
|
<!-- 模板2:三级分类标签横滑 (置于右栏顶部) -->
|
||||||
|
<sub-tag-bar
|
||||||
|
v-if="template === 2 && l3List.length"
|
||||||
|
:list="l3List"
|
||||||
|
:current-id="currentL3 && currentL3.id"
|
||||||
|
@change="onL3Change"
|
||||||
|
/>
|
||||||
|
<!-- 模板4:右上二级分类文字横滑(起点为当前一级名称,作为"全部"入口) -->
|
||||||
|
<category-scroller
|
||||||
|
v-if="template === 4"
|
||||||
|
:list="l2Items"
|
||||||
|
:current-id="topCurrentId"
|
||||||
|
mode="text"
|
||||||
|
@change="onL2Change"
|
||||||
|
/>
|
||||||
|
<sort-bar :sort="sort" :order="order" @change="onSortChange" />
|
||||||
|
<scroll-view scroll-y class="goods-scroll" @scrolltolower="loadMore">
|
||||||
|
<m-goods-list
|
||||||
|
v-if="goodsList.length"
|
||||||
|
:res="goodsList"
|
||||||
|
type="oneColumns"
|
||||||
|
:show-fields="setting.showFields"
|
||||||
|
:tab-bar-gap="false"
|
||||||
|
:store-name="false"
|
||||||
|
@add-cart="onAddCart"
|
||||||
|
/>
|
||||||
|
<view v-else-if="!loading" class="empty-state">
|
||||||
|
<u-empty
|
||||||
|
:text="failed ? '加载失败,请重试' : '暂无相关商品'"
|
||||||
|
mode="data"
|
||||||
|
icon="http://cdn.uviewui.com/uview/empty/data.png"
|
||||||
|
margin-top="100"
|
||||||
|
>
|
||||||
|
<view v-if="failed" class="retry" @click="loadGoods(true)">重试</view>
|
||||||
|
</u-empty>
|
||||||
|
</view>
|
||||||
|
<uni-load-more
|
||||||
|
v-if="showLoadMore"
|
||||||
|
:status="loading ? 'loading' : hasMore ? 'more' : 'noMore'"
|
||||||
|
:color="'#bfbfbf'"
|
||||||
|
:content-text="loadMoreText"
|
||||||
|
></uni-load-more>
|
||||||
|
</scroll-view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, computed, watch } from 'vue'
|
||||||
|
import { getGoodsList } from '@/api/goods.js'
|
||||||
|
import CategoryScroller from './category-scroller.vue'
|
||||||
|
import CategorySideList from './category-side-list.vue'
|
||||||
|
import SubTagBar from './sub-tag-bar.vue'
|
||||||
|
import SortBar from './sort-bar.vue'
|
||||||
|
import MGoodsList from '@/components/m-goods-list/list.vue'
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
options: {
|
||||||
|
virtualHost: true,
|
||||||
|
addGlobalClass: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
categoryList?: any[]
|
||||||
|
setting?: any
|
||||||
|
template?: number
|
||||||
|
}>(), {
|
||||||
|
categoryList: () => [],
|
||||||
|
setting: () => ({ template: 1, showFields: {} }),
|
||||||
|
template: 2
|
||||||
|
})
|
||||||
|
|
||||||
|
const currentL1 = ref<any>(null)
|
||||||
|
const currentL2 = ref<any>(null)
|
||||||
|
const currentL3 = ref<any>(null)
|
||||||
|
const sort = ref('releaseTime')
|
||||||
|
const order = ref('desc')
|
||||||
|
|
||||||
|
const goodsList = ref<any[]>([])
|
||||||
|
const pageNumber = ref(1)
|
||||||
|
const hasMore = ref(true)
|
||||||
|
const loading = ref(false)
|
||||||
|
const failed = ref(false)
|
||||||
|
|
||||||
|
const loadMoreText = {
|
||||||
|
contentdown: '上拉加载更多',
|
||||||
|
contentrefresh: '正在加载...',
|
||||||
|
contentnomore: '—— 到底啦 ——',
|
||||||
|
}
|
||||||
|
|
||||||
|
// 仅在正在加载、或者有下一页、或者商品总数达到 6 件以上触底时才展示底线,避免少量商品(如1~2件)时在空白区域突兀展示
|
||||||
|
const showLoadMore = computed(() => {
|
||||||
|
if (!goodsList.value.length) return false
|
||||||
|
if (loading.value) return true
|
||||||
|
if (hasMore.value) return true
|
||||||
|
return goodsList.value.length >= 6
|
||||||
|
})
|
||||||
|
|
||||||
|
// 模板2/3:左侧为当前一级的二级分类;模板4:左侧为一级分类
|
||||||
|
const sideList = computed(() =>
|
||||||
|
props.template === 4
|
||||||
|
? props.categoryList
|
||||||
|
: (currentL1.value && currentL1.value.children) || []
|
||||||
|
)
|
||||||
|
const sideCurrentId = computed(() =>
|
||||||
|
props.template === 4
|
||||||
|
? currentL1.value && currentL1.value.id
|
||||||
|
: currentL2.value && currentL2.value.id
|
||||||
|
)
|
||||||
|
// 模板2 的三级标签
|
||||||
|
const l3List = computed(() =>
|
||||||
|
(currentL2.value && currentL2.value.children) || []
|
||||||
|
)
|
||||||
|
// 模板4 顶部:当前一级名称(作为"全部") + 其二级分类
|
||||||
|
const l2Items = computed(() => {
|
||||||
|
if (!currentL1.value) return []
|
||||||
|
return [currentL1.value, ...((currentL1.value.children) || [])]
|
||||||
|
})
|
||||||
|
const topCurrentId = computed(() =>
|
||||||
|
(currentL2.value && currentL2.value.id) || (currentL1.value && currentL1.value.id)
|
||||||
|
)
|
||||||
|
|
||||||
|
const queryCategoryId = computed(() =>
|
||||||
|
(currentL3.value && currentL3.value.id) ||
|
||||||
|
(currentL2.value && currentL2.value.id) ||
|
||||||
|
(currentL1.value && currentL1.value.id)
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.categoryList,
|
||||||
|
(list) => {
|
||||||
|
if (list && list.length && !currentL1.value) {
|
||||||
|
currentL1.value = list[0]
|
||||||
|
currentL2.value = props.template === 4 ? null : (list[0].children && list[0].children[0]) || null
|
||||||
|
currentL3.value = (currentL2.value && currentL2.value.children && currentL2.value.children[0]) || null
|
||||||
|
loadGoods(true)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
function onL1Change(item: any) {
|
||||||
|
if (currentL1.value && item.id === currentL1.value.id) return
|
||||||
|
currentL1.value = item
|
||||||
|
currentL2.value = props.template === 4 ? null : (item.children && item.children[0]) || null
|
||||||
|
currentL3.value = (currentL2.value && currentL2.value.children && currentL2.value.children[0]) || null
|
||||||
|
resetSort()
|
||||||
|
loadGoods(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSideChange(item: any) {
|
||||||
|
if (props.template === 4) {
|
||||||
|
onL1Change(item)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (currentL2.value && item.id === currentL2.value.id) return
|
||||||
|
currentL2.value = item
|
||||||
|
currentL3.value = (item.children && item.children[0]) || null
|
||||||
|
loadGoods(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onL3Change(item: any) {
|
||||||
|
if (currentL3.value && item.id === currentL3.value.id) return
|
||||||
|
currentL3.value = item
|
||||||
|
loadGoods(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onL2Change(item: any) {
|
||||||
|
// 选中一级名称项 = 全部(L2 置空)
|
||||||
|
if (currentL1.value && item.id === currentL1.value.id) {
|
||||||
|
currentL2.value = null
|
||||||
|
} else {
|
||||||
|
currentL2.value = item
|
||||||
|
}
|
||||||
|
loadGoods(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSortChange(payload: { sort: string; order: string }) {
|
||||||
|
sort.value = payload.sort
|
||||||
|
order.value = payload.order
|
||||||
|
loadGoods(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetSort() {
|
||||||
|
sort.value = 'releaseTime'
|
||||||
|
order.value = 'desc'
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadGoods(reset = false) {
|
||||||
|
if (loading.value || !queryCategoryId.value) return
|
||||||
|
if (reset) {
|
||||||
|
pageNumber.value = 1
|
||||||
|
goodsList.value = []
|
||||||
|
hasMore.value = true
|
||||||
|
}
|
||||||
|
loading.value = true
|
||||||
|
failed.value = false
|
||||||
|
try {
|
||||||
|
const res = await getGoodsList({
|
||||||
|
categoryId: queryCategoryId.value,
|
||||||
|
sort: sort.value,
|
||||||
|
order: order.value,
|
||||||
|
pageNumber: pageNumber.value,
|
||||||
|
pageSize: 10,
|
||||||
|
})
|
||||||
|
const records = (res.data && res.data.result && res.data.result.records) || []
|
||||||
|
goodsList.value.push(...records)
|
||||||
|
hasMore.value = records.length >= 10
|
||||||
|
} catch (e) {
|
||||||
|
failed.value = true
|
||||||
|
uni.showToast({ title: '加载失败,请重试', icon: 'none' })
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadMore() {
|
||||||
|
if (!hasMore.value || loading.value) return
|
||||||
|
pageNumber.value += 1
|
||||||
|
loadGoods(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onAddCart(item: any) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages/product/goods?id=' + item.id + '&goodsId=' + item.goodsId,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.tpl-goods {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background: #ffffff;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.tpl-main {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
height: 0;
|
||||||
|
display: flex;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.tpl-right {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #ffffff;
|
||||||
|
}
|
||||||
|
.goods-scroll {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
.empty-state {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 60rpx 0 100rpx;
|
||||||
|
}
|
||||||
|
.retry {
|
||||||
|
margin-top: 24rpx;
|
||||||
|
padding: 12rpx 50rpx;
|
||||||
|
border: 1rpx solid $light-color;
|
||||||
|
color: $light-color;
|
||||||
|
border-radius: 36rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -27,18 +27,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<!-- 正常商品的价格 -->
|
<!-- 正常商品的价格 -->
|
||||||
<view v-else>
|
<view v-else>
|
||||||
<!-- 批发阶梯价(E_COUPON 仅零售价) -->
|
<div class="goods-price">
|
||||||
<div class="price-row flex" v-if="goodsDetail.salesModel === 'WHOLESALE' && !isECoupon(goodsDetail.goodsType)">
|
|
||||||
<div class="goods-price" v-for="(item, index) in wholesaleList" :key="index">
|
|
||||||
<span>
|
|
||||||
¥
|
|
||||||
<span class="goods-price-bigshow">{{ goodsFormatPrice(item.price)[0] }}</span>
|
|
||||||
.{{ goodsFormatPrice(item.price)[1] }}
|
|
||||||
</span>
|
|
||||||
<span class="wholesale-item">{{ item.num }}{{ goodsDetail.goodsUnit }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="goods-price" v-else>
|
|
||||||
<span>
|
<span>
|
||||||
¥
|
¥
|
||||||
<span class="goods-price-bigshow">{{ goodsFormatPrice(goodsDetail.price)[0] }}</span>
|
<span class="goods-price-bigshow">{{ goodsFormatPrice(goodsDetail.price)[0] }}</span>
|
||||||
@@ -135,7 +124,6 @@ import {
|
|||||||
} from '@/utils/goodsType.js'
|
} from '@/utils/goodsType.js'
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
wholesaleList?: any[] | boolean
|
|
||||||
buyMask?: boolean
|
buyMask?: boolean
|
||||||
isGroup?: boolean
|
isGroup?: boolean
|
||||||
goodsDetail?: any
|
goodsDetail?: any
|
||||||
@@ -144,7 +132,6 @@ const props = withDefaults(defineProps<{
|
|||||||
addr?: any | null
|
addr?: any | null
|
||||||
pointDetail?: any | null
|
pointDetail?: any | null
|
||||||
}>(), {
|
}>(), {
|
||||||
wholesaleList: false,
|
|
||||||
buyMask: false,
|
buyMask: false,
|
||||||
isGroup: false,
|
isGroup: false,
|
||||||
goodsDetail: () => ({}),
|
goodsDetail: () => ({}),
|
||||||
@@ -156,7 +143,7 @@ const props = withDefaults(defineProps<{
|
|||||||
|
|
||||||
const emit = defineEmits(['closeBuy', 'changed', 'handleClickSku', 'queryCart'])
|
const emit = defineEmits(['closeBuy', 'changed', 'handleClickSku', 'queryCart'])
|
||||||
|
|
||||||
const num = ref(props.wholesaleList && Array.isArray(props.wholesaleList) && props.wholesaleList.length > 0 ? props.wholesaleList[0].num : 1)
|
const num = ref(1)
|
||||||
|
|
||||||
const selectName = ref('')
|
const selectName = ref('')
|
||||||
const selectSkuList = ref<any>('')
|
const selectSkuList = ref<any>('')
|
||||||
@@ -231,18 +218,7 @@ watch(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const numCheck = (val: number) => {
|
|
||||||
if (Array.isArray(props.wholesaleList) && props.wholesaleList.length > 0) {
|
|
||||||
if (num.value <= props.wholesaleList[0].num) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '批发商品购买数量不能小于起批数量!',
|
|
||||||
duration: 2000,
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
num.value = props.wholesaleList[0].num
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const closeMask = () => {
|
const closeMask = () => {
|
||||||
emit('closeBuy', false)
|
emit('closeBuy', false)
|
||||||
@@ -541,13 +517,6 @@ defineExpose({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.wholesale-item {
|
|
||||||
color: #999 !important;
|
|
||||||
font-size: 24rpx;
|
|
||||||
margin: 0 20rpx;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.goods-header {
|
.goods-header {
|
||||||
height: 200rpx;
|
height: 200rpx;
|
||||||
|
|||||||
@@ -8,4 +8,11 @@
|
|||||||
| `type` | 商品展示类型 oneColumns twoColumns ,默认展示一行两列商品 | String | 否 |
|
| `type` | 商品展示类型 oneColumns twoColumns ,默认展示一行两列商品 | String | 否 |
|
||||||
| `storeName` | 是否展示店铺名称,默认展示 | Boolean | 否 |
|
| `storeName` | 是否展示店铺名称,默认展示 | Boolean | 否 |
|
||||||
| `keywords` | 高亮展示搜索内容 | String | 否 |
|
| `keywords` | 高亮展示搜索内容 | String | 否 |
|
||||||
|
| `showFields` | 商品卡片字段开关(Object,null=现状渲染全量字段)。键:`subTitle` 副标题、`spec` 规格摘要(取 attrList 前 2 项)、`tags` 促销标签、`selfTag` 自营、`price` 价格、`linePrice` 划线价(仅 marketPrice>price 时显示)、`sales` 已售/评论、`cart` 购物车按钮。新增字段(副标题/规格/划线价/购物车)仅在 showFields 提供时才会渲染;目前仅 oneColumns 布局支持开关 | Object | 否 |
|
||||||
|
|
||||||
|
### EVENTS 事件说明
|
||||||
|
|
||||||
|
| 事件名 | 说明 | 回调参数 |
|
||||||
|
| ------ | ---- | -------- |
|
||||||
|
| `addCart` | 点击购物车按钮(showFields.cart 开启时渲染) | 当前商品对象 |
|
||||||
|
|
||||||
|
|||||||
@@ -82,9 +82,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</view>
|
</view>
|
||||||
<div class="promotion" @click="navigateToDetailPage(item)">
|
<div class="promotion" @click="navigateToDetailPage(item)">
|
||||||
<div v-if="item.salesModel == 'WHOLESALE'">
|
|
||||||
<span>批</span>
|
|
||||||
</div>
|
|
||||||
<div
|
<div
|
||||||
v-for="(promotionItem, promotionIndex) in getPromotion(item)"
|
v-for="(promotionItem, promotionIndex) in getPromotion(item)"
|
||||||
:key="promotionIndex"
|
:key="promotionIndex"
|
||||||
|
|||||||
@@ -21,9 +21,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</view>
|
</view>
|
||||||
<div class="promotion" @click="navigateToDetailPage(item)">
|
<div class="promotion" @click="navigateToDetailPage(item)">
|
||||||
<div v-if="item.salesModel == 'WHOLESALE'">
|
|
||||||
<span class="promotion-tag">批</span>
|
|
||||||
</div>
|
|
||||||
<div v-for="(promotionItem,promotionIndex) in getPromotion(item)" :key="promotionIndex">
|
<div v-for="(promotionItem,promotionIndex) in getPromotion(item)" :key="promotionIndex">
|
||||||
<span class="promotion-tag" v-if="promotionItem.indexOf('COUPON') != -1">劵</span>
|
<span class="promotion-tag" v-if="promotionItem.indexOf('COUPON') != -1">劵</span>
|
||||||
<span class="promotion-tag" v-if="promotionItem.indexOf('FULL_DISCOUNT') != -1">满减</span>
|
<span class="promotion-tag" v-if="promotionItem.indexOf('FULL_DISCOUNT') != -1">满减</span>
|
||||||
@@ -46,40 +43,46 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 一行一列商品展示 -->
|
<!-- 一行一列商品展示 -->
|
||||||
<div v-if="type == 'oneColumns'" class="goods-one-row">
|
<div v-if="type == 'oneColumns'" class="goods-one-row" :class="{ 'goods-one-row--embedded': !tabBarGap }">
|
||||||
<div v-for="(item, index) in res" :key="index" class="goods-row">
|
<div v-for="(item, index) in res" :key="index" class="goods-row">
|
||||||
<div class="flex goods-col">
|
<div class="flex goods-col">
|
||||||
<div class="goods-img" @click="navigateToDetailPage(item)">
|
<div class="goods-img" @click="navigateToDetailPage(item)">
|
||||||
<u-image width="230rpx" mode="aspectFit" border-radius='16' height="230rpx" :src="item.thumbnail">
|
<u-image :width="!tabBarGap ? '170rpx' : '230rpx'" mode="aspectFit" :border-radius="!tabBarGap ? '12' : '16'" :height="!tabBarGap ? '170rpx' : '230rpx'" :src="item.thumbnail">
|
||||||
<template #loading><u-loading-icon></u-loading-icon></template>
|
<template #loading><u-loading-icon></u-loading-icon></template>
|
||||||
</u-image>
|
</u-image>
|
||||||
</div>
|
</div>
|
||||||
<div class="goods-detail">
|
<div class="goods-detail">
|
||||||
<div class="title clamp3" @click="navigateToDetailPage(item)">{{ item.goodsName }}</div>
|
<div class="title clamp2" @click="navigateToDetailPage(item)">
|
||||||
<view class="price-box" @click="navigateToDetailPage(item)">
|
<text class="self-tag" v-if="(!storeName || flag('selfTag')) && item.selfOperated">自营</text>
|
||||||
<div class="price" v-if="item.price!=undefined">
|
{{ item.goodsName }}
|
||||||
¥<span class="price-int">{{ goodsFormatPrice(item.price )[0] }} </span>.{{
|
</div>
|
||||||
goodsFormatPrice(item.price )[1]
|
<div class="selling-point" v-if="extra('subTitle') && item.sellingPoint">{{ item.sellingPoint }}</div>
|
||||||
}}
|
<div class="spec-summary" v-if="extra('spec') && specSummary(item)">{{ specSummary(item) }}</div>
|
||||||
</div>
|
<div class="promotion" v-if="flag('tags')" @click="navigateToDetailPage(item)">
|
||||||
</view>
|
<div v-for="(promotionItem,promotionIndex) in getPromotion(item)" :key="promotionIndex">
|
||||||
<div class="promotion" @click="navigateToDetailPage(item)">
|
|
||||||
<div v-if="item.salesModel == 'WHOLESALE'">
|
|
||||||
<span class="promotion-tag">批</span>
|
|
||||||
</div>
|
|
||||||
<div v-for="(promotionItem,promotionIndex) in getPromotion(item)" :key="promotionIndex">
|
|
||||||
<span class="promotion-tag" v-if="promotionItem.indexOf('COUPON') != -1">劵</span>
|
<span class="promotion-tag" v-if="promotionItem.indexOf('COUPON') != -1">劵</span>
|
||||||
<span class="promotion-tag" v-if="promotionItem.indexOf('FULL_DISCOUNT') != -1">满减</span>
|
<span class="promotion-tag" v-if="promotionItem.indexOf('FULL_DISCOUNT') != -1">满减</span>
|
||||||
<span class="promotion-tag" v-if="promotionItem.indexOf('SECKILL') != -1">秒杀</span>
|
<span class="promotion-tag" v-if="promotionItem.indexOf('SECKILL') != -1">秒杀</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="overflow: hidden" @click="navigateToDetailPage(item)" class="count-config">
|
<div style="overflow: hidden" v-if="flag('sales')" @click="navigateToDetailPage(item)" class="count-config">
|
||||||
<span style="float: left; font-size: 22rpx">已售 {{ item.buyCount || '0' }}</span>
|
<span style="float: left; font-size: 22rpx">已售 {{ item.buyCount || '0' }}</span>
|
||||||
<span style="float: right; font-size: 22rpx">{{ item.commentNum || '0' }}条评论</span>
|
<span style="float: right; font-size: 22rpx" v-if="item.commentNum">{{ item.commentNum }}条评论</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="store-seller-name" @click="navigateToStoreDetailPage(item)">
|
<view class="price-box" @click="navigateToDetailPage(item)">
|
||||||
<view class="store-name-row" v-if="storeName">
|
<div class="price" v-if="flag('price') && item.price!=undefined">
|
||||||
<text class="self-tag" v-if="item.selfOperated">自营</text>
|
¥<span class="price-int">{{ goodsFormatPrice(item.price )[0] }} </span>.{{
|
||||||
|
goodsFormatPrice(item.price )[1]
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
|
<div class="market-price" v-if="extra('linePrice') && hasMarketPrice(item)">¥{{ item.marketPrice }}</div>
|
||||||
|
<div class="cart-btn" v-if="extra('cart')" @click.stop="emit('addCart', item)">
|
||||||
|
<u-icon name="shopping-cart" size="16" :color="mainColor"></u-icon>
|
||||||
|
</div>
|
||||||
|
</view>
|
||||||
|
<div class="store-seller-name" v-if="storeName" @click="navigateToStoreDetailPage(item)">
|
||||||
|
<view class="store-name-row">
|
||||||
|
<text class="self-tag" v-if="item.selfOperated && flag('selfTag')">自营</text>
|
||||||
<text class="store-name-text">{{ item.storeName }}</text>
|
<text class="store-name-text">{{ item.storeName }}</text>
|
||||||
<text class="to-store">进店</text>
|
<text class="to-store">进店</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -87,18 +90,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { watch } from 'vue'
|
import { computed, watch } from 'vue'
|
||||||
|
import { useStore } from '@/store'
|
||||||
import { useGoodsListCommon } from './common'
|
import { useGoodsListCommon } from './common'
|
||||||
import { goodsFormatPrice } from '@/utils/filters.js'
|
import { goodsFormatPrice } from '@/utils/filters.js'
|
||||||
|
|
||||||
|
const store = useStore()
|
||||||
|
const mainColor = computed(() => (store && store.getters && store.getters.mainColor) || '#ff3c2a')
|
||||||
|
|
||||||
const { lightSearchStr, getPromotion, navigateToDetailPage, navigateToStoreDetailPage } = useGoodsListCommon()
|
const { lightSearchStr, getPromotion, navigateToDetailPage, navigateToStoreDetailPage } = useGoodsListCommon()
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
@@ -107,14 +112,29 @@ const props = withDefaults(defineProps<{
|
|||||||
storeName?: boolean
|
storeName?: boolean
|
||||||
tabBarGap?: boolean
|
tabBarGap?: boolean
|
||||||
keyword?: string | null
|
keyword?: string | null
|
||||||
|
showFields?: Record<string, boolean> | null
|
||||||
}>(), {
|
}>(), {
|
||||||
res: () => [],
|
res: () => [],
|
||||||
type: 'twoColumns',
|
type: 'twoColumns',
|
||||||
storeName: true,
|
storeName: true,
|
||||||
tabBarGap: true,
|
tabBarGap: true,
|
||||||
keyword: ''
|
keyword: '',
|
||||||
|
showFields: null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(['addCart'])
|
||||||
|
|
||||||
|
// 存量字段(促销/销量/自营/价格):showFields 为 null 时维持现状渲染
|
||||||
|
const flag = (key: string) => props.showFields == null || props.showFields[key] !== false
|
||||||
|
// 新增字段(副标题/规格/划线价/购物车按钮):仅 showFields 提供时可渲染
|
||||||
|
const extra = (key: string) => props.showFields != null && props.showFields[key] !== false
|
||||||
|
const hasMarketPrice = (item: any) =>
|
||||||
|
item.marketPrice != null && item.price != null && item.marketPrice > item.price
|
||||||
|
const specSummary = (item: any) =>
|
||||||
|
Array.isArray(item.attrList)
|
||||||
|
? item.attrList.slice(0, 2).map((a: any) => `${a.name}: ${a.value}`).join(' · ')
|
||||||
|
: ''
|
||||||
|
|
||||||
watch(() => props.keyword, (val) => {
|
watch(() => props.keyword, (val) => {
|
||||||
if (val) {
|
if (val) {
|
||||||
lightSearchStr(val as string, '')
|
lightSearchStr(val as string, '')
|
||||||
@@ -217,6 +237,128 @@ watch(() => props.keyword, (val) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.goods-one-row--embedded {
|
||||||
|
.goods-row {
|
||||||
|
padding: 20rpx 16rpx;
|
||||||
|
border-bottom: 1rpx solid #f6f6f6;
|
||||||
|
background: #ffffff;
|
||||||
|
|
||||||
|
>.goods-col {
|
||||||
|
display: flex;
|
||||||
|
align-items: stretch;
|
||||||
|
|
||||||
|
>.goods-img {
|
||||||
|
flex: 0 0 170rpx;
|
||||||
|
width: 170rpx;
|
||||||
|
height: 170rpx;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #f8f8f8;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.goods-detail {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
margin: 0 0 0 16rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
>.title {
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #222;
|
||||||
|
line-height: 1.4;
|
||||||
|
max-height: 74rpx;
|
||||||
|
padding: 0;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
|
||||||
|
.self-tag {
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 8rpx;
|
||||||
|
padding: 1rpx 8rpx;
|
||||||
|
border-radius: 6rpx;
|
||||||
|
background: $main-color;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 20rpx;
|
||||||
|
line-height: 1.4;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.selling-point {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #999;
|
||||||
|
line-height: 1.3;
|
||||||
|
margin-top: 4rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spec-summary {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #999;
|
||||||
|
line-height: 1.3;
|
||||||
|
margin-top: 2rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.count-config {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #999;
|
||||||
|
margin-top: 4rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.price-box {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-top: auto;
|
||||||
|
padding-top: 8rpx;
|
||||||
|
|
||||||
|
.price {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: $main-color;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1;
|
||||||
|
|
||||||
|
.price-int {
|
||||||
|
font-size: 34rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.market-price {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #bbb;
|
||||||
|
text-decoration: line-through;
|
||||||
|
margin-left: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cart-btn {
|
||||||
|
width: 48rpx;
|
||||||
|
height: 48rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #ffffff;
|
||||||
|
border: 2rpx solid $main-color;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
box-sizing: border-box;
|
||||||
|
box-shadow: 0 2rpx 8rpx rgba(255, 60, 42, 0.12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.goods-row {
|
.goods-row {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
padding: 16rpx;
|
padding: 16rpx;
|
||||||
@@ -250,7 +392,48 @@ watch(() => props.keyword, (val) => {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.promotion {
|
.selling-point {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #999;
|
||||||
|
line-height: 1.4;
|
||||||
|
margin-top: 4rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spec-summary {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #999;
|
||||||
|
line-height: 1.4;
|
||||||
|
margin-top: 4rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.market-price {
|
||||||
|
font-size: 22rpx;
|
||||||
|
color: #999;
|
||||||
|
text-decoration: line-through;
|
||||||
|
margin-left: 8rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cart-btn {
|
||||||
|
width: 48rpx;
|
||||||
|
height: 48rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #ffffff;
|
||||||
|
border: 2rpx solid $main-color;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
box-shadow: 0 2rpx 8rpx rgba(255, 60, 42, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.promotion {
|
||||||
margin-top: 4rpx;
|
margin-top: 4rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
|
|||||||
1
main.js
1
main.js
@@ -39,6 +39,7 @@ export function createApp() {
|
|||||||
setConfig({
|
setConfig({
|
||||||
config: {
|
config: {
|
||||||
loadFontOnce: true,
|
loadFontOnce: true,
|
||||||
|
iconUrl: 'https://lilishop-uniapp.oss-cn-beijing.aliyuncs.com/font_2225171_8kdcwk4po24.ttf',
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
form: {
|
form: {
|
||||||
|
|||||||
@@ -55,6 +55,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<view class="submit" @click="cashd">提现</view>
|
<view class="submit" @click="cashd">提现</view>
|
||||||
|
|
||||||
|
<!-- 提现规则说明(满足微信小程序审核要求) -->
|
||||||
|
<view class="rule-card">
|
||||||
|
<view class="rule-title">
|
||||||
|
<text class="rule-icon"></text>
|
||||||
|
<text>提现规则说明</text>
|
||||||
|
</view>
|
||||||
|
<view class="rule-content">
|
||||||
|
<text class="rule-text">{{ displayRule }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -75,6 +86,7 @@ const minPrice = ref(0)
|
|||||||
const type = ref('')
|
const type = ref('')
|
||||||
const connectNumber = ref('')
|
const connectNumber = ref('')
|
||||||
const realName = ref('')
|
const realName = ref('')
|
||||||
|
const withdrawRule = ref('')
|
||||||
|
|
||||||
const typeLabel = computed(() => {
|
const typeLabel = computed(() => {
|
||||||
if (type.value === 'ALI') return '支付宝'
|
if (type.value === 'ALI') return '支付宝'
|
||||||
@@ -82,12 +94,28 @@ const typeLabel = computed(() => {
|
|||||||
return '--'
|
return '--'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const defaultRule = computed(() => {
|
||||||
|
const minText = minPrice.value ? `单笔最低提现金额为 ${minPrice.value} 元` : '单笔最低提现金额以页面提示为准'
|
||||||
|
const channelText = typeLabel.value === '支付宝' ? '支付宝账户' : '微信零钱账户'
|
||||||
|
return `1. 提现额度:${minText},单日累计最高提现 5000 元;
|
||||||
|
2. 提现频次:每个用户每日最多可申请提现 1 次;
|
||||||
|
3. 提现时间:支持全天 24 小时随时发起提现申请;
|
||||||
|
4. 到账时间:提交申请后预计 1~3 个工作日内审核并转账至您的${channelText};
|
||||||
|
5. 手续费说明:提现免收手续费;
|
||||||
|
6. 如有其他疑问或遇到提现未到账,请联系在线客服协助处理。`
|
||||||
|
})
|
||||||
|
|
||||||
|
const displayRule = computed(() => {
|
||||||
|
return withdrawRule.value ? withdrawRule.value : defaultRule.value
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const result = await getUserWallet()
|
const result = await getUserWallet()
|
||||||
const res = await withdrawalSettingVO()
|
const res = await withdrawalSettingVO()
|
||||||
walletNum.value = result.data.result.memberWallet
|
walletNum.value = result.data.result.memberWallet
|
||||||
minPrice.value = res.data.result.minPrice
|
minPrice.value = res.data.result.minPrice
|
||||||
type.value = res.data.result.type
|
type.value = res.data.result.type
|
||||||
|
withdrawRule.value = res.data.result.withdrawRule || ''
|
||||||
})
|
})
|
||||||
|
|
||||||
function cashd() {
|
function cashd() {
|
||||||
@@ -265,4 +293,37 @@ function handleAll() {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 32rpx;
|
font-size: 32rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.rule-card {
|
||||||
|
margin-top: 48rpx;
|
||||||
|
padding: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rule-title {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 16rpx;
|
||||||
|
|
||||||
|
.rule-icon {
|
||||||
|
width: 6rpx;
|
||||||
|
height: 26rpx;
|
||||||
|
background: $main-color;
|
||||||
|
border-radius: 4rpx;
|
||||||
|
margin-right: 12rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.rule-content {
|
||||||
|
.rule-text {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #888;
|
||||||
|
line-height: 1.8;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -101,20 +101,7 @@
|
|||||||
<view class="-goods-price" v-if="goodsDetail.price != undefined">
|
<view class="-goods-price" v-if="goodsDetail.price != undefined">
|
||||||
|
|
||||||
<span>
|
<span>
|
||||||
<span v-if="wholesaleList.length">
|
<span>
|
||||||
<span>¥</span><span class="price">{{
|
|
||||||
goodsFormatPrice(wholesaleList[wholesaleList.length - 1].price)[0]
|
|
||||||
}}</span>.{{
|
|
||||||
goodsFormatPrice(wholesaleList[wholesaleList.length - 1].price)[1]
|
|
||||||
}}
|
|
||||||
~
|
|
||||||
<span>¥</span><span class="price">{{
|
|
||||||
goodsFormatPrice(wholesaleList[0].price)[0]
|
|
||||||
}}</span>.{{
|
|
||||||
goodsFormatPrice(wholesaleList[0].price)[1]
|
|
||||||
}}
|
|
||||||
</span>
|
|
||||||
<span v-else>
|
|
||||||
<span>¥</span><span class="price">{{
|
<span>¥</span><span class="price">{{
|
||||||
goodsFormatPrice(goodsDetail.price)[0]
|
goodsFormatPrice(goodsDetail.price)[0]
|
||||||
}}</span>.{{ goodsFormatPrice(goodsDetail.price)[1] }}
|
}}</span>.{{ goodsFormatPrice(goodsDetail.price)[1] }}
|
||||||
@@ -183,17 +170,6 @@
|
|||||||
<u-icon name="more-dot-fill"></u-icon>
|
<u-icon name="more-dot-fill"></u-icon>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="card-flex" @click="shutMask(3)">
|
|
||||||
<view class="card-title"> 送至</view>
|
|
||||||
<view class="card-content">
|
|
||||||
<span v-if="delivery">{{clearStrComma(delivery.consigneeAddressPath)
|
|
||||||
}}</span>
|
|
||||||
<span v-else>暂无地址信息</span>
|
|
||||||
</view>
|
|
||||||
<view class="card-bottom">
|
|
||||||
<u-icon name="more-dot-fill"></u-icon>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 评价 -->
|
<!-- 评价 -->
|
||||||
@@ -284,14 +260,10 @@
|
|||||||
</view>
|
</view>
|
||||||
</u-popup>
|
</u-popup>
|
||||||
|
|
||||||
<!-- 配送地址弹窗 -->
|
|
||||||
<popupAddress @closeAddress="closePopupAddress" @deliveryData="deliveryFun" v-if="goodsDetail.id"
|
|
||||||
:goodsId="goodsDetail.id" :addressFlag="addressFlag" />
|
|
||||||
|
|
||||||
<!-- 商品规格 商品详情,以及默认参与活动的id-->
|
<!-- 商品规格 商品详情,以及默认参与活动的id-->
|
||||||
<popupGoods :addr="delivery" ref="popupGoodsRef" @changed="changedGoods" @closeBuy="closePopupBuy"
|
<popupGoods ref="popupGoodsRef" @changed="changedGoods" @closeBuy="closePopupBuy"
|
||||||
@queryCart="cartCount()" :goodsDetail="goodsDetail" :goodsSpec="goodsSpec" :isGroup="isGroup" :id="productId"
|
@queryCart="cartCount()" :goodsDetail="goodsDetail" :goodsSpec="goodsSpec" :isGroup="isGroup" :id="productId"
|
||||||
v-if="goodsDetail.id" :pointDetail="pointDetail" :wholesaleList="wholesaleList" @handleClickSku="selectSku"
|
v-if="goodsDetail.id" :pointDetail="pointDetail" @handleClickSku="selectSku"
|
||||||
:buyMask="buyMask" />
|
:buyMask="buyMask" />
|
||||||
|
|
||||||
<!-- 下架框 -->
|
<!-- 下架框 -->
|
||||||
@@ -331,7 +303,6 @@ import storeLayout from './product/shop/-shop'
|
|||||||
import Evaluation from './product/evaluation/-evaluation'
|
import Evaluation from './product/evaluation/-evaluation'
|
||||||
import GoodsSwiper from './product/goods/-goods-swiper'
|
import GoodsSwiper from './product/goods/-goods-swiper'
|
||||||
import popupGoods from '@/components/m-buy/goods'
|
import popupGoods from '@/components/m-buy/goods'
|
||||||
import popupAddress from './product/popup/address'
|
|
||||||
import shares from '@/components/m-share/index'
|
import shares from '@/components/m-share/index'
|
||||||
import takeDownFormSaleGoods from '@/components/m-take-down-sale-goods/index'
|
import takeDownFormSaleGoods from '@/components/m-take-down-sale-goods/index'
|
||||||
import setup from './product/popup/popup'
|
import setup from './product/popup/popup'
|
||||||
@@ -371,7 +342,6 @@ const goodsSpec = ref<any>("")
|
|||||||
const imgList = ref<any[]>([])
|
const imgList = ref<any[]>([])
|
||||||
const favorite = ref(false)
|
const favorite = ref(false)
|
||||||
const recommendList = ref<any[]>([])
|
const recommendList = ref<any[]>([])
|
||||||
const addressFlag = ref(false)
|
|
||||||
const buyMask = ref(false)
|
const buyMask = ref(false)
|
||||||
const num = ref(1)
|
const num = ref(1)
|
||||||
const skuId = ref<any>("")
|
const skuId = ref<any>("")
|
||||||
@@ -385,13 +355,11 @@ const PromotionList = ref<any>("")
|
|||||||
const specList = ref<any[]>([])
|
const specList = ref<any[]>([])
|
||||||
const selectedSpec = ref<any[]>([])
|
const selectedSpec = ref<any[]>([])
|
||||||
const nums = ref(0)
|
const nums = ref(0)
|
||||||
const delivery = ref<any>("")
|
|
||||||
const exchange = ref<any>({})
|
const exchange = ref<any>({})
|
||||||
const productId = ref(0)
|
const productId = ref(0)
|
||||||
const startTimer = ref(false)
|
const startTimer = ref(false)
|
||||||
const routerVal = ref<any>("")
|
const routerVal = ref<any>("")
|
||||||
const IMLink = ref("")
|
const IMLink = ref("")
|
||||||
const wholesaleList = ref<any[]>([])
|
|
||||||
const takeDownFromSale = ref(false)
|
const takeDownFromSale = ref(false)
|
||||||
|
|
||||||
// computed
|
// computed
|
||||||
@@ -520,7 +488,6 @@ async function init(id: any, goodsId: any, distributionId = "", shareId = "") {
|
|||||||
if (goodsDetail.value) {
|
if (goodsDetail.value) {
|
||||||
goodsDetail.value.thumbnail = parseGoodsImageUrl(goodsDetail.value.thumbnail)
|
goodsDetail.value.thumbnail = parseGoodsImageUrl(goodsDetail.value.thumbnail)
|
||||||
}
|
}
|
||||||
wholesaleList.value = response.data.result.wholesaleList || []
|
|
||||||
goodsSpec.value = response.data.result.specs || ""
|
goodsSpec.value = response.data.result.specs || ""
|
||||||
PromotionList.value = response.data.result.promotionMap || ""
|
PromotionList.value = response.data.result.promotionMap || ""
|
||||||
goodsParams.value = response.data.result.goodsParamsDTOList || []
|
goodsParams.value = response.data.result.goodsParamsDTOList || []
|
||||||
@@ -565,13 +532,6 @@ function changedGoods(val: any) {
|
|||||||
selectedGoods.value = val
|
selectedGoods.value = val
|
||||||
}
|
}
|
||||||
|
|
||||||
function deliveryFun(val: any) {
|
|
||||||
delivery.value = val
|
|
||||||
}
|
|
||||||
|
|
||||||
function closePopupAddress(val: any) {
|
|
||||||
addressFlag.value = val
|
|
||||||
}
|
|
||||||
|
|
||||||
function closePopupBuy(val: any) {
|
function closePopupBuy(val: any) {
|
||||||
buyMask.value = val
|
buyMask.value = val
|
||||||
@@ -709,15 +669,11 @@ function handleBuyClick() {
|
|||||||
function shutMask(flag: any, buyFlag?: any, type?: any) {
|
function shutMask(flag: any, buyFlag?: any, type?: any) {
|
||||||
promotionShow.value = false
|
promotionShow.value = false
|
||||||
buyMask.value = false
|
buyMask.value = false
|
||||||
addressFlag.value = false
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
switch (flag) {
|
switch (flag) {
|
||||||
case 1:
|
case 1:
|
||||||
promotionShow.value = true
|
promotionShow.value = true
|
||||||
break
|
break
|
||||||
case 3:
|
|
||||||
addressFlag.value = true
|
|
||||||
break
|
|
||||||
case 4:
|
case 4:
|
||||||
buyMask.value = true
|
buyMask.value = true
|
||||||
if (buyFlag == "PINTUAN") {
|
if (buyFlag == "PINTUAN") {
|
||||||
|
|||||||
@@ -54,10 +54,6 @@ const cityList = ref([
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (isLogin('auth')) {
|
if (isLogin('auth')) {
|
||||||
getShippingAddress()
|
getShippingAddress()
|
||||||
} else {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: '/pages/passport/login',
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,6 @@
|
|||||||
</p>
|
</p>
|
||||||
<!-- 规格 -->
|
<!-- 规格 -->
|
||||||
<p class="sp-type" style="width:300rpx">{{skuItem.goodsSku.simpleSpecs}}</p>
|
<p class="sp-type" style="width:300rpx">{{skuItem.goodsSku.simpleSpecs}}</p>
|
||||||
<p class="sp-type" v-if="skuItem.goodsSku.salesModel == 'WHOLESALE'">批发商品</p>
|
|
||||||
<view class="sp-number">
|
<view class="sp-number">
|
||||||
<view class="sp-price">
|
<view class="sp-price">
|
||||||
<div class="main-color">
|
<div class="main-color">
|
||||||
|
|||||||
@@ -11,48 +11,63 @@
|
|||||||
bg-color="#ffffff"
|
bg-color="#ffffff"
|
||||||
>
|
>
|
||||||
<template #left>
|
<template #left>
|
||||||
<view class="nav-content">
|
<view class="nav-search-box" :style="searchBarStyle" @click="search">
|
||||||
<text class="title">商品分类</text>
|
<u-icon name="search" size="16" color="#999999"></u-icon>
|
||||||
<view class="nav-search-wrap" :style="searchBarStyle">
|
<text class="search-placeholder">搜索商品</text>
|
||||||
<!-- #ifdef H5 -->
|
|
||||||
<u-search class="nav-search" @click="search" placeholder="搜索商品" :show-action="false"></u-search>
|
|
||||||
<!-- #endif -->
|
|
||||||
<!-- #ifndef H5 -->
|
|
||||||
<u-search class="nav-search" disabled @click="search" placeholder="搜索商品" :show-action="false"></u-search>
|
|
||||||
<!-- #endif -->
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</u-navbar>
|
</u-navbar>
|
||||||
<view class="content">
|
<view class="content" v-if="pageTemplate === 1">
|
||||||
<scroll-view scroll-y scroll-with-animation class="left-aside">
|
<scroll-view scroll-y scroll-with-animation class="left-aside">
|
||||||
<view v-for="(item, index) in tabList" :key="item.id" class="f-item b-b" :class="{ active: item.id === currentId }" @click="tabtap(item, index)">
|
<view
|
||||||
{{ item.name }}
|
v-for="(item, index) in tabList"
|
||||||
|
:key="item.id"
|
||||||
|
class="f-item"
|
||||||
|
:class="{ active: item.id === currentId }"
|
||||||
|
@click="tabtap(item, index)"
|
||||||
|
>
|
||||||
|
<text class="f-text">{{ item.name }}</text>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
<scroll-view scroll-with-animation scroll-y class="right-aside" :upper-threshold="-100" :lower-threshold="-100">
|
<scroll-view scroll-with-animation scroll-y class="right-aside" :upper-threshold="-100" :lower-threshold="-100">
|
||||||
<!-- 头部图片 -->
|
<!-- 头部图片 -->
|
||||||
<view class="top-img" id="main-top">
|
<view class="top-img" id="main-top" v-if="topImg && topImg.image">
|
||||||
<u-image width="500rpx" height="230rpx" @click="navigateToList(topImg.id,topImg.id)" :src="topImg.image" mode="">
|
<u-image width="100%" height="200rpx" border-radius="12rpx" @click="navigateToList(topImg.id, topImg.id)" :src="topImg.image" mode="aspectFill">
|
||||||
</u-image>
|
</u-image>
|
||||||
</view>
|
</view>
|
||||||
<view v-for="item in categoryList" :key="item.id" class="s-list" :id="'main-' + item.id">
|
<view v-for="item in categoryList" :key="item.id" class="s-list" :id="'main-' + item.id">
|
||||||
<!-- 分类标题 -->
|
<!-- 分类标题 -->
|
||||||
<text class="s-item">{{ item.name }}</text>
|
<view class="s-header" @click="navigateToList(item.id, item.id)">
|
||||||
|
<text class="s-item">{{ item.name }}</text>
|
||||||
|
<u-icon name="arrow-right" size="12" color="#bbbbbb"></u-icon>
|
||||||
|
</view>
|
||||||
<!-- 分类详情 -->
|
<!-- 分类详情 -->
|
||||||
<view class="t-list">
|
<view class="t-list">
|
||||||
<template v-for="(children, cIndex) in item.children" :key="children.id">
|
<template v-for="(children, cIndex) in item.children" :key="children.id">
|
||||||
<view @click="navigateToList(item.id, children.id)" v-if="children.parentId === item.id" class="t-item"
|
<view
|
||||||
:class="{ 'margin-right': (cIndex + 1) % 3 == 0 }">
|
@click="navigateToList(item.id, children.id)"
|
||||||
<u-image width="70px" height="70px" :src="children.image" :lazy-load="true">
|
v-if="children.parentId === item.id"
|
||||||
</u-image>
|
class="t-item"
|
||||||
<text>{{ children.name }}</text>
|
>
|
||||||
</view>
|
<view class="t-img-box">
|
||||||
|
<u-image width="128rpx" height="128rpx" border-radius="12rpx" :src="children.image" :lazy-load="true" mode="aspectFit">
|
||||||
|
<template #loading><u-loading-icon></u-loading-icon></template>
|
||||||
|
</u-image>
|
||||||
|
</view>
|
||||||
|
<text class="t-name">{{ children.name }}</text>
|
||||||
|
</view>
|
||||||
</template>
|
</template>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
|
<tpl-category-goods
|
||||||
|
v-else
|
||||||
|
class="tpl-goods-wrapper"
|
||||||
|
:category-list="tabList"
|
||||||
|
:setting="categoryPageSetting"
|
||||||
|
:template="pageTemplate"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -61,10 +76,17 @@ import { ref, computed } from 'vue'
|
|||||||
import { onLoad, onReady } from '@dcloudio/uni-app'
|
import { onLoad, onReady } from '@dcloudio/uni-app'
|
||||||
import { getCategoryList } from '@/api/goods.js'
|
import { getCategoryList } from '@/api/goods.js'
|
||||||
import { getThemeStyle } from '@/utils/theme'
|
import { getThemeStyle } from '@/utils/theme'
|
||||||
|
import { DEFAULT_CATEGORY_PAGE_SETTING } from '@/utils/categoryPageSetting'
|
||||||
import { useStore } from '@/store'
|
import { useStore } from '@/store'
|
||||||
|
import TplCategoryGoods from '@/components/category/tpl-category-goods.vue'
|
||||||
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
|
|
||||||
|
const categoryPageSetting = computed(
|
||||||
|
() => store.state.categoryPageSetting || DEFAULT_CATEGORY_PAGE_SETTING
|
||||||
|
)
|
||||||
|
const pageTemplate = computed(() => categoryPageSetting.value.template || 1)
|
||||||
|
|
||||||
const currentId = ref(0)
|
const currentId = ref(0)
|
||||||
const tabList = ref<any[]>([]) // 左侧标题列表
|
const tabList = ref<any[]>([]) // 左侧标题列表
|
||||||
const categoryList = ref<any[]>([]) // 右侧分类数据列表
|
const categoryList = ref<any[]>([]) // 右侧分类数据列表
|
||||||
@@ -75,9 +97,9 @@ const themeStyle = computed(() => getThemeStyle(store.state.theme))
|
|||||||
|
|
||||||
const searchBarStyle = computed(() => {
|
const searchBarStyle = computed(() => {
|
||||||
if (searchBarWidth.value) {
|
if (searchBarWidth.value) {
|
||||||
return { width: `${searchBarWidth.value}px` }
|
return { width: searchBarWidth.value + 'px' }
|
||||||
}
|
}
|
||||||
return { width: "460rpx" }
|
return { width: "680rpx" }
|
||||||
})
|
})
|
||||||
|
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
@@ -98,18 +120,25 @@ function setSearchBarWidth() {
|
|||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
try {
|
try {
|
||||||
const menuButton = uni.getMenuButtonBoundingClientRect()
|
const menuButton = uni.getMenuButtonBoundingClientRect()
|
||||||
const { windowWidth } = uni.getWindowInfo()
|
const leftMargin = uni.upx2px(24) // 搜索框左边距
|
||||||
const capsuleInsetRight = windowWidth - menuButton.left
|
|
||||||
const titleWidth = uni.upx2px(160) // "商品分类" 标题宽度
|
|
||||||
const leftPadding = uni.upx2px(60) // 左侧内边距
|
|
||||||
const gap = uni.upx2px(20) // 搜索框与胶囊间距
|
const gap = uni.upx2px(20) // 搜索框与胶囊间距
|
||||||
searchBarWidth.value =
|
// 搜索框延伸至胶囊左边沿
|
||||||
windowWidth - capsuleInsetRight - titleWidth - leftPadding - gap
|
const calcWidth = menuButton.left - leftMargin - gap
|
||||||
|
searchBarWidth.value = Math.max(calcWidth, 200)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
searchBarWidth.value = 180
|
searchBarWidth.value = 240
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
// #ifndef MP-WEIXIN
|
||||||
|
try {
|
||||||
|
const info = (uni.getWindowInfo ? uni.getWindowInfo() : (uni.getSystemInfoSync ? uni.getSystemInfoSync() : {})); const windowWidth = info.windowWidth || 375;
|
||||||
|
searchBarWidth.value = windowWidth - uni.upx2px(48)
|
||||||
|
} catch (e) {
|
||||||
|
searchBarWidth.value = 340
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询
|
* 查询
|
||||||
*/
|
*/
|
||||||
@@ -125,8 +154,10 @@ function search() {
|
|||||||
async function loadData() {
|
async function loadData() {
|
||||||
let list = await getCategoryList(0)
|
let list = await getCategoryList(0)
|
||||||
tabList.value = list.data.result
|
tabList.value = list.data.result
|
||||||
currentId.value = list.data.result[0].id
|
if (tabList.value && tabList.value.length) {
|
||||||
loadListContent(0)
|
currentId.value = tabList.value[0].id
|
||||||
|
loadListContent(0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -136,6 +167,7 @@ function loadListContent(index: number) {
|
|||||||
topImg.value = tabList.value[index]
|
topImg.value = tabList.value[index]
|
||||||
categoryList.value = tabList.value[index].children
|
categoryList.value = tabList.value[index].children
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 一级分类点击
|
* 一级分类点击
|
||||||
*/
|
*/
|
||||||
@@ -148,7 +180,7 @@ function tabtap(item: any, i: number) {
|
|||||||
|
|
||||||
function navigateToList(sid: any, tid: any) {
|
function navigateToList(sid: any, tid: any) {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/navigation/search/searchPage?category=${tid}`,
|
url: '/pages/navigation/search/searchPage?category=' + tid,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -156,7 +188,7 @@ function navigateToList(sid: any, tid: any) {
|
|||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
page {
|
page {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background-color: #fdfaff;
|
background-color: #ffffff;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
@@ -170,36 +202,42 @@ page {
|
|||||||
/* 解决H5 的问题 */
|
/* 解决H5 的问题 */
|
||||||
/* #ifdef H5 */
|
/* #ifdef H5 */
|
||||||
uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
|
uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
|
||||||
/* 隐藏滚动条,但依旧具备可以滚动的功能 */
|
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
/* #endif */
|
/* #endif */
|
||||||
.s-list {
|
|
||||||
box-shadow: 0 4rpx 12rpx 0 rgba(0, 0, 0, 0.05);
|
|
||||||
}
|
|
||||||
.nav-content {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.nav-search-wrap {
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
.nav-search {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
.title {
|
|
||||||
flex-shrink: 0;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 28rpx;
|
|
||||||
padding-right: 16rpx;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
.category-wrap {
|
.category-wrap {
|
||||||
height: 100vh;
|
height: 100%;
|
||||||
|
min-height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
background-color: #ffffff;
|
||||||
|
|
||||||
|
.navbar {
|
||||||
|
border-bottom: 1rpx solid #f2f3f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-search-box {
|
||||||
|
height: 64rpx;
|
||||||
|
background: #f4f5f7;
|
||||||
|
border-radius: 32rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 24rpx;
|
||||||
|
margin-left: 24rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-placeholder {
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #999999;
|
||||||
|
margin-left: 12rpx;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
@@ -207,85 +245,159 @@ uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
|
|||||||
display: flex;
|
display: flex;
|
||||||
color: #333;
|
color: #333;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
background: #fff;
|
background: #ffffff;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.left-aside {
|
.left-aside {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
width: 200rpx;
|
width: 176rpx;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background-color: #f7f7f7;
|
background-color: #f6f7f9;
|
||||||
|
border-right: 1rpx solid #ebebeb;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.f-item {
|
.f-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 97rpx;
|
min-height: 96rpx;
|
||||||
|
padding: 16rpx 14rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color: #666;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 1.35;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
font-weight: bold;
|
font-weight: 600;
|
||||||
color: $light-color;
|
color: $light-color;
|
||||||
background: #fff;
|
background: #ffffff;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
width: 6rpx;
|
||||||
|
height: 36rpx;
|
||||||
|
border-radius: 0 4rpx 4rpx 0;
|
||||||
|
background: $light-color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.f-text {
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 2;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
.right-aside {
|
.right-aside {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: 40rpx 0 0 30rpx;
|
padding: 20rpx 20rpx 40rpx;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
background: #f8f9fa;
|
||||||
}
|
}
|
||||||
|
|
||||||
.top-img {
|
.top-img {
|
||||||
width: 500rpx;
|
width: 100%;
|
||||||
height: 230rpx;
|
height: 200rpx;
|
||||||
border-radius: 8px;
|
border-radius: 14rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
image {
|
margin-bottom: 20rpx;
|
||||||
width: 100%;
|
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.s-item {
|
|
||||||
|
.s-list {
|
||||||
|
background: #ffffff;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
padding: 24rpx 20rpx 12rpx;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.02);
|
||||||
|
}
|
||||||
|
|
||||||
|
.s-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 70rpx;
|
justify-content: space-between;
|
||||||
padding-top: 16rpx;
|
padding-bottom: 16rpx;
|
||||||
font-weight: 500;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.s-item {
|
||||||
|
font-size: 26rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #222;
|
||||||
|
}
|
||||||
|
|
||||||
.t-list {
|
.t-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding-top: 12rpx;
|
|
||||||
}
|
|
||||||
.margin-right {
|
|
||||||
margin-right: 0 !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.t-item {
|
.t-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 150rpx;
|
width: 33.333%;
|
||||||
margin-right: 25rpx;
|
padding: 10rpx 0 20rpx;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.t-img-box {
|
||||||
|
width: 128rpx;
|
||||||
|
height: 128rpx;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #f9f9f9;
|
||||||
|
margin-bottom: 12rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.t-name {
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
padding-bottom: 20rpx;
|
color: #333;
|
||||||
image {
|
max-width: 140rpx;
|
||||||
width: 140rpx;
|
overflow: hidden;
|
||||||
height: 140rpx;
|
text-overflow: ellipsis;
|
||||||
border-radius: 8px;
|
white-space: nowrap;
|
||||||
margin-bottom: 20rpx;
|
text-align: center;
|
||||||
}
|
line-height: 1.2;
|
||||||
::v-deep .u-image {
|
|
||||||
width: 140rpx !important;
|
|
||||||
height: 140rpx !important;
|
|
||||||
border-radius: 8px !important;
|
|
||||||
margin-bottom: 20rpx !important;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tpl-goods-wrapper {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #ifdef MP-WEIXIN || MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || MP-QQ */
|
||||||
|
tpl-category-goods {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
height: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
/* #endif */
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,355 +1,489 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="user" :style="themeStyle">
|
<view class="user-page" :style="themeStyle">
|
||||||
<!-- 个人信息 -->
|
<!-- 顶部沉浸式头部区域 -->
|
||||||
<view class="status_bar">
|
<view class="hero-header" :style="{ paddingTop: headerPaddingTop + 'px' }">
|
||||||
<!-- 这里是状态栏 -->
|
<!-- 用户信息区(沉降至胶囊安全区下方,舒展大气) -->
|
||||||
</view>
|
<view class="user-profile" @click="userDetail">
|
||||||
<view class="header" @click="userDetail">
|
<view class="avatar-container">
|
||||||
<view class="head-1">
|
<image class="avatar-img" :src="userInfo.face || userImage" mode="aspectFill"></image>
|
||||||
<image class="head-avatar" :src="userInfo.face || userImage"></image>
|
<view class="vip-tag-icon" v-if="userInfo.id">
|
||||||
</view>
|
<u-icon name="level" size="10" color="#ffffff"></u-icon>
|
||||||
<view class="head-2" v-if="userInfo.id">
|
</view>
|
||||||
<view class="user-name">{{ userInfo.nickName }}</view>
|
</view>
|
||||||
</view>
|
|
||||||
<view class="head-2" v-else>
|
<view class="user-detail-info">
|
||||||
<view class="user-name">登录/注册</view>
|
<view class="user-title-row">
|
||||||
</view>
|
<text class="user-nickname">{{ userInfo.id ? userInfo.nickName : '登录 / 注册' }}</text>
|
||||||
<u-icon class="header-arrow" name="arrow-right"></u-icon>
|
</view>
|
||||||
</view>
|
<view class="user-sub-row">
|
||||||
<!-- 积分,优惠券,关注, -->
|
<view class="badge-tag" v-if="userInfo.id">
|
||||||
<div class="pointBox box">
|
<text>普通会员</text>
|
||||||
<view class="point">
|
</view>
|
||||||
<view class="point-item" @click="navigateTo('/pages/mine/deposit/operation')">
|
<text class="user-sub-text" v-else>
|
||||||
<view class="point-label">预存款</view>
|
登录享受更多会员特权与折扣
|
||||||
<view class="point-value money">{{ unitPrice(walletNum) }}</view>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="point-item" @click="navigateTo('/pages/cart/coupon/myCoupon')">
|
</view>
|
||||||
<view class="point-label">优惠券</view>
|
|
||||||
<view class="point-value">{{ couponNum || 0 }}</view>
|
<view class="profile-arrow">
|
||||||
</view>
|
<u-icon name="arrow-right" size="14" color="rgba(255, 255, 255, 0.75)"></u-icon>
|
||||||
<view class="point-item" @click="navigateTo('/pages/mine/myTracks')">
|
</view>
|
||||||
<view class="point-label">足迹</view>
|
</view>
|
||||||
<view class="point-value">{{ footNum || 0 }}</view>
|
|
||||||
</view>
|
<!-- 沉浸式核心资产栏(纯白字,融入顶部主色调) -->
|
||||||
</view>
|
<view class="hero-assets">
|
||||||
<!-- 我的订单 -->
|
<view class="asset-col" @click="navigateTo('/pages/mine/deposit/operation')">
|
||||||
<view class="order">
|
<view class="asset-number-row">
|
||||||
<view class="order-head">
|
<text class="symbol">¥</text>
|
||||||
<text class="order-head-title">我的订单</text>
|
<text class="num money">{{ unitPrice(walletNum) }}</text>
|
||||||
<view class="order-head-all" @click="navigateTo('/pages/order/myOrder?status=0')">
|
</view>
|
||||||
<text>全部</text>
|
<view class="asset-title">预存款</view>
|
||||||
<u-icon name="arrow-right" size="12" color="#999"></u-icon>
|
</view>
|
||||||
</view>
|
<view class="asset-sep"></view>
|
||||||
</view>
|
<view class="asset-col" @click="navigateTo('/pages/cart/coupon/myCoupon')">
|
||||||
<view class="order-row">
|
<view class="asset-number-row">
|
||||||
<view class="order-item" @click="navigateTo('/pages/order/myOrder?status=1')">
|
<text class="num">{{ couponNum || 0 }}</text>
|
||||||
<view class="bag bag2">
|
<text class="unit">张</text>
|
||||||
<u-icon name="bag-fill" size="22" color="#fff"></u-icon>
|
</view>
|
||||||
</view>
|
<view class="asset-title">优惠券</view>
|
||||||
<view class="order-item-label">待支付</view>
|
</view>
|
||||||
</view>
|
<view class="asset-sep"></view>
|
||||||
<view class="order-item" @click="navigateTo('/pages/order/myOrder?status=2')">
|
<view class="asset-col" @click="navigateTo('/pages/mine/myTracks')">
|
||||||
<view class="bag bag1">
|
<view class="asset-number-row">
|
||||||
<u-icon name="gift-fill" size="22" color="#fff"></u-icon>
|
<text class="num">{{ footNum || 0 }}</text>
|
||||||
</view>
|
<text class="unit">条</text>
|
||||||
<view class="order-item-label">待发货</view>
|
</view>
|
||||||
</view>
|
<view class="asset-title">浏览足迹</view>
|
||||||
<view class="order-item" @click="navigateTo('/pages/order/myOrder?status=3')">
|
</view>
|
||||||
<view class="bag bag3">
|
</view>
|
||||||
<u-icon name="car-fill" size="22" color="#fff"></u-icon>
|
</view>
|
||||||
</view>
|
|
||||||
<view class="order-item-label">待收货</view>
|
<!-- 下方主内容卡片区域 -->
|
||||||
</view>
|
<view class="main-container">
|
||||||
<view class="order-item" @click="navigateTo('/pages/order/myOrder?status=4')">
|
<!-- 我的订单卡片 -->
|
||||||
<view class="bag bag4">
|
<view class="card-box order-box">
|
||||||
<u-icon name="star-fill" size="22" color="#fff"></u-icon>
|
<view class="card-title-bar">
|
||||||
</view>
|
<text class="card-title-text">我的订单</text>
|
||||||
<view class="order-item-label">待评价</view>
|
<view class="card-more-btn" @click="navigateTo('/pages/order/myOrder?status=0')">
|
||||||
</view>
|
<text>全部订单</text>
|
||||||
<view class="order-item" @click="navigateTo('/pages/order/myOrder?status=5')">
|
<u-icon name="arrow-right" size="11" color="#a0a0a0"></u-icon>
|
||||||
<view class="bag bag5">
|
</view>
|
||||||
<u-icon name="server-fill" size="22" color="#fff"></u-icon>
|
</view>
|
||||||
</view>
|
|
||||||
<view class="order-item-label">售后</view>
|
<view class="order-action-row">
|
||||||
</view>
|
<view class="order-action-item" @click="navigateTo('/pages/order/myOrder?status=1')">
|
||||||
</view>
|
<view class="icon-wrap">
|
||||||
</view>
|
<u-icon name="bag-fill" size="27" color="#ff7a00"></u-icon>
|
||||||
</div>
|
</view>
|
||||||
<!-- 常用工具 -->
|
<text class="order-action-label">待支付</text>
|
||||||
|
</view>
|
||||||
<tool />
|
|
||||||
|
<view class="order-action-item" @click="navigateTo('/pages/order/myOrder?status=2')">
|
||||||
</view>
|
<view class="icon-wrap">
|
||||||
</template>
|
<u-icon name="gift-fill" size="27" color="#ff4d4f"></u-icon>
|
||||||
<script setup lang="ts">
|
</view>
|
||||||
import { ref, computed } from 'vue'
|
<text class="order-action-label">待发货</text>
|
||||||
import {
|
</view>
|
||||||
onLoad,
|
|
||||||
onShow,
|
<view class="order-action-item" @click="navigateTo('/pages/order/myOrder?status=3')">
|
||||||
onPullDownRefresh,
|
<view class="icon-wrap">
|
||||||
onNavigationBarButtonTap,
|
<u-icon name="car-fill" size="27" color="#1677ff"></u-icon>
|
||||||
} from '@dcloudio/uni-app'
|
</view>
|
||||||
import tool from '@/pages/tabbar/user/utils/tool.vue'
|
<text class="order-action-label">待收货</text>
|
||||||
import { getCouponsNum, getFootprintNum } from '@/api/members.js'
|
</view>
|
||||||
import { getUserWallet } from '@/api/members'
|
|
||||||
import configs from '@/config/config'
|
<view class="order-action-item" @click="navigateTo('/pages/order/myOrder?status=4')">
|
||||||
import { useStore } from '@/store'
|
<view class="icon-wrap">
|
||||||
import { getThemeStyle } from '@/utils/theme'
|
<u-icon name="star-fill" size="27" color="#13c2c2"></u-icon>
|
||||||
import { isLogin, navigateToLogin, unitPrice } from '@/utils/filters.js'
|
</view>
|
||||||
|
<text class="order-action-label">待评价</text>
|
||||||
const store = useStore()
|
</view>
|
||||||
const themeStyle = computed(() => getThemeStyle(store.state.theme))
|
|
||||||
const lightColor = computed(() => store.getters.lightColor)
|
<view class="order-action-item" @click="navigateTo('/pages/order/myOrder?status=5')">
|
||||||
const mainColor = computed(() => store.getters.mainColor)
|
<view class="icon-wrap">
|
||||||
const aiderLightColor = computed(() => store.getters.aiderLightColor)
|
<u-icon name="server-fill" size="27" color="#20b286"></u-icon>
|
||||||
|
</view>
|
||||||
const userImage = configs.defaultUserPhoto
|
<text class="order-action-label">退款/售后</text>
|
||||||
const userInfo = ref<any>({})
|
</view>
|
||||||
const couponNum = ref<string | number>('')
|
</view>
|
||||||
const footNum = ref<string | number>('')
|
</view>
|
||||||
const walletNum = ref<string | number>('')
|
|
||||||
|
<!-- 服务工具卡片(分组化重构) -->
|
||||||
onLoad(() => {})
|
<tool />
|
||||||
|
</view>
|
||||||
onShow(() => {
|
</view>
|
||||||
userInfo.value = isLogin() || {}
|
</template>
|
||||||
if (isLogin('auth')) {
|
|
||||||
getUserOrderNum()
|
<script setup lang="ts">
|
||||||
} else {
|
import { ref, computed } from 'vue'
|
||||||
walletNum.value = 0
|
import {
|
||||||
couponNum.value = 0
|
onLoad,
|
||||||
footNum.value = 0
|
onShow,
|
||||||
}
|
onPullDownRefresh,
|
||||||
})
|
onNavigationBarButtonTap,
|
||||||
|
} from '@dcloudio/uni-app'
|
||||||
onPullDownRefresh(() => {
|
import tool from '@/pages/tabbar/user/utils/tool.vue'
|
||||||
getUserOrderNum()
|
import { getCouponsNum, getFootprintNum } from '@/api/members.js'
|
||||||
userInfo.value = isLogin()
|
import { getUserWallet } from '@/api/members'
|
||||||
})
|
import configs from '@/config/config'
|
||||||
|
import { useStore } from '@/store'
|
||||||
// #ifndef MP
|
import { getThemeStyle } from '@/utils/theme'
|
||||||
onNavigationBarButtonTap((e) => {
|
import { isLogin, navigateToLogin, unitPrice } from '@/utils/filters.js'
|
||||||
if (e.index === 0) {
|
|
||||||
navigateTo('/pages/mine/set/setUp')
|
const store = useStore()
|
||||||
}
|
const themeStyle = computed(() => getThemeStyle(store.state.theme))
|
||||||
})
|
const lightColor = computed(() => store.getters.lightColor)
|
||||||
// #endif
|
const mainColor = computed(() => store.getters.mainColor)
|
||||||
|
const aiderLightColor = computed(() => store.getters.aiderLightColor)
|
||||||
function navigateTo(url: string) {
|
|
||||||
uni.navigateTo({ url })
|
const userImage = configs.defaultUserPhoto
|
||||||
}
|
const userInfo = ref<any>({})
|
||||||
|
const couponNum = ref<string | number>('')
|
||||||
function userDetail() {
|
const footNum = ref<string | number>('')
|
||||||
userInfo.value.id
|
const walletNum = ref<string | number>('')
|
||||||
? navigateTo('/pages/mine/set/personMsg')
|
|
||||||
: navigateToLogin()
|
// 动态计算顶部安全留白,避免顶到灵动岛/状态栏
|
||||||
}
|
const headerPaddingTop = ref<number>(88)
|
||||||
|
|
||||||
async function getUserOrderNum() {
|
function initSafeTop() {
|
||||||
uni.stopPullDownRefresh()
|
try {
|
||||||
|
const sys = uni.getSystemInfoSync()
|
||||||
Promise.all([
|
const statusBar = sys.statusBarHeight || 44
|
||||||
getCouponsNum(),
|
// #ifdef MP-WEIXIN
|
||||||
getFootprintNum(),
|
const menu = uni.getMenuButtonBoundingClientRect()
|
||||||
getUserWallet(),
|
if (menu && menu.bottom) {
|
||||||
]).then((res: any[]) => {
|
// 头像整行落到微信胶囊下方,预留 16px 呼吸空隙,彻底消除压迫感
|
||||||
couponNum.value = res[0].data.result
|
headerPaddingTop.value = menu.bottom + 16
|
||||||
footNum.value = res[1].data.result
|
} else {
|
||||||
walletNum.value = res[2].data.result.memberWallet
|
headerPaddingTop.value = statusBar + 54
|
||||||
})
|
}
|
||||||
}
|
// #endif
|
||||||
</script>
|
// #ifndef MP-WEIXIN
|
||||||
|
headerPaddingTop.value = statusBar + 32
|
||||||
<style lang="scss" scoped>
|
// #endif
|
||||||
html,
|
} catch (e) {
|
||||||
body {
|
headerPaddingTop.value = 88
|
||||||
overflow: auto;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.money {
|
onLoad(() => {
|
||||||
overflow: hidden;
|
initSafeTop()
|
||||||
|
})
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
onShow(() => {
|
||||||
}
|
userInfo.value = isLogin() || {}
|
||||||
|
if (isLogin('auth')) {
|
||||||
.user {
|
getUserOrderNum()
|
||||||
.header {
|
} else {
|
||||||
max-width: 100%;
|
walletNum.value = 0
|
||||||
padding: calc(50rpx + var(--status-bar-height)) 30rpx 0 6%;
|
couponNum.value = 0
|
||||||
height: calc(var(--status-bar-height) + 360rpx);
|
footNum.value = 0
|
||||||
background-size: cover;
|
}
|
||||||
border-bottom-left-radius: 30rpx;
|
})
|
||||||
border-bottom-right-radius: 30rpx;
|
|
||||||
background-image: url("https://lilishop-uniapp.oss-cn-beijing.aliyuncs.com/main-bg.png");
|
onPullDownRefresh(() => {
|
||||||
background-position: bottom;
|
getUserOrderNum()
|
||||||
background-repeat: no-repeat;
|
userInfo.value = isLogin()
|
||||||
color: #ffffff;
|
})
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
// #ifndef MP
|
||||||
|
onNavigationBarButtonTap((e) => {
|
||||||
.head-1 {
|
if (e.index === 0) {
|
||||||
flex-shrink: 0;
|
navigateTo('/pages/mine/set/setUp')
|
||||||
width: 152rpx;
|
}
|
||||||
|
})
|
||||||
.head-avatar {
|
// #endif
|
||||||
width: 152rpx;
|
|
||||||
height: 144rpx;
|
function navigateTo(url: string) {
|
||||||
border-radius: 50%;
|
uni.navigateTo({ url })
|
||||||
border: 3px solid #fff;
|
}
|
||||||
display: block;
|
|
||||||
}
|
function userDetail() {
|
||||||
|
userInfo.value.id
|
||||||
.edti-head {
|
? navigateTo('/pages/mine/set/personMsg')
|
||||||
position: absolute;
|
: navigateToLogin()
|
||||||
width: 40rpx;
|
}
|
||||||
height: 40rpx;
|
|
||||||
border-radius: 50%;
|
async function getUserOrderNum() {
|
||||||
background-color: rgba(255, 255, 255, 0.3);
|
uni.stopPullDownRefresh()
|
||||||
top: 100rpx;
|
|
||||||
right: 0;
|
Promise.all([
|
||||||
|
getCouponsNum(),
|
||||||
.head-avatar {
|
getFootprintNum(),
|
||||||
width: 100%;
|
getUserWallet(),
|
||||||
height: 100%;
|
]).then((res: any[]) => {
|
||||||
}
|
couponNum.value = res[0].data.result
|
||||||
}
|
footNum.value = res[1].data.result
|
||||||
}
|
walletNum.value = res[2].data.result.memberWallet
|
||||||
|
})
|
||||||
.head-2 {
|
}
|
||||||
flex: 1;
|
</script>
|
||||||
margin-left: 30rpx;
|
|
||||||
min-width: 0;
|
<style lang="scss" scoped>
|
||||||
display: flex;
|
.user-page {
|
||||||
align-items: center;
|
min-height: 100vh;
|
||||||
}
|
background-color: #f5f6f9;
|
||||||
|
padding-bottom: 40rpx;
|
||||||
.header-arrow {
|
box-sizing: border-box;
|
||||||
flex-shrink: 0;
|
}
|
||||||
margin-left: 20rpx;
|
|
||||||
}
|
/* 顶部沉浸式头部 */
|
||||||
}
|
.hero-header {
|
||||||
|
position: relative;
|
||||||
.pointBox {
|
width: 100%;
|
||||||
width: 94%;
|
background: linear-gradient(175deg, #e53238 0%, #eb4448 45%, #ff5e62 100%);
|
||||||
margin: 0 3%;
|
padding-left: 28rpx;
|
||||||
background: #fff;
|
padding-right: 28rpx;
|
||||||
border-radius: 20rpx;
|
padding-bottom: 64rpx;
|
||||||
box-shadow: 0 4rpx 24rpx 0 rgba($color: #f6f6f6, $alpha: 1);
|
border-bottom-left-radius: 36rpx;
|
||||||
}
|
border-bottom-right-radius: 36rpx;
|
||||||
|
/* CSS 静态兜底:状态栏高度 + 充足的沉降留白 */
|
||||||
.point {
|
padding-top: calc(var(--status-bar-height, 44px) + 88rpx);
|
||||||
display: flex;
|
box-sizing: border-box;
|
||||||
align-items: center;
|
}
|
||||||
text-align: center;
|
|
||||||
height: 160rpx;
|
/* 用户信息行(移到胶囊下方,拥有充裕横纵向空间) */
|
||||||
font-size: $font-sm;
|
.user-profile {
|
||||||
// #ifdef MP-WEIXIN
|
display: flex;
|
||||||
padding: 24rpx;
|
align-items: center;
|
||||||
// #endif
|
padding: 8rpx 6rpx;
|
||||||
|
transition: opacity 0.2s;
|
||||||
.point-item {
|
|
||||||
flex: 1;
|
&:active {
|
||||||
text-align: center;
|
opacity: 0.88;
|
||||||
}
|
}
|
||||||
|
|
||||||
.point-label {
|
.avatar-container {
|
||||||
color: $u-main-color;
|
position: relative;
|
||||||
font-size: 28rpx;
|
flex-shrink: 0;
|
||||||
}
|
|
||||||
|
.avatar-img {
|
||||||
.point-value {
|
width: 124rpx;
|
||||||
margin-top: 8rpx;
|
height: 124rpx;
|
||||||
color: $main-color;
|
border-radius: 50%;
|
||||||
font-size: $font-lg;
|
border: 4rpx solid rgba(255, 255, 255, 0.92);
|
||||||
}
|
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.16);
|
||||||
}
|
background-color: #ffffff;
|
||||||
|
display: block;
|
||||||
.order {
|
}
|
||||||
padding: 8rpx 16rpx 24rpx;
|
|
||||||
color: #333;
|
.vip-tag-icon {
|
||||||
|
position: absolute;
|
||||||
.order-head {
|
right: -2rpx;
|
||||||
display: flex;
|
bottom: 2rpx;
|
||||||
align-items: center;
|
width: 34rpx;
|
||||||
justify-content: space-between;
|
height: 34rpx;
|
||||||
padding: 8rpx 12rpx 20rpx;
|
background: linear-gradient(135deg, #f59e0b, #d97706);
|
||||||
}
|
border: 2rpx solid #ffffff;
|
||||||
|
border-radius: 50%;
|
||||||
.order-head-title {
|
display: flex;
|
||||||
font-size: 26rpx;
|
align-items: center;
|
||||||
font-weight: 600;
|
justify-content: center;
|
||||||
color: #111;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.order-head-all {
|
.user-detail-info {
|
||||||
display: flex;
|
flex: 1;
|
||||||
align-items: center;
|
margin-left: 24rpx;
|
||||||
gap: 4rpx;
|
min-width: 0;
|
||||||
font-size: 24rpx;
|
|
||||||
color: #999;
|
.user-title-row {
|
||||||
}
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
.order-row {
|
|
||||||
display: flex;
|
.user-nickname {
|
||||||
align-items: center;
|
font-size: 38rpx;
|
||||||
}
|
font-weight: 700;
|
||||||
|
color: #ffffff;
|
||||||
.order-item {
|
letter-spacing: 0.5rpx;
|
||||||
flex: 1;
|
overflow: hidden;
|
||||||
display: flex;
|
text-overflow: ellipsis;
|
||||||
flex-direction: column;
|
white-space: nowrap;
|
||||||
align-items: center;
|
}
|
||||||
justify-content: center;
|
}
|
||||||
text-align: center;
|
|
||||||
}
|
.user-sub-row {
|
||||||
|
margin-top: 12rpx;
|
||||||
.order-item-label {
|
display: flex;
|
||||||
margin-top: 12rpx;
|
align-items: center;
|
||||||
line-height: 1.4;
|
flex-wrap: wrap;
|
||||||
font-size: 24rpx;
|
gap: 12rpx;
|
||||||
color: #333;
|
|
||||||
}
|
.badge-tag {
|
||||||
}
|
font-size: 20rpx;
|
||||||
}
|
color: #ffffff;
|
||||||
|
background: rgba(255, 255, 255, 0.22);
|
||||||
.box {
|
padding: 3rpx 14rpx;
|
||||||
transform: translateY(-30rpx);
|
border-radius: 20rpx;
|
||||||
}
|
border: 1rpx solid rgba(255, 255, 255, 0.35);
|
||||||
|
font-weight: 500;
|
||||||
.user-name {
|
}
|
||||||
font-size: 34rpx;
|
|
||||||
overflow: hidden;
|
.user-sub-text {
|
||||||
text-overflow: ellipsis;
|
font-size: 23rpx;
|
||||||
white-space: nowrap;
|
color: rgba(255, 255, 255, 0.88);
|
||||||
}
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
.bag {
|
white-space: nowrap;
|
||||||
width: 56rpx;
|
}
|
||||||
height: 56rpx;
|
}
|
||||||
border-radius: 50%;
|
}
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
.profile-arrow {
|
||||||
justify-content: center;
|
flex-shrink: 0;
|
||||||
}
|
margin-left: 16rpx;
|
||||||
|
opacity: 0.85;
|
||||||
.bag1 {
|
}
|
||||||
background: #ff4a48;
|
}
|
||||||
}
|
|
||||||
|
/* 核心资产栏(沉浸在红色背景中) */
|
||||||
.bag2 {
|
.hero-assets {
|
||||||
background: #ff992f;
|
display: flex;
|
||||||
}
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
.bag3 {
|
margin-top: 44rpx;
|
||||||
background: #009ee0;
|
padding: 0 12rpx;
|
||||||
}
|
|
||||||
|
.asset-col {
|
||||||
.bag4 {
|
flex: 1;
|
||||||
background: #00d5d5;
|
display: flex;
|
||||||
}
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
.bag5 {
|
justify-content: center;
|
||||||
background: #28ccb0;
|
transition: transform 0.15s, opacity 0.15s;
|
||||||
}
|
|
||||||
</style>
|
&:active {
|
||||||
|
transform: scale(0.96);
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
|
||||||
|
.asset-number-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
color: #ffffff;
|
||||||
|
|
||||||
|
.symbol {
|
||||||
|
font-size: 22rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-right: 4rpx;
|
||||||
|
opacity: 0.95;
|
||||||
|
}
|
||||||
|
|
||||||
|
.num {
|
||||||
|
font-size: 40rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: 0.5rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unit {
|
||||||
|
font-size: 21rpx;
|
||||||
|
margin-left: 4rpx;
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
|
||||||
|
.money {
|
||||||
|
max-width: 230rpx;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.asset-title {
|
||||||
|
margin-top: 10rpx;
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.88);
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.asset-sep {
|
||||||
|
width: 2rpx;
|
||||||
|
height: 38rpx;
|
||||||
|
background-color: rgba(255, 255, 255, 0.22);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 主内容区(上浮自然压在红底圆角上) */
|
||||||
|
.main-container {
|
||||||
|
position: relative;
|
||||||
|
margin-top: -36rpx;
|
||||||
|
padding: 0 24rpx;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 通用白底圆角卡片 */
|
||||||
|
.card-box {
|
||||||
|
background: #ffffff;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
padding: 24rpx;
|
||||||
|
box-shadow: 0 4rpx 18rpx rgba(17, 30, 79, 0.04);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 订单卡片 */
|
||||||
|
.order-box {
|
||||||
|
.card-title-bar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding-bottom: 22rpx;
|
||||||
|
border-bottom: 1rpx solid #f6f7fa;
|
||||||
|
|
||||||
|
.card-title-text {
|
||||||
|
font-size: 29rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #1a1a1a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-more-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4rpx;
|
||||||
|
font-size: 23rpx;
|
||||||
|
color: #999999;
|
||||||
|
padding: 4rpx 0;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.order-action-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding-top: 24rpx;
|
||||||
|
|
||||||
|
.order-action-item {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transition: transform 0.15s, opacity 0.15s;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
transform: scale(0.93);
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-wrap {
|
||||||
|
width: 60rpx;
|
||||||
|
height: 60rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.order-action-label {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #333333;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,136 +1,116 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<view class="tool-wrapper">
|
||||||
<!-- 常用工具 -->
|
<!-- 卡片 1: 资产与常用 -->
|
||||||
<view class="interact-tools" style="margin-bottom: 15px">
|
<view class="service-card">
|
||||||
|
<view class="service-title-bar">
|
||||||
|
<text class="service-title-text">资产与常用</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<div class="paddingBox">
|
<view class="service-grid">
|
||||||
<view class="interact-container">
|
<view class="service-grid-item" @click="navigateTo('/pages/cart/coupon/couponCenter')">
|
||||||
<view class="interact-item" @click="navigateTo('/pages/mine/address/addressManage')">
|
<image class="grid-icon" src="/static/mine/couponcenter.png" mode="aspectFit"></image>
|
||||||
<image class="interact-item-icon" src="/static/mine/myaddress.png" mode=""></image>
|
<text class="grid-label">领券中心</text>
|
||||||
<view>地址管理</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="interact-item" @click="navigateTo('/pages/mine/myTracks')">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/logistics.png" mode=""></image>
|
|
||||||
<view>我的足迹</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="interact-item" @click="navigateTo('/pages/order/evaluate/myEvaluate')">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/feedback.png" mode=""></image>
|
|
||||||
<view>我的评价</view>
|
|
||||||
</view>
|
|
||||||
<view class="interact-item" @click="linkMsgDetail()">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/mycommit.png" mode=""></image>
|
|
||||||
<view>我的消息</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
<view class="interact-item" @click="navigateTo('/pages/mine/myCollect')">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/myfavorite.png" mode=""></image>
|
|
||||||
<view>我的关注</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<view class="interact-item" @click="navigateTo('/pages/mine/point/myPoint')">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/mypoint.png" mode=""></image>
|
|
||||||
<view>我的积分</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="interact-item" @click="distribution">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/distribution.png" mode=""></image>
|
|
||||||
<view>我的分销</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<view class="interact-item" @click="navigateTo('/pages/order/complain/complainList')">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/shensu.png" mode=""></image>
|
|
||||||
<view>我的投诉</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="interact-item" @click="navigateTo('/pages/cart/coupon/myCoupon')">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/mycoupon.png" mode=""></image>
|
|
||||||
<view>优惠券</view>
|
|
||||||
</view>
|
|
||||||
<view class="interact-item" @click="navigateTo('/pages/cart/gift-card/myGiftCards')">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/pointgift.png" mode=""></image>
|
|
||||||
<view>礼品卡</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<view class="interact-item" @click="navigateTo('/pages/mine/signIn')">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/sign.png" mode=""></image>
|
|
||||||
<view>每日签到</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<view class="interact-item" @click="navigateTo('/pages/cart/coupon/couponCenter')">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/couponcenter.png" mode=""></image>
|
|
||||||
<view>领券中心</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<view class="interact-item" @click="navigateTo('/pages/promotion/bargain/log')">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/kanjia.png" mode=""></image>
|
|
||||||
<view>砍价记录</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<view class="interact-item" @click="navigateTo('/pages/mine/set/feedBack')">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/feedback.png" mode=""></image>
|
|
||||||
<view>意见反馈</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="interact-item" @click="navigateTo('/pages/mine/set/editionIntro')">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/pointgift.png" mode=""></image>
|
|
||||||
<view>关于</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
<view class="interact-item" @click="navigateTo('/pages/passport/entry/seller/index')">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/feedback.png" mode=""></image>
|
|
||||||
<view>店铺入驻</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <view class="interact-item" @click="inviter()">-->
|
|
||||||
<!-- <image class="interact-item-icon" src="/static/mine/share.png" mode=""></image>-->
|
|
||||||
<!-- <view>邀新</view>-->
|
|
||||||
<!-- </view>-->
|
|
||||||
<view class="interact-item" @click="navigateTo('/pages/mine/set/setUp')">
|
|
||||||
<image class="interact-item-icon" src="/static/mine/setting.png" mode=""></image>
|
|
||||||
<view>设置</view>
|
|
||||||
</view>
|
|
||||||
|
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</div>
|
|
||||||
|
<view class="service-grid-item" @click="navigateTo('/pages/mine/point/myPoint')">
|
||||||
<template>
|
<image class="grid-icon" src="/static/mine/mypoint.png" mode="aspectFit"></image>
|
||||||
<u-popup v-model:show="sharingShow" mode="bottom" border-radius="14">
|
<text class="grid-label">我的积分</text>
|
||||||
<view style="margin: 10px; text-align: center;"> 请邀请用户扫描二维码或者将地址复制转发给其他用户 </view>
|
</view>
|
||||||
<view class='qrcode'>
|
|
||||||
<uqrcode v-if="sharingLink" ref="uqrcode" canvas-id="qrcode" :value="sharingLink" :options="{ margin: 10 }">
|
<view class="service-grid-item" @click="navigateTo('/pages/mine/signIn')">
|
||||||
</uqrcode>
|
<image class="grid-icon" src="/static/mine/sign.png" mode="aspectFit"></image>
|
||||||
</view>
|
<text class="grid-label">每日签到</text>
|
||||||
|
</view>
|
||||||
<view class="copy-text" @click="getDetail(sharingLink)">
|
|
||||||
{{sharingLink}}
|
<view class="service-grid-item" @click="navigateTo('/pages/cart/coupon/myCoupon')">
|
||||||
</view>
|
<image class="grid-icon" src="/static/mine/mycoupon.png" mode="aspectFit"></image>
|
||||||
<view class="confrim-btn">
|
<text class="grid-label">优惠券</text>
|
||||||
<u-button @click="sharingShow = false;">关闭</u-button>
|
</view>
|
||||||
</view>
|
|
||||||
</u-popup>
|
<view class="service-grid-item" @click="navigateTo('/pages/mine/address/addressManage')">
|
||||||
</template>
|
<image class="grid-icon" src="/static/mine/myaddress.png" mode="aspectFit"></image>
|
||||||
|
<text class="grid-label">地址管理</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="service-grid-item" @click="navigateTo('/pages/mine/myTracks')">
|
||||||
|
<image class="grid-icon" src="/static/mine/logistics.png" mode="aspectFit"></image>
|
||||||
|
<text class="grid-label">我的足迹</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="service-grid-item" @click="navigateTo('/pages/mine/myCollect')">
|
||||||
|
<image class="grid-icon" src="/static/mine/myfavorite.png" mode="aspectFit"></image>
|
||||||
|
<text class="grid-label">我的关注</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="service-grid-item" @click="navigateTo('/pages/order/evaluate/myEvaluate')">
|
||||||
|
<image class="grid-icon" src="/static/mine/feedback.png" mode="aspectFit"></image>
|
||||||
|
<text class="grid-label">我的评价</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 卡片 2: 更多服务 -->
|
||||||
|
<view class="service-card">
|
||||||
|
<view class="service-title-bar">
|
||||||
|
<text class="service-title-text">更多服务</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="service-grid">
|
||||||
|
<view class="service-grid-item" @click="distribution">
|
||||||
|
<image class="grid-icon" src="/static/mine/distribution.png" mode="aspectFit"></image>
|
||||||
|
<text class="grid-label">我的分销</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="service-grid-item" @click="navigateTo('/pages/cart/gift-card/myGiftCards')">
|
||||||
|
<image class="grid-icon" src="/static/mine/pointgift.png" mode="aspectFit"></image>
|
||||||
|
<text class="grid-label">礼品卡</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="service-grid-item" @click="navigateTo('/pages/promotion/bargain/log')">
|
||||||
|
<image class="grid-icon" src="/static/mine/kanjia.png" mode="aspectFit"></image>
|
||||||
|
<text class="grid-label">砍价记录</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="service-grid-item" @click="navigateTo('/pages/passport/entry/seller/index')">
|
||||||
|
<image class="grid-icon" src="/static/mine/feedback.png" mode="aspectFit"></image>
|
||||||
|
<text class="grid-label">店铺入驻</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="service-grid-item" @click="linkMsgDetail()">
|
||||||
|
<image class="grid-icon" src="/static/mine/mycommit.png" mode="aspectFit"></image>
|
||||||
|
<text class="grid-label">我的消息</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="service-grid-item" @click="navigateTo('/pages/order/complain/complainList')">
|
||||||
|
<image class="grid-icon" src="/static/mine/shensu.png" mode="aspectFit"></image>
|
||||||
|
<text class="grid-label">我的投诉</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="service-grid-item" @click="navigateTo('/pages/mine/set/feedBack')">
|
||||||
|
<image class="grid-icon" src="/static/mine/feedback.png" mode="aspectFit"></image>
|
||||||
|
<text class="grid-label">意见反馈</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="service-grid-item" @click="navigateTo('/pages/mine/set/setUp')">
|
||||||
|
<image class="grid-icon" src="/static/mine/setting.png" mode="aspectFit"></image>
|
||||||
|
<text class="grid-label">系统设置</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 分享二维码弹窗(保留原有能力) -->
|
||||||
|
<u-popup v-model:show="sharingShow" mode="bottom" border-radius="14">
|
||||||
|
<view style="margin: 10px; text-align: center;">请邀请用户扫描二维码或者将地址复制转发给其他用户</view>
|
||||||
|
<view class="qrcode">
|
||||||
|
<uqrcode v-if="sharingLink" ref="uqrcode" canvas-id="qrcode" :value="sharingLink" :options="{ margin: 10 }"></uqrcode>
|
||||||
|
</view>
|
||||||
|
<view class="copy-text" @click="getDetail(sharingLink)">
|
||||||
|
{{ sharingLink }}
|
||||||
|
</view>
|
||||||
|
<view class="confrim-btn">
|
||||||
|
<u-button @click="sharingShow = false;">关闭</u-button>
|
||||||
|
</view>
|
||||||
|
</u-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -227,7 +207,6 @@ function distribution() {
|
|||||||
if (!tipsToLogin('normal')) {
|
if (!tipsToLogin('normal')) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 入口按 distributionStatus 路由:有对象 ≠ 有效分销员。清退停住,不进 join / home。
|
|
||||||
fetchDistribution().then((res) => {
|
fetchDistribution().then((res) => {
|
||||||
if (res.data.result) {
|
if (res.data.result) {
|
||||||
const type = res.data.result.distributionStatus
|
const type = res.data.result.distributionStatus
|
||||||
@@ -264,6 +243,69 @@ function distribution() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.tool-wrapper {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20rpx;
|
||||||
|
margin-top: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.service-card {
|
||||||
|
background: #ffffff;
|
||||||
|
border-radius: 20rpx;
|
||||||
|
padding: 24rpx 16rpx 20rpx;
|
||||||
|
box-shadow: 0 4rpx 18rpx rgba(17, 30, 79, 0.04);
|
||||||
|
|
||||||
|
.service-title-bar {
|
||||||
|
padding: 0 12rpx 20rpx;
|
||||||
|
border-bottom: 1rpx solid #f6f7fa;
|
||||||
|
|
||||||
|
.service-title-text {
|
||||||
|
font-size: 29rpx;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #1a1a1a;
|
||||||
|
letter-spacing: 0.5rpx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.service-grid {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
padding-top: 14rpx;
|
||||||
|
|
||||||
|
.service-grid-item {
|
||||||
|
width: 25%;
|
||||||
|
flex: 0 0 25%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
height: 146rpx;
|
||||||
|
padding: 12rpx 4rpx;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
transition: transform 0.15s, opacity 0.15s;
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
transform: scale(0.92);
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-icon {
|
||||||
|
width: 52rpx;
|
||||||
|
height: 52rpx;
|
||||||
|
margin-bottom: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-label {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #444444;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.copy-text {
|
.copy-text {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -272,50 +314,8 @@ function distribution() {
|
|||||||
line-break: anywhere;
|
line-break: anywhere;
|
||||||
}
|
}
|
||||||
|
|
||||||
.interact-tools {
|
|
||||||
border-left: none;
|
|
||||||
border-right: none;
|
|
||||||
|
|
||||||
|
|
||||||
.interactBox {
|
|
||||||
height: 156rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.interact-container {
|
|
||||||
margin: 0 20rpx;
|
|
||||||
background: #fff;
|
|
||||||
border-radius: 20rpx;
|
|
||||||
box-shadow: 0 4rpx 24rpx 0 rgba($color: #f6f6f6, $alpha: 1);
|
|
||||||
|
|
||||||
.interact-item-icon {
|
|
||||||
width: 56rpx;
|
|
||||||
height: 56rpx;
|
|
||||||
margin-bottom: 10rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
text-align: center;
|
|
||||||
|
|
||||||
.interact-item {
|
|
||||||
font-size: 24rpx;
|
|
||||||
width: 25%;
|
|
||||||
flex: 0 0 25%;
|
|
||||||
box-sizing: border-box;
|
|
||||||
height: 150rpx;
|
|
||||||
padding: 20rpx 8rpx;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.qrcode {
|
.qrcode {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
width: 200px;
|
width: 200px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -2,8 +2,13 @@ import { createStore } from 'vuex'
|
|||||||
import storage from '@/utils/storage'
|
import storage from '@/utils/storage'
|
||||||
import config from '@/config/config'
|
import config from '@/config/config'
|
||||||
import { DEFAULT_THEME, loadCachedTheme } from '@/utils/theme'
|
import { DEFAULT_THEME, loadCachedTheme } from '@/utils/theme'
|
||||||
|
import {
|
||||||
|
DEFAULT_CATEGORY_PAGE_SETTING,
|
||||||
|
loadCachedCategoryPageSetting,
|
||||||
|
} from '@/utils/categoryPageSetting'
|
||||||
|
|
||||||
const cachedTheme = loadCachedTheme()
|
const cachedTheme = loadCachedTheme()
|
||||||
|
const cachedCategoryPageSetting = loadCachedCategoryPageSetting()
|
||||||
|
|
||||||
const store = createStore({
|
const store = createStore({
|
||||||
state: {
|
state: {
|
||||||
@@ -17,6 +22,8 @@ const store = createStore({
|
|||||||
uuid: storage.getUuid(),
|
uuid: storage.getUuid(),
|
||||||
token: '',
|
token: '',
|
||||||
theme: cachedTheme || { ...DEFAULT_THEME },
|
theme: cachedTheme || { ...DEFAULT_THEME },
|
||||||
|
categoryPageSetting:
|
||||||
|
cachedCategoryPageSetting || { ...DEFAULT_CATEGORY_PAGE_SETTING },
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
mainColor: (state) => state.theme.mainColor,
|
mainColor: (state) => state.theme.mainColor,
|
||||||
@@ -44,6 +51,9 @@ const store = createStore({
|
|||||||
aiderLightColor: theme.aiderLightColor || DEFAULT_THEME.aiderLightColor,
|
aiderLightColor: theme.aiderLightColor || DEFAULT_THEME.aiderLightColor,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
SET_CATEGORY_PAGE_SETTING(state, setting) {
|
||||||
|
state.categoryPageSetting = setting || { ...DEFAULT_CATEGORY_PAGE_SETTING }
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {}
|
actions: {}
|
||||||
})
|
})
|
||||||
|
|||||||
70
utils/categoryPageSetting.js
Normal file
70
utils/categoryPageSetting.js
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
export const DEFAULT_CATEGORY_PAGE_SETTING = {
|
||||||
|
template: 1,
|
||||||
|
showFields: {
|
||||||
|
subTitle: true,
|
||||||
|
spec: true,
|
||||||
|
tags: true,
|
||||||
|
selfTag: true,
|
||||||
|
price: true,
|
||||||
|
linePrice: false,
|
||||||
|
sales: true,
|
||||||
|
cart: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const STORAGE_KEY = "category_page_setting";
|
||||||
|
const EXPIRATION_KEY = "category_page_setting_expiration_time";
|
||||||
|
|
||||||
|
function fallback() {
|
||||||
|
return JSON.parse(JSON.stringify(DEFAULT_CATEGORY_PAGE_SETTING));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 对已解析的配置对象做字段级清洗(缺键补默认、非法值回退)。 */
|
||||||
|
function sanitize(raw) {
|
||||||
|
if (!raw || typeof raw !== "object") return fallback();
|
||||||
|
const result = fallback();
|
||||||
|
if ([1, 2, 3, 4].includes(raw.template)) {
|
||||||
|
result.template = raw.template;
|
||||||
|
}
|
||||||
|
if (raw.showFields && typeof raw.showFields === "object") {
|
||||||
|
for (const key of Object.keys(result.showFields)) {
|
||||||
|
if (typeof raw.showFields[key] === "boolean") {
|
||||||
|
result.showFields[key] = raw.showFields[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 归一化分类页设置。入参为 buyer 接口 result(Setting 实体或 null),
|
||||||
|
* null / 解析失败 / 缺键 / template 非 1-4 一律回退默认值。
|
||||||
|
*/
|
||||||
|
export function normalizeCategoryPageSetting(setting = null) {
|
||||||
|
if (!setting || !setting.settingValue) return fallback();
|
||||||
|
try {
|
||||||
|
return sanitize(JSON.parse(setting.settingValue));
|
||||||
|
} catch {
|
||||||
|
return fallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function cacheCategoryPageSetting(data) {
|
||||||
|
const expirationTime = new Date().setHours(new Date().getHours() + 1);
|
||||||
|
uni.setStorageSync(EXPIRATION_KEY, expirationTime);
|
||||||
|
uni.setStorageSync(STORAGE_KEY, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadCachedCategoryPageSetting() {
|
||||||
|
const expirationTime = uni.getStorageSync(EXPIRATION_KEY);
|
||||||
|
const cacheValid =
|
||||||
|
expirationTime && new Date() <= new Date(Number(expirationTime));
|
||||||
|
if (!cacheValid) return null;
|
||||||
|
try {
|
||||||
|
const cached = uni.getStorageSync(STORAGE_KEY);
|
||||||
|
// 缓存可能被篡改/来自旧版本,读出后同样过清洗
|
||||||
|
return cached ? sanitize(cached) : null;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user