


The content of this article is about the construction of the https framework and the implementation of top and bottom navigation for the development of WeChat mini program mall. It has certain reference value. Friends in need can refer to it. I hope it will be useful to you. helped. <br>
The previous mini program mall series has been updated to the shopping cart module, but many readers have reported how it can be closer to actual combat scenarios, dynamically obtain data and display it! So after this period of preparation, we started to make a new micro-mall version, which was developed completely according to the work scenario.
Mini program https domain name configuration
Log in to the registered WeChat mini program official account and log in to the platform——>Settings——>Development settings, as shown in the figure below:
<br>
Note: https://100boot.cn is a certified domain name, you can use it with confidence.
Create a mini program project and encapsulate ajax requests
To create a mini program project, you can refer to the article WeChat mini program e-commerce practice-getting started
New ajax.js
#目录结构-pages --utils ---ajax.js
Declare api global variable calling address
const api = 'https://100boot.cn/wxShop/';
Encapsulate request request
wx.request({ method: opt.method || 'GET', url: api + opt.url, header: { 'content-type': 'application/json' // 默认值 }, data: opt.data, success: function (res) { if (res.data.code == 100) { if (opt.success) { opt.success(res.data); } } else { console.error(res); wx.showToast({ title: res.data.message, }) } } }) }module.exports.request = request
Configure developer key
Open utils/util.js, add key
module.exports = { formatTime: formatTime, key: '开发者key' }
WeChat Mini Program Micro Mall: Developer key acquisition
app.json
{ "pages": [ "pages/home/home", "pages/cart/cart", "pages/detail/detail", "pages/classify/classify", "pages/mine/mine", "pages/index/index", "pages/logs/logs" ], "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#f0145a", "navigationBarTitleText": "微商城", "backgroundColor": "#f0145a" }, "tabBar": { "color": "#858585", "selectedColor": "#f0145a", "backgroundColor": "#ffffff", "borderStyle": "#000", "list": [ { "pagePath": "pages/home/home", "iconPath": "images/home.png", "selectedIconPath": "images/home_select.png", "text": "首页" }, { "pagePath": "pages/classify/classify", "iconPath": "images/classify.png", "selectedIconPath": "images/classify_select.png", "text": "分类" }, { "pagePath": "pages/cart/cart", "iconPath": "images/cart.png", "selectedIconPath": "images/cart_select.png", "text": "购物车" }, { "pagePath": "pages/mine/mine", "iconPath": "images/mine.png", "selectedIconPath": "images/mine_select.png", "text": "我的" } ] } }
app.wxss
.container { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 200rpx 0; box-sizing: border-box; }
home.wxml
<!--导航条--> <view class="navbar"> <text wx:for="{{navbars}}" data-idx="{{index}}" class="item {{currentTab==index ? 'active' : ''}}" wx:key="unique" bindtap="navbarTap">{{item.navbarName}}</text> </view>
home.wxss
page{ display: flex; flex-direction: column; height: 100%; } .navbar{ flex: none; display: flex; background: #fff; } .navbar .item{ position: relative; flex: auto; text-align: center; line-height: 80rpx; font-size:14px; } /* 顶部导航字体颜色 */ .navbar .item.active{ color: #f0145a; } /* 顶部指示条属性 */ .navbar .item.active:after{ content: ""; display: block; position: absolute; bottom: 0; left: 0; right: 0; height: 6rpx; background: #f0145a; }
home.js
Reference ajax and utils public js
const ajax = require('../../utils/ajax.js'); const utils = require('../../utils/util.js');
Page initialization navigation data
data: { navbars:null, currentTab: 0, },
Page initialization loading navigation data Function
/** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; //加载navbar导航条 that.navbarShow(); },
ajax gets navigation data<br>
navbarShow:function(success){ var that = this; ajax.request({ method: 'GET', url: 'home/navBar?key=' + utils.key, success: data => { that.setData({ navbars: data.result }) console.log(data.result) } }) },
The effect is as follows
<br>
Related Recommended:
WeChat Mini Program Shopping Mall System Development Series - Tools<br>
WeChat Development Demo and Practical Mall Development
The above is the detailed content of Construction of https framework for WeChat mini program mall development and implementation of top and bottom navigation. For more information, please follow other related articles on the PHP Chinese website!

本篇文章给大家带来了关于微信小程序的相关问题,其中主要介绍了关于基础架构原理的相关内容,其中包括了宿主环境、执行环境、小程序整体架构、运行机制、更新机制、数据通信机制等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于微信小程序的相关知识,其中主要介绍了关于云服务的配置详解,包括了创建使用云开发项目、搭建云环境、测试云服务等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于微信小程序的相关知识,其中主要介绍了关于富文本编辑器的实战示例,包括了创建发布页面、实现基本布局、实现编辑区操作栏的功能等内容,下面一起来看一下,希望对大家有帮助。

西安坐地铁用的小程序为“乘车码”。使用方法:1、打开手机微信客户端,点击“发现”中的“小程序”;2、在搜索栏中输入“乘车码”进行搜索;3、直接定位城市西安,或者搜索西安,点击“西安地铁乘车码”选项的“去乘车”按钮;4、根据腾讯官方提示进行授权,开通“乘车码”业务即可利用该小程序提供的二维码来支付乘车了。

本篇文章给大家带来了关于微信小程序的相关知识,其中主要介绍了怎么实现小程序授权登录功能的相关内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于微信小程序的相关问题,其中主要介绍了关于开发工具介绍的相关内容,包括了下载开发工具以及编辑器总结等内容,下面一起来看一下,希望对大家有帮助。


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

WebStorm Mac version
Useful JavaScript development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver Mac version
Visual web development tools

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