美文网首页
接口文档

接口文档

作者: 皇甫圣坤 | 来源:发表于2020-04-30 09:05 被阅读0次

    1. 微信登录 获取token

    onGetToken () {
        // 获取临时 code码
        wx.login({
          success: (res) => {
            console.log(res.code)
            if(res.code){
              wx.request({
                // url: 'http://localhost:3000/v1/token',
                url: 'https://island.huangfushengkun.online/v1/token/',
                method: "POST",
                data: {
                  account: res.code,
                  type: 100
                },
                success: (res) => {
                  console.log(res)
                  // 判断状态码是否是2开头的
                  const code = res.statusCode.toString()
                  if (code.startsWith('2')) {
                    // 写入缓存
                    wx.setStorageSync('token',res.data.token)
                  }
                }
              })
            }
          }
        })
      },
    

    2. 验证token

    onVerifyToken() {
        wx.request({
          url: 'https://island.huangfushengkun.online/v1/token/verify',
          method: "POST",
          data: {
            token:wx.getStorageSync('token')  //缓存中取出token
          },
          success: res => {
            console.log(res.data)
          }
        })
      },
    

    3. 获取最新期刊

    onGetLatest () {
        wx.request({
          // url: 'http://localhost:3000/v1/classic/latest',
          url: 'https://island.huangfushengkun.online/v1/classic/latest',
          method: "GET",
          header: {
            Authorization: this._encode()
          },
          success: res => {
            console.log(res.data)
          }
        })
      },
    

    4.喜欢

    onLike() {
        wx.request({
          // url: 'http://localhost:3000/v1/like',
          url: 'https://island.huangfushengkun.online/v1/like',
          method: "POST",
          data: {
            art_id:1,
            type:100
          }, 
          header: {
            Authorization: this._encode()
          },
          success: res => {
            console.log(res.data)
          }
        })
      },
    

    5.取消喜欢

    onDislike () {
        wx.request({
          // url: 'http://localhost:3000/v1/like/cancel',
          url: 'https://island.huangfushengkun.online/v1/like/cancel',
          method: "POST",
          data: {
            art_id: 1,
            type: 100
          },
          header: {
            Authorization: this._encode()
          },
          success: res => {
            console.log(res.data)
          }
        })
      },
    

    6.获取下一期期刊内容

    onGetNext () {
        wx.request({
          url: 'https://island.huangfushengkun.online/v1/classic/4/next',
          method: "GET",
          header: {
            Authorization: this._encode()
          },
          success: res => {
            console.log(res.data)
          }
        })
      },
    

    7.获取某期刊的喜欢信息

    onGetLike () {
        wx.request({
          url: 'https://island.huangfushengkun.online/v1/classic/100/1/favor',
          method: "GET",
          header: {
            Authorization: this._encode()
          },
          success: res => {
            console.log(res.data)
          }
        })
      },
    

    8.获取用户所喜欢的期刊列表

    onGetFavorList () {
        wx.request({
          // url: 'http://localhost:3000/v1/classic/favor',
          url: 'https://island.huangfushengkun.online/v1/classic/favor',
          method: "GET",
          header: {
            Authorization: this._encode()
          },
          success: res => {
            console.log(res.data)
          }
        })
      },
    

    9.获取期刊的详情信息

      onGetAllMessage () {
        wx.request({
          // url: 'http://localhost:3000/v1/classic/100/1',
    
          url: 'https://island.huangfushengkun.online/v1/classic/100/1',
          method: "GET",
          header: {
            Authorization: this._encode()
          },
          success: res => {
            console.log(res.data)
          }
        })
      },
    

    相关文章

      网友评论

          本文标题:接口文档

          本文链接:https://www.haomeiwen.com/subject/acfloctx.html