import Taro from "@tarojs/taro";
import classifyStore from "@src/store/classIfy";
/**
 * 获取分类列表
 * */
export function getBookCategoryList(workDirection) {
    return new Promise(async (resolve, reject) => {
        try {
            // 初始化
            Taro.request({
                url: '/app/bookCategory/list',
                method: 'GET',
                data: { workDirection },
                success: (res) => {
                    if(res.data.data.length > 0 ){
                        classifyStore.setData({categoryId:res.data.data[0]})//存放数据的第一个值为默认首次选中
                    }
                    resolve(res)
                },
                fail: (err) => {
                    reject(err);
                }
            })
        } catch (error) {
            reject(error);
        }
    })
}
