From 033431f73f8bf56c9287bebf32fe1e1dbb5d6476 Mon Sep 17 00:00:00 2001 From: mason369 <1960638223@qq.com> Date: Fri, 20 Jan 2023 16:42:17 +0800 Subject: [PATCH] =?UTF-8?q?update:=E6=9B=B4=E6=96=B0=E5=85=A8=E9=83=A8?= =?UTF-8?q?=E5=95=86=E5=93=81=E3=80=81=E5=A2=9E=E5=8A=A0=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 9 +- src/request/api.js | 3 + src/utils/index.js | 43 ++++++++ src/views/Details.vue | 2 + src/views/Goods.vue | 228 ++++++++++++++++++++++++++++++++++++++++-- 5 files changed, 277 insertions(+), 8 deletions(-) diff --git a/src/App.vue b/src/App.vue index abd5bd3..6513808 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,7 +4,7 @@ - + @@ -22,7 +22,7 @@ import { mapState } from "vuex"; export default { data() { - return {topBarKeyValue: 0}; + return { topBarKeyValue: 0 }; }, name : "App", //注册组件 @@ -48,6 +48,11 @@ export default { isShowLoginModal: (state) => state.isShowLoginModal.isShowLoginModal }) + }, + methods: { + reloadTopBar() { + this.topBarKeyValue++; + } } }; diff --git a/src/request/api.js b/src/request/api.js index df45bd7..84fa040 100644 --- a/src/request/api.js +++ b/src/request/api.js @@ -27,3 +27,6 @@ export const reqGetDetail = (id) => request.get(`/products/${id}`); //加入购物车 export const reqAddCart = (params) => request.post("/shop/carts/add", qs.stringify( params )); + +//商品搜索 +export const reqGetGoodsSearch = (params) => request.get("/products", { params }); diff --git a/src/utils/index.js b/src/utils/index.js index e69de29..b81c353 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -0,0 +1,43 @@ +// validatePhoneNumber这个方法用来验证手机号是否符合规则 +export const validatePhoneNumber = (value) => { + let reg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/; + return reg.test(value); +}; + +//获取滚动条当前的位置 +export function getScrollTop() { + var scrollTop = 0; + if (document.documentElement && document.documentElement.scrollTop) { + scrollTop = document.documentElement.scrollTop; + } + else if (document.body) { + scrollTop = document.body.scrollTop; + } + return scrollTop; +} + +//获取当前可视范围的高度 +export function getClientHeight() { + var clientHeight = 0; + if (document.body.clientHeight && document.documentElement.clientHeight) { + clientHeight = Math.min( + document.body.clientHeight, + document.documentElement.clientHeight + ); + } + else { + clientHeight = Math.max( + document.body.clientHeight, + document.documentElement.clientHeight + ); + } + return clientHeight; +} + +//获取文档完整的高度 +export function getScrollHeight() { + return Math.max( + document.body.scrollHeight, + document.documentElement.scrollHeight + ); +} diff --git a/src/views/Details.vue b/src/views/Details.vue index e6c0eac..20610c9 100644 --- a/src/views/Details.vue +++ b/src/views/Details.vue @@ -231,6 +231,8 @@ export default { //加入成功 if (res.code === 0) { this.$message.success("加入购物车成功"); + //topBar的购物车数量重载 + this.$emit("fn"); } //加入失败 else { diff --git a/src/views/Goods.vue b/src/views/Goods.vue index c3263c1..0f9daa5 100644 --- a/src/views/Goods.vue +++ b/src/views/Goods.vue @@ -1,13 +1,229 @@ - - - + + + + + + + 排序: + + {{ item.txt }} + + + 分类: + + {{ item.txt }} + + + + + {{ isReachBottom ? "已经没有数据了" : "正在加载 ... ..." }} + + + - \ No newline at end of file +.goods { + padding-bottom: 50px; + background: #efefef; + padding-top: 20px; + .options { + padding-top: 20px; + padding-bottom: 40px; + li { + margin-top: 20px; + strong { + color: #000; + font-weight: bold; + } + span { + margin-right: 20px; + margin-left: 10px; + cursor: pointer; + color: #999; + &.active { + color: #0a328d; + font-weight: bold; + } + } + } + } +} +
+ {{ isReachBottom ? "已经没有数据了" : "正在加载 ... ..." }} +