Selaa lähdekoodia

大仓 分类商品刷新机制调整

李战雷 2 vuotta sitten
vanhempi
commit
8e42b54470

+ 13 - 14
src/components/ProductList/ProductList.vue

@@ -1,10 +1,7 @@
1 1
 <script lang="ts" setup>
2
-
3
-import ProductCard from "~/components/ProductCard/ProductCard.vue";
4
-import CXBEmpty from "~/components/CXBEmpty/CXBEmpty.vue";
5
-import { debounce } from "lodash-es";
6
-import { useThrottleFn } from "@vueuse/core";
7
-import { throttle } from "~/utils/throttle";
2
+import ProductCard from '~/components/ProductCard/ProductCard.vue'
3
+import CXBEmpty from '~/components/CXBEmpty/CXBEmpty.vue'
4
+import { useUserStore } from '~/stores/userStore'
8 5
 
9 6
 const props = defineProps({
10 7
   list: {
@@ -12,28 +9,30 @@ const props = defineProps({
12 9
     required: true,
13 10
     default: () => {
14 11
       return []
15
-    }
16
-  }
12
+    },
13
+  },
17 14
 })
18 15
 
16
+const userStore = useUserStore()
17
+
19 18
 function handleClickItem(item) {
20 19
   // console.log(item)
20
+  userStore.isPushToProductDetail = true
21 21
   uni.navigateTo({
22
-    url: `/pages/store/product/detail?id=${item.product_id}`
22
+    url: `/pages/store/product/detail?id=${item.product_id}`,
23 23
   })
24
-
25 24
 }
26 25
 </script>
26
+
27 27
 <template>
28
-  <!--  <scroll-view type="custom">-->
29
-  <div class="px-3" v-if="list && list.length > 0">
28
+  <!--  <scroll-view type="custom"> -->
29
+  <div v-if="list && list.length > 0" class="px-3">
30 30
     <grid-view type="masonry" cross-axis-count="2" cross-axis-gap="10px" main-axis-gap="10px">
31 31
       <div v-for="(item, index) in list" :key="index">
32 32
         <ProductCard :item="item" @click:item="handleClickItem" />
33 33
       </div>
34 34
     </grid-view>
35
-
36 35
   </div>
37 36
   <CXBEmpty v-else />
38
-  <!--  </scroll-view>-->
37
+  <!--  </scroll-view> -->
39 38
 </template>

+ 54 - 55
src/pages/dacang/list/components/dacang-header.vue

@@ -1,9 +1,34 @@
1 1
 <script lang="ts" setup>
2
-import { computed, PropType } from "vue";
3
-import FSearch from "~/components/FSearch/FSearch.vue";
4
-import type { UserInfoModel } from "~/apis/model/userInfoModel";
5
-import { useUserStore } from "~/stores/userStore";
6
-import { useDacangStore } from "~/stores/dacangStore";
2
+import { computed } from 'vue'
3
+import { useUserStore } from '~/stores/userStore'
4
+import { useDacangStore } from '~/stores/dacangStore'
5
+
6
+const props = defineProps({
7
+  exClass: {
8
+    type: String,
9
+  },
10
+  tabs: {
11
+    type: Array,
12
+  },
13
+  // userInfo: {
14
+  //   type: Object as PropType<UserInfoModel>,
15
+  //   required: true
16
+  // },
17
+  yanglaojin: {
18
+    type: Number,
19
+    default: Number.NaN,
20
+  },
21
+  current: {
22
+    type: String,
23
+    default: '-1',
24
+  },
25
+})
26
+// function handleShowSearchPage() {
27
+//
28
+// }
29
+const emit = defineEmits<{
30
+  (e: 'click:item', value: string): void
31
+}>()
7 32
 // import {useUserStore} from "~/stores/userStore";
8 33
 const userStore = useUserStore()
9 34
 const dacangStore = useDacangStore()
@@ -31,94 +56,69 @@ const navBarStyle = computed(() => {
31 56
   }
32 57
 })
33 58
 
34
-const props = defineProps({
35
-  exClass: {
36
-    type: String
37
-  },
38
-  tabs: {
39
-    type: Array
40
-  },
41
-  // userInfo: {
42
-  //   type: Object as PropType<UserInfoModel>,
43
-  //   required: true
44
-  // },
45
-  yanglaojin: {
46
-    type: Number,
47
-    default: NaN
48
-  },
49
-  current: {
50
-    type: String,
51
-    default: '-1'
52
-  }
53
-})
54
-
55 59
 const tabValue = ref(dacangStore.currentClassify)
56 60
 
57
-
58 61
 watch(() => dacangStore.currentClassify, (val) => {
59 62
   tabValue.value = val
60 63
 })
61 64
 function handleClick() {
62 65
   if (userStore.userInfo) {
63 66
     uni.navigateTo({
64
-      url: '/pages/annuity/index'
67
+      url: '/pages/annuity/index',
65 68
     })
66
-  } else {
69
+  }
70
+  else {
67 71
     uni.navigateTo({
68
-      url: '/pages/user/login/index?key=30'
72
+      url: '/pages/user/login/index?key=30',
69 73
     })
70 74
   }
71 75
 }
