当前位置:首页 > JS逆向 > 【小程序实战系列】电商平台源码及功能实现_import { fetchhome } from ‘

【小程序实战系列】电商平台源码及功能实现_import { fetchhome } from ‘

一叶知秋2024-05-13 15:07:27JS逆向11

img
img

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

"backgroundColor": "#ffffff",
"borderStyle": "black",
"list": [
  {
    "pagePath": "pages/home/home",
    "text": "首页"
  },
  {
    "pagePath": "pages/goods/category/index",
    "text": "分类"
  },
  {
    "pagePath": "pages/cart/index",
    "text": "购物车"
  },
  {
    "pagePath": "pages/usercenter/index",
    "text": "我的"
  }
]

},
“lazyCodeLoading”: “requiredComponents”,
“usingComponents”: {},
“window”: {
“backgroundTextStyle”: “light”,
“navigationBarBackgroundColor”: “#fff”,
“navigationBarTitleText”: “Weixin”,
“navigationBarTextStyle”: “black”
},
“sitemapLocation”: “sitemap.json”,
“permission”: {
“scope.userLocation”: {
“desc”: “你的位置信息将用于小程序位置接口的效果展示”
}
}
}


### 4.2、home 首页



// home.js

import { fetchHome } from ‘…/…/services/home/home’;
import { fetchGoodsList } from ‘…/…/services/good/fetchGoods’;
import Toast from ‘tdesign-miniprogram/toast/index’;

Page({
data: {
imgSrcs: [],
tabList: [],
goodsList: [],
goodsListLoadStatus: 0,
pageLoading: false,
current: 1,
autoplay: true,
duration: 500,
interval: 5000,
navigation: { type: ‘dots’ },
},

goodListPagination: {
index: 0,
num: 20,
},

privateData: {
tabIndex: 0,
},

onShow() {
this.getTabBar().init();
},

onLoad() {
this.init();
},

onReachBottom() {
if (this.data.goodsListLoadStatus === 0) {
this.loadGoodsList();
}
},

onPullDownRefresh() {
this.init();
},

init() {
this.loadHomePage();
},

loadHomePage() {
wx.stopPullDownRefresh();

this.setData({
  pageLoading: true,
});
fetchHome().then(({ swiper, tabList }) => {
  this.setData({
    tabList,
    imgSrcs: swiper,
    pageLoading: false,
  });
  this.loadGoodsList(true);
});

},

tabChangeHandle(e) {
this.privateData.tabIndex = e.detail;
this.loadGoodsList(true);
},

onReTry() {
this.loadGoodsList();
},

async loadGoodsList(fresh = false) {
if (fresh) {
wx.pageScrollTo({
scrollTop: 0,
});
}

this.setData({ goodsListLoadStatus: 1 });

const pageSize = this.goodListPagination.num;
let pageIndex =
  this.privateData.tabIndex \* pageSize + this.goodListPagination.index + 1;
if (fresh) {
  pageIndex = 0;
}

try {
  const nextList = await fetchGoodsList(pageIndex, pageSize);
  this.setData({
    goodsList: fresh ? nextList : this.data.goodsList.concat(nextList),
    goodsListLoadStatus: 0,
  });

  this.goodListPagination.index = pageIndex;
  this.goodListPagination.num = pageSize;
} catch (err) {
  this.setData({ goodsListLoadStatus: 3 });
}

},

goodListClickHandle(e) {
const { index } = e.detail;
const { spuId } = this.data.goodsList[index];
wx.navigateTo({
url: /pages/goods/details/index?spuId=${spuId},
});
},

goodListAddCartHandle() {
Toast({
context: this,
selector: ‘#t-toast’,
message: ‘点击加入购物车’,
});
},

navToSearchPage() {
wx.navigateTo({ url: ‘/pages/goods/search/index’ });
},

navToActivityDetail({ detail }) {
const { index: promotionID = 0 } = detail || {};
wx.navigateTo({
url: /pages/promotion-detail/index?promotion_id=${promotionID},
});
},
});



// home.json
{
“navigationBarTitleText”: “首页”,
“onReachBottomDistance”: 10,
“backgroundTextStyle”: “light”,
“enablePullDownRefresh”: true,
“usingComponents”: {
“t-search”: “tdesign-miniprogram/search/search”,
“t-loading”: “tdesign-miniprogram/loading/loading”,
“t-swiper”: “tdesign-miniprogram/swiper/swiper”,
“t-swiper-item”: “tdesign-miniprogram/swiper/swiper-item”,
“t-swiper-nav”: “tdesign-miniprogram/swiper/swiper-nav”,
“t-image”: “/components/webp-image/index”,
“t-icon”: “tdesign-miniprogram/icon/icon”,
“t-toast”: “tdesign-miniprogram/toast/toast”,
“t-tabs”: “tdesign-miniprogram/tabs/tabs”,
“t-tab-panel”: “tdesign-miniprogram/tabs/tab-panel”,
“goods-list”: “/components/goods-list/index”,
“load-more”: “/components/load-more/index”
}
}



加载中...


/* home.wxss */

page {
box-sizing: border-box;
padding-bottom: calc(env(safe-area-inset-bottom) + 96rpx);
}

.t-tabs.t-tabs–top .t-tabs__scroll {
border-bottom: none !important;
}

.home-page-header {
background: linear-gradient(#fff, #f5f5f5);
}

.home-page-container {
background: #f5f5f5;
}

.home-page-container,
.home-page-header {
display: block;
padding: 0 24rpx;
}

.home-page-header .t-search__input-container {
border-radius: 32rpx !important;
height: 64rpx !important;
}

.home-page-header .t-search__input {
font-size: 28rpx !important;
color: rgb(116, 116, 116) !important;
}

.home-page-header .swiper-wrap {

img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化资料的朋友,可以戳这里获取

p {

[外链图片转存中…(img-psaG1MSU-1715002216618)]
[外链图片转存中…(img-H0xB2XN7-1715002216619)]
[外链图片转存中…(img-9EnWXIkt-1715002216619)]

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化资料的朋友,可以戳这里获取

扫描二维码推送至手机访问。

版权声明:本站部分文章来自互联网采集,请查看免责申明

本文链接:https://blog.yyzq.team/post/338522.html

标签: 小程序
分享给朋友:

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。