From 9740ed4fc32b5bcd12e4ad90fb80036a893cbd32 Mon Sep 17 00:00:00 2001 From: zc <2064281269@qq.com> Date: Sat, 29 Nov 2025 21:24:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=86=E7=B1=BB=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/category/index.js | 9 ++ api/goods/index.js | 10 ++ pages.json | 6 + pages/category/components/commodity.vue | 39 +++-- pages/category/components/primary.vue | 110 -------------- pages/category/index.vue | 63 ++------ .../components/secondary.vue | 8 +- pages/category2/index.vue | 139 ++++++++++++++++++ 8 files changed, 198 insertions(+), 186 deletions(-) delete mode 100644 pages/category/components/primary.vue rename pages/{category => category2}/components/secondary.vue (92%) create mode 100644 pages/category2/index.vue diff --git a/api/category/index.js b/api/category/index.js index 7198be0..3e283ea 100644 --- a/api/category/index.js +++ b/api/category/index.js @@ -1,4 +1,6 @@ import request from '@/utils/request' +import {httpRequest} from '@/utils/request/axios' +const baseUrl = 'https://api.1024api.com/api-interface' // api地址 const api = { @@ -9,3 +11,10 @@ const api = { export function list() { return request.get(api.list) } + +export const apiGetAppCategoryList = () => { + return httpRequest.post( + `${baseUrl}/app/category/list`, + {} + ); + } diff --git a/api/goods/index.js b/api/goods/index.js index 94b1fac..5a4b95c 100644 --- a/api/goods/index.js +++ b/api/goods/index.js @@ -1,4 +1,6 @@ import request from '@/utils/request' +import {httpRequest} from '@/utils/request/axios' +const baseUrl = 'https://api.1024api.com/api-interface' // api地址 const api = { @@ -35,3 +37,11 @@ export const specData = (goodsId) => { export const skuInfo = (goodsId, goodsSkuId, param) => { return request.get(api.skuInfo, { goodsId, goodsSkuId, ...param }) } + +export const apiGetCommodityList = (data) => { + return httpRequest.post( + `${baseUrl}/app/index/page/list`, + data + ); + } + diff --git a/pages.json b/pages.json index e8f9c63..e211c04 100644 --- a/pages.json +++ b/pages.json @@ -39,6 +39,12 @@ "navigationBarTitleText": "全部分类" } }, + { + "path": "pages/category2/index", + "style": { + "navigationBarTitleText": "全部分类" + } + }, { "path": "pages/cart/index", "style": { diff --git a/pages/category/components/commodity.vue b/pages/category/components/commodity.vue index 56c7cbe..589bae2 100644 --- a/pages/category/components/commodity.vue +++ b/pages/category/components/commodity.vue @@ -29,24 +29,24 @@ - + - + - {{ item.goods_name }} + {{ item.title }} - ¥{{ item.goods_price_min }} - ¥{{ item.line_price_min }} + ¥{{ item.showPromotionPrice }} + ¥{{ item.showSalePrice }} - + @@ -84,11 +84,6 @@ type: Array, default: [] }, - // 分类设置 - setting: { - type: Object, - default: () => {} - }, // query参数 query: { type: Object, @@ -133,8 +128,8 @@ computed: { // 二级分类列表 subCateList() { - if (this.list[this.curIndex] && this.list[this.curIndex].children) { - return this.list[this.curIndex].children + if (this.list[this.curIndex] && this.list[this.curIndex].childrens) { + return this.list[this.curIndex].childrens } return [] } @@ -145,7 +140,7 @@ findCateIndex(cateId, pIndex = -1) { if (!cateId) return -1 const data = pIndex > -1 ? this.list[pIndex].children : this.list - return data.findIndex(item => item.category_id == cateId) + return data.findIndex(item => item.id == cateId) }, /** @@ -173,11 +168,15 @@ const app = this const categoryId = app.getCategoryId() return new Promise((resolve, reject) => { - GoodsApi.list({ categoryId, page: pageNo }, { load: false }) + GoodsApi.list({ categoryId, page: pageNo }, { load: false }).then(res => { + console.warn('----- my data is categoryId: ', res) + }) + // testorigin GoodsApi.list({ categoryId, page: pageNo }, { load: false }) + GoodsApi.apiGetCommodityList({ categoryId }) .then(result => { - const newList = result.data.list - app.goodsList.data = getMoreListData(newList, app.goodsList, pageNo) - app.goodsList.last_page = newList.last_page + const newList = result.data.rows + app.goodsList.data = getMoreListData({ data: newList }, app.goodsList, pageNo) + // app.goodsList.last_page = newList.last_page resolve(newList) }) .catch(reject) @@ -188,9 +187,9 @@ getCategoryId() { const app = this if (app.curIndex2 > -1) { - return app.subCateList[app.curIndex2].category_id + return app.subCateList[app.curIndex2].id } - return app.curIndex > -1 ? app.list[app.curIndex].category_id : 0 + return app.curIndex > -1 ? app.list[app.curIndex].id : 0 }, // 一级分类:选中分类 diff --git a/pages/category/components/primary.vue b/pages/category/components/primary.vue deleted file mode 100644 index 80a26c6..0000000 --- a/pages/category/components/primary.vue +++ /dev/null @@ -1,110 +0,0 @@ - - - - - diff --git a/pages/category/index.vue b/pages/category/index.vue index ebf4a84..7392f9d 100644 --- a/pages/category/index.vue +++ b/pages/category/index.vue @@ -5,16 +5,8 @@ - - - - - - - + @@ -23,13 +15,8 @@ import store from '@/store' import MescrollCompMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-comp' import { setCartTabBadge } from '@/core/app' - import SettingKeyEnum from '@/common/enum/setting/Key' - import { PageCategoryStyleEnum } from '@/common/enum/store/page/category' - import SettingModel from '@/common/model/Setting' import * as CategoryApi from '@/api/category' import Search from '@/components/search' - import Primary from './components/primary' - import Secondary from './components/secondary' import Commodity from './components/commodity' // 最后一次刷新时间 @@ -38,37 +25,19 @@ export default { components: { Search, - Primary, - Secondary, Commodity }, mixins: [MescrollCompMixin], data() { return { - // 枚举类 - PageCategoryStyleEnum, - // 分类列表 list: [], - // 分类模板设置 - setting: {}, - // 正在加载中 isLoading: true, - // query参数 query: { categoryId1: undefined, categoryId2: undefined } } }, - - /** - * 生命周期函数--监听页面加载 - */ onLoad() { - // 加载页面数据 this.onRefreshPage() }, - - /** - * 生命周期函数--监听页面显示 - */ onShow() { // 监听query参数 @@ -80,15 +49,14 @@ // console.log('onShow', this.query, res ) }) - // 每间隔5分钟自动刷新一次页面数据 - const curTime = new Date().getTime() + // 每间隔5分钟自动刷新一次页面数据 testzc + /* const curTime = new Date().getTime() if ((curTime - lastRefreshTime) > 5 * 60 * 1000) { this.onRefreshPage() - } + } */ }, methods: { - // 刷新页面 onRefreshPage() { // 记录刷新时间 @@ -104,35 +72,26 @@ const app = this app.isLoading = true Promise.all([ - // 获取分类模板设置 - // 优化建议: 可以将此处的false改为true 启用缓存 - SettingModel.data(false), // 获取分类列表 - CategoryApi.list() + // CategoryApi.list(), // testorigin + CategoryApi.apiGetAppCategoryList() + ]) .then(result => { - // 初始化分类模板设置 - app.initSetting(result[0]) + // 初始化分类模板设置 testorigin + // app.initSetting(result[0]) // 初始化分类列表数据 - app.initCategory(result[1]) + app.initCategory(result[0]) }) .finally(() => app.isLoading = false) }, - /** - * 初始化分类模板设置 - * @param {Object} result - */ - initSetting(setting) { - this.setting = setting[SettingKeyEnum.PAGE_CATEGORY_TEMPLATE.value] - }, - /** * 初始化分类列表数据 * @param {Object} result */ initCategory(result) { - this.list = result.data.list + this.list = result.data }, diff --git a/pages/category/components/secondary.vue b/pages/category2/components/secondary.vue similarity index 92% rename from pages/category/components/secondary.vue rename to pages/category2/components/secondary.vue index e206584..68ede93 100644 --- a/pages/category/components/secondary.vue +++ b/pages/category2/components/secondary.vue @@ -7,10 +7,10 @@ - - - - + + + + {{ item.name }} diff --git a/pages/category2/index.vue b/pages/category2/index.vue new file mode 100644 index 0000000..a2e6aef --- /dev/null +++ b/pages/category2/index.vue @@ -0,0 +1,139 @@ + + + + + + \ No newline at end of file