hookehuyr

✨ feat: 解决方案详情页保存切换分类状态,返回时保持位置

1 <!-- 1 <!--
2 * @Date: 2024-10-18 12:06:09 2 * @Date: 2024-10-18 12:06:09
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-12-05 10:19:51 4 + * @LastEditTime: 2024-12-05 16:08:07
5 * @FilePath: /hager/src/views/solution/case.vue 5 * @FilePath: /hager/src/views/solution/case.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -157,7 +157,7 @@ export default { ...@@ -157,7 +157,7 @@ export default {
157 }, 157 },
158 computed: { 158 computed: {
159 casePath () { 159 casePath () {
160 - return `/solution/detail?id=${this.success_info.category_id}`; 160 + return `/solution/detail?id=${this.success_info.category_id}&current_index=${this.$route.query.current_index}`;
161 } 161 }
162 }, 162 },
163 watch: { 163 watch: {
......
1 <!-- 1 <!--
2 * @Date: 2024-09-29 15:49:27 2 * @Date: 2024-09-29 15:49:27
3 * @LastEditors: hookehuyr hookehuyr@gmail.com 3 * @LastEditors: hookehuyr hookehuyr@gmail.com
4 - * @LastEditTime: 2024-12-05 13:30:26 4 + * @LastEditTime: 2024-12-05 16:07:14
5 * @FilePath: /hager/src/views/solution/detail.vue 5 * @FilePath: /hager/src/views/solution/detail.vue
6 * @Description: 文件描述 6 * @Description: 文件描述
7 --> 7 -->
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
18 <hager-box v-if="case_list.length > 1"> 18 <hager-box v-if="case_list.length > 1">
19 <div class="hager-solution-detail-nav"> 19 <div class="hager-solution-detail-nav">
20 <div class="nav" v-for="(item, index) in case_list" :key="index"> 20 <div class="nav" v-for="(item, index) in case_list" :key="index">
21 - <div @click="changeCase(item, index)" :class="[current_id === item.id ? 'current-nav' : '', 'detail-nav']">{{ item.category_name }}</div> 21 + <div @click="changeCase(item, index)" :class="[current_id == item.id ? 'current-nav' : '', 'detail-nav']">{{ item.category_name }}</div>
22 </div> 22 </div>
23 </div> 23 </div>
24 </hager-box> 24 </hager-box>
...@@ -206,6 +206,7 @@ export default { ...@@ -206,6 +206,7 @@ export default {
206 SuccessSlidesPerView: 4, 206 SuccessSlidesPerView: 4,
207 productSlidesPerView: 4, 207 productSlidesPerView: 4,
208 case_list: [], 208 case_list: [],
209 + current_index: 0,
209 current_id: '', 210 current_id: '',
210 category_description: '', 211 category_description: '',
211 } 212 }
...@@ -216,11 +217,12 @@ export default { ...@@ -216,11 +217,12 @@ export default {
216 this.case_info = data; 217 this.case_info = data;
217 this.case_banner = data.file?.banner ? data.file?.banner[0] : 'https://cdn.ipadbiz.cn/hager/banner/banner08.png'; 218 this.case_banner = data.file?.banner ? data.file?.banner[0] : 'https://cdn.ipadbiz.cn/hager/banner/banner08.png';
218 this.case_list = data.list; 219 this.case_list = data.list;
219 - this.current_id = this.case_list[0]['id']; 220 + this.current_index = this.$route.query.current_index ? +this.$route.query.current_index : 0;
220 - this.success_data_list = this.case_list[0].list ?? []; 221 + this.current_id = this.case_list[this.current_index]['id'];
221 - this.category_description = this.case_list[0].category_description ?? ''; 222 + this.success_data_list = this.case_list[this.current_index].list ?? [];
222 - this.case_img = this.case_list[0].file?.img ? this.case_list[0].file?.img : ['https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg']; 223 + this.category_description = this.case_list[this.current_index].category_description ?? '';
223 - this.product_list = this.case_list[0].product ?? []; 224 + this.case_img = this.case_list[this.current_index].file?.img ? this.case_list[this.current_index].file?.img : ['https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg'];
225 + this.product_list = this.case_list[this.current_index].product ?? [];
224 } 226 }
225 this.$nextTick(() => { 227 this.$nextTick(() => {
226 this.$refs.myProductSwiper.$swiper?.on('breakpoint', (swiper) => { 228 this.$refs.myProductSwiper.$swiper?.on('breakpoint', (swiper) => {
...@@ -248,6 +250,7 @@ export default { ...@@ -248,6 +250,7 @@ export default {
248 path: '/solution/case', 250 path: '/solution/case',
249 query: { 251 query: {
250 id: v.id, 252 id: v.id,
253 + current_index: this.current_index
251 } 254 }
252 }); 255 });
253 }, 256 },
...@@ -284,6 +287,7 @@ export default { ...@@ -284,6 +287,7 @@ export default {
284 } 287 }
285 }, 288 },
286 changeCase (v, idx) { 289 changeCase (v, idx) {
290 + this.current_index = idx;
287 this.current_id = this.case_list[idx]['id']; 291 this.current_id = this.case_list[idx]['id'];
288 this.success_data_list = this.case_list[idx].list ?? []; 292 this.success_data_list = this.case_list[idx].list ?? [];
289 this.category_description = this.case_list[idx].category_description ?? ''; 293 this.category_description = this.case_list[idx].category_description ?? '';
...@@ -299,6 +303,14 @@ export default { ...@@ -299,6 +303,14 @@ export default {
299 clampText('.clamp-text', 3); // 限制显示三行文本 303 clampText('.clamp-text', 3); // 限制显示三行文本
300 304
301 }) 305 })
306 + // 记录点击的分类ID,用于返回定位到该分类
307 + this.$router.push({
308 + path: '/solution/detail',
309 + query: {
310 + ...this.$route.query, // 先展开原来的参数
311 + current_index: this.current_index
312 + }
313 + });
302 } 314 }
303 } 315 }
304 } 316 }
...@@ -486,7 +498,9 @@ export default { ...@@ -486,7 +498,9 @@ export default {
486 justify-content:space-around; 498 justify-content:space-around;
487 margin-top: 2rem; 499 margin-top: 2rem;
488 .nav { 500 .nav {
489 - flex: 1; text-align: center; padding: 0.75rem 0; 501 + flex: 1;
502 + text-align: center;
503 + padding: 1.5rem 0;
490 position: relative; 504 position: relative;
491 &:not(:last-child) { 505 &:not(:last-child) {
492 &::after { 506 &::after {
...@@ -503,8 +517,8 @@ export default { ...@@ -503,8 +517,8 @@ export default {
503 .detail-nav { 517 .detail-nav {
504 display: inline; 518 display: inline;
505 color: @text-color; 519 color: @text-color;
506 - font-size: 1.05rem; 520 + font-size: 1.2rem;
507 - padding: 0.7rem 0; 521 + padding: 1.4rem 0;
508 &:hover { 522 &:hover {
509 cursor: pointer; 523 cursor: pointer;
510 } 524 }
......