Skip to content

Commit

Permalink
hzuapps#4 hzuapps#19 第四次实验代码
Browse files Browse the repository at this point in the history
  • Loading branch information
panxiaomian committed Nov 30, 2017
1 parent 3d86dec commit bf152ca
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 36 deletions.
136 changes: 136 additions & 0 deletions 1514080901223/pages/form/form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// pages/form/form.js
Page({

/**
* 页面的初始数据
*/
data: {
text: 'title',
area: 'content',
count: 'content'.length
},

/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this;
wx.getStorage({
key: 'input',
success: function (res) {
console.log(res.data.area.length)

that.setData({
text: res.data.text,
area: res.data.area,
count: res.data.area.length
})
}
})

},

/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {

},

/**
* 生命周期函数--监听页面显示
*/
onShow: function () {

},

/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {

},

/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {

},

/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {

},

/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {

},

/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {

},

onSubmit: function (event) {
console.dir(event)
var that = this
var text = event.detail.value.text
if (!text) {
console.dir(text)
that.setData({
hasError: true,
errorText: '标题不能为空!'
})
} else {
that.setData({
hasError: false
})
wx.setStorage({
key: "input",
data: event.detail.value,
success: function (res) {
wx.showToast({
title: '添加成功',
icon: 'success',
duration: 2000
})

}
})
}
},

onTextChange: function (e) {
var that = this;
console.dir(e)
var text = e.detail.value
console.dir(text);
if (!text) {
that.setData({
hasError: true,
errorText: '标题不能为空!'
})
} else {
that.setData({
hasError: false
})
}
},

onChange: function (e) {
var that = this;
var value = e.detail.value;
console.dir(value)
that.setData({
count: value.length
})
}
})
1 change: 1 addition & 0 deletions 1514080901223/pages/form/form.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
36 changes: 36 additions & 0 deletions 1514080901223/pages/form/form.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--pages/form/form.wxml-->
<view class="page" >
<view class="page__hd">
<view class="page__title">事项表单</view>
</view>
<view class="page__bd">
<form bindsubmit='onSubmit'>
<view class="weui-toptips weui-toptips_warn"
wx:if="{{hasError}}">{{errorText}}</view>

<view class="weui-cells__title">请输入事项标题</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell weui-cell_input">
<view class="weui-cell__bd">
<input class="weui-input" name="text"
value='{{text}}' placeholder="请输入文本" bindinput='onTextChange'/>
</view>
</view>
</view>

<view class="weui-cells__title">请输入事项内容</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell">
<view class="weui-cell__bd">
<textarea class="weui-textarea" name="area" placeholder="请输入文本" style="height: 4.4em" value='{{area}}' bindinput='onChange'/>
<view class="weui-textarea-counter">{{count}}/300</view>
</view>
</view>
</view>

<view class="weui-btn-area">
<button class="weui-btn" type="primary" form-type='submit'>确定</button>
</view>
</form>
</view>
</view>
10 changes: 10 additions & 0 deletions 1514080901223/pages/form/form.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* pages/form/form.wxss */
.page__hd {
font-size: 18px ;
color:whitesmoke;
text-align: center;

}
.page__bd{
font-size: 15px;
}
13 changes: 2 additions & 11 deletions 1514080901223/pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {promiseHandle, log, formatNumber} from '../../utils/util';
Page({
data: {
showMonth: {},
data: {
},
data: {},
selectDateText: '',
pickerDateValue: '',

isSelectMode: false,
isMaskShow: false,
isEditMode: false,
Expand All @@ -29,15 +29,6 @@ Page({

// 事项列表
itemList: [],

taskList: [{ id: 0, content: '事项1:今天是好朋友的生日', time: '2017年11月15日' },
{ id: 1, content: '事项2:今天有重要会议要开', time: '2017年12月1日' },
{ id: 2, content: '事项3:今天出去参加同学聚会', time: '2017年12月3日' },
{ id: 3, content: '事项4:一年一度的家庭旅游', time: '2018年1月1日' },
{ id: 4, content: '事项5:今天是期末考试的第一天', time: '2018年1月20日' },
{ id: 5, content: '事项6:今天开始放寒假', time: '2018年1月25日' }
],

editItemList: [] //编辑勾选中的事项id
},

Expand Down
43 changes: 18 additions & 25 deletions 1514080901223/pages/index/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,21 @@
</view>
</view>

<view class="section">
<view class="section__title">事项管理</view>
<scroll-view class="page" scroll-y="true" style="height:400px;" bindscrolltoupper="onUpper" bindscrolltolower="onLower" bindscroll="onScroll" >
<view class="page__bd" wx:for="{{taskList}}" wx:key='task'>
<view class="weui-panel weui-panel_access" >
<view class="weui-panel__bd">
<view class="weui-media-box weui-media-box_appmsg">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<icon type="waiting" size="56"/>
</view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__desc">{{item.time}}</view>
<view class="weui-media-box__desc">{{item.content}}</view>

</view>
</view>
</view>
</view>
<view class="weui-loadmore" wx:if="{{isLower}}">
</view>
<view class="weui-loadmore weui-loadmore_line" wx:if="{{isEnd}}">
</view>
</view>
</scroll-view>
</view>
<view class="btn-area">
<navigator url="/pages/form/form" hover-class="navigator-hover">点击跳转到"事项表单"页面</navigator>
</view>

<view class="updatePanel" style="top: {{updatePanelTop}}px;height:{{updatePanelTop}}px" animation="{{updatePanelAnimationData}}">
<!--<view class="title"><text>添加事项</text></view>-->
<input placeholder="请输入事项标题" value="{{todoInputValue}}" bindchange="todoInputChangeEvent" />
<textarea placeholder="请输入事项内容" value="{{todoTextAreaValue}}" bindblur="todoTextAreaChangeEvent"></textarea>
<view class="level">
<block wx:for="{{levelSelectData}}" wx:key="*this">
<view bindtap="levelClickEvent" data-level="{{item}}" class="item {{item == 1 ? 'border-normal' : ''}} {{item == 2 ? 'border-warning' : '' }} {{item == 3 ? 'border-danger' : ''}} {{item == levelSelectedValue && item == 1 ? 'bg-normal' : ''}} {{item == levelSelectedValue && item == 2 ? 'bg-warning' : ''}} {{item == levelSelectedValue && item == 3 ? 'bg-danger' : ''}}"></view>
</block>
</view>
<view class="footer">
<view class="btn" bindtap="closeUpdatePanelEvent">取消</view>
<view class="btn primary" bindtap="saveDataEvent">保存</view>
</view>
</view>

0 comments on commit bf152ca

Please sign in to comment.