| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- import {
- http,
- Method
- } from '@/utils/request.js';
- // 使用storage模块的方法设置登录状态为false
- import storage from "@/utils/storage.js";
- const request = http.request;
- /**
- * 获取农技知识列表
- * @param params
- */
- export function getTechList(params) {
- return http.request({
- url: "uniapp/knowledge/tech",
- method: Method.GET,
- // needToken: true,
- data:params,
- });
- }
- /**
- * 获取政策解读列表
- * @param params
- */
- export function getPolicyList(params) {
- return http.request({
- url: "uniapp/knowledge/policy",
- method: Method.GET,
- // needToken: true,
- data:params,
- });
- }
- /**
- * 获取知识文章详情
- * @param id 文章ID
- */
- export function getArticleDetail(id) {
- return http.request({
- url: `uniapp/knowledge/${id}`,
- method: Method.GET,
- // needToken: true,
- headers: {
- 'Accept': 'application/json'
- }
- });
- }
- /**
- * 获取文章相关图片
- * @param articleId 文章ID
- */
- export function getArticleImages(articleId) {
- return http.request({
- url: `uniapp/knowledge/images/${articleId}`,
- method: Method.GET,
- });
- }
- /**
- * 获取轮播图列表
- */
- export function getCarouselImages() {
- return http.request({
- url: "uniapp/knowledge/carousel",
- method: Method.GET,
- });
- }
- /**
- * 创建文章
- * @param article 文章数据
- */
- export function createArticle(article) {
- return http.request({
- url: "uniapp/knowledge",
- method: Method.POST,
- // needToken: true,
- data: article,
- headers: {
- 'Content-Type': 'application/json'
- }
- });
- }
- /**
- * 更新文章
- * @param article 文章数据
- */
- export function updateArticle(article) {
- return http.request({
- url: "uniapp/knowledge",
- method: Method.PUT,
- // needToken: true,
- data: article,
- headers: {
- 'Content-Type': 'application/json'
- }
- });
- }
- /**
- * 上传文件
- * @param formData 表单数据
- */
- export function uploadFile(formData) {
- return http.request({
- url: "uniapp/file/upload",
- method: Method.POST,
- needToken: true,
- data: formData,
- });
- }
- /**
- * 点赞文章
- * @param id 文章ID
- */
- export function likeArticle(id) {
- return http.request({
- url: `uniapp/knowledge/like/${id}`,
- method: Method.POST,
- needToken: true,
- });
- }
- /**
- * 取消点赞文章
- * @param id 文章ID
- */
- export function unlikeArticle(id) {
- return http.request({
- url: `uniapp/knowledge/like/${id}`,
- method: Method.DELETE,
- needToken: true,
- });
- }
- /**
- * 收藏文章
- * @param id 文章ID
- */
- export function favoriteArticle(id) {
- return http.request({
- url: `uniapp/knowledge/favorite/${id}`,
- method: Method.POST,
- needToken: true,
- });
- }
- /**
- * 取消收藏文章
- * @param id 文章ID
- */
- export function unfavoriteArticle(id) {
- return http.request({
- url: `uniapp/knowledge/favorite/${id}`,
- method: Method.DELETE,
- needToken: true,
- });
- }
|