心理测评接口调用文档

接入流程方案

方案A:DiggMind提供通用模板,即时开通即可使用
方案B:使用H5混合模式(答题页面、报告页面)
方案C:使用H5混合模式(报告页面)
方案D:DiggMind提供通用模板,即时开通即可使用,需要渠道使用公众号授权(类似有赞)

在这里插入图片描述

合作商接入流程简述

方案A:DiggMind提供通用模板,即时开通即可使用

案例:http://wx.diggmind.com/test?channel_id=2

方案B:使用H5混合模式(答题页面、报告页面)

流程如下:

1)合作商 需自行开发订单、支付业务。或对原有系统进行升级改造。

2)合作商自行参考DiggMind接口文档实现逻辑上对接。

3)获取token后做本地缓存策略(Cache),记录Token有效时长,超时需重新获取。

【GET:/api/v1/open/token 获取AccessToken】

4)对本地测试列表、测试分类数据做同步。(可选)

【GET:/api/v1/channel/test/category/list 测试分类】

【GET:/api/v1/channel/test/list 测试列表】

5)合作商 需在订单 创建后,记录in_code到订单记录的字段当中,以方便后续使用。

【GET:/api/v1/channel/test/code 获取测试订单兑换码】

6)合作商 需在订单 支付成功后,通知 DiggMind 更改对应in_code的支付状态。(未支付不能答题、看报告)

【POST:/api/v1/channel/notify/payCb 订单状态回调 (支付成功)】

7)加载H5入口地址,此页面已封装好答题、报告逻辑

7.1)基于局部加载,使用 iframe / webview 加载 H5 入口地址

https://wx.diggmind.com/channel/entry?channel_code=xxx&test_id=xxx&in_code=shudanc22634159db192db6bce-QdIb5ms9&is_iframe=1

注意:使用iframe加载会导致跨域问题,解决方案请看 iframe_cros_demo 项目

7.2)或直接浏览器跳转

https://wx.diggmind.com/channel/entry?channel_code=xxx&test_id=xxx&in_code=shudanc22634159db192db6bce-QdIb5ms9&is_iframe=0

方案C:使用H5混合模式(报告页面)

流程如下:

1)合作商 需自行开发订单、支付业务。或对原有系统进行升级改造。

2)合作商自行参考DiggMind接口文档实现逻辑上对接。

3)获取token后做本地缓存策略(Cache),记录Token有效时长,超时需重新获取。

【GET:/api/v1/open/token 获取AccessToken】

4)对本地测试列表、测试分类数据做同步。(可选)

【GET:/api/v1/channel/test/category/list 测试分类】

【GET:/api/v1/channel/test/list 测试列表】

5)合作商 需在订单 创建后,记录in_code到订单记录的字段当中,以方便后续使用。

【GET:/api/v1/channel/test/code 获取测试订单兑换码】

6)合作商 需在订单 支付成功后,通知 DiggMind 更改对应in_code的支付状态。(未支付不能答题、看报告)

【POST:/api/v1/channel/notify/payCb 订单状态回调 (支付成功)】

7)合作商 读取in_code状态,判定跳转的业务逻辑。

