From 3f631a174c2cdc7d151bd6c67f30c24b49afd939 Mon Sep 17 00:00:00 2001 From: "liujw155@outlook.com" Date: Sat, 8 Feb 2025 13:47:28 +0800 Subject: [PATCH] add classify for tid1878 --- src/pages.json | 6 + .../mall/components/index_classify_bar.vue | 2 +- .../mall/components/index_search_bar.vue | 13 +- .../mall/components/specification_modal.vue | 2 + src/subpackage/mall/js/api.js | 2 + src/subpackage/mall/js/handle.js | 25 ++ src/subpackage/mall/pages/classify.vue | 441 +++++++++++++++++++++ src/subpackage/mall/pages/goods_info.vue | 36 +- src/subpackage/mall/pages/index.vue | 12 +- src/subpackage/mall/static/images/arrow_094.png | Bin 0 -> 169 bytes .../mall/static/images/arrow_9ad_down.png | Bin 0 -> 165 bytes 11 files changed, 503 insertions(+), 36 deletions(-) create mode 100644 src/subpackage/mall/js/handle.js create mode 100644 src/subpackage/mall/pages/classify.vue create mode 100644 src/subpackage/mall/static/images/arrow_094.png create mode 100644 src/subpackage/mall/static/images/arrow_9ad_down.png diff --git a/src/pages.json b/src/pages.json index 123a016..6800ebc 100644 --- a/src/pages.json +++ b/src/pages.json @@ -1011,6 +1011,12 @@ "style" : { "navigationBarTitleText": "商品详情" } + }, + { + "path": "pages/classify", + "style" : { + "navigationBarTitleText": "商品分类" + } } ] } diff --git a/src/subpackage/mall/components/index_classify_bar.vue b/src/subpackage/mall/components/index_classify_bar.vue index 2e2396a..1590882 100644 --- a/src/subpackage/mall/components/index_classify_bar.vue +++ b/src/subpackage/mall/components/index_classify_bar.vue @@ -12,7 +12,7 @@ - + 分类 diff --git a/src/subpackage/mall/components/index_search_bar.vue b/src/subpackage/mall/components/index_search_bar.vue index ecf7947..bbdb18f 100644 --- a/src/subpackage/mall/components/index_search_bar.vue +++ b/src/subpackage/mall/components/index_search_bar.vue @@ -7,7 +7,7 @@ - 88 + {{ cartNUmShow }} @@ -18,6 +18,17 @@ export default { shoppingCart: { type: Boolean, default: false + }, + cartNum: { + type: Number, + default: 0 + } + }, + computed: { + cartNUmShow(){ + let { cartNum } = this; + if(!isNaN(cartNum))return cartNum > 99 ? 99 : cartNum; + return 0; } } } diff --git a/src/subpackage/mall/components/specification_modal.vue b/src/subpackage/mall/components/specification_modal.vue index 549bc2e..ec86f91 100644 --- a/src/subpackage/mall/components/specification_modal.vue +++ b/src/subpackage/mall/components/specification_modal.vue @@ -117,6 +117,7 @@ export default { * @param {Array} specArr[].value 规格值 * @param {Boolean} onlyGet 是否只获取选择数据 * @param {Function} success 回调函数 + * @param {Function} addCartComplete 回调函数 } } */ @@ -166,6 +167,7 @@ export default { setTimeout(_=>{ this.hide(); this.resetData(); + initData?.addCartComplete?.(); }, 1000); }, 300, true), diff --git a/src/subpackage/mall/js/api.js b/src/subpackage/mall/js/api.js index 6ed1d8d..2007d32 100644 --- a/src/subpackage/mall/js/api.js +++ b/src/subpackage/mall/js/api.js @@ -8,6 +8,8 @@ export const MALL_API = { homeGoodsBuy:`${ORIGIN}/shop2/homeGoodsBuy`, //商品详情 - 立即购买 goodsCartList:`${ORIGIN}/shop2/goodsCartList`, //购物车 - 商品列表 goodsComment:`${ORIGIN}/shop2/goodsComment`, //商品评价列表 + goodsList:`${ORIGIN}/shop2/goodsList`, //商品列表 + goodsCateList:`${ORIGIN}/shop2/goodsCateList`, // 商品分类列表 } export default { ORIGIN, MALL_API }; \ No newline at end of file diff --git a/src/subpackage/mall/js/handle.js b/src/subpackage/mall/js/handle.js new file mode 100644 index 0000000..1c6013a --- /dev/null +++ b/src/subpackage/mall/js/handle.js @@ -0,0 +1,25 @@ +import { MALL_API } from "./api"; +import server from "./server"; + +// 购物车商品列表 +export function goodsCartList(brand_id){ + return server.post({ + url: MALL_API.goodsCartList, + data: { brand_id }, + isDefaultGet: false, + }) + .then(res => { + let _data = res?.data || {}; + if(_data.code === 0){ + let _ls = _data?.data ?? []; + //product_invalid 商品状态 0-正常 1-已失效 + return ({ + totalList: _ls, + validList: _ls.filter(item => item.product_invalid === 0), + invalidList: _ls.filter(item => item.product_invalid === 0), + }); + }else{ + return Promise.reject(_data); + } + }) +} \ No newline at end of file diff --git a/src/subpackage/mall/pages/classify.vue b/src/subpackage/mall/pages/classify.vue new file mode 100644 index 0000000..21b8ec3 --- /dev/null +++ b/src/subpackage/mall/pages/classify.vue @@ -0,0 +1,441 @@ + + + + + diff --git a/src/subpackage/mall/pages/goods_info.vue b/src/subpackage/mall/pages/goods_info.vue index faed8cb..f03ace6 100644 --- a/src/subpackage/mall/pages/goods_info.vue +++ b/src/subpackage/mall/pages/goods_info.vue @@ -138,6 +138,7 @@ import specificationModal from "../components/specification_modal.vue"; import appraiseItem from "../components/appraise_item.vue"; import { MALL_API } from "../js/api"; import server from "../js/server"; +import { goodsCartList } from "../js/handle"; export default { components: { serviceModal, @@ -351,7 +352,6 @@ export default { hideLoad(); let _data = res?.data || {}; if(_data.code === 0){ - console.log('subpackage mall pages goods_info getGoodsInfo res --->', _data); return this.goodsInfo = _data?.data ?? {}; }else{ return Promise.reject(_data); @@ -359,10 +359,7 @@ export default { }) .catch(err => { hideLoad(); - showModal({ - title: '提示', - content: err.message || '加载失败!' - }) + showModal({ content: err.message || '加载失败!' }); console.warn('subpackage mall pages goods_info getGoodsInfo err --->', err); }) }, @@ -394,29 +391,14 @@ export default { }) }, // 购物车商品列表 - goodsCartList({ brand_id }){ - return server.post({ - url: MALL_API.goodsCartList, - data: { brand_id }, - isDefaultGet: false, - }) - .then(res => { - let _data = res?.data || {}; - if(_data.code === 0){ - console.log('subpackage mall pages goods_info goodsCartList res --->', _data); - let _ls = _data?.data ?? []; - //product_invalid 商品状态 0-正常 1-已失效 - let validLs = _ls.filter(item => item.product_invalid === 0); - let _length = validLs?.length ?? 0; - this.goodsCartNum = _length > 100 ? 99 : _length; - return _ls; - }else{ - return Promise.reject(_data); - } - }) - .catch(err => { + async goodsCartList({ brand_id }){ + try{ + let { validList } = await goodsCartList(brand_id); + let _length = validList?.length ?? 0; + this.goodsCartNum = _length > 100 ? 99 : _length; + }catch(err){ console.warn('subpackage mall pages goods_info goodsCartList err --->', err); - }) + } }, /** * 获取商品评价列表 diff --git a/src/subpackage/mall/pages/index.vue b/src/subpackage/mall/pages/index.vue index 3446f71..443b3f8 100644 --- a/src/subpackage/mall/pages/index.vue +++ b/src/subpackage/mall/pages/index.vue @@ -48,6 +48,7 @@ @@ -118,6 +119,10 @@ export default { this.getHomeData({ brand_id: _bid }); }, methods: { + toClassify(){ + let { brand_id } = this; + routeTo(`/subpackage/mall/pages/classify?brand_id=${brand_id}`,'nT'); + }, getGridLsFor(key){ let { showdata } = this; return showdata?.[key]?.grid_setting ?? []; @@ -149,11 +154,6 @@ export default { // 如果商品是多个规格属性的,则出现弹窗给用户选择规格加入购物车,如果是单规格的则直接加入购物车 // 根据product_spec_multi字段做判断 等于1则是多规格 if(e.product_spec_multi == 1){ - // e.product_spec.push({ - // id: 3, - // name: 'test', - // value: ['test1', 'test2', 'test3'] - // }) this.$refs.spacificationModal.alert({ id: e?.id ?? '', brand_id: brand_id, @@ -166,8 +166,6 @@ export default { } this.$refs?.spacificationModal?.goodsCartAdd({ brand_id, id: e?.id, }); - - }, // 是否展示模块 isShow(val) { diff --git a/src/subpackage/mall/static/images/arrow_094.png b/src/subpackage/mall/static/images/arrow_094.png new file mode 100644 index 0000000000000000000000000000000000000000..afa37942ed872b27dc8adf0fc9d48becc2970ab0 GIT binary patch literal 169 zcmeAS@N?(olHy`uVBq!ia0vp^JV4CH!VDx|PJVD7NXZ5Ggt!7}hMA=dGfNm|l!DN- z0uXz4KEs53h8ZOXKP;~UD&Q;$@(X4Vy?W`i$YF8ut){F=KtV%K7sn8e>&XWgyCMt4RJeecpB~Z-J)5S4_<9hM|t{Wi|5