本次作业由小组四人合力完成:
- 产品:程林可
- 前端:熊洋
- 后端:于毅仁、李景琦
小程序:TODO LIST
源码如下
-
:Todo list小程序
Js:
Page({data:{
tasks:[],
newTask:'',
key:0
},
changeTaskStatus: function(e){
let value = e.currentTarget.dataset.value;let tasks = this.data.tasks;
let index = tasks.findIndex(task => task.value == value);
if (index<0){
return;
}tasks[index].status = !tasks[index].status;
this.setData({
tasks : tasks
});
},
removeTask: function(e){
let value = e.currentTarget.dataset.value;let tasks = this.data.tasks; let newTasks = tasks.filter(task => task.value != value); this.setData({ tasks : newTasks
});
},
typeNewTask: function(e){
this.setData({
newTask: e.detail.value.trim()
});
},addTask: function(){
let tasks = this.data.tasks;let key = this.data.key;
let newTaskObj={content: this.data.newTask,value: key++,status: false};
tasks.push(newTaskObj);
this.setData({
tasks: tasks,
key: key,
newTask:''
});
},
})
Json:
{
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black",
"navigationBarTitleText": "Todo List",
"backgroundColor": "#eeeeee",
"backgroundTextStyle": "light"
}
Qml:
<view class="page">
<view class="page__bd">
<view class="weui-cell">
<view class="weui-cell__bd">
<input class="weui-input" placeholder='添加新任务' bindinput='typeNewTask' value="{{newTask}}"></input>
</view>
<view class="weui-cell__ft"><button class="weui-btn" type="primary" bindtap="addTask" disabled="{{newTask == ''}}">添加</button></view>
</view>
<view class="weui-cells__title">待办事项</view>
<view class="weui-cells weui-cells_after-title">
<radio-group>
<label class="weui-cell weui-check__label" wx:for="{{tasks}}" wx:key="{{item.value}}" wx:if="{{!item.status}}" data-value="{{item.value}}" bindtap="changeTaskStatus">
<checkbox class="weui-check" value="{{item.value}}"/>
<view class="weui-cell__hd weui-check__hd_in-checkbox">
<icon class="weui-icon-checkbox_circle" type="circle" size="23"></icon>
</view>
<view class="weui-cell__bd">{{item.content}}</view>
<view class="weui-cell__ft"><button class="weui-btn" type="warn" data-value="{{item.value}}" catchtap="removeTask">删除</button></view>
</label>
</radio-group>
</view>
</view>
</view>
Qss:
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
}
.userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.userinfo-nickname {
color: #aaa;
}
.usermotto {
margin-top: 200px;
}