Files
ChowBox/miniapp/pages/mine/mine.js
王鹏 802b4ba229 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>
2026-05-08 20:02:27 +08:00

46 lines
1.3 KiB
JavaScript

const storage = require('../../utils/storage');
Page({
data: {
avatarUrl: '',
nickname: '',
prefs: { taste: '都可以', priceRange: 'all', allergies: '' },
shoppingList: []
},
onShow() {
const prefs = storage.get('user_prefs', { taste: '都可以', priceRange: 'all', allergies: '' });
const shoppingList = storage.get('shopping_list', []);
this.setData({ prefs, shoppingList });
},
setPref(e) {
const { key, val } = e.currentTarget.dataset;
const prefs = { ...this.data.prefs, [key]: val };
this.setData({ prefs });
storage.set('user_prefs', prefs);
},
setAllergies(e) {
const prefs = { ...this.data.prefs, allergies: e.detail.value };
this.setData({ prefs });
storage.set('user_prefs', prefs);
},
toggleItem(e) {
const idx = e.currentTarget.dataset.index;
const list = this.data.shoppingList;
list[idx].checked = !list[idx].checked;
this.setData({ shoppingList: list });
storage.set('shopping_list', list);
},
clearShopping() {
wx.showModal({
title: '清空清单',
content: '确定清空所有购物清单吗?',
success: (res) => {
if (res.confirm) {
this.setData({ shoppingList: [] });
storage.set('shopping_list', []);
}
}
});
}
});