|
|
@@ -1,29 +1,30 @@
|
|
1
|
1
|
<script lang="ts" setup>
|
|
2
|
2
|
import FNavBar from "~/components/FNavBar/FNavBar.vue";
|
|
3
|
|
-import {getDcProductClassify, getDcProductList} from "~/apis/dacang";
|
|
|
3
|
+import { getDcProductClassify, getDcProductList } from "~/apis/dacang";
|
|
4
|
4
|
import FTabs from "~/components/FTabs/FTabs.vue";
|
|
5
|
5
|
import ProductList from "~/components/ProductList/ProductList.vue";
|
|
6
|
|
-import type {DcProductModel} from "~/apis/model/dacang.model";
|
|
7
|
|
-import {useDacangStore} from "~/stores/dacangStore";
|
|
8
|
|
-import {CDN_URL} from "~/config/app";
|
|
|
6
|
+import type { DcProductModel } from "~/apis/model/dacang.model";
|
|
|
7
|
+import { useDacangStore } from "~/stores/dacangStore";
|
|
|
8
|
+import { CDN_URL } from "~/config/app";
|
|
9
|
9
|
import DacangHeader from "~/pages/dacang/list/components/dacang-header.vue";
|
|
10
|
10
|
import CXBBackTop from "~/components/CXBBackTop/CXBBackTop.vue";
|
|
11
|
|
-import {getProductShare} from "~/apis/common";
|
|
12
|
|
-import {useUserStore} from "~/stores/userStore";
|
|
|
11
|
+import { getProductShare } from "~/apis/common";
|
|
|
12
|
+import { useUserStore } from "~/stores/userStore";
|
|
13
|
13
|
import Cache from "~/utils/cache";
|
|
14
|
|
-const headerImage = CDN_URL + `/static/assets/banner-dacang.png`
|
|
|
14
|
+import { getBannerImg } from '~/apis/product'
|
|
|
15
|
+import Banner from "./components/banner.vue";
|
|
|
16
|
+
|
|
|
17
|
+
|
|
15
|
18
|
const usePageStore = usePageStoreWidthOut()
|
|
16
|
19
|
|
|
17
|
20
|
|
|
18
|
21
|
const state = reactive({
|
|
19
|
|
- tabs: [{store_category_id: '-1', cate_name: '全部'}],
|
|
|
22
|
+ tabs: [{ store_category_id: '-1', cate_name: '全部' }],
|
|
20
|
23
|
productList: <Array<DcProductModel>>[],
|
|
21
|
|
-
|
|
22
|
24
|
currentClassify: '',
|
|
23
|
25
|
keyword: '',
|
|
24
|
|
-
|
|
25
|
26
|
status: 'noMore',
|
|
26
|
|
-
|
|
|
27
|
+ banner:'',
|
|
27
|
28
|
currentPage: 1,
|
|
28
|
29
|
pageSize: 10,
|
|
29
|
30
|
totalPage: 1
|
|
|
@@ -35,14 +36,16 @@ let Scroll_X = ref(0)
|
|
35
|
36
|
const dacangStore = useDacangStore()
|
|
36
|
37
|
const userStore = useUserStore()
|
|
37
|
38
|
|
|
|
39
|
+
|
|
38
|
40
|
onLoad(async (option) => {
|
|
39
|
|
- state.tabs = [{store_category_id: '-1', cate_name: '全部'}]
|
|
|
41
|
+ state.tabs = [{ store_category_id: '-1', cate_name: '全部' }]
|
|
40
|
42
|
const classifyRes = await getDcProductClassify()
|
|
|
43
|
+
|
|
41
|
44
|
state.tabs.push(...classifyRes)
|
|
42
|
45
|
usePageStore.setPageConfig({
|
|
43
|
46
|
currentPage: {
|
|
44
|
47
|
type: 'tab',
|
|
45
|
|
- url: '/pages/dacang/list/index'
|
|
|
48
|
+ url: '/pages/dacang/list/index'
|
|
46
|
49
|
}
|
|
47
|
50
|
})
|
|
48
|
51
|
|
|
|
@@ -57,7 +60,12 @@ onLoad(async (option) => {
|
|
57
|
60
|
// console.log(message)
|
|
58
|
61
|
})
|
|
59
|
62
|
userStore.setRedirectPage(`/pages/dacang/list/index`, 'tab')
|
|
60
|
|
-
|
|
|
63
|
+ getBannerImg().then(res=>{
|
|
|
64
|
+ console.log('banner',res);
|
|
|
65
|
+ state.banner=res[0].pic
|
|
|
66
|
+ console.log(state.banner);
|
|
|
67
|
+
|
|
|
68
|
+ })
|
|
61
|
69
|
|
|
62
|
70
|
})
|
|
63
|
71
|
|
|
|
@@ -85,26 +93,25 @@ onShow(async (options) => {
|
|
85
|
93
|
usePageStore.setPageConfig({
|
|
86
|
94
|
currentPage: {
|
|
87
|
95
|
type: 'tab',
|
|
88
|
|
- url: '/pages/dacang/list/index'
|
|
|
96
|
+ url: '/pages/dacang/list/index'
|
|
89
|
97
|
}
|
|
90
|
98
|
})
|
|
91
|
99
|
loadList('reload')
|
|
92
|
100
|
})
|
|
93
|
101
|
|
|
94
|
102
|
function loadList(action: 'page' | 'reload', callback?: (items) => void) {
|
|
95
|
|
-
|
|
|
103
|
+ console.log(action);
|
|
96
|
104
|
let params: any = {
|
|
97
|
105
|
page: state.currentPage,
|
|
98
|
106
|
limit: state.pageSize,
|
|
99
|
107
|
keyword: state.keyword
|
|
100
|
108
|
}
|
|
|
109
|
+ console.log(params);
|
|
101
|
110
|
if (dacangStore.currentClassify !== '-1') {
|
|
102
|
111
|
params.classify = dacangStore.currentClassify
|
|
103
|
112
|
}
|
|
104
|
113
|
|
|
105
|
|
- if (action === 'reload') {
|
|
106
|
|
- params.page = 1
|
|
107
|
|
- }
|
|
|
114
|
+
|
|
108
|
115
|
|
|
109
|
116
|
getDcProductList({
|
|
110
|
117
|
...params
|
|
|
@@ -136,7 +143,7 @@ const headerClass = ref('')
|
|
136
|
143
|
onPageScroll((page) => {
|
|
137
|
144
|
Scroll_X.value = Number(page.scrollTop.toFixed())
|
|
138
|
145
|
// page.scrollTop
|
|
139
|
|
- if (page.scrollTop >= 76 ) {
|
|
|
146
|
+ if (page.scrollTop >= 76) {
|
|
140
|
147
|
headerClass.value = '!bg-primary !text-white'
|
|
141
|
148
|
} else {
|
|
142
|
149
|
headerClass.value = ''
|
|
|
@@ -150,7 +157,7 @@ onReachBottom(() => {
|
|
150
|
157
|
state.currentPage += 1
|
|
151
|
158
|
loadList('page', (items) => {
|
|
152
|
159
|
uni.hideLoading()
|
|
153
|
|
- // console.log(items)
|
|
|
160
|
+ console.log(items)
|
|
154
|
161
|
if (!items.length > 0) {
|
|
155
|
162
|
// console.log('没有更多了')
|
|
156
|
163
|
state.status = 'noMore'
|
|
|
@@ -169,12 +176,12 @@ onPullDownRefresh(() => {
|
|
169
|
176
|
</script>
|
|
170
|
177
|
<template>
|
|
171
|
178
|
<div class="h-screen">
|
|
172
|
|
- <DacangHeader :ex-class="headerClass" :tabs="state.tabs" @click:item="handleTabItemClick"/>
|
|
|
179
|
+ <DacangHeader :ex-class="headerClass" :tabs="state.tabs" @click:item="handleTabItemClick" />
|
|
173
|
180
|
|
|
174
|
181
|
<div class="flex flex-col gap-2 ">
|
|
175
|
|
- <CXBBackTop :Scroll_X="Scroll_X"/>
|
|
176
|
|
- <image :src="headerImage" mode="widthFix" class="w-full h-50"></image>
|
|
177
|
|
- <ProductList :list="state.productList" />
|
|
|
182
|
+ <CXBBackTop :Scroll_X="Scroll_X" :isCss="1" />
|
|
|
183
|
+ <image lazy-load :src="state.banner" mode="widthFix" class="w-full h-50"></image>
|
|
|
184
|
+ <ProductList :list="state.productList" />
|
|
178
|
185
|
<div class="pb-safe flex justify-center items-center text-[12px] text-gray-500" v-if="state.productList.length > 0">
|
|
179
|
186
|
<div v-if="state.status === 'loading'">
|
|
180
|
187
|
加载中...
|
|
|
@@ -195,8 +202,6 @@ page {
|
|
195
|
202
|
.nut-tab-pane {
|
|
196
|
203
|
display: none !important;
|
|
197
|
204
|
}
|
|
198
|
|
-
|
|
199
|
|
-
|
|
200
|
205
|
</style>
|
|
201
|
206
|
<route lang="yaml" >
|
|
202
|
207
|
style:
|