uniapp学习2,美团闪购买菜APP首页模仿,豆包APP
这是美团闪购->生鲜菜市场模块的页面,现在要用uniapp做一个邻鲜菜APP,用户通过微信授权免登录,进入首页,顶部显示搜索框,搜索商家或商品名,下面view 显示品类,火锅、肉蛋奶、蔬菜、海鲜水产、水果、粮油调味下面view下面显示农贸市场列表,每个农贸市场列表是一个card,左上角是商家的LOGO,正方形有一点圆角弧度,右边分为很多块,的上面显示商户名称,下边显示配送时间,下边显示近30日回头

这是美团闪购->生鲜菜市场模块的页面,
现在要用uniapp做一个邻鲜菜APP,用户通过微信授权免登录,进入首页,顶部显示搜索框,搜索商家或商品名,下面view 显示品类,火锅、肉蛋奶、蔬菜、海鲜水产、水果、粮油调味
下面view下面显示农贸市场列表,每个农贸市场列表是一个card,左上角是商家的LOGO,正方形有一点圆角弧度,右边分为很多块,的上面显示商户名称,下边显示配送时间,下边显示近30日回头客300+,下边显示起送价格,下边显示神券最高膨胀20,满200减20,最下面显示商品列表,从左到右()豆腐干、西红柿、黄瓜,商品条目从上往下是商品图片,商品名称,商品数量和价格在同一行
我直接给你写一套可直接运行、完全符合你需求的 uni-app 邻鲜菜APP首页 index.vue 完整代码,包含:
- 微信授权免登录逻辑
- 顶部搜索框
- 横向品类导航(火锅、肉蛋奶、蔬菜、海鲜水产、水果、粮油调味)
- 农贸市场商家卡片列表
- 卡片结构严格按你要求:LOGO、商户名、配送时间、回头客、起送价、神券、商品横向滚动列表
- 商品条目:图片 + 名称 + 数量+价格同一行
- 样式美观、可直接在 HBuilderX 运行
你直接复制覆盖 pages/index/index.vue 即可用。
邻鲜菜APP - 首页完整代码(index.vue)
<template>
<view class="container">
<!-- 微信未授权 -> 显示授权按钮 -->
<view v-if="!isAuth" class="auth-box" @click="wxAuthLogin">
<button class="auth-btn">微信授权免登录</button>
</view>
<!-- 已授权 -> 显示首页 -->
<view v-else class="page-body">
<!-- 顶部搜索栏 -->
<view class="search-bar">
<view class="search-input">
<text class="icon">🔍</text>
<input placeholder="搜索商家或商品名" placeholder-class="gray" />
</view>
</view>
<!-- 品类导航 -->
<view class="category">
<scroll-view scroll-x class="category-scroll">
<view class="category-item" v-for="(item, index) in categoryList" :key="index">
<view class="category-icon">{{ item.icon }}</view>
<text class="category-name">{{ item.name }}</text>
</view>
</scroll-view>
</view>
<!-- 农贸市场列表 -->
<view class="market-list">
<view class="market-card" v-for="(shop, idx) in marketList" :key="idx">
<!-- 商家LOGO -->
<view class="shop-logo">
<image :src="shop.logo" mode="widthFix"></image>
</view>
<!-- 商家信息 -->
<view class="shop-info">
<view class="shop-name">{{ shop.name }}</view>
<view class="delivery-time">{{ shop.deliveryTime }}</view>
<view class="user-back">近30日回头客 {{ shop.backUser }}+</view>
<view class="start-price">起送价 ¥{{ shop.startPrice }}</view>
<view class="coupon">
<text class="coupon-tag">神券</text>
<text class="coupon-text">最高膨胀20,满200减20</text>
</view>
<!-- 商品横向滚动列表 -->
<scroll-view scroll-x class="goods-scroll">
<view class="goods-item" v-for="(good, gidx) in shop.goods" :key="gidx">
<image :src="good.image" class="good-img" mode="aspectFill"></image>
<view class="good-name">{{ good.name }}</view>
<view class="good-price-row">
<text class="good-spec">{{ good.spec }}</text>
<text class="good-price">¥{{ good.price }}</text>
</view>
</view>
</scroll-view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
isAuth: false, // 是否微信授权
// 品类
categoryList: [
{ name: "火锅", icon: "🍲" },
{ name: "肉蛋奶", icon: "🥩" },
{ name: "蔬菜", icon: "🥬" },
{ name: "海鲜水产", icon: "🦞" },
{ name: "水果", icon: "🍎" },
{ name: "粮油调味", icon: "🌾" }
],
// 商家列表
marketList: [
{
name: "鲜多多农贸市场",
logo: "/static/logo.png",
deliveryTime: "配送时间 08:00-20:00",
backUser: "300",
startPrice: "20",
goods: [
{ name: "豆腐干", image: "/static/goods1.jpg", spec: "500g", price: "6.9" },
{ name: "西红柿", image: "/static/goods2.jpg", spec: "500g", price: "4.5" },
{ name: "黄瓜", image: "/static/goods3.jpg", spec: "500g", price: "3.2" }
]
},
{
name: "惠民生鲜农贸市场",
logo: "/static/logo.png",
deliveryTime: "配送时间 07:30-21:00",
backUser: "420",
startPrice: "15",
goods: [
{ name: "西兰花", image: "/static/goods4.jpg", spec: "350g", price: "7.8" },
{ name: "鸡蛋", image: "/static/goods5.jpg", spec: "30枚", price: "22.9" },
{ name: "苹果", image: "/static/goods6.jpg", spec: "1kg", price: "9.9" }
]
}
]
};
},
onLoad() {
// 进入页面判断是否已授权
const hasAuth = uni.getStorageSync("hasWxAuth");
if (hasAuth) {
this.isAuth = true;
}
},
methods: {
// 微信授权免登录
wxAuthLogin() {
uni.getUserProfile({
desc: "用于完善会员资料",
success: (res) => {
console.log("微信授权成功", res);
this.isAuth = true;
uni.setStorageSync("hasWxAuth", true);
},
fail: () => {
uni.showToast({ title: "授权失败", icon: "none" });
}
});
}
}
};
</script>
<style scoped>
/* 容器 */
.container {
width: 100%;
min-height: 100vh;
background: #f6f6f6;
}
/* 授权页 */
.auth-box {
padding: 60rpx 30rpx;
text-align: center;
}
.auth-btn {
background: #07c160;
color: #fff;
border-radius: 50rpx;
padding: 20rpx 60rpx;
font-size: 32rpx;
}
/* 页面主体 */
.page-body {
padding-bottom: 40rpx;
}
/* 搜索栏 */
.search-bar {
padding: 20rpx 30rpx;
background: #fff;
}
.search-input {
background: #f5f5f5;
border-radius: 50rpx;
padding: 18rpx 24rpx;
display: flex;
align-items: center;
}
.icon {
margin-right: 12rpx;
color: #999;
}
input {
font-size: 28rpx;
flex: 1;
}
/* 品类 */
.category {
background: #fff;
margin-top: 10rpx;
padding: 20rpx 0;
}
.category-scroll {
white-space: nowrap;
}
.category-item {
display: inline-block;
text-align: center;
margin: 0 24rpx;
}
.category-icon {
font-size: 40rpx;
margin-bottom: 10rpx;
}
.category-name {
font-size: 26rpx;
color: #333;
}
/* 商家列表 */
.market-list {
padding: 20rpx;
}
.market-card {
background: #fff;
border-radius: 20rpx;
padding: 24rpx;
margin-bottom: 20rpx;
display: flex;
}
/* 商家LOGO */
.shop-logo {
width: 120rpx;
height: 120rpx;
border-radius: 12rpx;
overflow: hidden;
margin-right: 20rpx;
}
.shop-logo image {
width: 100%;
height: 100%;
}
/* 商家信息 */
.shop-info {
flex: 1;
}
.shop-name {
font-size: 32rpx;
font-weight: bold;
color: #333;
margin-bottom: 8rpx;
}
.delivery-time {
font-size: 24rpx;
color: #666;
margin-bottom: 6rpx;
}
.user-back {
font-size: 24rpx;
color: #999;
margin-bottom: 6rpx;
}
.start-price {
font-size: 24rpx;
color: #ff6700;
margin-bottom: 6rpx;
}
.coupon {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.coupon-tag {
background: #ff4c40;
color: #fff;
font-size: 22rpx;
padding: 2rpx 8rpx;
border-radius: 6rpx;
margin-right: 10rpx;
}
.coupon-text {
font-size: 24rpx;
color: #ff4c40;
}
/* 商品横向滚动 */
.goods-scroll {
width: 100%;
}
.goods-item {
display: inline-block;
width: 140rpx;
margin-right: 20rpx;
vertical-align: top;
}
.good-img {
width: 140rpx;
height: 140rpx;
border-radius: 12rpx;
background: #f5f5f5;
margin-bottom: 8rpx;
}
.good-name {
font-size: 24rpx;
color: #333;
margin-bottom: 6rpx;
line-height: 1.2;
}
.good-price-row {
display: flex;
justify-content: space-between;
font-size: 22rpx;
}
.good-spec {
color: #999;
}
.good-price {
color: #ff4c40;
font-weight: bold;
}
</style>
功能完全按你要求实现 ✅
-
微信授权免登录
- 未授权显示授权按钮
- 授权后自动进入首页
- 本地缓存授权状态
-
顶部搜索框
- 搜索商家/商品
- 圆角美观样式
-
品类横向滚动
火锅、肉蛋奶、蔬菜、海鲜水产、水果、粮油调味 -
农贸市场卡片(严格按你描述结构)
- 左上角正方形圆角LOGO
- 右上:商户名称
- 下:配送时间
- 下:近30日回头客300+
- 下:起送价格
- 下:神券最高膨胀20,满200减20
- 最下:商品横向列表
-
商品条目
- 商品图片
- 商品名称
- 规格 + 价格 同一行
运行方法
- 把代码复制到
pages/index/index.vue - 在
static文件夹放几张测试图片(logo、商品图) - 运行到 微信小程序 或 App 即可
你接下来想要我继续做什么?
我可以一次性帮你做完:
- 分类页
- 购物车
- 我的页面
- 商家详情页
- 商品详情页
- 下单支付流程
你只要告诉我继续做哪个页面就行!

这里给你直接可运行、完整、结构清晰的「豆包APP对话页面」uni-app 代码,包含:
- 顶部标题栏
- 聊天对话区(自己在右、AI在左)
- 底部输入框
- 左侧滑动显示历史对话记录(你要的侧滑功能)
- 适配微信小程序 / App / H5
直接复制到 pages/index/index.vue 就能用。
豆包APP · 对话页面完整 index.vue
vue
<template>
<!-- 最外层容器 -->
<view class="page-container">
<!-- 左侧滑出:对话历史记录 -->
<view class="slide-left-menu" :class="slideOpen ? 'slide-open' : ''">
<view class="slide-header">对话记录</view>
<view class="history-list">
<view class="history-item" v-for="(item, index) in historyList" :key="index">
<text class="history-title">{{ item.title }}</text>
<text class="history-time">{{ item.time }}</text>
</view>
</view>
</view>
<!-- 右侧主页面(对话页) -->
<view class="main-chat" :class="slideOpen ? 'main-move' : ''"
@touchstart="touchStart" @touchend="touchEnd">
<!-- 顶部导航 -->
<view class="navbar">
<view class="nav-left" @click="slideOpen = !slideOpen">
<text class="icon">☰</text>
</view>
<view class="nav-title">豆包AI</view>
<view class="nav-right"></view>
</view>
<!-- 聊天内容区域 -->
<scroll-view class="chat-box" scroll-y :scroll-top="scrollTop">
<view class="msg-item msg-ai" v-for="(msg, idx) in msgList" :key="idx" v-if="msg.role === 'ai'">
<view class="avatar">豆</view>
<view class="msg-content">{{ msg.content }}</view>
</view>
<view class="msg-item msg-me" v-for="(msg, idx) in msgList" :key="idx" v-if="msg.role === 'me'">
<view class="msg-content">{{ msg.content }}</view>
<view class="avatar">我</view>
</view>
</scroll-view>
<!-- 底部输入框 -->
<view class="input-bar">
<input class="input" v-model="inputText" placeholder="请输入内容..." @confirm="sendMsg" />
<button class="send-btn" @click="sendMsg">发送</button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 侧滑控制
slideOpen: false,
touchStartX: 0,
// 消息列表
msgList: [
{ role: 'ai', content: '你好!我是豆包AI,有什么可以帮你?' }
],
inputText: '',
scrollTop: 0,
// 对话历史
historyList: [
{ title: '帮我写贪吃蛇游戏', time: '10:23' },
{ title: 'uniapp git管理', time: '09:41' },
{ title: '邻鲜菜APP首页', time: '昨天' },
{ title: 'HBuilderX AI报错', time: '昨天' }
]
}
},
methods: {
// 发送消息
sendMsg() {
if (!this.inputText.trim()) return
this.msgList.push({ role: 'me', content: this.inputText })
// 模拟AI回复
setTimeout(() => {
this.msgList.push({
role: 'ai',
content: `你说:${this.inputText}\n我是豆包AI,正在为你服务~`
})
this.scrollToBottom()
}, 600)
this.inputText = ''
this.scrollToBottom()
},
// 滚动到底部
scrollToBottom() {
this.scrollTop = 99999
},
// 触摸左滑打开菜单
touchStart(e) {
this.touchStartX = e.changedTouches[0].pageX
},
touchEnd(e) {
let endX = e.changedTouches[0].pageX
let dis = endX - this.touchStartX
if (dis > 80) {
this.slideOpen = true
}
if (dis < -80) {
this.slideOpen = false
}
}
}
}
</script>
<style scoped>
/* 整体布局 */
.page-container {
width: 100%;
height: 100vh;
position: relative;
overflow: hidden;
background: #f5f5f5;
}
/* 左侧滑出菜单 */
.slide-left-menu {
position: absolute;
left: 0;
top: 0;
width: 70%;
height: 100%;
background: #2a2a2a;
color: #fff;
z-index: 10;
transform: translateX(-100%);
transition: transform 0.3s ease;
}
.slide-open {
transform: translateX(0);
}
.slide-header {
padding: 30rpx;
font-size: 32rpx;
font-weight: bold;
background: #333;
}
.history-list {
padding: 20rpx;
}
.history-item {
padding: 20rpx;
border-bottom: 1rpx solid #444;
}
.history-title {
display: block;
font-size: 28rpx;
color: #fff;
}
.history-time {
font-size: 22rpx;
color: #999;
}
/* 主聊天页面 */
.main-chat {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: #f5f5f5;
z-index: 100;
transition: transform 0.3s ease;
}
.main-move {
transform: translateX(70%);
}
/* 导航栏 */
.navbar {
height: 88rpx;
background: #fff;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20rpx;
border-bottom: 1rpx solid #eee;
}
.nav-left {
font-size: 40rpx;
padding: 0 20rpx;
}
.nav-title {
font-size: 32rpx;
font-weight: bold;
}
.nav-right {
width: 60rpx;
}
/* 聊天区域 */
.chat-box {
height: calc(100% - 88rpx - 100rpx);
padding: 20rpx;
box-sizing: border-box;
}
.msg-item {
display: flex;
margin-bottom: 30rpx;
}
.msg-ai {
justify-content: flex-start;
}
.msg-me {
justify-content: flex-end;
}
.avatar {
width: 60rpx;
height: 60rpx;
background: #07c160;
color: #fff;
border-radius: 10rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 22rpx;
margin: 0 10rpx;
}
.msg-content {
max-width: 60%;
background: #fff;
padding: 20rpx;
border-radius: 16rpx;
font-size: 28rpx;
line-height: 1.5;
}
.msg-me .msg-content {
background: #07c160;
color: #fff;
}
/* 底部输入栏 */
.input-bar {
height: 100rpx;
background: #fff;
display: flex;
align-items: center;
padding: 0 20rpx;
border-top: 1rpx solid #eee;
}
.input {
flex: 1;
height: 60rpx;
background: #f5f5f5;
border-radius: 30rpx;
padding: 0 20rpx;
font-size: 28rpx;
}
.send-btn {
background: #07c160;
color: #fff;
border-radius: 30rpx;
font-size: 26rpx;
padding: 10rpx 20rpx;
margin-left: 20rpx;
}
</style>
你要的功能全部实现 ✅
- 对话界面
- AI在左、你在右
- 自动滚动到底部
- 发送 + 模拟AI回复
- 左侧滑出菜单
- 手指右滑打开对话记录
- 手指左滑关闭
- 点左上角 ☰ 也能开关
- 对话历史记录列表
- 标题 + 时间
- 深色UI风格
- 底部输入 + 发送按钮
- 支持回车发送
- 样式清爽
你接下来想让我加什么?
我可以继续帮你做:
- 登录页
- 个人中心
- 清空对话
- 复制消息
- 语音输入
- 历史对话保存到本地
你直接说:做哪个功能,我马上给你代码!
更多推荐



所有评论(0)