diff --git a/pages/goods/list/index.js b/pages/goods/list/index.js index e642878..d4a010c 100644 --- a/pages/goods/list/index.js +++ b/pages/goods/list/index.js @@ -1,4 +1,4 @@ -import { fetchGoodsList } from '../../../services/good/fetchGoodsList'; +import { fetchGoodsList } from '~/services/good/fetchGoodsList'; import Toast from 'tdesign-miniprogram/toast/index'; const initFilters = { diff --git a/pages/home/home.js b/pages/home/home.js index 578b3a3..adcf5a2 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -1,6 +1,15 @@ -import { fetchHome } from '~/services/home/home'; -import { fetchGoodsList } from '~/services/good/fetchGoods'; -import { getbannerList } from '~/services/home/getbannerList'; +import { + fetchHome +} from '~/services/home/home'; +import { + fetchGoodsList +} from '~/services/good/fetchGoodsList'; +import { + getbannerList +} from '~/services/home/getbannerList'; +import { + getHomeCategoryListApi +} from '~/services/home/getHomeCategoryListApi'; import Toast from 'tdesign-miniprogram/toast/index'; Page({ @@ -23,8 +32,8 @@ Page({ }, goodListPagination: { - index: 0, - num: 20, + index: 1, + num: 6, }, privateData: { @@ -69,10 +78,18 @@ Page({ } }); - fetchHome().then(({ swiper, tabList }) => { + // 获取首页推荐类目 + getHomeCategoryListApi().then((res) => { this.setData({ - tabList, - // imgSrcs: swiper, + tabList: res.data, + }); + this.data.tabList.unshift({ + text: "精选推荐", + key: 0, + categoryGuid: 1, + }) + this.setData({ + tabList: res.data, pageLoading: false, }); this.loadGoodsList(true); @@ -81,14 +98,15 @@ Page({ tabChangeHandle(e) { this.privateData.tabIndex = e.detail; - this.loadGoodsList(true); + console.log(e.detail.value, 'tab的看看'); + this.loadGoodsList(true, e.detail.value); }, onReTry() { this.loadGoodsList(); }, - async loadGoodsList(fresh = false) { + async loadGoodsList(fresh = false, categoryGuid = 0) { if (fresh) { wx.pageScrollTo({ scrollTop: 0, @@ -100,15 +118,21 @@ Page({ }); const pageSize = this.goodListPagination.num; - let pageIndex = this.privateData.tabIndex * pageSize + this.goodListPagination.index + 1; + let pageIndex = this.goodListPagination.index + 1; if (fresh) { - pageIndex = 0; + pageIndex = 1; } + let params = { + pageNum: pageIndex, + pageSize: pageSize, + goodsCategoryGuid: categoryGuid + } + console.log(params, '看看参数'); try { - const nextList = await fetchGoodsList(pageIndex, pageSize); + const nextList = await fetchGoodsList(params); this.setData({ - goodsList: fresh ? nextList : this.data.goodsList.concat(nextList), + goodsList: fresh ? nextList.result : this.data.goodsList.concat(nextList.result), goodsListLoadStatus: 0, }); @@ -122,8 +146,12 @@ Page({ }, goodListClickHandle(e) { - const { index } = e.detail; - const { spuId } = this.data.goodsList[index]; + const { + index + } = e.detail; + const { + spuId + } = this.data.goodsList[index]; wx.navigateTo({ url: `/pages/goods/details/index?spuId=${spuId}`, }); @@ -143,10 +171,14 @@ Page({ }); }, - navToActivityDetail({ detail }) { - const { index: promotionID = 0 } = detail || {}; + navToActivityDetail({ + detail + }) { + const { + index: promotionID = 0 + } = detail || {}; wx.navigateTo({ url: `/pages/promotion-detail/index?promotion_id=${promotionID}`, }); }, -}); +}); \ No newline at end of file diff --git a/pages/order/order-confirm/pay.js b/pages/order/order-confirm/pay.js index f5f5b6d..ef02ef8 100644 --- a/pages/order/order-confirm/pay.js +++ b/pages/order/order-confirm/pay.js @@ -59,9 +59,9 @@ export const paySuccess = (payOrderInfo) => { .map((k) => `${k}=${params[k]}`) .join('&'); // 跳转支付结果页面 - // wx.redirectTo({ - // url: `/pages/order/pay-result/index?${paramsStr}` - // }); + wx.redirectTo({ + url: `/pages/order/pay-result/index?${paramsStr}` + }); }; export const payFail = (payOrderInfo, resultMsg) => { @@ -97,11 +97,11 @@ export const payFail = (payOrderInfo, resultMsg) => { icon: 'close-circle', }); console.log(resultMsg,'错误信息'); - // setTimeout(() => { - // wx.redirectTo({ - // url: '/pages/order/order-list/index' - // }); - // }, 2000); + setTimeout(() => { + wx.redirectTo({ + url: '/pages/order/order-list/index' + }); + }, 2000); } }; diff --git a/services/home/getHomeCategoryListApi.js b/services/home/getHomeCategoryListApi.js new file mode 100644 index 0000000..7c9229a --- /dev/null +++ b/services/home/getHomeCategoryListApi.js @@ -0,0 +1,19 @@ +import { + request +} from '../_utils/request'; + +/** 获取轮播图列表 */ +export function getHomeCategoryListApi() { + return new Promise((resolve, reject) => { + request({ + url: `HomeApi/getHomeCategoryListApi`, + method: 'GET', + success: function (res) { + resolve(res); + }, + fail: function (error) { + reject(error); + } + }); + }); +} \ No newline at end of file diff --git a/services/home/home.js b/services/home/home.js index 9aef66f..7a4af0b 100644 --- a/services/home/home.js +++ b/services/home/home.js @@ -6,7 +6,6 @@ function mockFetchHome() { const { genSwiperImageList } = require('~/model/swiper'); return delay().then(() => { return { - swiper: genSwiperImageList(), tabList: [ { text: '精选推荐',