feat: 小程序连接服务器IP + 同步未提交开发
- miniprogram/config.js: BASE_URL 指向 http://192.227.237.8:3001 - 动作标题中文化(nameZh),搜索匹配 name/nameZh/nameEn - 新增计划/收藏/我的 等页面与组件 - 后端 Docker 化(Dockerfile/.dockerignore)与翻译脚本 - .gitignore 补充 .DS_Store
This commit is contained in:
55
miniprogram/pages/favorites/favorites.js
Normal file
55
miniprogram/pages/favorites/favorites.js
Normal file
@@ -0,0 +1,55 @@
|
||||
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' });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user