72 76
 
73
-// function handleShowSearchPage() {
74
-//
75
-// }
76
-const emit = defineEmits<{
77
-  (e: 'click:item', value: string): void
78
-}>()
79 77
 function handleTabItemClick(currentTab) {
80 78
   emit('click:item', tabValue.value)
81 79
 }
82 80
 function handleShowSearchPage() {
83 81
   uni.navigateTo({
84
-    url: '/pages/search/search-dacang'
82
+    url: '/pages/search/search-dacang',
85 83
   })
86 84
 }
87 85
 </script>
86
+
88 87
 <template>
89 88
   <div class="dacang-header fixed w-screen text-white z-10 w-full h-20" :style="navBarStyle" :class="exClass">
90 89
     <div class="pl-2 pt-2">
91 90
       <div
92
-        class="w-60% bg-white rounded-full flex flex-row justify-between items-center border-solid border-1 border-red">
93
-
94
-        <image src="https://cdn.bjtdba.com/vod/image/2023-02-15/20230215112840149.png" mode="widthFix"
95
-          class="w-4 h-4  pl-2 py-1"></image>
91
+        class="w-60% bg-white rounded-full flex flex-row justify-between items-center border-solid border-1 border-red"
92
+      >
93
+        <image
94
+          src="https://cdn.bjtdba.com/vod/image/2023-02-15/20230215112840149.png" mode="widthFix"
95
+          class="w-4 h-4  pl-2 py-1"
96
+        />
96 97
         <div class="flex flex-1 items-center w-100%" @tap.stop="handleShowSearchPage">
97
-          <div class="flex-1 pl-2  font_size ">搜索商品关键词</div>
98
+          <div class="flex-1 pl-2  font_size ">
99
+            搜索商品关键词
100
+          </div>
98 101
           <div class="bg-[#D71608] text-white text-xs w-11 rounded-full text-center py-1 my-0.5 mr-0.5 ">
99 102
             搜索
100 103
           </div>
101 104
         </div>
102
-
103
-
104 105
       </div>
105
-
106 106
     </div>
107 107
 
108
-    <!--    <div class="p-3">-->
108
+    <!--    <div class="p-3"> -->
109 109
     <div class=" ">
110 110
       <nut-tabs v-model="tabValue" title-scroll title-gutter="10" name="catePanel" @change="handleTabItemClick">
111
-        <!--         <nut-tab-panel :title="全部"></nut-tab-panel>-->
112
-        <nut-tab-pane v-for="item in tabs" :title="item.cate_name" :pane-key="item.store_category_id"
113
-          :key="item.store_category_id">
114
-        </nut-tab-pane>
111
+        <!--         <nut-tab-panel :title="全部"></nut-tab-panel> -->
112
+        <nut-tab-pane
113
+          v-for="item in tabs" :key="item.store_category_id" :title="item.cate_name"
114
+          :pane-key="item.store_category_id"
115
+        />
115 116
       </nut-tabs>
116
-
117 117
     </div>
118
-    <!--    </div>-->
119
-
118
+    <!--    </div> -->
120 119
   </div>
121 120
 </template>
121
+
122 122
 <style>
123 123
 .dacang-header {
124 124
   --nut-tabs-horizontal-tab-line-color: #fff;
@@ -127,10 +127,9 @@ function handleShowSearchPage() {
127 127
   --nut-tabs-titles-item-active-color: #fff;
128 128
 }
129 129
 
130
-
131 130
 .font_size {
132 131
   font-size: 24rpx;
133 132
   line-height: 42rpx;
134 133
   color: #c0c5cc;
135 134
 }
136
-</style>
135
+</style>

+ 23 - 12
src/pages/dacang/list/index.vue

@@ -30,7 +30,6 @@
30 30
 		pageSize: 10,
31 31
 		totalPage: 1,
32 32
 		isResponseReachBotton: true, // 是否详情触底事件
33
-
34 33
 	})
35 34
 
36 35
 	// 距离顶部距离
@@ -39,8 +38,9 @@
39 38
 	let scrollPositions = reactive({})
40 39
 	const dacangStore = useDacangStore()
41 40
 	const userStore = useUserStore()
42
-
43
-
41
+
42
+	let count = 0
43
+	
44 44
 	onLoad(async (option) => {
45 45
 		state.tabs = [{ store_category_id: '-1', cate_name: '全部' }]
46 46
 		const classifyRes = await getDcProductClassify()
@@ -69,11 +69,6 @@
69 69
 			console.log(state.banner);
70 70
 
71 71
 		})
72
-
73
-		if (dacangStore) {
74
-			state.currentClassify = dacangStore.currentClassify
75
-		}
76
-		loadList('reload')
77 72
 	})
78 73
 
79 74
 
@@ -104,7 +99,24 @@
104 99
 				url: '/pages/dacang/list/index'
105 100
 			}
106 101
 		})
