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

export default {
    workerTypeText(type) {
        switch (type) {
            case 0: return ['待审核', '#ff0000'];
            case 1: return ['普通师傅', '#bfbfbf'];
            case 2: return ['入驻师傅', '#d9a019'];
            default: return ['未知', '#000000'];
        }
    },
    /**
     * 师傅详情
     */
    workerDetail(uid) {
        return new Promise((resolve, reject) => {
            prototype.$request({
                api: "worker.detail",
                data: {
                    uid: uid,
                }
            }).then(response => {
                if (response.code == 1) {
                    let worker = {
                        times: response.data.count,
                        favorableRate: response.data.good,
                        grade: response.data.score,
                        worker: {},
                    }
                    if (prototype.$utils.isType(response.data.worker, "object")) {
                        worker.worker = {
                            id: response.data.worker.id,
                            uid: response.data.worker.uid,
                            name: response.data.worker.name,
                            type: response.data.worker.status,
                            avatar: response.data.worker.avatar,
                            mobile: response.data.worker.mobile,
                        }
                    }
                    return resolve(worker);
                }
                return reject(response.msg);
            }).catch(e => { });
        });
    }
}
