


Implementation code for mall home page carousel, product classification navigation and new product special sales developed by WeChat mini program mall
The content of this article is about the implementation code of the mall homepage carousel, product classification navigation and new product special sales developed by the WeChat mini-program mall. It has certain reference value. Friends in need can For reference, I hope it will be helpful to you.
Previous articleWe set up the https domain name setting of the mini program backend server, built the https framework based on the mini program and implemented the homepage navigation module. Let’s take a look at it today. Implementation of e-commerce home page carousel, category navigation and new product sale modules.
Implementation of functional modules
Mainly implement 2, 3, 4, API data services used As shown in the figure below:
Home page carousel module implementation
home.js
<!--首页轮播 banner --> <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}"> <block wx:for="{{banners}}"> <swiper-item> <image src="{{item.imgUrl}}" mode="widthFix"/> </swiper-item> </block> </swiper>
home.wxss
/* 直接设置swiper属性 */ swiper { height: 300rpx; } swiper-item image { width: 100%; height: 100%; }
home.js
Page initialization carousel data
data: { navbars:null,//接上篇导航初始化数据 currentTab: 0,//接上篇导航初始化数据 banners:null, indicatorDots: true, //是否显示面板指示点 autoplay: true, //是否自动切换 interval: 3000, //自动切换时间间隔,3s duration: 1000, // 滑动动画时长1s },
Page initialization loading carousel data function
/** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; //加载navbar导航条,接上篇导航数据 that.navbarShow(); //加载banner轮播 that.bannerShow(); },
ajax to obtain carousel data
bannerShow: function (success) { var that = this; ajax.request({ method: 'GET', url: 'home/banners?key=' + utils.key, success: data => { that.setData({ banners: data.result }) console.log(data.result) } }) },
Homepage classification navigation implementation
home.js
<!-- 分类导航 --> <view> <view class="navy"> <block wx:for-items="{{menus}}" wx:key="name"> <view class="nav-item" data-type="{{item.menuName}}" data-typeid="{{item.id}}"> <image src="{{item.imgUrl}}" class="nav-image" /> <text>{{item.menuName}}</text> </view> </block> </view> </view>
home.wxss
/*=================分类导航====================*/ .navs { display: flex; justify-content: left; flex-direction: row; flex-wrap: wrap; } .nav-item { width: 25%; display: flex; align-items: center; flex-direction: column; /* padding: 20rpx; */ padding-top: 20rpx; } .nav-item .nav-image { width: 80rpx; height: 80rpx; /* border-radius: 50%;设置边界圆角 */ } .nav-item text { padding-top: 20rpx; font-size: 25rpx; }
home.js
页面初始化分类导航数据
data: { navbars:null,//导航数据 currentTab: 0, banners:null, //轮播数据 indicatorDots: true, //是否显示面板指示点 autoplay: true, //是否自动切换 interval: 3000, //自动切换时间间隔,3s duration: 1000, // 滑动动画时长1s menus: null, //分类导航数据},
页面初始化加载分类导航数据函数
/** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; //加载navbar导航条 that.navbarShow(); //加载banner轮播 that.bannerShow(); //加载menu分类导航菜单 that.menuShow(); },
ajax获取分类导航数据
menuShow: function (success) { var that = this; ajax.request({ method: 'GET', url: 'home/menus?key='+ utils.key, success: data => { that.setData({ menus: data.result }) console.log(data.result) } }) },
首页新品特卖模块实现
home.js
<view class="separate"></view> <view class="cate-container"> <view class="category-title"> <text class="name">新品特卖</text> <view class="line_flag"></view> <block wx:for-items="{{brands}}" wx:key="id"> <navigator url="/pages/detail/detail"> <image class="head-img" src="{{item.imgUrl}}" mode="widthFix"></image> </navigator> <text class="brand-name">{{item.name}}</text> <view class='pas'> <image class="activity-logo" src="../../images/activity_logo.png" mode="widthFix"></image> {{item.remark}} </view> </block> </view> </view>
home.wxss
/*=================新品特卖 样式====================*/ .category-title { display: flex; flex-direction: column; margin-top: 20rpx; margin-bottom: 0rpx; padding: 0px 10px; } .category-title .title{ font-size: 14px; font-weight:900; } .category-title .line_name{ font-size: 10px; color: #98989f; display: flex; justify-content:space-between; } /* 分割线 */ .separate { height: 15rpx; background-color: #f2f2f2; } .category-title { display: flex; flex-direction: column; margin-top: 25rpx; margin-bottom: 0rpx; } .category-title .name { font-size: 40rpx; text-align: center; margin: 10rpx auto; } .line_flag { width: 80rpx; height: 1rpx; display: inline-block; margin: 20rpx auto; background-color: gainsboro; text-align: center; } .line { width: 100%; height: 2rpx; display: inline-block; margin: 20rpx 0rpx; background-color: gainsboro; text-align: center; } .head-img { width: 100%; } .brand-name{ font-weight: 600; font-size: 32rpx; } .activity-logo { width:35rpx; height:35rpx; margin-right: 10rpx; /* position: absolute; */ } .pms{ font-size: 28rpx; margin-bottom: 20rpx; display: flex; justify-content: left; flex-direction: row; color: #5771a8; }
home.js
页面初始化新品特卖数据
data: { navbars:null,//导航数据 currentTab: 0, banners:null, //轮播数据 indicatorDots: true, //是否显示面板指示点 autoplay: true, //是否自动切换 interval: 3000, //自动切换时间间隔,3s duration: 1000, // 滑动动画时长1s menus: null, //分类导航数据 brands: null, //新品特卖数据},
页面初始化加载新品特卖数据函数
/** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; //加载navbar导航条 that.navbarShow(); //加载banner轮播 that.bannerShow(); //加载menu分类导航菜单 that.menuShow(); //加载新品特卖 that.brandShow(); },
ajax获取新品特卖数据
brandShow: function (success) { var that = this; ajax.request({ method: 'GET', url: 'activity/brands? key='+utils.key+'&type=temai&page=1&size=5', success: data => { that.setData({ brands: data.result.list }) console.log("brands:" + data.result.list) } }) },
实现效果预览
备注:本文是为了更好的让大家能够有模块化的思维来实现改电商案例,后续依然会采用这种方式,因为更贴近与实际工作场景,也让自己的编码更加的规范增加可阅读性。
相关推荐:
微信小程序商城开发之https框架的搭建以及顶部和底部导航的实现
The above is the detailed content of Implementation code for mall home page carousel, product classification navigation and new product special sales developed by WeChat mini program mall. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Xianyu's official WeChat mini program has quietly been launched. In the mini program, you can post private messages to communicate with buyers/sellers, view personal information and orders, search for items, etc. If you are curious about what the Xianyu WeChat mini program is called, take a look now. What is the name of the Xianyu WeChat applet? Answer: Xianyu, idle transactions, second-hand sales, valuations and recycling. 1. In the mini program, you can post idle messages, communicate with buyers/sellers via private messages, view personal information and orders, search for specified items, etc.; 2. On the mini program page, there are homepage, nearby, post idle, messages, and mine. 5 functions; 3. If you want to use it, you must activate WeChat payment before you can purchase it;

WeChat applet implements picture upload function With the development of mobile Internet, WeChat applet has become an indispensable part of people's lives. WeChat mini programs not only provide a wealth of application scenarios, but also support developer-defined functions, including image upload functions. This article will introduce how to implement the image upload function in the WeChat applet and provide specific code examples. 1. Preparatory work Before starting to write code, we need to download and install the WeChat developer tools and register as a WeChat developer. At the same time, you also need to understand WeChat

The official WeChat mini program of Xianyu has been quietly launched. It provides users with a convenient platform that allows you to easily publish and trade idle items. In the mini program, you can communicate with buyers or sellers via private messages, view personal information and orders, and search for the items you want. So what exactly is Xianyu called in the WeChat mini program? This tutorial guide will introduce it to you in detail. Users who want to know, please follow this article and continue reading! What is the name of the Xianyu WeChat applet? Answer: Xianyu, idle transactions, second-hand sales, valuations and recycling. 1. In the mini program, you can post idle messages, communicate with buyers/sellers via private messages, view personal information and orders, search for specified items, etc.; 2. On the mini program page, there are homepage, nearby, post idle, messages, and mine. 5 functions; 3.

To implement the drop-down menu effect in WeChat Mini Programs, specific code examples are required. With the popularity of mobile Internet, WeChat Mini Programs have become an important part of Internet development, and more and more people have begun to pay attention to and use WeChat Mini Programs. The development of WeChat mini programs is simpler and faster than traditional APP development, but it also requires mastering certain development skills. In the development of WeChat mini programs, drop-down menus are a common UI component, achieving a better user experience. This article will introduce in detail how to implement the drop-down menu effect in the WeChat applet and provide practical

How to use PHP to develop the second-hand transaction function of WeChat applet? As a popular mobile application development platform, WeChat applet is used by more and more developers. In WeChat mini programs, second-hand transactions are a common functional requirement. This article will introduce how to use PHP to develop the second-hand transaction function of the WeChat applet and provide specific code examples. 1. Preparation work Before starting development, you need to ensure that the following conditions are met: the development environment of the WeChat applet has been set up, including registering the AppID of the applet and setting it in the background of the applet.

Use the WeChat applet to achieve the carousel switching effect. The WeChat applet is a lightweight application that is simple and efficient to develop and use. In WeChat mini programs, it is a common requirement to achieve carousel switching effects. This article will introduce how to use the WeChat applet to achieve the carousel switching effect, and give specific code examples. First, add a carousel component to the page file of the WeChat applet. For example, you can use the <swiper> tag to achieve the switching effect of the carousel. In this component, you can pass b

Implementing picture filter effects in WeChat mini programs With the popularity of social media applications, people are increasingly fond of applying filter effects to photos to enhance the artistic effect and attractiveness of the photos. Picture filter effects can also be implemented in WeChat mini programs, providing users with more interesting and creative photo editing functions. This article will introduce how to implement image filter effects in WeChat mini programs and provide specific code examples. First, we need to use the canvas component in the WeChat applet to load and edit images. The canvas component can be used on the page

To implement the picture rotation effect in WeChat Mini Program, specific code examples are required. WeChat Mini Program is a lightweight application that provides users with rich functions and a good user experience. In mini programs, developers can use various components and APIs to achieve various effects. Among them, the picture rotation effect is a common animation effect that can add interest and visual effects to the mini program. To achieve image rotation effects in WeChat mini programs, you need to use the animation API provided by the mini program. The following is a specific code example that shows how to
