基于vue的商城小程序的毕业设计与实现(源码及报告)
环境搭建 ☞☞☞ Vue入手篇(一),防踩雷(全网最详细教程)_vue force-CSDN博客
目录
一、功能介绍
二、登录注册功能
三、首页
四、项目截图
五、源码获取
一、功能介绍
- 用户信息展示:页面顶部设有用户头像和昵称展示区,方便用户识别自己的账号信息。
- 搜索功能:配备有搜索栏,用户可以通过输入关键词来查找并可以删除历史查找记录。
- 商品分类:商品分为豆干制品、饼干点心、酒水饮料等
- 商品展示与选择:页面中间部分以缩略图形式展示多个商品,方便选择。每个商品下方附有价格标签并可以修改商品数量,已选商品会加入到购物车中。
- 购物结算:页面底部设有“选好了”红色按钮,然后在结算页面完成支付流程。
- 我的订单:查看订单内容。
- 登录和注册功能。
二、登录注册功能
页面代码
<template><div class="warp"><div class="container"><div ref="formBox" class="form-box"> <!-- 注册 --> <div ref="registerBox" class="register-box hidden"> <h1>register</h1> <input type="text" placeholder="请输入用户名" v-model="username"> <input type="password" placeholder="请输入密码" v-model="password"> <input type="password" placeholder="确认密码"> <button @click="register">注册</button> </div> <!-- 登录 --> ①<div ref="loginBox" class="login-box"> <h1>login</h1> <input type="text" v-model="Lusername" placeholder="请输入用户名"> <input type="password" v-model="Lpassword" placeholder="请输入密码"> <button @click="login">登录</button> </div> </div> <div class="con-box left"><h2><span>注册页面</span></h2><p>快来注册<span>账号</span>吧</p><img src="../../static/images/1.jpg" alt="" /><p>已有账号</p><button id="login" @click="switchToLogin">去登录</button></div><div class="con-box right"><h2><span>登录页面</span></h2><p>快来登录<span>账号</span>吧</p><img src="../../static/images/2.jpg" alt="" /><p>没有账号?</p><button id="register" @click="switchToRegister">去注册</button></div></div> </div>
</template>
功能实现
<script>
export default { data() { return { // 注册表单数据 username: '', password: '', // 登录表单数据 Lusername: '', Lpassword: '' }; },methods: { // 登录函数 login() { const storedUsername = uni.getStorageSync('username'); const storedPassword = uni.getStorageSync('password'); if (!this.Lusername || !this.Lpassword) { uni.showToast({ title: '账号密码为空', icon: 'none' }); return; } if (this.Lusername === storedUsername && this.Lpassword === storedPassword) { // 账号密码一致,跳转到 /index 页面 uni.navigateTo({ url: '/pages/index/index' }); } else if (this.Lusername === storedUsername) { // 账号正确,密码错误 uni.showToast({ title: '密码错误', icon: 'none' }); } else { // 账号不一致 uni.showToast({ title: '未检测到该账号', icon: 'none' }); } }, // 注册函数 register() { if (this.username && this.password) { console.log(this.username); console.log(this.password); // 将用户名和密码存储到localStorage中uni.setStorageSync('username', this.username); uni.setStorageSync('password', this.password); uni.showToast({ title: '注册成功!', icon: 'success' }); this.switchToLogin(); } else { uni.showToast({ title: '用户名和密码不能为空!', icon: 'none' }); } }, // 切换到注册界面的函数 switchToRegister() { this.$refs.formBox.style.transform = 'translateX(100%)'; this.$refs.loginBox.classList.add('hidden'); this.$refs.registerBox.classList.remove('hidden'); }, // 切换到登录界面的函数 switchToLogin() { this.$refs.formBox.style.transform = 'translateX(0%)'; this.$refs.registerBox.classList.add('hidden'); this.$refs.loginBox.classList.remove('hidden'); }, },
};
</script>
注册时的用户名和密码要和登录时保持一致即可登陆成功
三、首页
头部代码
<template><view class="customHead" :style="{height:totalHeight+'px'}"><view class="bg"><image class="bgimg" src="../../static/images/1.jpg" mode="aspectFill"></image></view> <view class="container"><view class="statusBar" :style="{height:statusBarHeight+'px'}"></view><view class="service" :style="{height:titleBarHeight+'px'}" v-if="!foldState"><view class="kefu"><u-icon name="server-fill" size="22" color="#fff"></u-icon></view></view><view class="body" :class="foldState?'fold':''" :style="{height:bodyBarHeight+'px'}"><view class="brand"><view class="pic"><image class="img" src="../../static/images/DJ2.jpg" mode="aspectFill"></image></view><view class="text"><view class="title"><text class="font">微信搜'K学啦'</text><u-icon class="icon" name="more-circle" size="22" color="#fff"></u-icon></view><view class="des">各项目源代码私聊,接期末毕设</view></view></view><view class="code"><view class="pic"><image class="img" src="../../static/images/qrcode.png" mode="aspectFill"></image></view><text class="pay">付款</text></view></view></view></view>
</template><script>import {mapState,mapGetters} from "vuex"export default {name:"custom-head-bar",data() {return {};},computed:{...mapGetters(["statusBarHeight","titleBarHeight","bodyBarHeight","totalHeight","foldState"])},props:{} }
</script><style lang="scss">
.customHead{height: 400rpx;overflow: hidden;position: relative;.bg{width: 100%;height: 100%;background: #000;.bgimg{width: 100%;height: 100%;filter: blur(30rpx);transform: scale(2);}}.container{position: absolute;top:0;left:0; width: 100%;.statusBar{ }.service{ padding-left: 30rpx;@include flex-box-set(start);color:#fff;.manage{margin-left:20rpx;@include flex-box-set(start);}}.body{@include flex-box();padding:0 45rpx;height: 100px; transition: 0.3s; .brand{width: 580rpx;@include flex-box-set(start);.pic{width: 110rpx;height: 110rpx;border-radius: 50%;overflow: hidden;transition: 0.3s;.img{width: 100%;height: 100%;}}.text{flex:1;padding:0 30rpx;color:#fff;.title{font-size: 36rpx;font-weight: 800; display: flex;align-items: center;.font{margin-right:10rpx;}}.des{font-size: 26rpx;width: 100%;opacity: 0.8;padding-top:5rpx;@include ellipsis()}}} .code{width: 80rpx;height: 80rpx;border-left:1px solid rgba(255,255,255,0.6);@include flex-box-set(between);flex-direction: column;.pic{width: 40rpx;height: 40rpx;.img{width: 100%;height: 100%;}}.pay{font-size: 22rpx;color:#fff;text-align: center;}} &.fold{padding:0 30rpx;.brand{.pic{width: 60rpx;height: 60rpx; }.text{padding-left:15rpx;.title{font-size: 28rpx;.icon{transform: scale(0.9);}}.des{display: none;}}}.code{display: none;}}}}}
</style>
下部代码
<template><view class="home"><custom-head-bar id="customHeadBar"></custom-head-bar><view class="wrapper"><view class="infoModel"><view class="left">免费配送</view><navigator url="/pages/order/order" class="right"><u-icon name="order" color="#576b95" size="22"></u-icon>我的订单</navigator></view><view class="scrollLayout"><view class="leftScroll"><scroll-view scroll-y class="sContent" :scroll-top="leftScrollValue"><view class="navitem" :class="index==navIdx?'active':''" v-for="(item,index) in dataList":key="item.id"@click="clickNav(index)">{{item.name}}</view></scroll-view></view><view class="rightScroll"><navigator url="/pages/search/search" class="searchView"><u-icon name="search" size="22" color="#576b95"></u-icon>搜索</navigator><scroll-view @scroll="rightScrollEnt" :scroll-top="rightScrollValue" scroll-y scroll-with-animationclass="sContent"><view class="productView" v-for="item in dataList"><u-sticky :customNavHeight="0" zIndex="2"><view class="proTitle">{{item.name}}</view></u-sticky><view class="proContent"><view class="proitem" v-for="pro in item.children"><product-item :item="pro"></product-item></view></view></view></scroll-view></view></view></view><car-layout v-if="buyNum>0"></car-layout></view>
</template><script>import {mapState,mapMutations,mapGetters} from "vuex"export default {data() {return {navIdx: 0,leftScrollValue: 0,rightScrollValue: 0,leftHitArr: [],rightHitArr: [],foldState: false,dataList: [{id: 1,name: "豆干制品",children: [{id: 11,name: "魔芋~爽!",price: 10,before_price: 22,thumb: "https://img1.baidu.com/it/u=3237764698,677787850&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500",numvalue:0}, {id: 12,name: "卫龙大面筋",price: 5,before_price: 12,thumb: "https://pic.rmb.bdstatic.com/bjh/0eecefb60e7b7c6c68ec6377ddb7025b7289.jpeg@h_1280",numvalue:0}]}, {id: 2,name: "饼干点心",children: [{id: 21,name: "奥利给饼干",price: 13,before_price: 22,thumb: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.alicdn.com%2Fimgextra%2Fi1%2F2200633062791%2FO1CN01WIfNhU1WUKGKS3ZnC_%21%212200633062791-0-scmitem6000.jpg_640x640.jpg&refer=http%3A%2F%2Fimg.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1720103940&t=0705e091433d282ae43ecb0f392b54bf",numvalue:0},{id: 22,name: "丹麦皇家曲奇",price: 50,before_price: 100,thumb: "https://btob.guangbo.net/uploadfile/all/image/20211118/20211118161710769_1637223429028.png",numvalue:0},{id: 23,name: "奶油小蛋糕",price: 33,before_price: 66,thumb: "https://img1.baidu.com/it/u=2341784055,4263735026&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=667",numvalue:0}]}, {id: 3,name: "酒水饮料",children: [{id: 31,name: "诺文斯基核动力金牌格瓦斯",price: 18,before_price: 29,thumb: "http://img.eftarkov.com/upFiles/infoImg/202309301632468882.png",numvalue:0},{id: 32,name: "Pevko Light瓶装啤酒",price: 33,before_price: 66,thumb: "http://img.eftarkov.com/upFiles/infoImg/202309301624428851.png",numvalue:0},{id: 33,name: "Dan Jackiel瓶装威士忌",price: 66,before_price: 99,thumb: "http://img.eftarkov.com/upFiles/infoImg/202309301607342250.png",numvalue:0},{id: 34,name: "Tarkovskaya瓶装伏特加",price: 100,before_price: 200,thumb: "http://img.eftarkov.com/upFiles/infoImg/202309301613404375.png",numvalue:0},{id: 35,name: "凶狠跑刀崽-月光【私酒】",price: 9999,before_price: 99999,thumb: "https://tse3-mm.cn.bing.net/th/id/OIP-C.1_lcxKT6LlpbKMLRbEM6lgAAAA?rs=1&pid=ImgDetMain",numvalue:0}]}]}},onLoad() {this.$nextTick(() => {this.getHeightArr();})},computed: {...mapGetters(["buyNum"])},methods: {...mapMutations(["setFoldState"]),//点击导航菜单clickNav(index) {if (this.navIdx == index) return;this.navIdx = index;if (this.timeout) {clearTimeout(this.timeout);}this.timeout = setTimeout(() => {this.leftScrollValue = this.leftHitArr[index];this.rightScrollValue = this.rightHitArr[index];}, 100)},//获取滚动条内容高度getHeightArr() {let selectorQuery = uni.createSelectorQuery();let customHeadBar;//获取自定义导航高度 selectorQuery.select("#customHeadBar").boundingClientRect(rect => {customHeadBar = rect.height;}).exec()//左侧滚到区域的节点组selectorQuery.selectAll(".navitem").boundingClientRect(rects => {this.leftHitArr = rects.map(item => item.top - customHeadBar - 40)}).exec()console.log(this.leftHitArr);//右侧滚到区域的节点组selectorQuery.selectAll(".productView").boundingClientRect(rects => {this.rightHitArr = rects.map(item => item.top - customHeadBar - 40)}).exec()},//监听右侧滚动条的改变rightScrollEnt(e) {let scrollTop = Math.ceil(e.detail.scrollTop);let idx = this.rightHitArr.findIndex((value, index, arr) => scrollTop >= value && scrollTop < arr[index +1])this.navIdx = idx;this.leftScrollValue = this.leftHitArr[idx];if (scrollTop < 300) {this.setFoldState(false)}if (scrollTop > 400) {this.setFoldState(true)}}}}
</script>
四、项目截图
五、源码获取
看到这里你是否受益了呢?你的支持就是我创作的动力,点赞+收藏+关注,学习不迷路,评论区留下你的疑问,可私信获取源码。
相关文章:

基于vue的商城小程序的毕业设计与实现(源码及报告)
环境搭建 ☞☞☞ Vue入手篇(一),防踩雷(全网最详细教程)_vue force-CSDN博客 目录 一、功能介绍 二、登录注册功能 三、首页 四、项目截图 五、源码获取 一、功能介绍 用户信息展示:页面顶部设有用户头像和昵称展示区,方便用户识别…...

NineData云原生智能数据管理平台新功能发布|2024年12月版
本月发布 7 项更新,其中重点发布 2 项、功能优化 5 项。 重点发布 数据库 Devops - Oracle 非表对象支持可视化创建与管理 Oracle 非表对象,包括视图(View)、包(Package)、存储过程(Procedur…...

【Vue.js 组件化】高效组件管理与自动化实践指南
文章目录 摘要引言组件命名规范与组织结构命名规范目录组织 依赖管理工具自动化组件文档生成构建自动引入和文档生成的组件化体系代码结构自动引入组件配置使用 Storybook 展示组件文档自动生成 代码详解QA 环节总结参考资料 摘要 在现代前端开发中,组件化管理是 V…...
Clojure语言的并发编程
Clojure语言的并发编程 引言 在现代软件开发中,并发编程成为了处理多个任务、提高应用效率和响应速度的重要手段。尤其是在多核处理器逐渐成为主流的今天,如何高效利用这些计算资源是每个开发者面临的挑战。Clojure作为一种函数式编程语言,…...

RabbitMQ-SpringAMQP使用介绍
RabbitMQ 1. Spring AMQP1.1 引入依赖1.2 消息发送1.3 消息接收1.4 WorkQueue模型1.4.1 实例代码1.4.2 能者多劳1.4.3 总结 1.5交换机1.6 Fanout交换机(广播)1.7 Direct交换机(订阅)1.8 Topic交换机(通配符订阅&#x…...

ASP.NET Core 中服务生命周期详解:Scoped、Transient 和 Singleton 的业务场景分析
前言 在 ASP.NET Core 中,服务的生命周期直接影响应用的性能和行为。通过依赖注入容器 (Dependency Injection, DI),我们可以为服务定义其生命周期:Scoped、Transient 和 Singleton。本文将详细阐述这些生命周期的区别及其在实际业务中的应用…...
c语言----------小知识
1 system函数的使用 #include <stdlib.h> int system(const char *command); 功能:在已经运行的程序中执行另外一个外部程序 参数:外部可执行程序名字 返回值: 成功:0 失败:任意数字示例代码: #inc…...
React Context用法总结
1. 基本概念 1.1 什么是 Context Context 提供了一种在组件树中共享数据的方式,而不必通过 props 显式地逐层传递。它主要用于共享那些对于组件树中许多组件来说是"全局"的数据。 1.2 基本用法 // 1. 创建 Context const ThemeContext React.createC…...

[笔记] 使用 Jenkins 实现 CI/CD :从 GitLab 拉取 Java 项目并部署至 Windows Server
随着软件开发节奏的加快,持续集成(CI)和持续部署(CD)已经成为确保软件质量和加速产品发布的不可或缺的部分。Jenkins作为一款广泛使用的开源自动化服务器,为开发者提供了一个强大的平台来实施这些实践。然而…...

腾讯云AI代码助手编程挑战赛-如意
作品简介 《如意》是一款结合腾讯云AI代码助手生成的、集智能问答、知识学习和生活助手功能于一体的应用,在通过先进的AI技术提升用户的工作效率、学习效果和生活质量。无论是解答疑难问题、提供专业建议,还是帮助规划日程、提升技能,它都能…...

TAS测评倍智题库 | 益丰大药房2025年中高层测评BA商业推理测评真题考什么?
您好!您已被邀请参加360评估。您的评估与反馈将有助于被评估人更深入地了解个人情况,发现个人优势和潜在风险。请您秉持公正、开放的心态进行评估。请尽快完成评估,在此衷心感谢您的配合与支持! 相关事宜: 请您在…...

2025 First LOOK! CnosDB 新版本 2.4.3.1 发布
🔹 版本号:2.4.3.1 🔹 发布日期:2024年11月05日 功能优化 简化编解码器错误定义 #2368 删除不必要的const DEFAULT_* #2378 添加 wal 压缩检查 #2377 移除 page reader #2380 创建配额 #2367 减少内存复制和计算 #2384 构…...

PyMysql 01|(包含超详细项目实战)连接数据库、增删改查、异常捕获
目录 一、数据库操作应用场景 二、安装PyMysql 三、事务的概念 四、数据库的准备 五、PyMysql连接数据库 1、建立连接方法 2、入门案例 六、PyMysql操作数据库 1、数据库查询 1️⃣查询操作流程 2️⃣cursor游标 3️⃣查询常用方法 4️⃣案例 5️⃣异常捕获 …...

Android14上使用libgpiod[gpioinfo gpioget gpioset ...]
环境 $ cat /etc/os-release NAME="Ubuntu" VERSION="20.04.5 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.5 LTS" VERSION_ID="20.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="…...

网络安全 信息收集入门
1.信息收集定义 信息收集是指收集有关目标应用程序和系统的相关信息。这些信息可以帮助攻击者了解目标系统的架构、技术实现细节、运行环境、网络拓扑结构、安全措施等方面的信息,以便我们在后续的渗透过程更好的进行。 2.收集方式-主动和被动收集 ①收集方式不同…...
修改sshd默认配置,提升安全
对于Linux服务器,特别是暴露在公网的服务器,会经常被人扫描、探测和攻击。包括通过ssh访问登录攻击。对此,对默认的sshd配置进行调整,提升安全。 下面以CentOS 7.9为例说明: 一、常见安全措施 以root用户编辑vim /e…...
Clojure语言的面向对象编程
Clojure语言的面向对象编程 引言 Clojure是一种现代的Lisp方言,它特别强调函数式编程,Immutable数据结构和强大的并发能力。然而,很多人可能会问:Clojure支持面向对象编程吗?虽然Clojure没有像Java或C那样的传统类和…...

spring boot启动源码分析(三)之Environment准备
上一篇《spring-boot启动源码分析(二)之SpringApplicationRunListener》 环境介绍: spring boot版本:2.7.18 主要starter:spring-boot-starter-web 本篇开始讲启动过程中Environment环境准备,Environment是管理所有…...

MySQL复习
基础篇 InnoDB、MyISAM 和 MEMORY 存储引擎的区别? 主要区别: 为什么MySQL选择 InnoDB 作为默认存储引擎? 1.innodb支持事务,myisam、memory不支持。 2.innodb支持行级锁,可以使多个事务同时访问不同的行…...
ASP.NET Core 实现微服务 -- Polly 服务降级熔断
在我们实施微服务之后,服务间的调用变的异常频繁。多个服务之间可能是互相依赖的关系。某个服务出现故障或者是服务间的网络出现故障都会造成服务调用的失败,进而影响到某个业务服务处理失败。某一个服务调用失败轻则造成当前相关业务无法处理࿱…...

Spark 之 入门讲解详细版(1)
1、简介 1.1 Spark简介 Spark是加州大学伯克利分校AMP实验室(Algorithms, Machines, and People Lab)开发通用内存并行计算框架。Spark在2013年6月进入Apache成为孵化项目,8个月后成为Apache顶级项目,速度之快足见过人之处&…...
从零实现富文本编辑器#5-编辑器选区模型的状态结构表达
先前我们总结了浏览器选区模型的交互策略,并且实现了基本的选区操作,还调研了自绘选区的实现。那么相对的,我们还需要设计编辑器的选区表达,也可以称为模型选区。编辑器中应用变更时的操作范围,就是以模型选区为基准来…...

23-Oracle 23 ai 区块链表(Blockchain Table)
小伙伴有没有在金融强合规的领域中遇见,必须要保持数据不可变,管理员都无法修改和留痕的要求。比如医疗的电子病历中,影像检查检验结果不可篡改行的,药品追溯过程中数据只可插入无法删除的特性需求;登录日志、修改日志…...

解决Ubuntu22.04 VMware失败的问题 ubuntu入门之二十八
现象1 打开VMware失败 Ubuntu升级之后打开VMware上报需要安装vmmon和vmnet,点击确认后如下提示 最终上报fail 解决方法 内核升级导致,需要在新内核下重新下载编译安装 查看版本 $ vmware -v VMware Workstation 17.5.1 build-23298084$ lsb_release…...
Go 语言接口详解
Go 语言接口详解 核心概念 接口定义 在 Go 语言中,接口是一种抽象类型,它定义了一组方法的集合: // 定义接口 type Shape interface {Area() float64Perimeter() float64 } 接口实现 Go 接口的实现是隐式的: // 矩形结构体…...
Auto-Coder使用GPT-4o完成:在用TabPFN这个模型构建一个预测未来3天涨跌的分类任务
通过akshare库,获取股票数据,并生成TabPFN这个模型 可以识别、处理的格式,写一个完整的预处理示例,并构建一个预测未来 3 天股价涨跌的分类任务 用TabPFN这个模型构建一个预测未来 3 天股价涨跌的分类任务,进行预测并输…...

ESP32 I2S音频总线学习笔记(四): INMP441采集音频并实时播放
简介 前面两期文章我们介绍了I2S的读取和写入,一个是通过INMP441麦克风模块采集音频,一个是通过PCM5102A模块播放音频,那如果我们将两者结合起来,将麦克风采集到的音频通过PCM5102A播放,是不是就可以做一个扩音器了呢…...

Springcloud:Eureka 高可用集群搭建实战(服务注册与发现的底层原理与避坑指南)
引言:为什么 Eureka 依然是存量系统的核心? 尽管 Nacos 等新注册中心崛起,但金融、电力等保守行业仍有大量系统运行在 Eureka 上。理解其高可用设计与自我保护机制,是保障分布式系统稳定的必修课。本文将手把手带你搭建生产级 Eur…...

04-初识css
一、css样式引入 1.1.内部样式 <div style"width: 100px;"></div>1.2.外部样式 1.2.1.外部样式1 <style>.aa {width: 100px;} </style> <div class"aa"></div>1.2.2.外部样式2 <!-- rel内表面引入的是style样…...

dify打造数据可视化图表
一、概述 在日常工作和学习中,我们经常需要和数据打交道。无论是分析报告、项目展示,还是简单的数据洞察,一个清晰直观的图表,往往能胜过千言万语。 一款能让数据可视化变得超级简单的 MCP Server,由蚂蚁集团 AntV 团队…...