fix: 首页我的计划点击跳转错页 + feat: 新增留言反馈功能
fix: - 首页'我的计划'卡片误绑 onExercise(跳动作详情),改为 onPlanTap 正确跳训练计划详情页 - 修复后点击计划可正常打开 plan-detail feat(留言反馈): - 后端新增 feedback 模块:POST /api/feedback(AuthGuard,content 必填/contact 选填),JsonStore 持久化 - 前端新增 pages/feedback 页面(留言内容 textarea + 联系方式选填 + 提交),profile 菜单新增'意见反馈'入口 - icon-svg 新增 message-circle 图标(反馈页用)
This commit is contained in:
56
miniprogram/pages/feedback/feedback.js
Normal file
56
miniprogram/pages/feedback/feedback.js
Normal file
@@ -0,0 +1,56 @@
|
||||
const app = getApp();
|
||||
const auth = require('../../utils/auth');
|
||||
const fbSvc = require('../../services/feedback');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
statusBarHeight: 20,
|
||||
content: '',
|
||||
contact: '',
|
||||
count: 0,
|
||||
maxLen: 1000,
|
||||
submitting: false
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.setData({ statusBarHeight: app.globalData.statusBarHeight || 20 });
|
||||
},
|
||||
|
||||
onContentInput(e) {
|
||||
const content = e.detail.value;
|
||||
this.setData({ content, count: content.length });
|
||||
},
|
||||
|
||||
onContactInput(e) {
|
||||
this.setData({ contact: e.detail.value });
|
||||
},
|
||||
|
||||
onSubmit() {
|
||||
const content = (this.data.content || '').trim();
|
||||
if (!content) {
|
||||
wx.showToast({ title: '请填写留言内容', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (this.data.submitting) return;
|
||||
this.setData({ submitting: true });
|
||||
wx.showLoading({ title: '提交中…', mask: true });
|
||||
fbSvc
|
||||
.submit(content, (this.data.contact || '').trim())
|
||||
.then(() => {
|
||||
wx.hideLoading();
|
||||
this.setData({ submitting: false, content: '', contact: '', count: 0 });
|
||||
wx.showModal({
|
||||
title: '已收到反馈',
|
||||
content: '感谢你的留言,我们会认真查看!',
|
||||
showCancel: false,
|
||||
confirmText: '好的'
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
wx.hideLoading();
|
||||
this.setData({ submitting: false });
|
||||
const msg = (err && err.message) || '提交失败,请稍后再试';
|
||||
wx.showToast({ title: msg, icon: 'none' });
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user