import Vue from "vue"
let prototype = Vue.prototype;

export default {
    count: {
        service(id) {
            return new Promise((resolve, reject) => {
                prototype.$request({
                    api: "appraise.count.service",
                    data: {
                        id: id,
                    }
                }).then(response => {
                    if (response.code == 1) {
                        return resolve(response.data);
                    }
                    return reject(response.msg);
                }).catch(e => { });
            });
        }
    },
    list: {
        /**
         * 服务评价
         */
        service(data) {
            return new Promise((resolve, reject) => {
                prototype.$request({
                    api: "appraise.list.service",
                    data: data
                }).then(response => {
                    if (response.code == 1) {
                        let list = [];
                        response.data.forEach((data) => {
                            list.push({
                                id: data.id,
                                avatar: data.u_avatar,
                                nickname: data.u_name,
                                createTime: data.time,
                                tags: data.msg.split(","),
                                area: "-",
                                worker: data.wid,
                                grade: data.score,
                                images: data.img,
                                content: data.desc,
                            });
                        });
                        return resolve(list);
                    }
                    return reject(response.msg);
                }).catch(e => { });
            });
        }
    },
}
