student.js 2.88 KB
const serviceAPI = global.yoho.ServiceAPI;

module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    getResource(code) {
        return this.get({
            api: serviceAPI,
            url: 'operations/api/v5/resource/get',
            data: {
                content_code: code,
                platform: 'iphone'
            }
        });
    }

    vip(limit) {
        return this.get({
            data: {
                method: 'app.student.vip',
                limit: limit || 60
            }
        });
    }

    verifiedStudentTotal() {
        return this.get({
            data: {
                method: 'app.student.verifiedStudentTotal'
            }
        });
    }

    getProvince() {
        return this.get({
            data: {
                method: 'app.studentMarket.getAddressList'
            },
            param: {
                cache: true
            }
        });
    }

    getSchool(code) {
        return this.get({
            data: {
                method: 'app.studentMarket.getSchoolInfoList',
                areaCode: code
            }
        });
    }

    getEducationLevelList() {
        return this.get({
            data: {
                method: 'app.studentMarket.getEducationLevelList'
            }
        });
    }

    userAcquireStatus(uid, couponIds) {
        return this.get({
            data: {
                method: 'app.coupons.userAcquireStatus',
                uid: uid,
                couponIds: couponIds
            }
        });
    }

    verifyStudent(uid, collegename, educationdegree, enrollmentyear) {
        return this.get({
            data: {
                method: 'app.student.verifyStudent',
                uid: uid,
                client_type: 'h5',
                college_name: collegename,
                enrollment_year: enrollmentyear,
                education_degree: educationdegree
            }
        });
    }

    verifyIdentity(uid, certno, name, pageurl) {
        return this.get({
            data: {
                method: 'app.student.verifyIdentity',
                uid: uid,
                client_type: 'h5',
                cert_no: certno,
                name: name,
                page_url: pageurl
            }
        });
    }

    getUser(uid) {
        if (!uid) {
            return Promise.resolve({
                code: 200,
                data: {}
            });
        }

        return this.get({
            data: {
                method: 'app.passport.profile',
                uid: uid
            },
            param: {
                cache: true
            }
        });
    }

    // 添加分享成功记录
    addStudent(ownuid, shareId) {
        return this.get({
            data: {
                method: 'app.student.addShare',
                uid: ownuid,
                shareUid: shareId
            }
        });
    }
};