【GET:/api/v1/channel/test/codeStatus 获取测试兑换码状态(支付状态\是否包含人口学角色信息\是否生成报告\是否支持重测)】


    {
      "http_status": 200,
      "status": true,
      "data": {
        "require_role": 0, // 是否需要角色信息
        "require_info": 0, // 是否需要人口学信息
        "is_role_finish": 0, // 是否完成角色填写
        "is_info_finish": 0, // 是否完成人口学填写
        "is_test_finish": 0,
        "is_test_package": 0,
        "is_order_pay": 0,
        "order_id": 253396,
        "test_id": 95,
        "test_limit_time": 1,
        "test_limit_time_gap": 0,
        "test_qa_template": "chat", // 答题模板 chat普通,normal高级
        "test_calculate_id": 0,
        "test_package_title": "",
        "test_package_brief": "",
        "user_role_id": 0,
        "user_result_id": 0,
        "user_limit_time_remain": 1
      },
      "meta": null,
      "msg": null
    }
    ```
7.1)合作商 自行开发 信息填写界面 业务逻辑,部分测试需要填写信息后才能取题测试。

【GET:/api/v1/channel/test/info/list 获取测试人口学信息】

```bash

    # 填写类型
    const TYPE_RADIO = 'radio';
    const TYPE_TEXT = 'text';
    const TYPE_DATE = 'date';
    const TYPE_CHECKBOX = 'checkbox';
    const TYPE = [
        self::TYPE_RADIO => '单选框',
        self::TYPE_CHECKBOX => '复选框',
        self::TYPE_TEXT => '文本框',
        self::TYPE_DATE => '日期框'
    ];
{
    "http_status": 200,
    "status": true,
    "data": [
        {
            "id": 13,
            "name": "请选择你的性别",
            "code": "sex",
            "type": "radio",
            "options": [
                {
                    "id": 27,
                    "name": "男",
                    "label": "男",
                    "value": "男",
                    "role_id": 1,
                    "role_level": "",
                    "disabled": false
                },
                {
                    "id": 28,
                    "name": "女",
                    "label": "女",
                    "value": "女",
                    "role_id": 2,
                    "role_level": "",
                    "disabled": false
                }
            ]
        },
        {
            "id": 15,
            "name": "婚姻状况",
            "code": "marry",
            "type": "radio",
            "options": [
                {
                    "id": 29,
                    "name": "未婚",
                    "label": "未婚",
                    "value": "未婚",
                    "role_id": 0,
                    "role_level": "",
                    "disabled": false
                },
                {
                    "id": 30,
                    "name": "已婚",
                    "label": "已婚",
                    "value": "已婚",
                    "role_id": 0,
                    "role_level": "",
                    "disabled": false
                },
                {
                    "id": 393,
                    "name": "离异",
                    "label": "离异",
                    "value": "离异",
                    "role_id": 0,
                    "role_level": "",
                    "disabled": false
                }
            ]
        },
        {
            "id": 16,
            "name": "父母是否离异",
            "code": "divorce",
            "type": "radio",
            "options": [
                {
                    "id": 31,
                    "name": "是",
                    "label": "是",
                    "value": "是",
                    "role_id": 0,
                    "role_level": "",
                    "disabled": false
                },
                {
                    "id": 32,
                    "name": "否",
                    "label": "否",
                    "value": "否",
                    "role_id": 0,
                    "role_level": "",
                    "disabled": false
                }
            ]
        },
        {
            "id": 17,
            "name": "你是排行第几的孩子",
            "code": "child_sort",
            "type": "radio",
            "options": [
                {
                    "id": 33,
                    "name": "第一",
                    "label": "第一",
                    "value": "第一",
                    "role_id": 0,
                    "role_level": "",
                    "disabled": false
                },
                {
                    "id": 34,
                    "name": "第二",
                    "label": "第二",
                    "value": "第二",
                    "role_id": 0,
                    "role_level": "",
                    "disabled": false
                },
                {
                    "id": 35,
                    "name": "第三",
                    "label": "第三",
                    "value": "第三",
                    "role_id": 0,
                    "role_level": "",
                    "disabled": false
                },
                {
                    "id": 36,
                    "name": "大于三",
                    "label": "大于三",
                    "value": "大于三",
                    "role_id": 0,
                    "role_level": "",
                    "disabled": false
                },
                {
                    "id": 37,
                    "name": "独生子女",
                    "label": "独生子女",
                    "value": "独生子女",
                    "role_id": 0,
                    "role_level": "",
                    "disabled": false
                }
            ]
        }
    ],
    "meta": [],
    "msg": ""
}

7.2)合作商 自行开发 信息填写界面后,并收集人口信息 或 角色ID 数据并提交到DM服务器

【POST:/api/v1/channel/test/info 提交测试人口学信息】

8)合作商 自行开发 答题界面 业务逻辑,部分测试需要根据填写的信息,进行抽题逻辑。

【GET:/api/v1/channel/test/question 获取测试题目】


    # 简单题目类型
    const TYPE_RADIO_TEXT = 'radio_text';
    self::TYPE_RADIO_TEXT => '文字单选'


    # 高级题目类型
    const TYPE_RADIO_TEXT = 'radio_text';
    const TYPE_CHECKBOX_TEXT = 'checkbox_text';
    const TYPE_FILL_TEXT = 'fill_text';
    const TYPE_SORT_TEXT = 'sort_text';
    const TYPE_CURSOR_TEXT = 'cursor_text';

    const TYPE_RADIO_IMAGE = 'radio_image';
    const TYPE_CHECKBOX_IMAGE = 'checkbox_image';
    const TYPE_SORT_IMAGE = 'sort_image';
    const TYPE_CURSOR_IMAGE = 'cursor_image';
    const TYPE_INTRO = 'intro';

       const TYPE = [
        self::TYPE_RADIO_TEXT => '文字单选',
        self::TYPE_RADIO_IMAGE => '图片单选',

        self::TYPE_CHECKBOX_TEXT => '文字多选',
        self::TYPE_CHECKBOX_IMAGE => '图片多选',

        self::TYPE_SORT_TEXT => '文字排序',
        self::TYPE_SORT_IMAGE => '图片排序',

        self::TYPE_CURSOR_TEXT => '文字游标',
        self::TYPE_CURSOR_IMAGE => '图片游标',

        self::TYPE_FILL_TEXT => '文字填空',
        self::TYPE_INTRO => '引导语',
   ];
   