107
-
102
+		
103
+		count = count + 1
104
+		console.log('count ---> ',count)
105
+		if (count > 1) {
106
+			userStore.isPushToProductDetail = false
107
+			count = 1
108
+			return
109
+		}
110
+		
111
+		// if (userStore.isPushToProductDetail) {
112
+		// 	userStore.isPushToProductDetail = false
113
+		// 	return
114
+		// }
115
+		
116
+		if (dacangStore) {
117
+			state.currentClassify = dacangStore.currentClassify
118
+		}
119
+		loadList('reload')
108 120
 		
109 121
 	})
110 122
 
@@ -181,7 +193,7 @@
181 193
 	onPageScroll((page) => {
182 194
 
183 195
 		Scroll_X.value = Number(page.scrollTop.toFixed())
184
-
196
+		console.log('Scroll_X ----> ', Scroll_X.value)
185 197
 		// 保存当前分类页的滚动位置
186 198
 		scrollPositions[state.currentClassify] = Scroll_X.value;
187 199
 
@@ -225,8 +237,7 @@
225 237
 	})
226 238
 
227 239
 	function moving(event) {
228
-		console.log('event = ', event)
229
-
240
+		// console.log('event = ', event)
230 241
 		state.isResponseReachBotton = true
231 242
 	}
232 243
 </script>

+ 162 - 168
src/pages/home/index.vue

@@ -1,56 +1,52 @@
1 1
 <script lang="ts" setup>
2
-import { getNewSignInInfo, getUserInfo, getYanglaojinStatistics } from "~/apis/user";
3
-import { getProduct } from "~/apis/home";
4
-
5
-import Navs from "~/pages/home/components/navs.vue";
6
-import Announcement from "~/pages/home/components/announcement.vue";
7
-import Banner from "~/pages/home/components/banner.vue";
8
-import Header from "~/pages/home/components/header.vue";
9
-import ProductList from "~/pages/home/components/product-list.vue";
10
-import { getHomeBanner, getHomeQuickLink, getNoticeList, getProductShare, getLocal} from "~/apis/common";
11
-import { useUserStore } from "~/stores/userStore";
12
-import CXBDialogSIgnIn from "~/components/CXBDialogSignIn/CXBDialogSIgnIn.vue";
13
-import CXBDialogSIgnInSucceed from "~/components/CXBDialogSignInSucceed/CXBDialogSIgnInSucceed.vue";
14
-import { CDM_URL, CDN_URL } from "~/config/app";
15
-import CXBPrivacyPopup from "~/components/CXBPrivacyPopup/CXBPrivacyPopup.vue";
16
-import { getShareId } from "~/apis/product";
2
+import { getNewSignInInfo, getUserInfo, getYanglaojinStatistics } from '~/apis/user'
3
+import { getProduct } from '~/apis/home'
4
+
5
+import Navs from '~/pages/home/components/navs.vue'
6
+import Banner from '~/pages/home/components/banner.vue'
7
+import Header from '~/pages/home/components/header.vue'
8
+import ProductList from '~/pages/home/components/product-list.vue'
9
+import { getHomeBanner, getHomeQuickLink, getProductShare } from '~/apis/common'
10
+import { useUserStore } from '~/stores/userStore'
11
+import CXBDialogSIgnIn from '~/components/CXBDialogSignIn/CXBDialogSIgnIn.vue'
12
+import { CDM_URL, CDN_URL } from '~/config/app'
13
+import CXBPrivacyPopup from '~/components/CXBPrivacyPopup/CXBPrivacyPopup.vue'
14
+
17 15
 // import CXBDialogSIgnIn from "~/components/CXBDialogSignIn/CXBDialogSIgnIn.vue";
18 16
 // import CXBDialogSIgnInSucceed from "~/components/CXBDialogSignInSucceed/CXBDialogSIgnInSucceed.vue";
19
-import Cache from "~/utils/cache";
17
+import Cache from '~/utils/cache'
18
+
19
+import CXBBackTop from '~/components/CXBBackTop/CXBBackTop.vue'
20
+import { getDcSeckill } from '~/apis/dacang'
20 21
 
21
-import CXBBackTop from "~/components/CXBBackTop/CXBBackTop.vue";
22
-import { getDcSeckill } from "~/apis/dacang";
23 22
 const userStore = useUserStore()
24 23
 const usePageStore = usePageStoreWidthOut()
25 24
 usePageStore.setPageConfig({
26 25
   currentPage: {
27 26
     type: 'tab',
28
-    url: '/pages/home/index'
29
-  }
27
+    url: '/pages/home/index',
28
+  },
30 29
 })
31 30
 
32 31
 // 限时秒杀  https://cdn.bjtdba.com/vod/image/2023-12-08/20231208174028968.png
33 32
 // 秒杀背景  https://cdn.bjtdba.com/vod/image/2023-12-08/20231208174007505.png
34 33
 // 秒杀价格  https://cdn.bjtdba.com/vod/image/2023-12-08/20231208173948533.png
35 34
 
