isubmit() {
// owner_id: wx.getStorageSync('ownerid'),
// broadcast_id: wx.getStorageSync('broadcastid'),
var obj = {};
for (var i = 0; i < this.data.value.length; i++) {
obj[this.data.value[i].key] = this.data.value[i].value
};
obj.owner_id = 1;
obj.broadcast_id = 145;
obj.mobile = '18792526925'
wx.request({
url: app.globalData.baseUrl + '/web/broadcast/broadcast/broadcast-add',
method: 'POST',
data: obj,
header: {
'Content-Type': 'application/json',
},
success: function(res) {
var code = res.data.code;
if (code == 0) {
wx.showToast({
title: "提交成功",
})
wx.redirectTo({
url: '/pages/tic/room_webview/room/room',
success: function(res) {},
fail: function(res) {},
complete: function(res) {},
})
} else {
wx.showToast({
title: res.data.msg,
})
}
},
fail: function(e) {
util.progressTips('请求失败!');
}
})
},
页面:
<view class="form">
<van-cell-group>
<block wx:for="{{field_info}}" wx:for-index="key" wx:for-item="value">
<van-field
wx:if="{{value.fieldtype == 'text'}}"
value="{{ value[key].value }}"
placeholder="请输入"
label="{{value.fieldlabel}}"
border="{{ false }}"
bind:change="onChange"
data-attr="{{value.fieldname}}"
/>
<view class="radioText" hover-class="none" hover-stop-propagation="false" wx:if="{{value.fieldtype == 'radio'}}">
{{value.fieldlabel}}
</view>
<van-radio-group value="{{ radio }}" bind:change="onChange" wx:if="{{value.fieldtype == 'radio'}}" data-attr="{{value.fieldname}}" data-type="{{value.fieldtype}}">
<van-radio name="{{item.optionid}}" checked-color="#5cdbd3" wx:for="{{value.value}}" wx:for-index="index" wx:for-item="item">{{item.option}}</van-radio>
</van-radio-group>
<van-cell title="{{value.fieldlabel}}" is-link wx:if="{{value.fieldtype == 'select'}}" value="{{selectValue}}" data-value="{{value.value}}" bind:click="showSelectPopup" data-attr="{{value.fieldname}}"/>
<van-cell title="{{value.fieldlabel}}" is-link wx:if="{{value.fieldtype == 'date'}}" bind:click="showDatePopup" value="{{currentDate}}" data-attr="{{value.fieldname}}"/>
<van-field
value="{{ value[key].value }}"
label="{{value.fieldlabel}}"
type="textarea"
placeholder="请输入"
autosize
border="{{ false }}"
wx:if="{{value.fieldtype == 'textarea'}}"
bind:change="onChange"
data-attr="{{value.fieldname}}"
/>
</block>
</van-cell-group>
<van-popup
show="{{ dateshow }}"
position="bottom"
custom-style="height: 50%;"
bind:close="onClose"
>
<van-datetime-picker
type="year-month"
value="{{ currentDate }}"
bind:input="onInput"
bind:confirm = "confirmDate"
/>
</van-popup>
<van-popup
show="{{ selectshow }}"
position="bottom"
custom-style="height: 50%;"
bind:close="onClose"
>
<van-picker show-toolbar
columns="{{ columns }}"
bind:cancel="onClose"
data-attr="{{value.fieldname}}"
bind:confirm="onConfirm" />
</van-popup>
</view>
网友评论