- miniprogram/config.js: BASE_URL 指向 http://192.227.237.8:3001 - 动作标题中文化(nameZh),搜索匹配 name/nameZh/nameEn - 新增计划/收藏/我的 等页面与组件 - 后端 Docker 化(Dockerfile/.dockerignore)与翻译脚本 - .gitignore 补充 .DS_Store
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
const app = getApp();
|
|
const favSvc = require('../../services/favorite');
|
|
const auth = require('../../utils/auth');
|
|
|
|
Page({
|
|
data: {
|
|
statusBarHeight: 20,
|
|
list: [],
|
|
loading: true,
|
|
managing: false
|
|
},
|
|
|
|
onLoad() {
|
|
this.setData({ statusBarHeight: app.globalData.statusBarHeight || 20 });
|
|
},
|
|
|
|
onShow() {
|
|
if (auth.isLogin()) this.load();
|
|
else {
|
|
wx.showToast({ title: '请先登录', icon: 'none' });
|
|
setTimeout(() => wx.navigateBack(), 600);
|
|
}
|
|
},
|
|
|
|
load() {
|
|
this.setData({ loading: true });
|
|
favSvc.listExercises().then((list) => {
|
|
this.setData({ list: list || [], loading: false });
|
|
}).catch(() => {
|
|
this.setData({ list: [], loading: false });
|
|
});
|
|
},
|
|
|
|
onManage() {
|
|
this.setData({ managing: !this.data.managing });
|
|
},
|
|
|
|
onRemove(e) {
|
|
const id = e.currentTarget.dataset.id;
|
|
favSvc.removeExercise(id).then(() => {
|
|
const list = this.data.list.filter(i => i.id !== id);
|
|
this.setData({ list });
|
|
wx.showToast({ title: '已移除', icon: 'none' });
|
|
}).catch(() => {});
|
|
},
|
|
|
|
onExercise(e) {
|
|
if (this.data.managing) return;
|
|
wx.navigateTo({ url: '/pages/detail/detail?id=' + encodeURIComponent(e.detail.id) });
|
|
},
|
|
|
|
goRecommend() {
|
|
wx.navigateTo({ url: '/pages/recommend/recommend' });
|
|
}
|
|
});
|