From 25e1ebd4305b1091a7f57cf83be0b0f8ee13d82b Mon Sep 17 00:00:00 2001 From: linwusheng <2707664982@qq.com> Date: Wed, 18 Oct 2017 11:44:59 +0800 Subject: [PATCH] =?UTF-8?q?#83=20=E7=AC=AC5=E6=AC=A1=E5=AE=9E=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1517060318/2017-10-18/network/form.js | 113 ++++++++++++++++++++++++ 1517060318/2017-10-18/network/form.wxml | 35 ++++++++ 1517060318/2017-10-18/network/form.wxss | 1 + 3 files changed, 149 insertions(+) create mode 100644 1517060318/2017-10-18/network/form.js create mode 100644 1517060318/2017-10-18/network/form.wxml create mode 100644 1517060318/2017-10-18/network/form.wxss diff --git a/1517060318/2017-10-18/network/form.js b/1517060318/2017-10-18/network/form.js new file mode 100644 index 0000000..d5b1243 --- /dev/null +++ b/1517060318/2017-10-18/network/form.js @@ -0,0 +1,113 @@ +// pages/form/form.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + text: "Hello" + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var that = this; + /* + wx.getStorage({ + key: 'formData', + success: function (res) { + console.log(res.data) + that.setData({ + text: res.data.text, + paragh: res.data.paragh + }); + } + }) + */ + wx.request({ + url: 'https://infoaas.com/data/hzc.json', //仅为示例,并非真实的接口地址 + data: {}, + header: { + 'content-type': 'application/json' // 默认值 + }, + success: function (res) { + console.log(res.data) + that.setData({ + text: res.data.name, + paragh: "任课老师是:" + res.data.teacher + " 2017" + }); + } + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + + doSubmit: function (e) { + console.dir(e) + var that = this; + var text = e.detail.value.text; + var paragh = e.detail.value.paragh; + + wx.setStorage({ + key: "formData", + data: { + text: text, + paragh: paragh + } + }) + + wx.showToast({ + title: '成功', + icon: 'success', + duration: 2000 + }) + } +}) \ No newline at end of file diff --git a/1517060318/2017-10-18/network/form.wxml b/1517060318/2017-10-18/network/form.wxml new file mode 100644 index 0000000..6adf6e7 --- /dev/null +++ b/1517060318/2017-10-18/network/form.wxml @@ -0,0 +1,35 @@ + + + + 表单示例 + 输入文字并提交 + +
+ + {{text + ", " + paragh}} + + 文本框 + + + + + + + + + 文本域 + + + +