当前位置: 首页 > news >正文

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

在这里插入图片描述

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.lryc.cn/news/519960.html

相关文章:

  • 详细全面讲解C++中重载、隐藏、覆盖的区别
  • 一文读懂单片机的串口
  • HTML5 网站模板
  • mybatis分页插件:PageHelper、mybatis-plus-jsqlparser(解决SQL_SERVER2005连接分页查询OFFSET问题)
  • uniapp中rpx和upx的区别
  • 什么是卷积网络中的平移不变性?平移shft在数据增强中的意义
  • java.net.SocketException: Connection reset 异常原因分析和解决方法
  • Maven 仓库的分类
  • 隧道网络:为数据传输开辟安全通道
  • CentOS 7 下 Nginx 的详细安装与配置
  • JAVA 使用apache poi实现EXCEL文件的输出;apache poi实现标题行的第一个字符为红色;EXCEL设置某几个字符为别的颜色
  • 通过vba实现在PPT中添加计时器功能
  • 检验统计量与p值笔记
  • 【集成学习】Bagging、Boosting、Stacking算法详解
  • Rabbit Rocket kafka 怎么实现消息有序消费和延迟消费的
  • 【Ubuntu与Linux操作系统:五、文件与目录管理】
  • 32_Redis分片集群原理
  • 微信小程序mp3音频播放组件,仅需传入url即可
  • Sql 创建用户
  • 数据结构:LinkedList与链表—面试题(三)
  • 【开发日记】Docker修改国内镜像源
  • Elasticsarch:使用全文搜索在 ES|QL 中进行过滤 - 8.17
  • 第432场周赛:跳过交替单元格的之字形遍历、机器人可以获得的最大金币数、图的最大边权的最小值、统计 K 次操作以内得到非递减子数组的数目
  • RK3399开发板Linux实时性改造
  • 青少年编程与数学 02-006 前端开发框架VUE 22课题、状态管理
  • Linux 内核中的 netif_start_queue 函数:启动网络接口发送队列的关键
  • 数据结构之顺序结构二叉树(超详解)
  • acwing_5722_十滴水
  • acwing-3194 最大的矩形
  • UnityDemo-TheBrave-制作笔记