fix: 修复 VoiceController Map.of 兼容性 + ExploreController 参数不匹配
- VoiceController: Map.of() -> Collections.singletonMap() 兼容 Java 8 - ExploreController: 补齐 takeoutService.roll() 缺失的 taste/priceRange/allergies 参数 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
89
miniapp/pages/index/index.js
Normal file
89
miniapp/pages/index/index.js
Normal file
@@ -0,0 +1,89 @@
|
||||
const app = getApp();
|
||||
const tips = [
|
||||
'今天宜尝试酸辣口味',
|
||||
'唯有美食与爱不可辜负',
|
||||
'厨房里的秘密,全在一勺之间',
|
||||
'一日三餐,每一餐都值得认真对待',
|
||||
'今天适合来点甜的犒劳自己',
|
||||
'好心情从一顿好饭开始',
|
||||
'美食是治愈一切的力量'
|
||||
];
|
||||
|
||||
Page({
|
||||
data: {
|
||||
greeting: '',
|
||||
locationText: '点击获取位置',
|
||||
dailyTip: ''
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.updateGreeting();
|
||||
this.updateLocation();
|
||||
this.setData({ dailyTip: tips[Math.floor(Math.random() * tips.length)] });
|
||||
},
|
||||
|
||||
updateGreeting() {
|
||||
const h = new Date().getHours();
|
||||
let g = '晚上好';
|
||||
if (h < 9) g = '早上好';
|
||||
else if (h < 12) g = '上午好';
|
||||
else if (h < 14) g = '中午好';
|
||||
else if (h < 18) g = '下午好';
|
||||
this.setData({ greeting: g });
|
||||
},
|
||||
|
||||
updateLocation() {
|
||||
const loc = app.globalData.location;
|
||||
if (loc) {
|
||||
this.setData({
|
||||
locationText: `已定位 (${loc.latitude.toFixed(2)}, ${loc.longitude.toFixed(2)})`
|
||||
});
|
||||
} else {
|
||||
// 尝试获取定位
|
||||
this.requestLocation();
|
||||
}
|
||||
},
|
||||
|
||||
requestLocation() {
|
||||
app.getLocation((err, loc) => {
|
||||
if (loc) {
|
||||
this.setData({
|
||||
locationText: `已定位 (${loc.latitude.toFixed(2)}, ${loc.longitude.toFixed(2)})`
|
||||
});
|
||||
} else {
|
||||
this.setData({ locationText: '点击选择位置' });
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
chooseLocation() {
|
||||
wx.chooseLocation({
|
||||
success: (res) => {
|
||||
app.globalData.location = {
|
||||
latitude: res.latitude,
|
||||
longitude: res.longitude
|
||||
};
|
||||
this.setData({
|
||||
locationText: `已定位 (${res.latitude.toFixed(2)}, ${res.longitude.toFixed(2)})`
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onOpenBox(e) {
|
||||
// 开盒前检查定位
|
||||
if (!app.globalData.location) {
|
||||
wx.showToast({ title: '请先获取位置', icon: 'none' });
|
||||
this.requestLocation();
|
||||
return;
|
||||
}
|
||||
|
||||
const type = e.detail.type;
|
||||
const routes = {
|
||||
takeout: '/pages/takeout-result/takeout-result',
|
||||
fridge: '/pages/fridge-input/fridge-input',
|
||||
explore: '/pages/explore-result/explore-result'
|
||||
};
|
||||
wx.navigateTo({ url: routes[type] || routes.takeout });
|
||||
}
|
||||
});
|
||||
6
miniapp/pages/index/index.json
Normal file
6
miniapp/pages/index/index.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"mode-card": "/components/mode-card/mode-card"
|
||||
},
|
||||
"navigationBarTitleText": "吃啥盲盒"
|
||||
}
|
||||
41
miniapp/pages/index/index.wxml
Normal file
41
miniapp/pages/index/index.wxml
Normal file
@@ -0,0 +1,41 @@
|
||||
<view class="home">
|
||||
<view class="header">
|
||||
<view class="greeting">{{greeting}}</view>
|
||||
<view class="location-badge" bind:tap="chooseLocation">{{locationText}}</view>
|
||||
</view>
|
||||
|
||||
<view class="hero">
|
||||
<view class="hero-emoji">🎁</view>
|
||||
<view class="hero-title">今天吃啥?</view>
|
||||
<view class="hero-subtitle">开个盲盒</view>
|
||||
</view>
|
||||
|
||||
<view class="modes">
|
||||
<mode-card
|
||||
type="takeout"
|
||||
icon="🛵"
|
||||
title="外卖盲盒"
|
||||
desc="随机高质量外卖"
|
||||
actionText="开个外卖盒"
|
||||
bind:open="onOpenBox"
|
||||
/>
|
||||
<mode-card
|
||||
type="fridge"
|
||||
icon="🥬"
|
||||
title="冰箱盲盒"
|
||||
desc="有啥食材做啥菜"
|
||||
actionText="开个冰箱盒"
|
||||
bind:open="onOpenBox"
|
||||
/>
|
||||
<mode-card
|
||||
type="explore"
|
||||
icon="🍱"
|
||||
title="探店盲盒"
|
||||
desc="发现隐藏好店"
|
||||
actionText="开个附近盒"
|
||||
bind:open="onOpenBox"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="daily-tip">{{dailyTip}}</view>
|
||||
</view>
|
||||
85
miniapp/pages/index/index.wxss
Normal file
85
miniapp/pages/index/index.wxss
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 首页 · 盲盒大厅
|
||||
* 空间节奏:32 → 48 → 48 → 64
|
||||
*/
|
||||
|
||||
.home {
|
||||
padding: var(--space-lg) var(--space-lg);
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* ── 顶部 ── */
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: var(--space-xl);
|
||||
}
|
||||
|
||||
.greeting {
|
||||
font-size: var(--text-body);
|
||||
font-weight: 500;
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
.location-badge {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: var(--text-body-sm);
|
||||
color: var(--color-primary);
|
||||
padding: var(--space-xs) var(--space-sm);
|
||||
background: var(--color-primary-pale);
|
||||
border-radius: var(--radius-full);
|
||||
}
|
||||
|
||||
.location-badge:active {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
/* ── 主视觉 ── */
|
||||
.hero {
|
||||
text-align: center;
|
||||
margin-bottom: var(--space-xl);
|
||||
}
|
||||
|
||||
.hero-emoji {
|
||||
display: inline-block;
|
||||
font-size: 88rpx;
|
||||
margin-bottom: var(--space-sm);
|
||||
animation: hero-float 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes hero-float {
|
||||
0%, 100% { transform: translateY(0); }
|
||||
50% { transform: translateY(-10rpx); }
|
||||
}
|
||||
|
||||
.hero-title {
|
||||
font-size: 44rpx;
|
||||
font-weight: 700;
|
||||
color: var(--color-text);
|
||||
letter-spacing: 2rpx;
|
||||
margin-bottom: var(--space-xs);
|
||||
}
|
||||
|
||||
.hero-subtitle {
|
||||
font-size: var(--text-subtitle);
|
||||
color: var(--color-primary);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* ── 卡片列表 ── */
|
||||
.modes {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-md);
|
||||
margin-bottom: var(--space-xl);
|
||||
}
|
||||
|
||||
/* ── 每日一言 ── */
|
||||
.daily-tip {
|
||||
text-align: center;
|
||||
font-size: var(--text-body-sm);
|
||||
color: var(--color-text-muted);
|
||||
padding: var(--space-lg) 0;
|
||||
}
|
||||
Reference in New Issue
Block a user