Skip to content

Commit

Permalink
hzuapps#4 hzuapps#157 第四次实验代码
Browse files Browse the repository at this point in the history
  • Loading branch information
lwYU committed Dec 1, 2017
1 parent 45ff058 commit 15e6963
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 2 deletions.
9 changes: 7 additions & 2 deletions 1514080901111/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"pages":[
"pages/index/index",
"pages/logs/logs",
"pages/sy/sy"
"pages/sy/sy",
"pages/sh/sh"
],
"window":{
"backgroundTextStyle":"light",
Expand All @@ -20,7 +21,11 @@
},
{
"pagePath": "pages/sy/sy",
"text": ""
"text": "1"
},
{
"pagePath": "pages/sh/sh",
"text": "2"
}
]
}
Expand Down
180 changes: 180 additions & 0 deletions 1514080901111/pages/sh/sh.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
// pages/sh/sh.js
Page({

/**
* 页面的初始数据
*/


/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {

},

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

},

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

},

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

},

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

},

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

},

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

},

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

},
// pages/form/form.js


/**
* 页面的初始数据
*/
data: {
text: '',

},


/**
* 生命周期函数--监听页面初次渲染完成
*/
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,
text: event.detail.value.text
})
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 1514080901111/pages/sh/sh.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
32 changes: 32 additions & 0 deletions 1514080901111/pages/sh/sh.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--pages/sh/sh.wxml-->

<!--pages/form/form.wxml-->

<view class="page__hd">
<view class="page__title">Input</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-btn-area">
<button class="weui-btn" type="primary" form-type='submit'>输入完毕</button>
</view>
</form>
<view>{{text}}</view>
</view>

1 change: 1 addition & 0 deletions 1514080901111/pages/sh/sh.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* pages/sh/sh.wxss */

0 comments on commit 15e6963

Please sign in to comment.