接口.txt 2.58 KB
POST https://devpay.brae.co
注册 /test/insurance/register
传入值
{
	"phone":13131313131,
	"password":"12313123",
	"nickname":"hhee"
}
返回值
{
	"id": 3,
	"nickname": "hhee"
}



登录  /test/insurance/login
传入值
{
	"phone":13131313131,
	"password":"12313123"
}
返回值
{
	"id": 3,
	"nickname": "hhee"
}

获取文章 /test/insurance/article
返回值
{
        "0": {
            "title": "家庭经济越差越应该买保险,因为你病不起,输不起,也折腾不起…",
            "content": "现实生活就是如此矛盾现实生活,就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实矛是如此此…",
            "name": "jack",
            "identify": "保险代理人",
            "num": "30",
            "id": "1"
        },
        "1": {
            "title": "因为你病不起,输不起,也折腾不起…",
            "content": "现实生活就是如此矛盾现实生活,就是如此矛盾现实生活就是如此矛盾现实生活,就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实矛是如此此…现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实生活就是如此矛盾现实矛是如此此…",
            "name": "luosf",
            "identify": "保险代理人",
            "num": "10",
            "id": "2"
        }
}


评论文章	/test/insurance/comment/add
传入值
{
	"user":2,
	"article":1,
	"content":"哈哈哈哈哈哈哈哈"
}


获取评论	/test/insurance/comment/get
返回值
{
        "0": {
            "time": "2017-09-08 16:35:28",
            "user": "yyy",
            "content": "哈哈~"
        }
}


  var that = this;
    return fetch(`https://devpay.brae.co/test/insurance/login`,{
      method: "POST",
      headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
      },
    })
      .then((resp) => {
        console.log("测试接口",resp);
        // return false;
        if (resp.status === 200) {
          return resp.json();
        } else {
          console.error("something went wrong!");
        }
      })
      .then((respJson) => {
        if (respJson.enmsg != 'ok') {
          console.error(err);
          alert(respJson.cnmsg);
        } else {
          that.setState({
            testData: respJson.data
          });
          console.log('state.testData',that.state.testData);
        }
      })
      .catch((err) => console.error(err))