校园跑腿小程序---轮播图,导航栏开发

在这里插入图片描述

hello hello~ ,这里是 code袁~💖💖 ,欢迎大家点赞🥳🥳关注💥💥收藏🌹🌹🌹

🦁作者简介:一名喜欢分享和记录学习的在校大学生
💥个人主页:code袁的博客
💥 个人QQ:2647996100
🐯 个人wechat:code8896
code袁系列专栏导航
1.《毕业设计与课程设计》本专栏分享一些毕业设计的源码以及项目成果。🥰🥰🥰
2.《微信小程序开发》本专栏从基础到入门的一系开发流程,并且分享了自己在开发中遇到的一系列问题。🤹🤹🤹
3.《vue开发系列全程线路》本专栏分享自己的vue的学习历程。

非常期待和您一起在这个小小的互联网世界里共同探索、学习和成长。💝💝💝 ✨✨ 欢迎订阅本专栏 ✨✨ 

在这里插入图片描述

文章目录

      • 1.底部导航栏
      • 2.小程序的组件封装
        • 2.1页面引入组件
      • 3.轮播图的封装
      • 4.通知栏的封装
      • 5.request.js封装
      • 6.api
      • 7.time.js封装
      • 🎉写在最后

B站 教学视频

B站:校园跑图小程序开发

1.底部导航栏

在这里插入图片描述

"tabBar": {"color": "2c2c2c","selectedColor": "#1296db","borderStyle": "black","position": "bottom","list": [{"pagePath": "pages/index/index","text": "首页","iconPath": "./image/tabr/index.png","selectedIconPath": "./image/tabr/index1.png"},{"pagePath": "pages/order/order","text": "订单","iconPath": "./image/tabr/order.png","selectedIconPath": "./image/tabr/order1.png"},{"pagePath": "pages/talk/talk","text": "论坛","iconPath": "./image/tabr/talk.png","selectedIconPath": "./image/tabr/talk1.png"},{"pagePath": "pages/my/my","text": "我的","iconPath": "./image/tabr/my.png","selectedIconPath": "./image/tabr/my1.png"}]}

2.小程序的组件封装

在这里插入图片描述

2.1页面引入组件

在这里插入图片描述

{"usingComponents": {"swiper":"../../components/swiper/swiperImg"}
}

在这里插入图片描述

3.轮播图的封装

<view class="banner"><swiper class="swip_main" indicator-dots autoplay interval="5000" circular><block wx:for="{{mglist}}"><swiper-item><image style="width: 100%;height: 100%;border-radius: 30rpx;" mode="scaleToFill" src="{{item.imgUrl}}" data-src="{{item.imgUrl}}" catchtap="previewImage"></image></swiper-item></block></swiper>
</view>
.banner{width: 96%;height: 350rpx;margin: 15rpx auto;border-radius: 20rpx
}
.swip_main{width: 100%;height: 100%;
}
// components/swiper/swiperImg.js
Component({/*** 组件的属性列表*/properties: {mglist:{type:Array,value:[]}},/*** 组件的初始数据*/data: {mglist:[]},/*** 组件的方法列表*/methods: {}
})

4.通知栏的封装