[{
        "id": 39621,
        "title": "",
        "image": "",
        "type": "checkbox_image",
        "duration": 0,
        "is_image": 1,
        "options": [{
                "id": 210259,
                "image": "http:\/\/img.diggmind.cn\/2018\/09\/05\/faf0788f5a6925adb7d778c0aaaa63e5.png",
                "jump_question_id": 0
            },
            {
                "id": 210260,
                "image": "http:\/\/img.diggmind.cn\/2018\/09\/05\/c209d4f9310cbb08ed20402aa87a15d7.jpg",
                "jump_question_id": 0
            }
        ],
        "maxLength": 0,
        "minLength": 0
    },
    {
        "id": 23584,
        "title": "您最期望南航开展的心理服务方式有哪些",
        "image": null,
        "type": "checkbox_text",
        "duration": 0,
        "is_image": 0,
        "options": [{
                "id": 113225,
                "label": "心理咨询",
                "title": "心理咨询",
                "jump_question_id": 0
            },
            {
                "id": 113226,
                "label": "心理培训",
                "title": "心理培训",
                "jump_question_id": 0
            },
            {
                "id": 113227,
                "label": "心理讲座",
                "title": "心理讲座",
                "jump_question_id": 0
            },
            {
                "id": 113228,
                "label": "心理文化宣传",
                "title": "心理文化宣传",
                "jump_question_id": 0
            },
            {
                "id": 113229,
                "label": "沙龙活动",
                "title": "沙龙活动",
                "jump_question_id": 0
            },
            {
                "id": 113230,
                "label": "危机干预",
                "title": "危机干预",
                "jump_question_id": 0
            },
            {
                "id": 113231,
                "label": "其他",
                "title": "其他",
                "jump_question_id": 0
            }
        ],
        "maxLength": 0,
        "minLength": 0
    },
    {
        "id": 39622,
        "title": "",
        "image": "",
        "type": "cursor_image",
        "duration": 0,
        "is_image": 1,
        "options": [{
            "id": 210261,
            "min": 0,
            "max": 100,
            "step": 5,
            "image": {
                "start": "http:\/\/img.diggmind.cn\/2018\/09\/05\/1ec5a86cd89c164690a15c138f10da52.jpg",
                "end": "http:\/\/img.diggmind.cn\/2018\/09\/05\/402b88f844d04d1feaeb62dd1e8bc1ae.png"
            }
        }]
    },
    {
        "id": 13618,
        "title": "一个高颜值、聪明、富有或有创造力的人,才有资格谈论幸福。",
        "image": "",
        "type": "cursor_text",
        "duration": 0,
        "is_image": 0,
        "options": [{
            "id": 62289,
            "min": 0,
            "max": 6,
            "step": 0.3,
            "label": {
                "start": "完全不同意",
                "end": "完全同意"
            }
        }]
    },
    {
        "id": 13594,
        "title": "最后,请填写您的姓名:",
        "image": "",
        "type": "fill_text",
        "duration": 0,
        "is_image": 0,
        "options": []
    },
    {
        "id": 13934,
        "title": "你是谁?",
        "image": "",
        "type": "intro",
        "is_image": 0,
        "options": [{
            "content": "<h4>你是谁?<\/h4><\/br>",
            "duration": 0,
            "show_button_after": 0
        }]
    },
    {
        "id": 10884,
        "title": "亲,接下来每个题目都会出",
        "image": "http:\/\/img.diggmind.cn\/2017\/08\/22\/f1e6c1d5627650595cae6801548b3d25.png",
        "type": "radio_image",
        "duration": 0,
        "is_image": 1,
        "options": [{
                "id": 43912,
                "image": "http:\/\/img.diggmind.cn\/2017\/08\/22\/b06022df2a7d7c588cf1c1027c960475.png",
                "jump_question_id": 0
            },
            {
                "id": 45406,
                "image": "http:\/\/img.diggmind.cn\/2017\/08\/22\/5a816e661b63c6be8e7b6a6eec21845c.png",
                "jump_question_id": 0
            },
            {
                "id": 45407,
                "image": "http:\/\/img.diggmind.cn\/2017\/08\/22\/99f3635abaad9f7c9f6f11555a2e22ac.png",
                "jump_question_id": 0
            },
            {
                "id": 45408,
                "image": "http:\/\/img.diggmind.cn\/2017\/08\/22\/5a839480323e9b5f8bfe8957639a8e47.png",
                "jump_question_id": 0
            },
            {
                "id": 45409,
                "image": "http:\/\/img.diggmind.cn\/2017\/08\/22\/13f067e490521158b61b4feeacda95e8.png",
                "jump_question_id": 0
            },
            {
                "id": 45410,
                "image": "http:\/\/img.diggmind.cn\/2017\/08\/22\/e8832245d327d79f2933ef37fb578964.png",
                "jump_question_id": 0
            }
        ]
    },
    {
        "id": 5,
        "title": "你喜欢热闹的地方吗?",
        "image": "",
        "type": "radio_text",
        "duration": 0,
        "is_image": 0,
        "options": [{
                "id": 9,
                "label": "喜欢",
                "title": "喜欢",
                "jump_question_id": 0
            },
            {
                "id": 10,
                "label": "不喜欢",
                "title": "不喜欢",
                "jump_question_id": 0
            }
        ]
    },
    {
        "id": 1666,
        "title": "请你对以下工作的感兴趣程度从高到低排序。",
        "image": "",
        "type": "sort_image",
        "duration": 0,
        "is_image": 1,
        "options": [{
                "id": 6578,
                "image": "http:\/\/img.diggmind.cn\/data\/upload\/img\/201611\/58294a27f38a9.jpg"
            },
            {
                "id": 6579,
                "image": "http:\/\/img.diggmind.cn\/data\/upload\/img\/201609\/57ebde86176cb.jpg"
            },
            {
                "id": 6580,
                "image": "http:\/\/img.diggmind.cn\/data\/upload\/img\/201609\/57ebde9c8b2e3.jpg"
            },
            {
                "id": 6581,
                "image": "http:\/\/img.diggmind.cn\/data\/upload\/img\/201609\/57ebdeacbe3c4.jpg"
            }
        ]
    },
    {
        "id": 29100,
        "title": "哪种事情会让你觉得更尴尬?",
        "image": "",
        "type": "sort_text",
        "duration": 0,
        "is_image": 0,
        "options": [{
                "id": 150964,
                "label": "脸上有墨水"
            },
            {
                "id": 150965,
                "label": "走错厕所"
            },
            {
                "id": 150966,
                "label": "被老师批评"
            },
            {
                "id": 150967,
                "label": "认错人"
            }
        ]
    }
]
  1. 按指定格式提交测试结果

