【声明】关于六久阁私自出售我公司dedecms小程序插件声明
发布时间:2022-05-10 11:26:43查看:0自定义表单form 
接口名称:小程序自定义表单
接口标识:diyform
接口url:https://你的网站/index.php?s=xiaochengxu&c=home&m=form&type=post
接口参数
字段名称 字段说明 类型 必填 备注
diyid 表单id num 必填  
type 操作类型 string 可不填 可选参数:post/提交表单、list/读取列表、view/阅读;默认:post
num 数量 num 可不填 调用数量,默认10,为空则按照分页调用

type不同所需参数也不同
1、当type=post时候,提交表单
此时除了必须的aid、type之外,其他的参数需要和你的后台参数类型相同,具体参考demo
字段名称 字段说明 类型 必填 备注
tablename 表单的表名 string 必填  
type 操作类型 string 必填 可选参数:post/提交表单、list/读取列表;默认:post

2、当type=list时,获取对应表单的内容列表
字段名称 字段说明 类型 必填 备注
tablename 表单的表名 string 必填  
type 操作类型 string 必填 可选参数:post/提交表单、list/读取列表;默认:post
num 数量 num 可不填 调用数量,默认10,为空则按照分页调用
pagesize 自定义分页大小 num 可不填 默认后台设置的页面大小
order 排序 string 可不填 默认:"id desc";

小程序参考代码:
  1. <view class='message'
  2.         <form bindsubmit="formSubmitHandle"
  3.             <view class='form_input'
  4.                 <input type='digit' placeholder="电话" name='phone' value='' /> 
  5.             </view> 
  6.             <view class='form_input'
  7.                 <input type='text' placeholder="姓名" name='author' value='' /> 
  8.             </view> 
  9.             <view class='form_input'
  10.                 <input type='text' placeholder="标题" name='title' /> 
  11.             </view> 
  12.             <view class='form_input'
  13.                 <textarea class='form_textarea' name="content" placeholder="留言内容" /> 
  14.             </view> 
  15.             <view class="c"></view> 
  16.             <view class="btn-area"
  17.             <button form-type="submit">提交留言</button> 
  18.             </view> 
  19.         </form> 
  20.     </view> 

小程序js代码:
  1. swan.request({ 
  2.             url: app.globalData.api + "form"
  3.             data: { 
  4.                 tablename: 'message',//表单必填 
  5.                 title:e.detail.value.title, 
  6.                 phone:e.detail.value.phone, 
  7.                 content: e.detail.value.content, 
  8.                 author:'小程序'+ author, 
  9.                 type: 'post'
  10.                 aid: app.globalData.aid//必填 
  11.             }, 
  12.             method: 'POST'
  13.             header: { 
  14.                 'content-type''application/x-www-form-urlencoded'
  15.                 'x-safecode': app.globalData.safecode 
  16.             }, 
  17.             success: function (res) { 
  18.                 console.log(res) 
  19.                 if (res.data.msg == 'ok') { 
  20.                     swan.showToast({ 
  21.                         title: '留言成功!!'
  22.                         icon: 'success'
  23.                         duration: 1500, 
  24.                         success: function () { 
  25.                             setTimeout(function () { 
  26.                                 swan.navigateBack(); 
  27.                             }, 2000) 
  28.                         } 
  29.                     }) 
  30.  
  31.                 } else { 
  32.                     swan.showToast({ 
  33.                         title: '留言失败,请重新提交!!'
  34.                         icon: 'warn'
  35.                         duration: 1500 
  36.                     }) 
  37.                 } 
  38.                 setTimeout(function () { 
  39.                     swan.hideToast() 
  40.                 }, 2000) 
  41.             } 
  42.         }) 

小程序获取表单内容列表代码:
  1. get_msglist(diyid) { 
  2.         swan.request({ 
  3.             url: app.globalData.api + "action=form"
  4.             data: { 
  5.                 diyid: diyid,//必填 
  6.                 type: 'list'
  7.                 aid: app.globalData.aid//必填 
  8.             }, 
  9.             method: 'POST'
  10.             header: { 
  11.                 'content-type''application/x-www-form-urlencoded'
  12.                 'x-appsecret': app.globalData.appsecret 
  13.             }, 
  14.             success: function (res) { 
  15.                 console.log(res) 
  16.             } 
  17.         }) 
  18.     }, 

你在使用自定义表单接口的时候如果遇到什么问题,请随时与我们交流QQ:2863868475


版权声明:本文为原创文章,未经允许不得转载。https://doc.tengcee.com/xunrui/xunruiapi/235.html
上一篇:文章标签tag
下一篇:用户授权member

服务热线

15137100750

我知道你不会打


但是我还是要写


你懂得!

微信二维码

QQ群二维码