From f0f78b811823801329a68bb1f41d25373583451a Mon Sep 17 00:00:00 2001 From: xiaoguang Date: Fri, 13 May 2022 20:43:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/img/home/icon-app.png | Bin 0 -> 569 bytes assets/img/home/icon-customer.png | Bin 0 -> 1096 bytes assets/img/home/icon-totop-light.png | Bin 0 -> 842 bytes assets/img/home/icon-totop.png | Bin 0 -> 841 bytes layouts/default.vue | 13 +-- pages/index/index.vue | 16 +++- pages/index/module/Banner.vue | 6 +- pages/index/module/TabbarFixed.vue | 131 +++++++++++++++++++++++++++ store/index.js | 4 +- 9 files changed, 153 insertions(+), 17 deletions(-) create mode 100644 assets/img/home/icon-app.png create mode 100644 assets/img/home/icon-customer.png create mode 100644 assets/img/home/icon-totop-light.png create mode 100644 assets/img/home/icon-totop.png create mode 100644 pages/index/module/TabbarFixed.vue diff --git a/assets/img/home/icon-app.png b/assets/img/home/icon-app.png new file mode 100644 index 0000000000000000000000000000000000000000..5e7dfea47994a5ca700b13a13fee3cee333087e9 GIT binary patch literal 569 zcmV-90>=G`P)Px$^GQTOR9HvtnaxeZKoEuB`mpCv0igmYA?Y9;fKMZzfC_*L2q$Y#fez>ZN{A~U zseqhwu+c=0n5PGmUG^J$VK?>%|(N|UDPB#I(_t?o`R?1fDr3WNo)RMJ3L zg-s9?2n%4Tq=B#sn;<9<7Qj+T17Q_5K~NwpfTfZK!YXWnpg>pvOC>#uFn~D`-Kr`p zgPe1Z0B%$tp~{-QhKatKd#$WY77Tv_j>oTjq~q0Ax}gbYd7jUbB-zc1(=;7NQS{oJ zmr1%~P{Y>Rljg*{oalc_Ojfl+8qSEQb06ZI~D(QOzLmI|^Bh1iv`xEcmqHKpn zxsCFLTGI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$L{Uzot2T2 z?4{rDUsD^_l(;WIbqeh08dW?5O-Yn$)Rf;rYP_Ln+9`0XYjhatGXR{1I-^|!o2{l8 z2eKx2nIy?1Cb4=?-~v=iIgkCmQAE5L5yZ~P^L&AbC%*Xr@bm5MZL+Oj?-bbciJ`p1 zI!Tg)n5TDLx>H~}#8>WwJV4A#b`Gp^Tq-IlKcJk1y7y#^^u?+5w~>EDof~TrJ15Kl O0000Px&1W80eR9HvtnNM=lFc`((M;9!~4Jap|H=sQMWyi!>q$i-=p|T(>z}ZnwK$wX$ z?0^%rJwe+OP)^Wf-6_FYL}x?;aIk{xsMJ@ek|Em|oHG^k-8ms_WN46achGVj6pS(G=jsg0|=s zoSagI*3LI=|CAG&FvlJ5<-Q)js{md%Y_UCDhmi(d0*67o#4p#OtUiZRY2X)$XkS%0 z4ER1^n<`BrO2m~FzOGMK{`RcvBef{~heWik0S`t1zgJ(nK3KcbWvWwMB8`r5i9QF@ z;j-4{Qq<@}>4zA{&K|%M60^g+uQN+@ope>>9)MS+?8BB=wX*+@!W;&_0VF1EZ>2Xj z8Y5)_4hOpcpSos94vOrAGb+sCK#Fr5gXeb(3xJYpIBTOk`mu7X)46u|yeR)p<6;$9 z9wX05=Om`-l|j}VC6avlRR_oK;PCY}uobUL(qu(=H0? zI)LQ_$6w?VCx_6~T9Al}EUhbJOc7wz+aqnv zIJf{~CtI(|&5%oBDRNfJm2^uep{dBN)n_G`s-or7t0~3IRdZ$knSkYOqpkw0MZq@` zQS#e|27Cq3yaxNM?%vH(=Bw7D+l#b^%WcCrqT}eK_8Al#bgrC9cQdeBJu4rR{4yQ~ zH$~A(xCBF1tF$C(d1V_k3DF+dVK1eMLF~=XEjuwcygCmy3eg(a4RAj_HZBkU1FpT{ UJpEx4`v3p{07*qoM6N<$f`b@@F8}}l literal 0 HcmV?d00001 diff --git a/assets/img/home/icon-totop.png b/assets/img/home/icon-totop.png new file mode 100644 index 0000000000000000000000000000000000000000..9f03d1a0fed13bd369e63f155d0971af89034e4e GIT binary patch literal 841 zcmV-P1GfB$P)Px&14%?dR9Hvtnay?7FcgK~n+BK;2o;bHNGbq2NH%`$*M>Laait zS(e?(I(1zi3L(7Eh;NL7Tu=LWtKcMN%qjj}cND5x-_xCYS18g_&7A z1Z=F*MAV9_6=vqUp>#E;vLlrKMMMWSuuM(wdpmMuFxkg70!r&t*K>(3I?7w`Jpi2T zYh6=+K)0r)fXgm7pQ*lrSz_v-bG3T{o=e%MB{8?M|Bu4V{1X6LlMWQ^jgf71CMe7D zXt7wxkQFTIgmWs)%x0XE;OcE*0|4!9SeB+~E>!fhj`bUh;+4^+jf(@oW*c+N8zO3- z45F3A+O=!%}olYk>A;hOV z&-IC;AS|^uL?mB)+F~oIzbf?Ae@_wX+h-zb z|4y)g<-?&2TXwk~dUtaIyVjrGt2OvJ5nZY}t|eu2sA(A70>?#t%{F(dFSkEl4p- T0v!>o00000NkvXXu0mjfvdMIU literal 0 HcmV?d00001 diff --git a/layouts/default.vue b/layouts/default.vue index e61e33d..a317081 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -24,7 +24,6 @@ export default { data() { return { isSticky: false, - ticking: false, }; }, computed: { @@ -45,16 +44,8 @@ export default { window.removeEventListener("scroll", this.scrollEventMethod); }, methods: { - scrollEventMethod(e) { - const that = this; - // 节流 - if (!that.ticking) { - window.requestAnimationFrame(function () { - that.ticking = false; - that.isSticky = window.scrollY > 300; - }); - that.ticking = true; - } + scrollEventMethod() { + this.isSticky = window.scrollY > 300; }, }, }; diff --git a/pages/index/index.vue b/pages/index/index.vue index b01ae58..4c0a35b 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -43,6 +43,7 @@ + @@ -61,11 +62,12 @@ import { import Banner from "./module/Banner.vue"; import Seckil from "./module/Seckill.vue"; import Pick from "./module/Pick.vue"; +import TabbarFixed from "./module/TabbarFixed.vue"; const SECKILL_COUNT = 20; // 秒杀商品数 const NEW_COUNT = 5; // 新品上架商品数 export default { - components: { Banner, Seckil, Pick, UiGoodsItem, UiPagination }, + components: { Banner, Seckil, Pick, UiGoodsItem, UiPagination, TabbarFixed }, async asyncData({ store }) { // 获取秒杀数据 let seckillData = { activityTimeVO: null }; @@ -122,12 +124,24 @@ export default { total: 0, loading: false, currentPage: 0, + scrollTop: 0, }; }, created() { this.getSelectProducts(); }, + mounted() { + // 监听滚动事件 + window.addEventListener("scroll", this.scrollEventMethod); + }, + destroyed() { + window.removeEventListener("scroll", this.scrollEventMethod); + }, methods: { + scrollEventMethod() { + this.scrollTop = window.scrollY; + }, + // 刷新秒杀活动状态 async handleSeckillRefresh() { const { result: seckillData } = await ApiGetHomeSeckill(); diff --git a/pages/index/module/Banner.vue b/pages/index/module/Banner.vue index 5655f54..f6b6dd2 100644 --- a/pages/index/module/Banner.vue +++ b/pages/index/module/Banner.vue @@ -26,11 +26,11 @@ export default { return { bannerList: [ { - url: "https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/uc/account-avatar/banner4.jpg", + url: "https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/uc/account-avatar/goods13.jpg", id: 13, }, { - url: "https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/uc/account-avatar/1.png", + url: "https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/uc/account-avatar/goods30.jpg", id: 30, }, { @@ -38,7 +38,7 @@ export default { id: 15, }, { - url: "https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/uc/account-avatar/3banner.png", + url: "https://msb-edu-dev.oss-cn-beijing.aliyuncs.com/uc/account-avatar/goods40.jpg", id: 40, }, ], diff --git a/pages/index/module/TabbarFixed.vue b/pages/index/module/TabbarFixed.vue new file mode 100644 index 0000000..c5625cf --- /dev/null +++ b/pages/index/module/TabbarFixed.vue @@ -0,0 +1,131 @@ + + + diff --git a/store/index.js b/store/index.js index d39677c..a7a54c4 100644 --- a/store/index.js +++ b/store/index.js @@ -44,11 +44,11 @@ const mutations = { }, }; const actions = { - async nuxtServerInit({ state, commit, dispatch }) { + nuxtServerInit({ state, commit, dispatch }) { const token = this.$cookies.get(TOKEN_KEY); if (!state.token && token) { commit("setToken", token); - await dispatch("getUserInfo"); + dispatch("getUserInfo"); } }, async getUserInfo({ commit }) {