fix(fe): 修社区图片撑破网格;发帖限 3 张;上传偶发失败自动重试 #5
@@ -41,6 +41,8 @@ Page({
|
|||||||
},
|
},
|
||||||
onLoad(q) {
|
onLoad(q) {
|
||||||
const code = (q && q.type) || '';
|
const code = (q && q.type) || '';
|
||||||
|
// 从首页「今日任务」勾选进来会带 taskId:这一笔记录保存后要把那条任务标完成
|
||||||
|
this.taskId = (q && q.taskId) || '';
|
||||||
const d = today();
|
const d = today();
|
||||||
this.setData({ code, date: d, dateLabel: fmtDate(d) });
|
this.setData({ code, date: d, dateLabel: fmtDate(d) });
|
||||||
store
|
store
|
||||||
@@ -151,9 +153,13 @@ Page({
|
|||||||
this.setData({ saving: true });
|
this.setData({ saving: true });
|
||||||
api
|
api
|
||||||
.createRecord(id, this.buildBody())
|
.createRecord(id, this.buildBody())
|
||||||
|
.then(() => {
|
||||||
|
// 从任务勾选进来的:记录存好后把那条任务标完成(失败不影响记录已保存)
|
||||||
|
if (this.taskId) return api.toggleTask(this.taskId).catch(() => {});
|
||||||
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.setData({ saving: false });
|
this.setData({ saving: false });
|
||||||
wx.showToast({ title: '已记录', icon: 'success' });
|
wx.showToast({ title: this.taskId ? '已完成' : '已记录', icon: 'success' });
|
||||||
setTimeout(() => wx.navigateBack(), 600);
|
setTimeout(() => wx.navigateBack(), 600);
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
|
|||||||
@@ -172,11 +172,15 @@ Page({
|
|||||||
onTapTask(e) {
|
onTapTask(e) {
|
||||||
const i = e.currentTarget.dataset.index;
|
const i = e.currentTarget.dataset.index;
|
||||||
const t = this.data.tasks[i];
|
const t = this.data.tasks[i];
|
||||||
// 任务关联了记录类型就直接去记那一笔
|
// 任务关联了记录类型:去记那一笔。未完成的带上 taskId,
|
||||||
|
// 在记录页保存成功后才回填这条任务完成(onShow 回来自动刷新任务+最近记录)
|
||||||
if (t.sheet) {
|
if (t.sheet) {
|
||||||
wx.navigateTo({ url: '/pages/addrecord/addrecord?type=' + t.sheet });
|
let url = '/pages/addrecord/addrecord?type=' + t.sheet;
|
||||||
|
if (!t.done) url += '&taskId=' + t.id;
|
||||||
|
wx.navigateTo({ url });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 没有关联记录类型的任务(如遛狗),直接切换完成
|
||||||
api
|
api
|
||||||
.toggleTask(t.id)
|
.toggleTask(t.id)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@@ -186,14 +190,6 @@ Page({
|
|||||||
})
|
})
|
||||||
.catch((err) => toastErr(err, '操作失败'));
|
.catch((err) => toastErr(err, '操作失败'));
|
||||||
},
|
},
|
||||||
completeTasks() {
|
|
||||||
const id = store.currentPetId();
|
|
||||||
if (!id) return;
|
|
||||||
api
|
|
||||||
.completeAllTasks(id)
|
|
||||||
.then((tasks) => this.setData({ tasks: (tasks || []).map(mapTask) }))
|
|
||||||
.catch((e) => toastErr(e, '操作失败'));
|
|
||||||
},
|
|
||||||
goPlan() {
|
goPlan() {
|
||||||
wx.navigateTo({ url: '/pages/plan/plan' });
|
wx.navigateTo({ url: '/pages/plan/plan' });
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -71,7 +71,6 @@
|
|||||||
<!-- 任务的增删改都在计划页 —— 合并之后首页这个「管理」不该再开一个弹层 -->
|
<!-- 任务的增删改都在计划页 —— 合并之后首页这个「管理」不该再开一个弹层 -->
|
||||||
<view class="head-links">
|
<view class="head-links">
|
||||||
<view class="link" bindtap="goPlan">管理</view>
|
<view class="link" bindtap="goPlan">管理</view>
|
||||||
<view class="link" bindtap="completeTasks">全部完成</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="task-list">
|
<view class="task-list">
|
||||||
|
|||||||
Reference in New Issue
Block a user