add two methods

kongweiyu_branch
孔维屿 1 year ago
parent dc8ab695c5
commit 3b82cb9c2f

@ -7,10 +7,10 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
tempFilePaths: {}
}, },
submit: (e)=> { submit: (e) => {
console.log(e.detail.value) console.log(e.detail.value)
db.add({ db.add({
@ -21,6 +21,22 @@ Page({
}) })
}, },
chooseFile: function() {
var that = this
wx.chooseMessageFile({
count: 10,
type: 'image',
success: function(res) {
// tempFilePath可以作为img标签的src属性显示图片
that.setData({
tempFilePaths: res.tempFiles
})
console.log(res.tempFiles);
console.log(that.data.tempFilePaths[0].path);
}
})
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */

@ -133,7 +133,11 @@
</view> </view>
<view class="input-group"> <view class="input-group">
<text>风采展示图:</text> <text>风采展示图:</text>
<input type="text" placeholder="在此插入图片" class="input" /> <button bind:tap="chooseFile">选择图片</button>
<!-- <view wx:for="{{tempFilePaths}}">
<image src="{{item}}"/>
</view> -->
<!-- <input type="text" placeholder="在此插入图片" class="input" /> -->
</view> </view>
</view> </view>

@ -4,7 +4,15 @@ Page({
region:"", region:"",
}, },
submit:function(e){ submit:function(e){
console.log(e); wx.cloud.database()
.collection("homeworks")
.add({
data: e.detail.value,
success: (res) =>{
console.log(res)
}
})
}, },
dateChange:function(e){ dateChange:function(e){

@ -1,25 +1,29 @@
<view class="container"> <view class="container">
<view> <form bindsubmit="submit">
<view class="form-group"> <view class="form-group">
<text>任务标题:</text> <text>任务标题:</text>
<input type="text" placeholder="请输入任务标题" /> <input type="text" name="title" placeholder="请输入任务标题" />
</view> </view>
<view class="form-group"> <view class="form-group">
<text>任务内容:</text> <text>任务内容:</text>
<textarea placeholder="请输入任务内容"></textarea> <textarea name="details" placeholder="请输入任务内容"></textarea>
</view> </view>
<view class="form-group"> <view class="form-group">
<text>截止时间:</text> <text>截止时间:</text>
<input type="datetime-local" /> <input name="deadLine" type="datetime-local" />
</view> </view>
<view class="form-group"> <view class="form-group">
<text>附件:</text> <text>附件:</text>
<button class="btn-attachment">上传附件</button> <button class="btn-attachment">上传附件</button>
</view> </view>
</view>
<button class="btn-submit">提交</button>
<button form-type="submit" class="btn-submit">提交</button>
</form>
</view> </view>

Loading…
Cancel
Save