Mudu.Room.Signup 报名问卷组件

获取报名问卷配置

Mudu.Init(41988, function () {
    console.log('Mudu Web Sdk 初始化成功')

    // 获取当前频道正在使用的问卷数据, 需要在频道初始化完成后调用
    Mudu.Room.Signup.GetUsingSignup(function(dataStr){
        // data 数据结果如下表所示
        var data = JSON.parse(dataStr); 
    });

    // 监听问卷的使用状态变更, 需要在频道初始化完成后调用
    Mudu.MsgBus.On('Signup.Status.Change', function(dataStr) {
        var data = JSON.parse(dataStr);
        console.log(data.status); // boolean 启用或关闭问卷
        console.log(data.position); // number 0表示内置问卷;1表示前置问卷
        console.log(data.question_id); // string 问卷的id

        // 根据业务逻辑决定是否重新调用Mudu.Room.Signup.GetUsingSignup方法 或者关闭问卷的弹窗
    });
  }
)
data 数据结构说明
字段 说明 类型
errcode 返回状态码(见页面底部) number
msg 返回结果的描述 string
page_before 使用中的前置问卷 signupItem[] (signupItem 结构如下)
page_in 使用中的内置问卷 signupItem[] (signupItem 结构如下)
signupItem 数据结构说明
字段 说明 类型
question_id 问卷id string
name 问卷名称 string
position 问卷位置,如下:
0 表示内置问卷
1 表示 前置问卷
number
desc 问卷的描述 string
status 问卷的开启状态, 如下:
0 表示未开启
1 表示 已开启
number
dialog_mode 内置问卷的弹窗方式
0 表示由观众手动点击弹窗
1 表示立即弹窗
number
columns 问卷的表单内容 formItem[] (formItem 结构如下)
privacy_url 隐私协议地址 string
formItem 数据结构说明
字段 说明 类型
type 'nickname':昵称
'phone':手机号
'privacyPolicy':隐私政策
'input':单行文本回复
'textarea':多行文本回复
'question':选择题
'questionAnswer':问答题
string
name 题目的显示名称或题目名称 string
must 是否必填(true为必填, false为非必填) boolean
multi_select 选择题是否为多选 boolean
allow_fill_by_self 选择题是否允许填写答案(true为允许,false为不允许) boolean
remind 是否开启短信提醒(仅当type为phone时存在) boolean
sendSms 是否开启发送验证码(仅当type为phone时存在) boolean
startTime 直播开始时间(仅当type为phone时存在) string
ahead 直播前多少分钟发送提醒(仅当type为phone时存在) number
options 选择题的选项列表 {A: '选项a', B: '选项b', ...} object

手机短信验证

操作流程如下
  • 初始化 智能人机校验 模块
  • 校验成功后,获取到token、sessionId、sig参数
  • 使用上述参数在内的数据 调用发送短信接口
智能人机校验
Mudu.Room.Signup.InitCaptcha({
    //声明智能验证需要渲染的目标元素ID。
    renderTo: '#sc',
    //智能验证组件的宽度。
    width: 300,
    //智能验证组件的高度。
    height: 42,
    //前端智能验证通过时会触发该回调参数。您可以在该回调参数中将请求标识(token)、会话ID(sessionid)、签名串(sig)字段记录下来,随业务请求一同发送至您的服务端调用验签。
    success: function(data) {
        // 以下数据是发送短信接口必须的参数
        console.log(data.token);
        console.log(data.sessionId);
        console.log(data.sig);
    },
    fail: function() {
        // 可以在这里调用ResetCaptcha方法进行重置
        console.log('ic error');
    },
    isH5: false, // 非必须 boolean 是否为H5应用,已默认自动检测,也可手动指定
})
发送问卷的手机验证码

注: 发送短信接口每个页面1分钟内只能调用一次, 且发送短信会产生相应的费用

Mudu.Room.Signup.SendSmsRequest({
        signupId: 'xxx', // 必须 string 当前问卷的question_id
        sig, sessionId, token, // 必须 string 人机智能验证成功回调的数据,见上一步success方法
        phone_number, // 必须 string 手机号码
        isH5: false, // 非必须 boolean 是否为H5应用,已默认自动检测,也可手动指定
    },function (response) {
        // response中 错误码见页面底部
        response = JSON.parse(response)
        console.log(response)
    }
)
重置人机智能验证
// 必须在Mudu.Room.Singup.InitCaptcha方法调用后才能使用
// 使用场景如:表单校验失败后,需要重新进行校验的场景
Mudu.Room.Signup.ResetCaptcha();

提交报名表单

// 提交表单数据
Mudu.Room.Signup.SubmitSingup({
        code: '8909', // 必须 string 手机验证码,若无,则为空字符串 
        signupId: 'dfzvda', // 必须 string 问卷id 
        columns: [ // 必须 columns为question及其答案数组
            {type: 'phone', 'name': '手机号', text: '18099998888'},
            {type: 'nickname', 'name': '姓名', text: '目睹君'},
            {type: 'privacyPolicy', 'name': '隐私政策', text: '1'},
            {type: 'question', 'name': '你喜欢听哪些歌手', selects: ['A', 'B', 'D'], text: 'Coldplay' }
        ],
    }, function (response) {
        // response 中对应的错误码见页面底部
        response = JSON.parse(response)
        console.log(response)
    }
)
提交表单时columns item 数据结构说明
名称 说明 类型
type question的类型(nickname为昵称, phone为手机号,privacyPolicy为隐私政策 input为单行文字, question为选择题, questionAnswer为问答题) string
name question的显示名称或题目名称 string
selects 观众选择题所选择的项 array
text 昵称、手机号、单行文字、多行文字、的答案,或者观众选择题的自填答案 string

errcode 错误码列表

errcode 说明
1000 成功
5601 参数错误
5602 系统繁忙,请稍后再试
5603 无效数据
5604 重复操作
5605 外部请求错误
5606 外部响应错误
5607 不允许的操作
5608 参数格式错误
5609 系统繁忙,请稍后再试~
5612 创建文件出错
5613 保存文件出错
5614 用户信息错误
5615 人机验证错误
5616 验证码错误次数超过5次
5617 验证码错误
5618 验证码过期
5619 问卷关闭
5620 获取用户权限列表失败
5621 添加用户权限失败
5622 发送短信失败
5699 短信发送频率过高

results matching ""

    No results matching ""