【POST:/api/v1/channel/test/result 提交测试结果】

choices 参数格式如下,提交结构为json对象数组 [obj1,obj2,obj3…]



[
    {
        "type": "radio_text",
        "option_ids": [132203],
        "question_id": 26596
    },
    {
        "type": "checkbox_text",
        "option_ids": [132272, 132273, 132274, 132275],
        "question_id": 26612
    },
    {
        "type": "fill_text",
        "value": "\u62d6\u5ef6",
        "question_id": 13656
    },
    {
        "type": "sort_text",
        "question_id": 1666,
        "option_ids": [6578, 6580, 6579, 6581]
    }, {
        "type": "cursor_text",
        "value": 8.5,
        "option_ids": [132104],
        "question_id": 26573
    },
    {
        "type": "radio_image",
        "option_ids": [132203],
        "question_id": 26596
    }, {
        "type": "checkbox_image",
        "option_ids": [132272, 132273, 132274, 132275],
        "question_id": 26612
    },

    {
        "type": "sort_image",
        "question_id": 1666,
        "option_ids": [6578, 6580, 6579, 6581]
    }, {
        "type": "cursor_image",
        "value": 8.5,
        "option_ids": [132104],
        "question_id": 26573
    }
]

10)使用H5模式获取报告

【GET:/api/v1/channel/test/report 获取测试报告】

http://wx.diggmind.com/channel/report?channel_code=xxx&test_id=xxx&in_code=shudanc22634159db192db6bce-QdIb5ms9

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

a123560mh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值