Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4 #29 第4次实验代码 #480

Merged
merged 2 commits into from
Dec 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions 1514080901105/pages/form/form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//dd
Page({
data: {
height: 20,
focus: false
},
bindButtonTap: function () {
this.setData({
focus: true
})
},

bindFormSubmit: function (e) {
console.log(e.detail.value.textarea)
},
formSubmit: function (event) {
var ggc = {};
var that = this
console.log(event)
ggc.radiogroup = event.detail.value.radiogroup;
ggc.radiogroup2 = event.detail.value.radiogroup2;
ggc.input = event.detail.value.input;
//console.log('form发生了submit事件,携带数据为:', e.detail.value)
if (!ggc.radiogroup || !ggc.radiogroup2 || !ggc.input) {
console.log(ggc)
that.setData({
hasError: true,
errorText: '选项不能为空'
})
} else {
that.setData({
hasError: false
})
wx.setStorage({

key: "ggc",
data: event.detail.value,
success: function (res) {
wx.showToast({
title: '成功',
icon: 'success',
duration: 2000
})
}
})
}

},
formReset: function () {
console.log('form发生了reset事件')
}
})
2 changes: 2 additions & 0 deletions 1514080901105/pages/form/form.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

{}
37 changes: 37 additions & 0 deletions 1514080901105/pages/form/form.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<form bindsubmit="formSubmit" bindreset="formReset">
<view class="weui-toptips weui-toptips_warn"
wx:if="{{hasError}}">{{errorText}}</view>
<view>选择景点类别:</view>
<view class="section section_gap">
<radio-group name="radiogroup">
<label><radio value="radio1"/>地质地貌景观</label>
<label><radio value="radio2"/>水体景观</label>
<label><radio value="radio3"/>气象气候旅游</label>
<label><radio value="radio4"/>生物旅游</label>
<label><radio value="radio5"/>人文旅游</label>
</radio-group>
</view>

<view>选择出行季节:</view>
<view class="section2 section_gap">
<radio-group name="radiogroup2">
<label><radio value="radio1"/>春</label>
<label><radio value="radio2"/>夏</label>
<label><radio value="radio3"/>秋</label>
<label><radio value="radio4"/>冬</label>
</radio-group>
</view>

<text>我的头衔:</text>
<view class="section">
<input name="input"/>
</view>

<text class="txt">介绍一下我自己:</text>
<view class="section1">
<textarea placeholder="" focus="{{focus}}" />
</view>
<view class="btn-area">
<button formType="submit" style="background:#ff9900">提交</button>
</view>
</form>
21 changes: 21 additions & 0 deletions 1514080901105/pages/form/form.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* es/ggs/ggs.wxss */
.section{
border:1px solid #ddd;
width:96%;
margin:auto;
height:200rpx;
margin-top:20rpx;
}
.section1{
border:1px solid #ddd;
width:96%;
margin:auto;
margin-top:20rpx;
}
.section2{
border:1px solid #ddd;
width:96%;
margin:auto;
height:80rpx;
margin-top:20rpx;
}