Wechat----model 层 book

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/damys/article/details/87858719

model 层

book models, 与page 分开管理

url 参数说明:因为原请求地址不支持https, 固做了二次封装请求,以满足小程序https 的要求
import { HTTP } from '../utils/http_p.js'

class BookModel extends HTTP{

  /**
   * 获取最新的 book
   */
  getHotList(){
    // return this.request('book/host_list')

    /**
     * 使用对象结构的方式传参
     */
    return this.request({
      url: 'weChatBl/BookHotList'
    })
  }


  /**
   * 搜索
   */
  search(start, q){
    return this.request({
      url: 'weChatBl/BookSearch',
      data:{
        q:q,
        start:start
      }
    })
  }


  /**
   * 获取我的 book
   */
  getMyBookCount(){
    return this.request({
      url: 'weChatBl/BookFavorCount'
    })
  }


  /**
   * 获取书本的详细信息
   */
  getDetail(id){
    return this.request({
      url:'weChatBl/BookDetail?id=' + id
    })
  }


  /**
   * 获取书本的点赞状态
   */
  getLikeStatus(id){
    return this.request({
      url:'weChatBl/BookLike?id=' + id
    })
  }


  /**
   * 获取书本的点评信息
   */
  getComments(id){
    return this.request({
      url:'weChatBl/BookComment?id=' + id
    })
  }


  /**
   * 按id提交短评信息
   */
  postComment(id, comment){   
    console.log(id, comment) 
    return this.request({
      url:'weChatBl/BookCommentAdd',
      method:'POST',
      data:{
        book_id:id,
        content:comment
      }
    })
  }

}

export {
  BookModel
}

猜你喜欢

转载自blog.csdn.net/damys/article/details/87858719