146 lines
4.7 KiB
Plaintext
146 lines
4.7 KiB
Plaintext
<page-layout id="page-layout" title="今日小任务">
|
||
<view class="screen">
|
||
<view class="summary">
|
||
<view>这一天也要照顾好它们</view>
|
||
<strong>
|
||
{{done}}
|
||
<text>/ {{tasks.length}}</text>
|
||
</strong>
|
||
<view class="progress">
|
||
<view style="width:{{tasks.length?done/tasks.length*100:0}}%"></view>
|
||
</view>
|
||
</view>
|
||
<view class="row">
|
||
<text class="section-title">{{date}} 的日常</text>
|
||
<text class="add" bindtap="open">+ 添加任务</text>
|
||
</view>
|
||
<view class="date-nav">
|
||
<text data-days="-1" bindtap="changeDay">‹ 前一天</text>
|
||
<text bindtap="showToday">回到今天</text>
|
||
<text data-days="1" bindtap="changeDay">后一天 ›</text>
|
||
</view>
|
||
<view wx:if="{{tasks.length}}" class="completion-toolbar">
|
||
<text>{{undoneCount ? '还有 '+undoneCount+' 项小事' : '这一份日常,已全部照顾好'}}</text>
|
||
<button wx:if="{{undoneCount}}" class="finish-all" bindtap="completeAll" loading="{{completingAll}}" disabled="{{completingAll || taskBusyIds.length}}">一键完成</button>
|
||
<text wx:else class="all-done">全部完成</text>
|
||
</view>
|
||
<view class="card list">
|
||
<view wx:for="{{tasks}}" wx:key="id" class="task {{item.completed?'task-completed':''}}">
|
||
<view
|
||
class="check {{item.completed?'done':''}}"
|
||
data-index="{{index}}"
|
||
bindtap="toggle"
|
||
>
|
||
{{item.completed?'✓':taskBusyIds[0]===item.id?'…':''}}
|
||
</view>
|
||
<view class="icon">
|
||
<app-icon kind="{{item.category}}" size="36" />
|
||
</view>
|
||
<view class="info" data-index="{{index}}" bindtap="edit">
|
||
<strong>{{item.title}}</strong>
|
||
<text>
|
||
{{item.petName}} · {{item.time_of_day}} ·
|
||
{{item.repeat_rule==='daily'?'每天':item.repeat_rule==='weekdays'?'工作日':'周末'}}
|
||
</text>
|
||
<text>{{item.completed?'已完成 · 点此编辑任务':taskBusyIds[0]===item.id?'正在记录…':'点击左侧完成 · 点此编辑'}}</text>
|
||
</view>
|
||
<text class="remove" data-index="{{index}}" bindtap="remove">×</text>
|
||
</view>
|
||
<view wx:if="{{!tasks.length}}" class="empty">
|
||
从喝水、喂食开始,安排温柔的小日常
|
||
</view>
|
||
</view>
|
||
<button class="primary" bindtap="open">+ 新建日常任务</button>
|
||
</view>
|
||
</page-layout>
|
||
<view wx:if="{{showForm}}" class="overlay">
|
||
<view class="sheet">
|
||
<view class="row">
|
||
<strong>{{editingId?'编辑小任务':'新建小任务'}}</strong>
|
||
<text bindtap="close">×</text>
|
||
</view>
|
||
<view class="field">
|
||
<view class="field-label">任务名称</view>
|
||
<input
|
||
placeholder="比如:更换饮水"
|
||
value="{{title}}"
|
||
data-key="title"
|
||
bindinput="field"
|
||
/>
|
||
</view>
|
||
<view class="field">
|
||
<view class="field-label">照顾谁</view>
|
||
<picker
|
||
range="{{pets}}"
|
||
range-key="name"
|
||
value="{{petIndex}}"
|
||
bindchange="petChange"
|
||
>
|
||
<view class="picker">{{pets[petIndex].name||'请先添加宠物'}}</view>
|
||
</picker>
|
||
</view>
|
||
<view class="field">
|
||
<view class="field-label">类型</view>
|
||
<radio-group bindchange="categoryChange">
|
||
<label>
|
||
<radio value="food" checked="{{category==='food'}}" color="#b95738" />
|
||
喂食
|
||
</label>
|
||
<label>
|
||
<radio
|
||
value="water"
|
||
checked="{{category==='water'}}"
|
||
color="#b95738"
|
||
/>
|
||
喝水
|
||
</label>
|
||
<label>
|
||
<radio
|
||
value="other"
|
||
checked="{{category==='other'}}"
|
||
color="#b95738"
|
||
/>
|
||
其他
|
||
</label>
|
||
</radio-group>
|
||
</view>
|
||
<view class="field">
|
||
<view class="field-label">时间</view>
|
||
<picker mode="time" value="{{time_of_day}}" bindchange="timeChange">
|
||
<view class="picker">{{time_of_day}}</view>
|
||
</picker>
|
||
</view>
|
||
<view class="field">
|
||
<view class="field-label">重复</view>
|
||
<radio-group bindchange="repeatChange">
|
||
<label>
|
||
<radio
|
||
value="daily"
|
||
checked="{{repeat_rule==='daily'}}"
|
||
color="#b95738"
|
||
/>
|
||
每天
|
||
</label>
|
||
<label>
|
||
<radio
|
||
value="weekdays"
|
||
checked="{{repeat_rule==='weekdays'}}"
|
||
color="#b95738"
|
||
/>
|
||
工作日
|
||
</label>
|
||
<label>
|
||
<radio
|
||
value="weekends"
|
||
checked="{{repeat_rule==='weekends'}}"
|
||
color="#b95738"
|
||
/>
|
||
周末
|
||
</label>
|
||
</radio-group>
|
||
</view>
|
||
<button class="primary" bindtap="save" disabled="{{saving}}">保存任务</button>
|
||
</view>
|
||
</view>
|
||
<tab-bar current="/pages/tasks/tasks" />
|