mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-11-06 17:09:01 +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 APPUpdate from '@/plugins/APPUpdate'
|
||||
import storage from '@/utils/storage'
|
||||
import { getThemeSetting } from '@/api/common.js'
|
||||
import { getThemeSetting, getCategoryPageSetting } from '@/api/common.js'
|
||||
import {
|
||||
applyTabBarStyle,
|
||||
cacheTheme,
|
||||
loadCachedTheme,
|
||||
normalizeTheme,
|
||||
} from '@/utils/theme'
|
||||
import {
|
||||
cacheCategoryPageSetting,
|
||||
loadCachedCategoryPageSetting,
|
||||
normalizeCategoryPageSetting,
|
||||
} from '@/utils/categoryPageSetting'
|
||||
import { onLaunch, onShow } from '@dcloudio/uni-app'
|
||||
import { useStore } from '@/store'
|
||||
import { handleAppLaunchScene } from '@/utils/distributionBind.js'
|
||||
@@ -24,6 +29,7 @@ wx.onAppRoute((res) => {
|
||||
|
||||
onLaunch((val) => {
|
||||
initTheme()
|
||||
initCategoryPageSetting()
|
||||
handleAppLaunchScene(val)
|
||||
if (val?.query?.inviter) {
|
||||
storage.setInviter(val.query.inviter)
|
||||
@@ -81,6 +87,22 @@ function initTheme() {
|
||||
.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() {
|
||||
const updateManager = uni.getUpdateManager()
|
||||
|
||||
|
||||
@@ -41,3 +41,14 @@ export function getThemeSetting() {
|
||||
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 v-else>
|
||||
<!-- 批发阶梯价(E_COUPON 仅零售价) -->
|
||||
<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>
|
||||
<div class="goods-price">
|
||||
<span>
|
||||
¥
|
||||
<span class="goods-price-bigshow">{{ goodsFormatPrice(goodsDetail.price)[0] }}</span>
|
||||
@@ -135,7 +124,6 @@ import {
|
||||
} from '@/utils/goodsType.js'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
wholesaleList?: any[] | boolean
|
||||
buyMask?: boolean
|
||||
isGroup?: boolean
|
||||
goodsDetail?: any
|
||||
@@ -144,7 +132,6 @@ const props = withDefaults(defineProps<{
|
||||
addr?: any | null
|
||||
pointDetail?: any | null
|
||||
}>(), {
|
||||
wholesaleList: false,
|
||||
buyMask: false,
|
||||
isGroup: false,
|
||||
goodsDetail: () => ({}),
|
||||
@@ -156,7 +143,7 @@ const props = withDefaults(defineProps<{
|
||||
|
||||
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 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 = () => {
|
||||
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 {
|
||||
height: 200rpx;
|
||||
|
||||
@@ -8,4 +8,11 @@
|
||||
| `type` | 商品展示类型 oneColumns twoColumns ,默认展示一行两列商品 | String | 否 |
|
||||
| `storeName` | 是否展示店铺名称,默认展示 | Boolean | 否 |
|
||||
| `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>
|
||||
</view>
|
||||
<div class="promotion" @click="navigateToDetailPage(item)">
|
||||
<div v-if="item.salesModel == 'WHOLESALE'">
|
||||
<span>批</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="(promotionItem, promotionIndex) in getPromotion(item)"
|
||||
:key="promotionIndex"
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
</div>
|
||||
</view>
|
||||
<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('FULL_DISCOUNT') != -1">满减</span>
|
||||
@@ -46,40 +43,46 @@
|
||||
</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 class="flex goods-col">
|
||||
<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>
|
||||
</u-image>
|
||||
</div>
|
||||
<div class="goods-detail">
|
||||
<div class="title clamp3" @click="navigateToDetailPage(item)">{{ item.goodsName }}</div>
|
||||
<view class="price-box" @click="navigateToDetailPage(item)">
|
||||
<div class="price" v-if="item.price!=undefined">
|
||||
¥<span class="price-int">{{ goodsFormatPrice(item.price )[0] }} </span>.{{
|
||||
goodsFormatPrice(item.price )[1]
|
||||
}}
|
||||
</div>
|
||||
</view>
|
||||
<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 class="title clamp2" @click="navigateToDetailPage(item)">
|
||||
<text class="self-tag" v-if="(!storeName || flag('selfTag')) && item.selfOperated">自营</text>
|
||||
{{ item.goodsName }}
|
||||
</div>
|
||||
<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 class="promotion" v-if="flag('tags')" @click="navigateToDetailPage(item)">
|
||||
<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('FULL_DISCOUNT') != -1">满减</span>
|
||||
<span class="promotion-tag" v-if="promotionItem.indexOf('SECKILL') != -1">秒杀</span>
|
||||
</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: right; font-size: 22rpx">{{ item.commentNum || '0' }}条评论</span>
|
||||
<span style="float: right; font-size: 22rpx" v-if="item.commentNum">{{ item.commentNum }}条评论</span>
|
||||
</div>
|
||||
<div class="store-seller-name" @click="navigateToStoreDetailPage(item)">
|
||||
<view class="store-name-row" v-if="storeName">
|
||||
<text class="self-tag" v-if="item.selfOperated">自营</text>
|
||||
<view class="price-box" @click="navigateToDetailPage(item)">
|
||||
<div class="price" v-if="flag('price') && item.price!=undefined">
|
||||
¥<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="to-store">进店</text>
|
||||
</view>
|
||||
@@ -87,18 +90,20 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { watch } from 'vue'
|
||||
import { computed, watch } from 'vue'
|
||||
import { useStore } from '@/store'
|
||||
import { useGoodsListCommon } from './common'
|
||||
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 props = withDefaults(defineProps<{
|
||||
@@ -107,14 +112,29 @@ const props = withDefaults(defineProps<{
|
||||
storeName?: boolean
|
||||
tabBarGap?: boolean
|
||||
keyword?: string | null
|
||||
showFields?: Record<string, boolean> | null
|
||||
}>(), {
|
||||
res: () => [],
|
||||
type: 'twoColumns',
|
||||
storeName: 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) => {
|
||||
if (val) {
|
||||
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 {
|
||||
background: #fff;
|
||||
padding: 16rpx;
|
||||
@@ -250,7 +392,48 @@ watch(() => props.keyword, (val) => {
|
||||
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;
|
||||
display: flex;
|
||||
|
||||
|
||||
1
main.js
1
main.js
@@ -39,6 +39,7 @@ export function createApp() {
|
||||
setConfig({
|
||||
config: {
|
||||
loadFontOnce: true,
|
||||
iconUrl: 'https://lilishop-uniapp.oss-cn-beijing.aliyuncs.com/font_2225171_8kdcwk4po24.ttf',
|
||||
},
|
||||
props: {
|
||||
form: {
|
||||
|
||||
@@ -55,6 +55,17 @@
|
||||
</template>
|
||||
|
||||
<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>
|
||||
</template>
|
||||
|
||||
@@ -75,6 +86,7 @@ const minPrice = ref(0)
|
||||
const type = ref('')
|
||||
const connectNumber = ref('')
|
||||
const realName = ref('')
|
||||
const withdrawRule = ref('')
|
||||
|
||||
const typeLabel = computed(() => {
|
||||
if (type.value === 'ALI') return '支付宝'
|
||||
@@ -82,12 +94,28 @@ const typeLabel = computed(() => {
|
||||
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 () => {
|
||||
const result = await getUserWallet()
|
||||
const res = await withdrawalSettingVO()
|
||||
walletNum.value = result.data.result.memberWallet
|
||||
minPrice.value = res.data.result.minPrice
|
||||
type.value = res.data.result.type
|
||||
withdrawRule.value = res.data.result.withdrawRule || ''
|
||||
})
|
||||
|
||||
function cashd() {
|
||||
@@ -265,4 +293,37 @@ function handleAll() {
|
||||
text-align: center;
|
||||
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>
|
||||
|
||||
@@ -101,20 +101,7 @@
|
||||
<view class="-goods-price" v-if="goodsDetail.price != undefined">
|
||||
|
||||
<span>
|
||||
<span v-if="wholesaleList.length">
|
||||
<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><span class="price">{{
|
||||
goodsFormatPrice(goodsDetail.price)[0]
|
||||
}}</span>.{{ goodsFormatPrice(goodsDetail.price)[1] }}
|
||||
@@ -183,17 +170,6 @@
|
||||
<u-icon name="more-dot-fill"></u-icon>
|
||||
</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>
|
||||
|
||||
<!-- 评价 -->
|
||||
@@ -284,14 +260,10 @@
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
<!-- 配送地址弹窗 -->
|
||||
<popupAddress @closeAddress="closePopupAddress" @deliveryData="deliveryFun" v-if="goodsDetail.id"
|
||||
:goodsId="goodsDetail.id" :addressFlag="addressFlag" />
|
||||
|
||||
<!-- 商品规格 商品详情,以及默认参与活动的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"
|
||||
v-if="goodsDetail.id" :pointDetail="pointDetail" :wholesaleList="wholesaleList" @handleClickSku="selectSku"
|
||||
v-if="goodsDetail.id" :pointDetail="pointDetail" @handleClickSku="selectSku"
|
||||
:buyMask="buyMask" />
|
||||
|
||||
<!-- 下架框 -->
|
||||
@@ -331,7 +303,6 @@ import storeLayout from './product/shop/-shop'
|
||||
import Evaluation from './product/evaluation/-evaluation'
|
||||
import GoodsSwiper from './product/goods/-goods-swiper'
|
||||
import popupGoods from '@/components/m-buy/goods'
|
||||
import popupAddress from './product/popup/address'
|
||||
import shares from '@/components/m-share/index'
|
||||
import takeDownFormSaleGoods from '@/components/m-take-down-sale-goods/index'
|
||||
import setup from './product/popup/popup'
|
||||
@@ -371,7 +342,6 @@ const goodsSpec = ref<any>("")
|
||||
const imgList = ref<any[]>([])
|
||||
const favorite = ref(false)
|
||||
const recommendList = ref<any[]>([])
|
||||
const addressFlag = ref(false)
|
||||
const buyMask = ref(false)
|
||||
const num = ref(1)
|
||||
const skuId = ref<any>("")
|
||||
@@ -385,13 +355,11 @@ const PromotionList = ref<any>("")
|
||||
const specList = ref<any[]>([])
|
||||
const selectedSpec = ref<any[]>([])
|
||||
const nums = ref(0)
|
||||
const delivery = ref<any>("")
|
||||
const exchange = ref<any>({})
|
||||
const productId = ref(0)
|
||||
const startTimer = ref(false)
|
||||
const routerVal = ref<any>("")
|
||||
const IMLink = ref("")
|
||||
const wholesaleList = ref<any[]>([])
|
||||
const takeDownFromSale = ref(false)
|
||||
|
||||
// computed
|
||||
@@ -520,7 +488,6 @@ async function init(id: any, goodsId: any, distributionId = "", shareId = "") {
|
||||
if (goodsDetail.value) {
|
||||
goodsDetail.value.thumbnail = parseGoodsImageUrl(goodsDetail.value.thumbnail)
|
||||
}
|
||||
wholesaleList.value = response.data.result.wholesaleList || []
|
||||
goodsSpec.value = response.data.result.specs || ""
|
||||
PromotionList.value = response.data.result.promotionMap || ""
|
||||
goodsParams.value = response.data.result.goodsParamsDTOList || []
|
||||
@@ -565,13 +532,6 @@ function changedGoods(val: any) {
|
||||
selectedGoods.value = val
|
||||
}
|
||||
|
||||
function deliveryFun(val: any) {
|
||||
delivery.value = val
|
||||
}
|
||||
|
||||
function closePopupAddress(val: any) {
|
||||
addressFlag.value = val
|
||||
}
|
||||
|
||||
function closePopupBuy(val: any) {
|
||||
buyMask.value = val
|
||||
@@ -709,15 +669,11 @@ function handleBuyClick() {
|
||||
function shutMask(flag: any, buyFlag?: any, type?: any) {
|
||||
promotionShow.value = false
|
||||
buyMask.value = false
|
||||
addressFlag.value = false
|
||||
if (flag) {
|
||||
switch (flag) {
|
||||
case 1:
|
||||
promotionShow.value = true
|
||||
break
|
||||
case 3:
|
||||
addressFlag.value = true
|
||||
break
|
||||
case 4:
|
||||
buyMask.value = true
|
||||
if (buyFlag == "PINTUAN") {
|
||||
|
||||
@@ -54,10 +54,6 @@ const cityList = ref([
|
||||
onMounted(() => {
|
||||
if (isLogin('auth')) {
|
||||
getShippingAddress()
|
||||
} else {
|
||||
uni.navigateTo({
|
||||
url: '/pages/passport/login',
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -68,7 +68,6 @@
|
||||
</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-price">
|
||||
<div class="main-color">
|
||||
|
||||
@@ -11,48 +11,63 @@
|
||||
bg-color="#ffffff"
|
||||
>
|
||||
<template #left>
|
||||
<view class="nav-content">
|
||||
<text class="title">商品分类</text>
|
||||
<view class="nav-search-wrap" :style="searchBarStyle">
|
||||
<!-- #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 class="nav-search-box" :style="searchBarStyle" @click="search">
|
||||
<u-icon name="search" size="16" color="#999999"></u-icon>
|
||||
<text class="search-placeholder">搜索商品</text>
|
||||
</view>
|
||||
</template>
|
||||
</u-navbar>
|
||||
<view class="content">
|
||||
<view class="content" v-if="pageTemplate === 1">
|
||||
<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)">
|
||||
{{ item.name }}
|
||||
<view
|
||||
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>
|
||||
</scroll-view>
|
||||
<scroll-view scroll-with-animation scroll-y class="right-aside" :upper-threshold="-100" :lower-threshold="-100">
|
||||
<!-- 头部图片 -->
|
||||
<view class="top-img" id="main-top">
|
||||
<u-image width="500rpx" height="230rpx" @click="navigateToList(topImg.id,topImg.id)" :src="topImg.image" mode="">
|
||||
<view class="top-img" id="main-top" v-if="topImg && topImg.image">
|
||||
<u-image width="100%" height="200rpx" border-radius="12rpx" @click="navigateToList(topImg.id, topImg.id)" :src="topImg.image" mode="aspectFill">
|
||||
</u-image>
|
||||
</view>
|
||||
<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">
|
||||
<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"
|
||||
:class="{ 'margin-right': (cIndex + 1) % 3 == 0 }">
|
||||
<u-image width="70px" height="70px" :src="children.image" :lazy-load="true">
|
||||
</u-image>
|
||||
<text>{{ children.name }}</text>
|
||||
</view>
|
||||
<view
|
||||
@click="navigateToList(item.id, children.id)"
|
||||
v-if="children.parentId === item.id"
|
||||
class="t-item"
|
||||
>
|
||||
<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>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<tpl-category-goods
|
||||
v-else
|
||||
class="tpl-goods-wrapper"
|
||||
:category-list="tabList"
|
||||
:setting="categoryPageSetting"
|
||||
:template="pageTemplate"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -61,10 +76,17 @@ import { ref, computed } from 'vue'
|
||||
import { onLoad, onReady } from '@dcloudio/uni-app'
|
||||
import { getCategoryList } from '@/api/goods.js'
|
||||
import { getThemeStyle } from '@/utils/theme'
|
||||
import { DEFAULT_CATEGORY_PAGE_SETTING } from '@/utils/categoryPageSetting'
|
||||
import { useStore } from '@/store'
|
||||
import TplCategoryGoods from '@/components/category/tpl-category-goods.vue'
|
||||
|
||||
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 tabList = ref<any[]>([]) // 左侧标题列表
|
||||
const categoryList = ref<any[]>([]) // 右侧分类数据列表
|
||||
@@ -75,9 +97,9 @@ const themeStyle = computed(() => getThemeStyle(store.state.theme))
|
||||
|
||||
const searchBarStyle = computed(() => {
|
||||
if (searchBarWidth.value) {
|
||||
return { width: `${searchBarWidth.value}px` }
|
||||
return { width: searchBarWidth.value + 'px' }
|
||||
}
|
||||
return { width: "460rpx" }
|
||||
return { width: "680rpx" }
|
||||
})
|
||||
|
||||
onLoad(() => {
|
||||
@@ -98,18 +120,25 @@ function setSearchBarWidth() {
|
||||
// #ifdef MP-WEIXIN
|
||||
try {
|
||||
const menuButton = uni.getMenuButtonBoundingClientRect()
|
||||
const { windowWidth } = uni.getWindowInfo()
|
||||
const capsuleInsetRight = windowWidth - menuButton.left
|
||||
const titleWidth = uni.upx2px(160) // "商品分类" 标题宽度
|
||||
const leftPadding = uni.upx2px(60) // 左侧内边距
|
||||
const leftMargin = uni.upx2px(24) // 搜索框左边距
|
||||
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) {
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
@@ -125,8 +154,10 @@ function search() {
|
||||
async function loadData() {
|
||||
let list = await getCategoryList(0)
|
||||
tabList.value = list.data.result
|
||||
currentId.value = list.data.result[0].id
|
||||
loadListContent(0)
|
||||
if (tabList.value && tabList.value.length) {
|
||||
currentId.value = tabList.value[0].id
|
||||
loadListContent(0)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,6 +167,7 @@ function loadListContent(index: number) {
|
||||
topImg.value = tabList.value[index]
|
||||
categoryList.value = tabList.value[index].children
|
||||
}
|
||||
|
||||
/**
|
||||
* 一级分类点击
|
||||
*/
|
||||
@@ -148,7 +180,7 @@ function tabtap(item: any, i: number) {
|
||||
|
||||
function navigateToList(sid: any, tid: any) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/navigation/search/searchPage?category=${tid}`,
|
||||
url: '/pages/navigation/search/searchPage?category=' + tid,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@@ -156,7 +188,7 @@ function navigateToList(sid: any, tid: any) {
|
||||
<style lang="scss">
|
||||
page {
|
||||
height: 100%;
|
||||
background-color: #fdfaff;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -170,36 +202,42 @@ page {
|
||||
/* 解决H5 的问题 */
|
||||
/* #ifdef H5 */
|
||||
uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
|
||||
/* 隐藏滚动条,但依旧具备可以滚动的功能 */
|
||||
display: none;
|
||||
}
|
||||
/* #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 {
|
||||
height: 100vh;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
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 {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
@@ -207,85 +245,159 @@ uni-scroll-view .uni-scroll-view::-webkit-scrollbar {
|
||||
display: flex;
|
||||
color: #333;
|
||||
font-size: 28rpx;
|
||||
background: #fff;
|
||||
background: #ffffff;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.left-aside {
|
||||
flex-shrink: 0;
|
||||
width: 200rpx;
|
||||
width: 176rpx;
|
||||
height: 100%;
|
||||
background-color: #f7f7f7;
|
||||
background-color: #f6f7f9;
|
||||
border-right: 1rpx solid #ebebeb;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.f-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
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;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&.active {
|
||||
font-weight: bold;
|
||||
font-weight: 600;
|
||||
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 {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
padding: 40rpx 0 0 30rpx;
|
||||
padding: 20rpx 20rpx 40rpx;
|
||||
box-sizing: border-box;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.top-img {
|
||||
width: 500rpx;
|
||||
height: 230rpx;
|
||||
border-radius: 8px;
|
||||
width: 100%;
|
||||
height: 200rpx;
|
||||
border-radius: 14rpx;
|
||||
overflow: hidden;
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
margin-bottom: 20rpx;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
.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;
|
||||
align-items: center;
|
||||
height: 70rpx;
|
||||
padding-top: 16rpx;
|
||||
font-weight: 500;
|
||||
justify-content: space-between;
|
||||
padding-bottom: 16rpx;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.s-item {
|
||||
font-size: 26rpx;
|
||||
font-weight: 600;
|
||||
color: #222;
|
||||
}
|
||||
|
||||
.t-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
width: 100%;
|
||||
padding-top: 12rpx;
|
||||
}
|
||||
.margin-right {
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
|
||||
.t-item {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
width: 150rpx;
|
||||
margin-right: 25rpx;
|
||||
width: 33.333%;
|
||||
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;
|
||||
padding-bottom: 20rpx;
|
||||
image {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
::v-deep .u-image {
|
||||
width: 140rpx !important;
|
||||
height: 140rpx !important;
|
||||
border-radius: 8px !important;
|
||||
margin-bottom: 20rpx !important;
|
||||
}
|
||||
color: #333;
|
||||
max-width: 140rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
line-height: 1.2;
|
||||
}
|
||||
}
|
||||
|
||||
.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>
|
||||
|
||||
@@ -1,355 +1,489 @@
|
||||
<template>
|
||||
<view class="user" :style="themeStyle">
|
||||
<!-- 个人信息 -->
|
||||
<view class="status_bar">
|
||||
<!-- 这里是状态栏 -->
|
||||
</view>
|
||||
<view class="header" @click="userDetail">
|
||||
<view class="head-1">
|
||||
<image class="head-avatar" :src="userInfo.face || userImage"></image>
|
||||
</view>
|
||||
<view class="head-2" v-if="userInfo.id">
|
||||
<view class="user-name">{{ userInfo.nickName }}</view>
|
||||
</view>
|
||||
<view class="head-2" v-else>
|
||||
<view class="user-name">登录/注册</view>
|
||||
</view>
|
||||
<u-icon class="header-arrow" name="arrow-right"></u-icon>
|
||||
</view>
|
||||
<!-- 积分,优惠券,关注, -->
|
||||
<div class="pointBox box">
|
||||
<view class="point">
|
||||
<view class="point-item" @click="navigateTo('/pages/mine/deposit/operation')">
|
||||
<view class="point-label">预存款</view>
|
||||
<view class="point-value money">{{ unitPrice(walletNum) }}</view>
|
||||
</view>
|
||||
<view class="point-item" @click="navigateTo('/pages/cart/coupon/myCoupon')">
|
||||
<view class="point-label">优惠券</view>
|
||||
<view class="point-value">{{ couponNum || 0 }}</view>
|
||||
</view>
|
||||
<view class="point-item" @click="navigateTo('/pages/mine/myTracks')">
|
||||
<view class="point-label">足迹</view>
|
||||
<view class="point-value">{{ footNum || 0 }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 我的订单 -->
|
||||
<view class="order">
|
||||
<view class="order-head">
|
||||
<text class="order-head-title">我的订单</text>
|
||||
<view class="order-head-all" @click="navigateTo('/pages/order/myOrder?status=0')">
|
||||
<text>全部</text>
|
||||
<u-icon name="arrow-right" size="12" color="#999"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
<view class="order-row">
|
||||
<view class="order-item" @click="navigateTo('/pages/order/myOrder?status=1')">
|
||||
<view class="bag bag2">
|
||||
<u-icon name="bag-fill" size="22" color="#fff"></u-icon>
|
||||
</view>
|
||||
<view class="order-item-label">待支付</view>
|
||||
</view>
|
||||
<view class="order-item" @click="navigateTo('/pages/order/myOrder?status=2')">
|
||||
<view class="bag bag1">
|
||||
<u-icon name="gift-fill" size="22" color="#fff"></u-icon>
|
||||
</view>
|
||||
<view class="order-item-label">待发货</view>
|
||||
</view>
|
||||
<view class="order-item" @click="navigateTo('/pages/order/myOrder?status=3')">
|
||||
<view class="bag bag3">
|
||||
<u-icon name="car-fill" size="22" color="#fff"></u-icon>
|
||||
</view>
|
||||
<view class="order-item-label">待收货</view>
|
||||
</view>
|
||||
<view class="order-item" @click="navigateTo('/pages/order/myOrder?status=4')">
|
||||
<view class="bag bag4">
|
||||
<u-icon name="star-fill" size="22" color="#fff"></u-icon>
|
||||
</view>
|
||||
<view class="order-item-label">待评价</view>
|
||||
</view>
|
||||
<view class="order-item" @click="navigateTo('/pages/order/myOrder?status=5')">
|
||||
<view class="bag bag5">
|
||||
<u-icon name="server-fill" size="22" color="#fff"></u-icon>
|
||||
</view>
|
||||
<view class="order-item-label">售后</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</div>
|
||||
<!-- 常用工具 -->
|
||||
|
||||
<tool />
|
||||
|
||||
</view>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import {
|
||||
onLoad,
|
||||
onShow,
|
||||
onPullDownRefresh,
|
||||
onNavigationBarButtonTap,
|
||||
} from '@dcloudio/uni-app'
|
||||
import tool from '@/pages/tabbar/user/utils/tool.vue'
|
||||
import { getCouponsNum, getFootprintNum } from '@/api/members.js'
|
||||
import { getUserWallet } from '@/api/members'
|
||||
import configs from '@/config/config'
|
||||
import { useStore } from '@/store'
|
||||
import { getThemeStyle } from '@/utils/theme'
|
||||
import { isLogin, navigateToLogin, unitPrice } from '@/utils/filters.js'
|
||||
|
||||
const store = useStore()
|
||||
const themeStyle = computed(() => getThemeStyle(store.state.theme))
|
||||
const lightColor = computed(() => store.getters.lightColor)
|
||||
const mainColor = computed(() => store.getters.mainColor)
|
||||
const aiderLightColor = computed(() => store.getters.aiderLightColor)
|
||||
|
||||
const userImage = configs.defaultUserPhoto
|
||||
const userInfo = ref<any>({})
|
||||
const couponNum = ref<string | number>('')
|
||||
const footNum = ref<string | number>('')
|
||||
const walletNum = ref<string | number>('')
|
||||
|
||||
onLoad(() => {})
|
||||
|
||||
onShow(() => {
|
||||
userInfo.value = isLogin() || {}
|
||||
if (isLogin('auth')) {
|
||||
getUserOrderNum()
|
||||
} else {
|
||||
walletNum.value = 0
|
||||
couponNum.value = 0
|
||||
footNum.value = 0
|
||||
}
|
||||
})
|
||||
|
||||
onPullDownRefresh(() => {
|
||||
getUserOrderNum()
|
||||
userInfo.value = isLogin()
|
||||
})
|
||||
|
||||
// #ifndef MP
|
||||
onNavigationBarButtonTap((e) => {
|
||||
if (e.index === 0) {
|
||||
navigateTo('/pages/mine/set/setUp')
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
|
||||
function navigateTo(url: string) {
|
||||
uni.navigateTo({ url })
|
||||
}
|
||||
|
||||
function userDetail() {
|
||||
userInfo.value.id
|
||||
? navigateTo('/pages/mine/set/personMsg')
|
||||
: navigateToLogin()
|
||||
}
|
||||
|
||||
async function getUserOrderNum() {
|
||||
uni.stopPullDownRefresh()
|
||||
|
||||
Promise.all([
|
||||
getCouponsNum(),
|
||||
getFootprintNum(),
|
||||
getUserWallet(),
|
||||
]).then((res: any[]) => {
|
||||
couponNum.value = res[0].data.result
|
||||
footNum.value = res[1].data.result
|
||||
walletNum.value = res[2].data.result.memberWallet
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
html,
|
||||
body {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.money {
|
||||
overflow: hidden;
|
||||
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.user {
|
||||
.header {
|
||||
max-width: 100%;
|
||||
padding: calc(50rpx + var(--status-bar-height)) 30rpx 0 6%;
|
||||
height: calc(var(--status-bar-height) + 360rpx);
|
||||
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");
|
||||
background-position: bottom;
|
||||
background-repeat: no-repeat;
|
||||
color: #ffffff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.head-1 {
|
||||
flex-shrink: 0;
|
||||
width: 152rpx;
|
||||
|
||||
.head-avatar {
|
||||
width: 152rpx;
|
||||
height: 144rpx;
|
||||
border-radius: 50%;
|
||||
border: 3px solid #fff;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.edti-head {
|
||||
position: absolute;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
border-radius: 50%;
|
||||
background-color: rgba(255, 255, 255, 0.3);
|
||||
top: 100rpx;
|
||||
right: 0;
|
||||
|
||||
.head-avatar {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.head-2 {
|
||||
flex: 1;
|
||||
margin-left: 30rpx;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header-arrow {
|
||||
flex-shrink: 0;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.pointBox {
|
||||
width: 94%;
|
||||
margin: 0 3%;
|
||||
background: #fff;
|
||||
border-radius: 20rpx;
|
||||
box-shadow: 0 4rpx 24rpx 0 rgba($color: #f6f6f6, $alpha: 1);
|
||||
}
|
||||
|
||||
.point {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
height: 160rpx;
|
||||
font-size: $font-sm;
|
||||
// #ifdef MP-WEIXIN
|
||||
padding: 24rpx;
|
||||
// #endif
|
||||
|
||||
.point-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.point-label {
|
||||
color: $u-main-color;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.point-value {
|
||||
margin-top: 8rpx;
|
||||
color: $main-color;
|
||||
font-size: $font-lg;
|
||||
}
|
||||
}
|
||||
|
||||
.order {
|
||||
padding: 8rpx 16rpx 24rpx;
|
||||
color: #333;
|
||||
|
||||
.order-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 8rpx 12rpx 20rpx;
|
||||
}
|
||||
|
||||
.order-head-title {
|
||||
font-size: 26rpx;
|
||||
font-weight: 600;
|
||||
color: #111;
|
||||
}
|
||||
|
||||
.order-head-all {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.order-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.order-item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.order-item-label {
|
||||
margin-top: 12rpx;
|
||||
line-height: 1.4;
|
||||
font-size: 24rpx;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.box {
|
||||
transform: translateY(-30rpx);
|
||||
}
|
||||
|
||||
.user-name {
|
||||
font-size: 34rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.bag {
|
||||
width: 56rpx;
|
||||
height: 56rpx;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.bag1 {
|
||||
background: #ff4a48;
|
||||
}
|
||||
|
||||
.bag2 {
|
||||
background: #ff992f;
|
||||
}
|
||||
|
||||
.bag3 {
|
||||
background: #009ee0;
|
||||
}
|
||||
|
||||
.bag4 {
|
||||
background: #00d5d5;
|
||||
}
|
||||
|
||||
.bag5 {
|
||||
background: #28ccb0;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<view class="user-page" :style="themeStyle">
|
||||
<!-- 顶部沉浸式头部区域 -->
|
||||
<view class="hero-header" :style="{ paddingTop: headerPaddingTop + 'px' }">
|
||||
<!-- 用户信息区(沉降至胶囊安全区下方,舒展大气) -->
|
||||
<view class="user-profile" @click="userDetail">
|
||||
<view class="avatar-container">
|
||||
<image class="avatar-img" :src="userInfo.face || userImage" mode="aspectFill"></image>
|
||||
<view class="vip-tag-icon" v-if="userInfo.id">
|
||||
<u-icon name="level" size="10" color="#ffffff"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="user-detail-info">
|
||||
<view class="user-title-row">
|
||||
<text class="user-nickname">{{ userInfo.id ? userInfo.nickName : '登录 / 注册' }}</text>
|
||||
</view>
|
||||
<view class="user-sub-row">
|
||||
<view class="badge-tag" v-if="userInfo.id">
|
||||
<text>普通会员</text>
|
||||
</view>
|
||||
<text class="user-sub-text" v-else>
|
||||
登录享受更多会员特权与折扣
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="profile-arrow">
|
||||
<u-icon name="arrow-right" size="14" color="rgba(255, 255, 255, 0.75)"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 沉浸式核心资产栏(纯白字,融入顶部主色调) -->
|
||||
<view class="hero-assets">
|
||||
<view class="asset-col" @click="navigateTo('/pages/mine/deposit/operation')">
|
||||
<view class="asset-number-row">
|
||||
<text class="symbol">¥</text>
|
||||
<text class="num money">{{ unitPrice(walletNum) }}</text>
|
||||
</view>
|
||||
<view class="asset-title">预存款</view>
|
||||
</view>
|
||||
<view class="asset-sep"></view>
|
||||
<view class="asset-col" @click="navigateTo('/pages/cart/coupon/myCoupon')">
|
||||
<view class="asset-number-row">
|
||||
<text class="num">{{ couponNum || 0 }}</text>
|
||||
<text class="unit">张</text>
|
||||
</view>
|
||||
<view class="asset-title">优惠券</view>
|
||||
</view>
|
||||
<view class="asset-sep"></view>
|
||||
<view class="asset-col" @click="navigateTo('/pages/mine/myTracks')">
|
||||
<view class="asset-number-row">
|
||||
<text class="num">{{ footNum || 0 }}</text>
|
||||
<text class="unit">条</text>
|
||||
</view>
|
||||
<view class="asset-title">浏览足迹</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 下方主内容卡片区域 -->
|
||||
<view class="main-container">
|
||||
<!-- 我的订单卡片 -->
|
||||
<view class="card-box order-box">
|
||||
<view class="card-title-bar">
|
||||
<text class="card-title-text">我的订单</text>
|
||||
<view class="card-more-btn" @click="navigateTo('/pages/order/myOrder?status=0')">
|
||||
<text>全部订单</text>
|
||||
<u-icon name="arrow-right" size="11" color="#a0a0a0"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="order-action-row">
|
||||
<view class="order-action-item" @click="navigateTo('/pages/order/myOrder?status=1')">
|
||||
<view class="icon-wrap">
|
||||
<u-icon name="bag-fill" size="27" color="#ff7a00"></u-icon>
|
||||
</view>
|
||||
<text class="order-action-label">待支付</text>
|
||||
</view>
|
||||
|
||||
<view class="order-action-item" @click="navigateTo('/pages/order/myOrder?status=2')">
|
||||
<view class="icon-wrap">
|
||||
<u-icon name="gift-fill" size="27" color="#ff4d4f"></u-icon>
|
||||
</view>
|
||||
<text class="order-action-label">待发货</text>
|
||||
</view>
|
||||
|
||||
<view class="order-action-item" @click="navigateTo('/pages/order/myOrder?status=3')">
|
||||
<view class="icon-wrap">
|
||||
<u-icon name="car-fill" size="27" color="#1677ff"></u-icon>
|
||||
</view>
|
||||
<text class="order-action-label">待收货</text>
|
||||
</view>
|
||||
|
||||
<view class="order-action-item" @click="navigateTo('/pages/order/myOrder?status=4')">
|
||||
<view class="icon-wrap">
|
||||
<u-icon name="star-fill" size="27" color="#13c2c2"></u-icon>
|
||||
</view>
|
||||
<text class="order-action-label">待评价</text>
|
||||
</view>
|
||||
|
||||
<view class="order-action-item" @click="navigateTo('/pages/order/myOrder?status=5')">
|
||||
<view class="icon-wrap">
|
||||
<u-icon name="server-fill" size="27" color="#20b286"></u-icon>
|
||||
</view>
|
||||
<text class="order-action-label">退款/售后</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 服务工具卡片(分组化重构) -->
|
||||
<tool />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import {
|
||||
onLoad,
|
||||
onShow,
|
||||
onPullDownRefresh,
|
||||
onNavigationBarButtonTap,
|
||||
} from '@dcloudio/uni-app'
|
||||
import tool from '@/pages/tabbar/user/utils/tool.vue'
|
||||
import { getCouponsNum, getFootprintNum } from '@/api/members.js'
|
||||
import { getUserWallet } from '@/api/members'
|
||||
import configs from '@/config/config'
|
||||
import { useStore } from '@/store'
|
||||
import { getThemeStyle } from '@/utils/theme'
|
||||
import { isLogin, navigateToLogin, unitPrice } from '@/utils/filters.js'
|
||||
|
||||
const store = useStore()
|
||||
const themeStyle = computed(() => getThemeStyle(store.state.theme))
|
||||
const lightColor = computed(() => store.getters.lightColor)
|
||||
const mainColor = computed(() => store.getters.mainColor)
|
||||
const aiderLightColor = computed(() => store.getters.aiderLightColor)
|
||||
|
||||
const userImage = configs.defaultUserPhoto
|
||||
const userInfo = ref<any>({})
|
||||
const couponNum = ref<string | number>('')
|
||||
const footNum = ref<string | number>('')
|
||||
const walletNum = ref<string | number>('')
|
||||
|
||||
// 动态计算顶部安全留白,避免顶到灵动岛/状态栏
|
||||
const headerPaddingTop = ref<number>(88)
|
||||
|
||||
function initSafeTop() {
|
||||
try {
|
||||
const sys = uni.getSystemInfoSync()
|
||||
const statusBar = sys.statusBarHeight || 44
|
||||
// #ifdef MP-WEIXIN
|
||||
const menu = uni.getMenuButtonBoundingClientRect()
|
||||
if (menu && menu.bottom) {
|
||||
// 头像整行落到微信胶囊下方,预留 16px 呼吸空隙,彻底消除压迫感
|
||||
headerPaddingTop.value = menu.bottom + 16
|
||||
} else {
|
||||
headerPaddingTop.value = statusBar + 54
|
||||
}
|
||||
// #endif
|
||||
// #ifndef MP-WEIXIN
|
||||
headerPaddingTop.value = statusBar + 32
|
||||
// #endif
|
||||
} catch (e) {
|
||||
headerPaddingTop.value = 88
|
||||
}
|
||||
}
|
||||
|
||||
onLoad(() => {
|
||||
initSafeTop()
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
userInfo.value = isLogin() || {}
|
||||
if (isLogin('auth')) {
|
||||
getUserOrderNum()
|
||||
} else {
|
||||
walletNum.value = 0
|
||||
couponNum.value = 0
|
||||
footNum.value = 0
|
||||
}
|
||||
})
|
||||
|
||||
onPullDownRefresh(() => {
|
||||
getUserOrderNum()
|
||||
userInfo.value = isLogin()
|
||||
})
|
||||
|
||||
// #ifndef MP
|
||||
onNavigationBarButtonTap((e) => {
|
||||
if (e.index === 0) {
|
||||
navigateTo('/pages/mine/set/setUp')
|
||||
}
|
||||
})
|
||||
// #endif
|
||||
|
||||
function navigateTo(url: string) {
|
||||
uni.navigateTo({ url })
|
||||
}
|
||||
|
||||
function userDetail() {
|
||||
userInfo.value.id
|
||||
? navigateTo('/pages/mine/set/personMsg')
|
||||
: navigateToLogin()
|
||||
}
|
||||
|
||||
async function getUserOrderNum() {
|
||||
uni.stopPullDownRefresh()
|
||||
|
||||
Promise.all([
|
||||
getCouponsNum(),
|
||||
getFootprintNum(),
|
||||
getUserWallet(),
|
||||
]).then((res: any[]) => {
|
||||
couponNum.value = res[0].data.result
|
||||
footNum.value = res[1].data.result
|
||||
walletNum.value = res[2].data.result.memberWallet
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.user-page {
|
||||
min-height: 100vh;
|
||||
background-color: #f5f6f9;
|
||||
padding-bottom: 40rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 顶部沉浸式头部 */
|
||||
.hero-header {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
background: linear-gradient(175deg, #e53238 0%, #eb4448 45%, #ff5e62 100%);
|
||||
padding-left: 28rpx;
|
||||
padding-right: 28rpx;
|
||||
padding-bottom: 64rpx;
|
||||
border-bottom-left-radius: 36rpx;
|
||||
border-bottom-right-radius: 36rpx;
|
||||
/* CSS 静态兜底:状态栏高度 + 充足的沉降留白 */
|
||||
padding-top: calc(var(--status-bar-height, 44px) + 88rpx);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 用户信息行(移到胶囊下方,拥有充裕横纵向空间) */
|
||||
.user-profile {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 8rpx 6rpx;
|
||||
transition: opacity 0.2s;
|
||||
|
||||
&:active {
|
||||
opacity: 0.88;
|
||||
}
|
||||
|
||||
.avatar-container {
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
|
||||
.avatar-img {
|
||||
width: 124rpx;
|
||||
height: 124rpx;
|
||||
border-radius: 50%;
|
||||
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;
|
||||
}
|
||||
|
||||
.vip-tag-icon {
|
||||
position: absolute;
|
||||
right: -2rpx;
|
||||
bottom: 2rpx;
|
||||
width: 34rpx;
|
||||
height: 34rpx;
|
||||
background: linear-gradient(135deg, #f59e0b, #d97706);
|
||||
border: 2rpx solid #ffffff;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
.user-detail-info {
|
||||
flex: 1;
|
||||
margin-left: 24rpx;
|
||||
min-width: 0;
|
||||
|
||||
.user-title-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.user-nickname {
|
||||
font-size: 38rpx;
|
||||
font-weight: 700;
|
||||
color: #ffffff;
|
||||
letter-spacing: 0.5rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.user-sub-row {
|
||||
margin-top: 12rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 12rpx;
|
||||
|
||||
.badge-tag {
|
||||
font-size: 20rpx;
|
||||
color: #ffffff;
|
||||
background: rgba(255, 255, 255, 0.22);
|
||||
padding: 3rpx 14rpx;
|
||||
border-radius: 20rpx;
|
||||
border: 1rpx solid rgba(255, 255, 255, 0.35);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.user-sub-text {
|
||||
font-size: 23rpx;
|
||||
color: rgba(255, 255, 255, 0.88);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.profile-arrow {
|
||||
flex-shrink: 0;
|
||||
margin-left: 16rpx;
|
||||
opacity: 0.85;
|
||||
}
|
||||
}
|
||||
|
||||
/* 核心资产栏(沉浸在红色背景中) */
|
||||
.hero-assets {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 44rpx;
|
||||
padding: 0 12rpx;
|
||||
|
||||
.asset-col {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: transform 0.15s, opacity 0.15s;
|
||||
|
||||
&: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>
|
||||
<view>
|
||||
<!-- 常用工具 -->
|
||||
<view class="interact-tools" style="margin-bottom: 15px">
|
||||
<view class="tool-wrapper">
|
||||
<!-- 卡片 1: 资产与常用 -->
|
||||
<view class="service-card">
|
||||
<view class="service-title-bar">
|
||||
<text class="service-title-text">资产与常用</text>
|
||||
</view>
|
||||
|
||||
<div class="paddingBox">
|
||||
<view class="interact-container">
|
||||
<view class="interact-item" @click="navigateTo('/pages/mine/address/addressManage')">
|
||||
<image class="interact-item-icon" src="/static/mine/myaddress.png" mode=""></image>
|
||||
<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 class="service-grid">
|
||||
<view class="service-grid-item" @click="navigateTo('/pages/cart/coupon/couponCenter')">
|
||||
<image class="grid-icon" src="/static/mine/couponcenter.png" mode="aspectFit"></image>
|
||||
<text class="grid-label">领券中心</text>
|
||||
</view>
|
||||
</div>
|
||||
|
||||
<template>
|
||||
<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>
|
||||
</template>
|
||||
|
||||
<view class="service-grid-item" @click="navigateTo('/pages/mine/point/myPoint')">
|
||||
<image class="grid-icon" src="/static/mine/mypoint.png" mode="aspectFit"></image>
|
||||
<text class="grid-label">我的积分</text>
|
||||
</view>
|
||||
|
||||
<view class="service-grid-item" @click="navigateTo('/pages/mine/signIn')">
|
||||
<image class="grid-icon" src="/static/mine/sign.png" mode="aspectFit"></image>
|
||||
<text class="grid-label">每日签到</text>
|
||||
</view>
|
||||
|
||||
<view class="service-grid-item" @click="navigateTo('/pages/cart/coupon/myCoupon')">
|
||||
<image class="grid-icon" src="/static/mine/mycoupon.png" mode="aspectFit"></image>
|
||||
<text class="grid-label">优惠券</text>
|
||||
</view>
|
||||
|
||||
<view class="service-grid-item" @click="navigateTo('/pages/mine/address/addressManage')">
|
||||
<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>
|
||||
|
||||
<!-- 卡片 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>
|
||||
</template>
|
||||
|
||||
@@ -227,7 +207,6 @@ function distribution() {
|
||||
if (!tipsToLogin('normal')) {
|
||||
return
|
||||
}
|
||||
// 入口按 distributionStatus 路由:有对象 ≠ 有效分销员。清退停住,不进 join / home。
|
||||
fetchDistribution().then((res) => {
|
||||
if (res.data.result) {
|
||||
const type = res.data.result.distributionStatus
|
||||
@@ -264,6 +243,69 @@ function distribution() {
|
||||
</script>
|
||||
|
||||
<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 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -272,50 +314,8 @@ function distribution() {
|
||||
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 {
|
||||
margin: 0 auto;
|
||||
width: 200px;
|
||||
margin: 0 auto;
|
||||
width: 200px;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -2,8 +2,13 @@ import { createStore } from 'vuex'
|
||||
import storage from '@/utils/storage'
|
||||
import config from '@/config/config'
|
||||
import { DEFAULT_THEME, loadCachedTheme } from '@/utils/theme'
|
||||
import {
|
||||
DEFAULT_CATEGORY_PAGE_SETTING,
|
||||
loadCachedCategoryPageSetting,
|
||||
} from '@/utils/categoryPageSetting'
|
||||
|
||||
const cachedTheme = loadCachedTheme()
|
||||
const cachedCategoryPageSetting = loadCachedCategoryPageSetting()
|
||||
|
||||
const store = createStore({
|
||||
state: {
|
||||
@@ -17,6 +22,8 @@ const store = createStore({
|
||||
uuid: storage.getUuid(),
|
||||
token: '',
|
||||
theme: cachedTheme || { ...DEFAULT_THEME },
|
||||
categoryPageSetting:
|
||||
cachedCategoryPageSetting || { ...DEFAULT_CATEGORY_PAGE_SETTING },
|
||||
},
|
||||
getters: {
|
||||
mainColor: (state) => state.theme.mainColor,
|
||||
@@ -44,6 +51,9 @@ const store = createStore({
|
||||
aiderLightColor: theme.aiderLightColor || DEFAULT_THEME.aiderLightColor,
|
||||
}
|
||||
},
|
||||
SET_CATEGORY_PAGE_SETTING(state, setting) {
|
||||
state.categoryPageSetting = setting || { ...DEFAULT_CATEGORY_PAGE_SETTING }
|
||||
},
|
||||
},
|
||||
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