-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #418 from linhaohong/master
- Loading branch information
Showing
4 changed files
with
248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
// pages/form/form.js | ||
Page({ | ||
|
||
/** | ||
* 页面的初始数据 | ||
*/ | ||
data: { | ||
//text: '勿忘初心', | ||
text1:'勿忘初心', | ||
text2:'', | ||
text3: '', | ||
text4: '', | ||
text5: '', | ||
text6: '', | ||
area1: '...', | ||
count1: '...'.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 | ||
}) | ||
} | ||
}) | ||
// 从服务器取回来 JSON | ||
wx.request({ | ||
url: 'https://infoaas.com/data/hzc.json', | ||
//仅为示例,并非真实的接口地址 | ||
data: { }, | ||
header: { | ||
'content-type': 'application/json' // 默认值 | ||
}, | ||
success: function (res) { | ||
console.log(res.data) | ||
/* | ||
that.setData({ | ||
hasError: true, | ||
errorText: res.data.name + ',' + res.data.teacher + ' ' + res.data.year | ||
})*/ | ||
} | ||
}) | ||
}, | ||
|
||
/** | ||
* 生命周期函数--监听页面初次渲染完成 | ||
*/ | ||
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 | ||
}) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<!--pages/form/form.wxml--> | ||
<view class="page" xmlns:wx="http://www.w3.org/1999/xhtml"> | ||
<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="text1" | ||
value='{{text1}}' placeholder="输入姓名" bindinput='onTextChange'/> | ||
</view> | ||
</view> | ||
</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="text2" | ||
value='{{text2}}' placeholder="常用手机号码" bindinput='onTextChange'/> | ||
</view> | ||
</view> | ||
</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="text3" | ||
value='{{text3}}' placeholder="常用邮箱" bindinput='onTextChange'/> | ||
</view> | ||
</view> | ||
</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="text4" | ||
value='{{text4}}' placeholder="您的公司" bindinput='onTextChange'/> | ||
</view> | ||
</view> | ||
</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="text5" | ||
value='{{text5}}' placeholder="您的职位" bindinput='onTextChange'/> | ||
</view> | ||
</view> | ||
</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="text6" | ||
value='{{text6}}' 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="area1" placeholder="一句话介绍一下自己吧,让更多的人了解你。" style="height: 3.3em" value='{{area1}}' bindinput='onChange'/> | ||
<view class="weui-textarea-counter">{{count1}}/200</view> | ||
</view> | ||
</view> | ||
</view> | ||
|
||
<view class="weui-btn-area"> | ||
<button class="weui-btn" type="primary" form-type='submit'>保存信息</button> | ||
</view> | ||
</form> | ||
</view> | ||
</view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* pages/form/form.wxss */ |