在页面必要点击的地方批量获取formid保存下来,代码如下:
wxml:
<form bindsubmit="formSubmit" report-submit="{{true}}">
<button formType="submit" class='btn'>
<form bindsubmit="formSubmit" report-submit="{{true}}">
<button formType="submit" class='btn'>
<view class='u-publish-btn' bindtap='test'>立即下单</view>
</button>
</form>
</button>
</form>
wxss:
form button{
padding: 0;
}
form button::after{
content: '';
display: none;
}
.u-publish-btn{
position: fixed;
bottom: 0;
right:0;
width: 180rpx;
line-height: 100rpx;
border-radius: 4rpx;
background: #fcd15e;
font-size: 38rpx;
font-weight: bolder;
color: #fff;
}
js:
//批量存储formid
formSubmit: function(e) {
if (e.detail.formId != 'the formId is a mock one') {
var form = this.data.formIds;
form.push(e.detail.formId)
this.setData({
formId: form
})
console.log(form)
wx.setStorageSync("formids", form)
}
console.log(e.detail)
}
注:注意fromid存储的异步问题,把需要取得formid的事件延迟执行,最好批量获取id时加一个弹窗事件已解决这个问题。
网友评论