import upload from '@/utils/upload'
import request from '@/utils/request'

// 查询伴宠师列表
export function getTeacherList(params) {
    return request({
        url: '/applet/mall/teacher/getTeacherList',
        headers: {
            "isToken": true
        },
        method: 'get',
        params
    })
}


// 查询伴宠师详情
export function getTeacherDetail(params) {
    return request({
        url: '/applet/mall/teacher/getTeacherDetail',
        headers: {
            "isToken": true
        },
        method: 'get',
        params
    })
}

// 查询指定伴宠师的宠物列表
export function getTeacherPetList(params) {
    return request({
        headers: {
            "isToken": true
        },
        url: "/applet/pet/list",
        method: 'get',
        params
    })
}

// 查询指定伴宠师的地址列表
export const getTeacherAddressList = (params) => {
    return request({
        url: '/applet/address/addressList',
        headers: {
            isToken: true
        },
        method: "get",
        params
    })
}

// 查询指定伴宠师的服务小结
export const getTeacherServiceLogList = (params) => {
    return request({
        url: '/applet/serviceLog/serviceLogList',
        headers: {
            isToken: true
        },
        method: "get",
        params
    }).then(res => {
        return res.data?.map?.(item => {
            return {
                ...item,
                typeIds: item.serviceType?.split?.(','),
                images: item.image?.split?.(',') || []
            }
        }) || []
    })
}

// 查询订单列表
export const getOrderList = (params) => {
    return request({
        url: '/applet/mall/order/listByOpenid',
        headers: {
            isToken: true
        },
        method: "get",
        params
    })
}

// 查询订单详情
export const getOrderDetail = (params) => {
    return request({
        url: '/applet/mall/order/orderDetail',
        headers: {
            isToken: true
        },
        method: "get",
        params
    })
}

// 根据id查询
export function getOrderDetailById(data) {
    return request({
        url: '/api/order/detail',
        method: 'post',
        data: data
    })
}

// 创建订单
export function createOrder(data) {
    return request({
        url: '/api/order/create',
        method: 'post',
        data: data
    })
}

// 更新订单
export function updateOrder(data) {
    return request({
        url: '/api/order/update',
        method: 'post',
        data: data
    })
}

// 评价订单
export const orderEvaluate = (params) => {
    return request({
        url: '/applet/mall/order/orderEvaluate',
        headers: {
            isToken: true
        },
        method: "get",
        params
    })
}

// 取消订单
export const orderCancel = (data) => {
    return request({
        url: '/applet/mall/order/orderCancel',///applet/mall/order/orderCancel
        headers: {
            isToken: true
        },
        method: "POST",
        data
    })
}