36
-
37
-const msbkImg = CDM_URL + '/image/2023-12-08/20231208174007505.png'
38
-const xsmsImg = CDM_URL + '/image/2023-12-08/20231208174028968.png'
39
-const mspcImg = CDM_URL + '/image/2023-12-08/20231208173948533.png'
40
-
41
-
35
+const msbkImg = `${CDM_URL}/image/2023-12-08/20231208174007505.png`
36
+const xsmsImg = `${CDM_URL}/image/2023-12-08/20231208174028968.png`
37
+const mspcImg = `${CDM_URL}/image/2023-12-08/20231208173948533.png`
42 38
 
43 39
 const msData = reactive({
44 40
   currentPage: 1,
45 41
   pageSize: 10,
46 42
   list: [],
47
-  duration: 60 * 60 * 1000, //秒杀活动时长
43
+  duration: 60 * 60 * 1000, // 秒杀活动时长
48 44
 })
49 45
 
50 46
 const remainingTime: any = ref({
51
-  hours: "00",
52
-  minutes: "00",
53
-  seconds: "00"
47
+  hours: '00',
48
+  minutes: '00',
49
+  seconds: '00',
54 50
 })
55 51
 const msProductList = ref([])
56 52
 const msSeckillDate = ref('')
@@ -68,8 +64,8 @@ const state = reactive({
68 64
   closeMoney: '',
69 65
   // 结算养老金
70 66
   openMoney: '',
71
-  all_yanglao: NaN,
72
-  signToday: NaN,
67
+  all_yanglao: Number.NaN,
68
+  signToday: Number.NaN,
73 69
   isShowSignIn: false,
74 70
   banners: [],
75 71
   announcementList: [],
@@ -79,89 +75,86 @@ const state = reactive({
79 75
   autoplay: true,
80 76
   interval: 5000,
81 77
   duration: 500,
82
-  currents: "0",
78
+  currents: '0',
83 79
 })
84 80
 // 距离顶部距离
85
-let Scroll_X = ref(0)
81
+const Scroll_X = ref(0)
86 82
 onShow(() => {
87 83
   usePageStore.setPageConfig({
88 84
     currentPage: {
89 85
       type: 'tab',
90
-      url: '/pages/home/index'
91
-    }
86
+      url: '/pages/home/index',
87
+    },
92 88
   })
93 89
   if (!userStore.uid) {
94 90
     state.closeMoney = ''
95 91
     state.openMoney = ''
96
-  } else {
97
-    getUserInfo().then(res => {
92
+  }
93
+  else {
94
+    getUserInfo().then((res) => {
98 95
       userStore.setUserInfo(res)
99 96
     })
100
-    getYanglaojinStatistics().then(res => {
97
+    getYanglaojinStatistics().then((res) => {
101 98
       state.all_yanglao = res.all_yanglao
102 99
     })
103
-    //加载秒杀数据
100
+    // 加载秒杀数据
104 101
     loadList('reload')
105 102
   }
106
-
107
-
108 103
 })
109 104
 
110 105
 function checkSignIn() {
111 106
   // if (userStore.uid && state.isEject === 1) {
112 107
   // 2 检查用户签到信息
113
-  getNewSignInInfo().then(res => {
108
+  getNewSignInInfo().then((res) => {
114 109
     // console.log(res)
115 110
     const { today, day } = res
116 111
     state.signToday = today
117
-    if (today === 0) {
112
+    if (today === 0)
118 113
       state.isShowSignIn = true
119
-    }
114
+
120 115
     state.day = day
121 116
 
122 117
     // // if (today === 0) {
123 118
     //   2.1 弹出签到窗口
124 119
     // }
125
-  }).catch(error => {
126
-    console.error(error + '->GetNewsSignInInfo')
120
+  }).catch((error) => {
121
+    console.error(`${error}->GetNewsSignInInfo`)
127 122
   })
128 123
   // }
129 124
 }
130 125
 onLoad((option) => {
131
-  if (option && option.shareId) {
126
+  if (option && option.shareId)
132 127
     userStore.setShareId(option.shareId)
133
-  }
128
+
134 129
   // getLocal()
135 130
   getIsShow()
136
-  getHomeBanner().then(res => {
131
+  getHomeBanner().then((res) => {
137 132
     // console.log(res)
138 133
     state.banners = res
139 134
   })
140 135
   // 加载地址数据
141 136
   // orderStore.getCurrentAddress()
142 137
   // 1加载首页数据
143
-  getHomeQuickLink().then(res => { })
138
+  getHomeQuickLink().then((res) => { })
144 139
   state.page = 1
145 140
   loadProductList()
146 141
   loadList('reload')
147
-  getProductShare().then(res => {
148
-    if (res) {
142
+  getProductShare().then((res) => {
143
+    if (res)
149 144
       userStore.setShareId(res.share_id)
150
-    }
151
-  }).catch(message => {
145
+  }).catch((message) => {
152 146
     // console.log(message)
153 147
   })
154
-  userStore.setRedirectPage(`/pages/home/index`, 'tab')
155
-
148
+  userStore.setRedirectPage('/pages/home/index', 'tab')
156 149
 })
157 150
 
158 151
 onShareAppMessage(() => {
159 152
   const shareId = Cache.get('SHARE_ID')
160 153
 
161 154
   return {
162
-    title: `消费储蓄 保障未来`,
155
+    title: '消费储蓄 保障未来',
163 156
     path: `/pages/home/index?shareId=${shareId}`,
164
-    imageUrl: 'https://cdn.bjtdba.com/vod/image/2023-10-09/20231009202402136.png'
157
+    imageUrl: 'https://cdn.bjtdba.com/vod/image/2023-10-09/20231009202402136.png',
165 158
   }
166 159
 })
167 160
 
@@ -169,44 +162,43 @@ onShareTimeline(() => {
169 162
   const shareId = Cache.get('SHARE_ID')
170 163
 
171 164
   return {
172
-    title: `消费储蓄 保障未来`,
165
+    title: '消费储蓄 保障未来',
173 166
     imageUrl: 'https://cdn.bjtdba.com/vod/image/2023-10-11/20231011062523504.png',
174
-    query: `from=share&shareId=${shareId}`
167
+    query: `from=share&shareId=${shareId}`,
175 168
     // imageUrl: 'https://cdn.bjtdba.com/vod/image/2023-10-09/20231009202402136.png'
176 169
   }
177 170
 })
178 171
 
179
-
180 172
 function loadList(action: 'page' | 'reload', callback?: (items) => void) {
181
-  if (action === 'reload') {
173
+  if (action === 'reload')
182 174
     msData.currentPage = 1
183
-  }
175
+
184 176
   const params = {
185 177
     page: msData.currentPage,
186
-    limit: msData.pageSize
178
+    limit: msData.pageSize,
187 179
   }
188 180
 
189 181
   getDcSeckill({
190
-    ...params
191
-  }).then(res => {
192
-    console.log('秒杀', res);
182
+    ...params,
183
+  }).then((res) => {
184
+    console.log('秒杀', res)
193 185
     // status 1 开始抢 2 即将开始 3 已结束
194
-    let status2FilterList = res.filter((val) => {
186
+    const status2FilterList = res.filter((val) => {
195 187
       return val.status == 2
196 188
     })
197
-    let status1FilterList = res.filter((val) => {
189
+    const status1FilterList = res.filter((val) => {
198 190
       return val.status == 1
199 191
     })
200 192
     // console.log('秒杀', ...res);
201
-    if (status2FilterList.length > 0) {
193
+    if (status2FilterList.length > 0)
202 194
       msData.list.push(...status2FilterList)
203
-    }
204
-    if (status1FilterList.length > 0) {
195
+
196
+    if (status1FilterList.length > 0)
205 197
       msData.list.unshift(...status1FilterList)
206
-    }
198
+
207 199
     if (msData.list.length > 0) {
208 200
       msProductList.value = msData.list[0].product_data
209
-      msSeckillDate.value = msData.list[0].seckill_date.slice(0, 5);
201
+      msSeckillDate.value = msData.list[0].seckill_date.slice(0, 5)
210 202
       msStatus.value = msData.list[0].status
211 203
       // console.log(11221111, msProductList.value);
212 204
       // console.log(11221111, msSeckillDate.value);
@@ -214,65 +206,65 @@ function loadList(action: 'page' | 'reload', callback?: (items) => void) {
214 206
   })
215 207
 }
216 208
 
217
-//计算秒杀
209
+// 计算秒杀
218 210
 function getCountdown() {
219
-  const now = new Date();
220
-  const startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), parseHours(msSeckillDate.value), 0, 0);
211
+  const now = new Date()
212
+  const startDate = new Date(now.getFullYear(), now.getMonth(), now.getDate(), parseHours(msSeckillDate.value), 0, 0)
221 213
   // const startDate = new Date('2023-12-26 10:55:00');
222
-  const endDate = new Date(startDate.getTime() + 60 * 60 * 1000); // 结束时间为开始时间的一小时后
214
+  const endDate = new Date(startDate.getTime() + 60 * 60 * 1000) // 结束时间为开始时间的一小时后
223 215
 
224 216
   if (now > startDate && now < endDate) {
225
-    let milliseconds = endDate - now;
217
+    const milliseconds = endDate - now
226 218
 
227
-    const hours = Math.floor(milliseconds / (1000 * 60 * 60));
228
-    const minutes = Math.floor((milliseconds % (1000 * 60 * 60)) / (1000 * 60));
229
-    const seconds = Math.floor((milliseconds % (1000 * 60)) / 1000);
219
+    const hours = Math.floor(milliseconds / (1000 * 60 * 60))
220
+    const minutes = Math.floor((milliseconds % (1000 * 60 * 60)) / (1000 * 60))
221
+    const seconds = Math.floor((milliseconds % (1000 * 60)) / 1000)
230 222
 
231 223
     // 更新数据
232 224
     remainingTime.value = {
233
-      hours: hours < 10 ? '0' + hours : hours,
234
-      minutes: minutes < 10 ? '0' + minutes : minutes,
235
-      seconds: seconds < 10 ? '0' + seconds : seconds
225
+      hours: hours < 10 ? `0${hours}` : hours,
226
+      minutes: minutes < 10 ? `0${minutes}` : minutes,
227
+      seconds: seconds < 10 ? `0${seconds}` : seconds,
236 228
     }
237
-  } else if (now >= endDate) {
238
-    clearInterval(timer);
239
-    //加载秒杀数据
240
-    console.log('时间到,自动关闭');
229
+  }
230
+  else if (now >= endDate) {
231
+    clearInterval(timer)
232
+    // 加载秒杀数据
233
+    console.log('时间到,自动关闭')
241 234
     // loadList('reload')
242 235
     uni.reLaunch({
243
-      url: '/pages/home/index'
236
+      url: '/pages/home/index',
244 237
     })
245
-  } else if (now < startDate) {
246
-    console.log(111);
247
-
248
-  } else if (now == startDate) {
249
-    clearInterval(timer);
250
-    //加载秒杀数据
251
-    console.log('时间到,自动关闭');
238
+  }
239
+  else if (now < startDate) {
240
+    console.log(111)
241
+  }
242
+  else if (now == startDate) {
243
+    clearInterval(timer)
244
+    // 加载秒杀数据
245
+    console.log('时间到,自动关闭')
252 246
     // loadList('reload')
253 247
     uni.reLaunch({
254
-      url: '/pages/home/index'
248
+      url: '/pages/home/index',
255 249
     })
256 250
   }
257 251
 }
258 252
 
259 253
 function parseHours(time: any) {
260
-  const [hours, minutes] = time.split(":");
261
-  return parseInt(hours);
254
+  const [hours, minutes] = time.split(':')
255
+  return Number.parseInt(hours)
262 256
 }
263 257
 
264 258
 // 每秒更新剩余时间
265 259
 const timer = setInterval(() => {
266 260
   getCountdown()
267
-}, 1000);
261
+}, 1000)
268 262
 
269 263
 onUnload(() => {
270
-  clearInterval(timer);
271
-  console.log('卸载关闭');
264
+  clearInterval(timer)
265
+  console.log('卸载关闭')
272 266
 })
273 267
 
274
-
275
-
276 268
 watch(() => state.isShowSignIn, (val) => {
277 269
   val ? uni.hideTabBar() : uni.showTabBar()
278 270
 })
@@ -282,11 +274,10 @@ onPageScroll((page) => {
282 274
   // console.log(page.scrollTop.toFixed(),'距离顶部的距离')
283 275
   Scroll_X.value = Number(page.scrollTop.toFixed())
284 276
   // page.scrollTop
285
-  if (page.scrollTop >= 76) {
277
+  if (page.scrollTop >= 76)
286 278
     headerClass.value = 'bg-white !text-gray-900'
287
-  } else {
279
+  else
288 280
     headerClass.value = ''
289
-  }
290 281
 })
291 282
 // 下拉刷新
292 283
 onPullDownRefresh(() => {
@@ -302,127 +293,134 @@ onReachBottom(() => {
302 293
 function loadProductList() {
303 294
   uni.showLoading({
304 295
     title: '加载中',
305
-  });
296
+  })
306 297
 
307 298
   getProduct({
308 299
     page: state.page,
309
-    limit: state.limit
310
-  }).then(res => {
311
-    uni.stopPullDownRefresh();
300
+    limit: state.limit,
301
+  }).then((res) => {
302
+    uni.stopPullDownRefresh()
312 303
     if (state.page === 1) {
313 304
       state.productList = res
314
-    } else {
305
+    }
306
+    else {
315 307
       setTimeout(() => {
316 308
         state.productList.push(...res)
317 309
       }, 300)
318 310
     }
319 311
     uni.hideLoading()
320
-  }).catch(error => {
321
-    console.error(error + '->getProduct')
312
+  }).catch((error) => {
313
+    console.error(`${error}->getProduct`)
322 314
   })
323 315
 }
324
-const homeBanner = CDN_URL + '/static/assets/home-banner.png'
316
+const homeBanner = `${CDN_URL}/static/assets/home-banner.png`
325 317
 
326 318
 function handleBannerClick(item) {
327 319
   if (item.url == 'rich') {
328 320
     uni.navigateTo({
329
-      url: '/pages/vip/index?type=user'
321
+      url: '/pages/vip/index?type=user',
330 322
     })
331 323
   }
332 324
 }
333 325
 
334 326
 function getIsShow() {
335
-  //首先获取是否执行过
327
+  // 首先获取是否执行过
336 328
   uni.getStorage({
337 329
     key: 'today',
338
-    success: function (res) {
330
+    success(res) {
339 331
       // console.log(res.data)
340 332
       // console.log('----')
341
-      //成功的话 说明之前执行过,再判断时间是否是当天
333
+      // 成功的话 说明之前执行过,再判断时间是否是当天
342 334
       // 如果不是当天更新
343 335
       if (res.data && res.data != new Date().toLocaleDateString()) {
344 336
         // getApp().globalData.isEject = 0; //自定义要更改的变量 或者方法
345 337
         state.isEject = 1
346 338
         checkSignIn()
347
-        uni.setStorageSync("today", new Date().toLocaleDateString()); //把新得日期更新到本地
339
+        uni.setStorageSync('today', new Date().toLocaleDateString()) // 把新得日期更新到本地
348 340
       }
349 341
     },
350
-    fail: function (res) {
342
+    fail(res) {
351 343
       // console.log(res + 'FAIL...')
352
-      //没有执行过的话 先存一下当前的执行时间
344
+      // 没有执行过的话 先存一下当前的执行时间
353 345
       // console.log(res);
354 346
       state.isEject = 1
355 347
       checkSignIn()
356 348
 
357 349
       // getApp().globalData.isEject = 0; //自定义要更改的变量 或者方法
358
-      let today = new Date().toLocaleDateString();
350
+      const today = new Date().toLocaleDateString()
359 351
       uni.setStorageSync('today', today)
360
-    }
352
+    },
361 353
   })
362
-
363 354
 }
364 355
 
365 356
 function Tomsindex() {
366 357
   uni.navigateTo({
367
-    url: '/pages/miaosha/index?type_show=2'
358
+    url: '/pages/miaosha/index?type_show=2',
368 359
   })
369 360
   // uni.navigateTo({
370 361
   //   url: `/pages/user/login/invite-login`
371 362
   // })
372 363
 }
373 364
 
374
-//秒杀跳转详情页
365
+// 秒杀跳转详情页
375 366
 function handleToDeatil(product_id: any) {
376 367
   uni.navigateTo({
377
-    url: `/pages/store/product/detail?id=${product_id}`
368
+    url: `/pages/store/product/detail?id=${product_id}`,
378 369
   })
379 370
 }
380
-
381 371
 </script>
372
+
382 373
 <template>
383 374
   <div class="h-screen ">
384
-    <CXBBackTop :Scroll_X="Scroll_X" :isCss="1" />
385
-    <Header :yanglaojin="state.all_yanglao" :exClass="headerClass" />
375
+    <CXBBackTop :Scroll_X="Scroll_X" :is-css="1" />
376
+    <Header :yanglaojin="state.all_yanglao" :ex-class="headerClass" />
386 377
     <div class="flex flex-col gap-3 ">
387
-      <!--      <image-->
388
-      <!--          @click="handleBannerClick"-->
389
-      <!--          :src="homeBanner"-->
390
-      <!--             mode="widthFix" class="h-60 w-full "-->
391
-      <!--      ></image>-->
378
+      <!--      <image -->
379
+      <!--          @click="handleBannerClick" -->
380
+      <!--          :src="homeBanner" -->
381
+      <!--             mode="widthFix" class="h-60 w-full " -->
382
+      <!--      ></image> -->
392 383
 
393 384
       <div class="w-screen h-65">
394
-        <swiper v-if="state.banners" :indicator-dots="state.indicatorDots" indicator-active-color="#e93323"
385
+        <swiper
386
+          v-if="state.banners" :indicator-dots="state.indicatorDots" indicator-active-color="#e93323"
395 387
           :autoplay="state.autoplay" :circular="state.circular" :interval="state.interval" :duration="state.duration"
396
-          class="w-full h-full">
388
+          class="w-full h-full"
389
+        >
397 390
           <swiper-item v-for="(item, index) in state.banners" :key="index">
398
-            <image :src="item.pic" @tap="handleBannerClick(item)" class="!w-full !h-full" mode="aspectFill" />
391
+            <image :src="item.pic" class="!w-full !h-full" mode="aspectFill" @tap="handleBannerClick(item)" />
399 392
           </swiper-item>
400 393
         </swiper>
401 394
       </div>
402 395
       <Navs />
403
-      <div class="px-3 relative " style="width: 700rpx; height: 458rpx;" v-if="msProductList.length > 0">
396
+      <div v-if="msProductList.length > 0" class="px-3 relative " style="width: 700rpx; height: 458rpx;">
404 397
         <!-- 秒杀大图 -->
405
-        <image lazy-load style="width: 100%;height: 100%; " :src="msbkImg"></image>
398
+        <image lazy-load style="width: 100%;height: 100%; " :src="msbkImg" />
406 399
         <!-- 限时秒杀 -->
407
-        <image lazy-load class="xsmsimg" style="width: 185rpx;height: 41rpx; " :src="xsmsImg"></image>
400
+        <image lazy-load class="xsmsimg" style="width: 185rpx;height: 41rpx; " :src="xsmsImg" />
408 401
         <!-- scroll 秒杀list -->
409 402
         <scroll-view class="scroll-view_H" :scroll-x="true">
410
-          <div v-for="(item, index) in msProductList" :key="index" style="background-color: #FFFFFF; position: relative; "
411
-            class="scroll-view-item_H">
403
+          <div
404
+            v-for="(item, index) in msProductList" :key="index" style="background-color: #FFFFFF; position: relative; "
405
+            class="scroll-view-item_H"
406
+          >
412 407
             <!-- img  -->
413 408
             <div @click="handleToDeatil(item.product_id)">
414 409
               <div class="scroll-view-item_O">
415 410
                 <div style="width: 202rpx; height: 202rpx; margin-bottom: 23rpx; border-radius: 16rpx; ">
416
-                  <image :src="item.image" style="border-radius: 16rpx; width: 100%; height: 100%; "></image>
411
+                  <image :src="item.image" style="border-radius: 16rpx; width: 100%; height: 100%; " />
417 412
                 </div>
418 413
                 <div class="px-1">
419 414
                   <div class="text_image_d mt-1 ">
420 415
                     {{ item.store_name }}
421 416
                   </div>
422 417
                   <div
423
-                    class="mt-1 border border-solid border-1 border-red rounded flex  items-center text-[#FE0032] w-fit">
424
-                    <image src="https://cdn.bjtdba.com/vod/image/2023-12-11/20231211115513936.png" mode="widthFix"
425
-                      style="width: 46rpx; height: 28rpx;"></image>
418
+                    class="mt-1 border border-solid border-1 border-red rounded flex  items-center text-[#FE0032] w-fit"
419
+                  >
420
+                    <image
421
+                      src="https://cdn.bjtdba.com/vod/image/2023-12-11/20231211115513936.png" mode="widthFix"
422
+                      style="width: 46rpx; height: 28rpx;"
423
+                    />
426 424
                     <div class="ylj_d flex items-center jusitify-center">
427 425
                       <div>
428 426
                         养老金 ¥{{ item.yanglao }}
@@ -430,19 +428,18 @@ function handleToDeatil(product_id: any) {
430 428
                     </div>
431 429
                   </div>
432 430
                 </div>
433
-
434 431
               </div>
435 432
               <!-- 价格 -->
436
-              <div class="jg_img" :style="{ background: 'url(' + mspcImg + ')', backgroundSize: 'cover' }">
437
-                <div class="jg_price">¥{{ item.seckill_price }}</div>
433
+              <div class="jg_img" :style="{ background: `url(${mspcImg})`, backgroundSize: 'cover' }">
434
+                <div class="jg_price">
435
+                  ¥{{ item.seckill_price }}
436
+                </div>
438 437
               </div>
439 438
             </div>
440
-
441 439
           </div>
442
-
443 440
         </scroll-view>
444 441
         <!-- 倒计时 -->
445
-        <div class="ms_time" v-if="msStatus == '1'">
442
+        <div v-if="msStatus == '1'" class="ms_time">
446 443
           <span class="ms_span">{{ remainingTime.hours }}</span> :
447 444
           <span class="ms_span">{{ remainingTime.minutes }}</span> :
448 445
           <span class="ms_span">{{ remainingTime.seconds }}</span>
@@ -450,28 +447,27 @@ function handleToDeatil(product_id: any) {
450 447
         <div class="ckgdtext" @click="Tomsindex">
451 448
           查看更多
452 449
           <span>
453
-            <image style="width: 10rpx; height: 17rpx; " src="../../static/icon/ckgd.png"></image>
450
+            <image style="width: 10rpx; height: 17rpx; " src="../../static/icon/ckgd.png" />
454 451
           </span>
455 452
         </div>
456
-
457
-
458
-
459 453
       </div>
460 454
       <!-- <Announcement :list="state.announcementList" /> -->
461
-      <!--      {{userStore.userInfo}}-->
455
+      <!--      {{userStore.userInfo}} -->
462 456
 
463 457
       <Banner />
464 458
 
465 459
       <ProductList :list="state.productList" />
466 460
     </div>
467
-
468 461
   </div>
469
-  <CXBDialogSIgnIn :show="state.isShowSignIn" :today="state.signToday" :day="state.day"
470
-    @confirm="state.isShowSignIn = false" @close="state.isShowSignIn = false" />
462
+  <CXBDialogSIgnIn
463
+    :show="state.isShowSignIn" :today="state.signToday" :day="state.day"
464
+    @confirm="state.isShowSignIn = false" @close="state.isShowSignIn = false"
465
+  />
471 466
 
472 467
   <CXBPrivacyPopup />
473 468
 </template>
474
-<style  >
469
+
470
+<style>
475 471
 page {
476 472
   background-color: #f8f8f8;
477 473
 }
@@ -483,8 +479,6 @@ page {
483 479
   z-index: 2;
484 480
 }
485 481
 
486
-
487
-
488 482
 .scroll-view_H {
489 483
   white-space: nowrap;
490 484
   width: 700rpx;
@@ -495,7 +489,6 @@ page {
495 489
   z-index: 1;
496 490
 }
497 491
 
498
-
499 492
 .ckgdtext {
500 493
   position: absolute;
501 494
   top: 28rpx;
@@ -589,6 +582,7 @@ page {
589 582
   box-shadow: 2rpx 2rpx 12rpx 2rpx #FFC8CE;
590 583
 }
591 584
 </style>
585
+
592 586
 <route lang="yaml"   type="home">
593 587
 style:
594 588
   navigationStyle: custom

+ 1 - 0
src/stores/userStore.ts

@@ -15,6 +15,7 @@ interface UserStoreState {
15 15
     redirectPage: string | null,
16 16
     shareId: string | null
17 17
     openid:string
18
+	isPushToProductDetail: boolean
18 19
 }
19 20
 
20 21
 export const useUserStore = defineStore('userStore', {