import Taro from "@tarojs/taro";
import bookStore from "@src/store/book";
/**
 * 获取分类列表
 * */
export function bookrackShrot(data) {
    return new Promise(async (resolve, reject) => {
        try {
            // 初始化
            Taro.request({
                url: '/app/shortBookshelf/listOfPage',
                method: 'GET',
                data,
                success: (res) => {
                    resolve(res)
                },
                fail: (err) => {
                    reject(err);
                }
            })
        } catch (error) {
            reject(error);
        }
    })
}

/**
 * 加入或移出书架
 * */ 
export function bookrackShrotAddOrRemove(data) {
    return new Promise(async (resolve, reject) => {
        try {
            // 添加或移出书架
            let {bookId,add} = data
            Taro.request({
                url: `/app/shortBookshelf/addOrRemove/${bookId}/${add}`,
                method: 'PATCH',
                data,
                success: (res) => {
                    resolve(res)
                },
                fail: (err) => {
                    reject(err);
                }
            })
        }catch (error) {
            reject(error);
        }
    })
}