<view class="tz"><view class="tz_zp"><image src="../../image/gg.png"></image></view><swiper class="swiper-news-top" vertical="true" autoplay="true" circular="true" interval="3000"><block wx:for="{{messageList}}"><navigator url="" open-type="navigate"><swiper-item><view class="swiper_item">{{item.content}}</view></swiper-item></navigator></block></swiper>
</view>
/* components/notice/notice.wxss */
.tz{width: 95%;height: 80rpx;background-color: white;margin-top: 20rpx;margin: 0 auto;display: flex;justify-content: flex-start;box-shadow: 0 0 15px rgb(0 0 0 / 20%);
}
.tz_zp{width: 50rpx;height: 50rpx;margin-top: 15rpx;margin-left: 10rpx;float: left;
}
.tz_zp image{width: 100%;height: 100%;
}
.swiper-news-top{width: 550rpx;height: 80rpx;float: right;margin-top: 10rpx;
}
.swiper_item {font-size: 28rpx;font-weight: 700;line-height: 80rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;letter-spacing: 2px;text-align: center;color: #167BF9;}
// components/notice/notice.js
Component({/*** 组件的属性列表*/properties: {messageList:{type:Array,value:[]}},/*** 组件的初始数据*/data: {messageList:[]},/*** 组件的方法列表*/methods: {}
})

5.request.js封装

在这里插入图片描述

// 配置的域名
const baseUrl = "http://localhost:3000" // 请求公共接口// 封装请求
// 封装请求
module.exports = {request: (url, method, data) => {return new Promise((resolve, reject) => {wx.showLoading({title: '加载中',});wx.request({url: `${baseUrl}${url}`,data: data,method: method,header: {'content-type': (method === 'GET') ? 'application/x-www-form-urlencoded' : 'application/json','Cookie': wx.getStorageSync('Cookie') || ''},success: (res) => {// console.log('原始响应:', res); // 打印原始响应if (res.statusCode === 200) {// 处理 Cookieif (res.cookies && res.cookies.length > 0) {wx.setStorageSync('Cookie', res.cookies[0]); // 存储 Cookie}// 成功返回值// console.log('返回数据:', res.data); // 打印返回的数据if (res.data.code === 200) {resolve(res.data); // 确保这里返回的是 data} else {wx.showToast({title: res.data.message || '请求失败',icon: 'none'});reject(res.data.message);}} else {wx.showToast({title: '请求失败,请稍后再试',icon: 'none'});reject('请求失败');}},fail: (error) => {console.error('请求失败:', error); // 打印请求失败的错误wx.showToast({title: '网络错误,请检查网络',icon: 'none'});reject(error);},complete: () => {setTimeout(() => {wx.hideLoading();}, 100);},});});},
}

6.api

在这里插入图片描述

const {request
} = require('../utils/request')//基于业务封装的接口
module.exports = {// 获取轮播图
login: (data) => {return request('/login/login', 'POST',data);}
}

7.time.js封装

在这里插入图片描述

const formatTime = date => {const year = date.getFullYear()const month = date.getMonth() + 1const day = date.getDate()const hour = date.getHours()const minute = date.getMinutes()const second = date.getSeconds()return `${[year, month, day].map(formatNumber).join('-')} ${[hour, minute, second].map(formatNumber).join(':')}`}function getLastSevenDays() {const dates = [];const today = new Date();for (let i = 0; i < 7; i++) {const pastDate = new Date(today);pastDate.setDate(today.getDate() - i);const month = String(pastDate.getMonth() + 1).padStart(2, '0'); // 获取月份并补零const day = String(pastDate.getDate()).padStart(2, '0'); // 获取日期并补零dates.push(`${month}-${day}`); // 格式化为 MM-DD}return dates;
}
function getLastSevenDaysALL() {const dates = [];const today = new Date();for (let i = 0; i < 7; i++) {const pastDate = new Date(today);pastDate.setDate(today.getDate() - i);const formattedDate = pastDate.toISOString().split('T')[0]; // 格式化为 YYYY-MM-DDdates.push(formattedDate);}return dates;
}const formatNumber = n => {n = n.toString()return n[1] ? n : `0${n}`}    //获取星期const getWeekByDate = dates => {let show_day = new Array('周日', '周一', '周二', '周三', '周四', '周五', '周六');let date = new Date(dates);date.setDate(date.getDate());let day = date.getDay();return show_day[day];}module.exports = {formatTime: formatTime,getLastSevenDays:getLastSevenDays,getWeekByDate: getWeekByDate,getLastSevenDaysALL:getLastSevenDaysALL}

🎉写在最后

🍻伙伴们,如果你已经看到了这里,觉得这篇文章有帮助到你的话不妨点赞👍或 Star ✨支持一下哦!手动码字,如有错误,欢迎在评论区指正💬~

你的支持就是我更新的最大动力💪~
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/986.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

前端练习题

图片&#xff1a; 代码&#xff1a; <!DOCTYPE html> <html> <head><meta charset"UTF-8"><title>用户信息页面</title><style>body {font-family: Arial, sans-serif;margin: 20px;}.user-info {display: flex;align-it…

AllData是怎么样的一款数据中台产品?

&#x1f525;&#x1f525; AllData大数据产品是可定义数据中台&#xff0c;以数据平台为底座&#xff0c;以数据中台为桥梁&#xff0c;以机器学习平台为中层框架&#xff0c;以大模型应用为上游产品&#xff0c;提供全链路数字化解决方案。 ✨奥零数据科技官网&#xff1a;…

一学就废|Python基础碎片,OS模块

Python 中的操作系统模块提供了与操作系统交互的功能。操作系统属于 Python 的标准实用程序模块。该模块提供了一种使用依赖于操作系统的功能的可移植方式。os和os. path模块包括许多与文件系统交互的函数。 Python-OS 模块函数 我们将讨论 Python os 模块的一些重要功能&…

2.Numpy练习(1)

一.练习一&#xff1a; 1.打印当前numpy版本&#xff1a; 2.构造一个全零的矩阵&#xff0c;并打印其占用内存大小&#xff1a; 3.打印一个函数的帮助文档&#xff0c;比如numpy.add&#xff1a; 4.创建一个10~49数组&#xff0c;并将其倒序排列: 5.找到一个数组中不为0的索引…

Ubuntu Server挂载AWS S3成一个本地文件夹

2023年&#xff0c;AWS出了个mountpoint的工具&#xff1a; https://github.com/awslabs/mountpoint-s3 如下是另外一种方式&#xff0c;通过s3fs-fuse 这个工具 sudo apt-get install automake autotools-dev \fuse g git libcurl4-gnutls-dev libfuse-dev \libssl-dev libx…

CSS3的aria-hidden学习

前言 aria-hidden 属性可用于隐藏非交互内容&#xff0c;使其在无障碍 API 中不可见。即当aria-hidden"true" 添加到一个元素会将该元素及其所有子元素从无障碍树中移除&#xff0c;这可以通过隐藏来改善辅助技术用户的体验&#xff1a; 纯装饰性内容&#xff0c;如…

nvm use使用nodejs版本时报错

文章目录 报错原因分析解决方法 报错 nvm use报错出现乱码&#xff1a; 比如nvm use 22.12.0&#xff0c;出现下面报错&#xff1a; exit status 1: ‘D:\Program’ &#xfffd;&#xfffd;&#xfffd;&#xfffd;&#xfffd;ڲ&#xfffd;&#xfffd;&#xfffd;&…

C++中线程同步与互斥的4种方式介绍、对比、场景举例

在C中&#xff0c;当两个或更多的线程需要访问共享数据时&#xff0c;就会出现线程安全问题。这是因为&#xff0c;如果没有适当的同步机制&#xff0c;一个线程可能在另一个线程还没有完成对数据的修改就开始访问数据&#xff0c;这将导致数据的不一致性和程序的不可预测性。为…

1、docker概念和基本使用命令

docker概念 微服务&#xff1a;不再是以完整的物理机为基础的服务软件&#xff0c;而是借助于宿主机的性能。以小量的形式&#xff0c;单独部署的应用。 docker&#xff1a;是一个开源的应用容器引擎&#xff0c;基于go语言开发的&#xff0c;使用时apache2.0的协议。docker是…

信息安全、网络安全和数据安全的区别和联系

信息安全、网络安全和数据安全是信息安全领域的三大支柱&#xff0c;它们之间既存在区别又相互联系。以下是对这三者的详细比较&#xff1a; 一.区别 1.信息安全 定义 信息安全是指为数据处理系统建立和采用的技术和管理的安全保护&#xff0c;保护计算机硬件、软件和数据不…

Linux网络编程5——多路IO转接

一.TCP状态时序理解 1.TCP状态理解 **CLOSED&#xff1a;**表示初始状态。 **LISTEN&#xff1a;**该状态表示服务器端的某个SOCKET处于监听状态&#xff0c;可以接受连接。 **SYN_SENT&#xff1a;**这个状态与SYN_RCVD遥相呼应&#xff0c;当客户端SOCKET执行CONNECT连接时…

【Linux网络编程】数据链路层 | MAC帧 | ARP协议

前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。点击跳转到网站 &#x1f308;个人主页&#xff1a; 南桥几晴秋 &#x1f308;C专栏&#xff1a; 南桥谈C &#x1f308;C语言专栏&#xff1a; C语言学习系…

React Fiber框架中的Render渲染阶段——workLoop(performUnitOfWork【beginWork与completeWork】)

触发渲染过程——renderRoot renderRoot 是一个函数&#xff0c;用于触发渲染工作。它通常会调用并递归地执行一系列的渲染任务&#xff0c;直到完成整个更新过程。这个过程包括执行 Fiber 树中的 beginWork 和 completeWork&#xff0c;以及渲染新状态或 DOM。 function ren…

STM32裸机开发转FreeRTOS教程

目录 1. 简介2. RTOS设置&#xff08;1&#xff09;分配内存&#xff08;2&#xff09;查看任务剩余空间&#xff08;3&#xff09;使用osDelay 3. 队列的使用&#xff08;1&#xff09;创建队列&#xff08;1&#xff09;直接传值和指针传值&#xff08;2&#xff09;发送/接收…

Elasticsearch快速入门

Elasticsearch是由elastic公司开发的一套搜索引擎技术&#xff0c;它是elastic技术栈中的一部分,提供核心的数据存储、搜索、分析功能 elasticsearch之所以有如此高性能的搜索表现&#xff0c;正是得益于底层的倒排索引技术。那么什么是倒排索引呢&#xff1f; Elasticsearch…

新版AndroidStudio通过系统快捷创建带BottomNavigationView的项目踩坑记录

选择上面这个玩意创建的项目 坑点1 &#xff1a;配置的写法和不一样了 镜像的写法&#xff1a; 新的settings.gradle.kts中配置镜像的代码&#xff1a; pluginManagement {repositories {mavenCentral()google {content {includeGroupByRegex("com\\.android.*")…

Unity 自定义批量打包工具

打包配置项 using UnityEngine; using System.Collections.Generic;namespace MYTOOL.Build {/// <summary>/// 批量打包配置文件/// </summary>[CreateAssetMenu]public class BatchBuildProfile : ScriptableObject{public List<BuildTask> tasks new Li…

【JVM-2.3】深入解析JVisualVM:Java性能监控与调优利器

在Java应用的开发和运维过程中&#xff0c;性能监控与调优是不可或缺的环节。无论是排查内存泄漏、分析CPU瓶颈&#xff0c;还是优化线程使用&#xff0c;开发者都需要借助一些强大的工具来辅助诊断。JVisualVM 正是这样一款由Oracle提供的免费工具&#xff0c;它集成了多种性能…

基于大语言模型的组合优化

摘要&#xff1a;组合优化&#xff08;Combinatorial Optimization, CO&#xff09;对于提高工程应用的效率和性能至关重要。随着问题规模的增大和依赖关系的复杂化&#xff0c;找到最优解变得极具挑战性。在处理现实世界的工程问题时&#xff0c;基于纯数学推理的算法存在局限…

计算机网络 (40)域名系统DNS

前言 计算机网络域名系统DNS&#xff08;Domain Name System&#xff09;是互联网的基础技术之一&#xff0c;它负责将人类可读的域名转换为计算机用来通信的数字IP地址。 一、基本概念 DNS的主要目的是将域名解析或翻译为IP地址&#xff0c;使得用户可以通过简单易记的域名来访…