Blame view

apps/product/models/students.js 9.23 KB
周少峰 authored
1 2 3 4 5 6 7
/**
 * 学生营销数据处理
 * @date: 2016-08-06 14:24:04
 * @author: name<emial@yoho.cn>
 */

'use strict';
周少峰 authored
8
周少峰 authored
9 10 11 12 13 14
// const utils = '../../../utils';

// const logger = global.yoho.logger;
// const camelCase = global.yoho.camelCase;
const api = global.yoho.API;
周少峰 authored
15
const studentsApi = require('./students-api');
周少峰 authored
16 17 18 19 20 21 22 23
const stuHandler = require('./students-handler');

// const productProcess = require(`${utils}/product-process`);
// const _ = require('lodash');
const headerModel = require('../../../doraemon/models/header');
const serviceApi = global.yoho.ServiceAPI;

// 学生营销资源码
周少峰 authored
24 25
const studentsCode = '989396a17443bf61e3e269702e51ef04'; // h5 a83b7d55324fb65f96c1f85a3387ebd8
// const studentsCode = 'a83b7d55324fb65f96c1f85a3387ebd8'; // h5 a83b7d55324fb65f96c1f85a3387ebd8
周少峰 authored
26 27 28

/**
 * 获取学生营销页面数据
周少峰 authored
29
 * @params channel Object 频道
周少峰 authored
30 31 32 33 34
 * @return name returnType 返回值描述
 */
exports.getStudentsData = (channel) => {
    return api.all([
        headerModel.requestHeaderData(channel),
35 36 37 38 39 40 41 42 43 44

        // 资源位数据
        serviceApi.get('operations/api/v5/resource/get', {content_code: studentsCode}),

        // 认证总数
        studentsApi.getVerifiedTotal(),

        // 商品数据
        studentsApi.getStuProducts()
周少峰 authored
45 46 47 48 49 50 51
    ]).then(result => {
        let responseData = {
            module: 'product',
            page: 'students',

            // 头部数据
            headerData: result[0],
周少峰 authored
52 53 54 55 56 57 58

            realData: {
                sortItem: [{title: '学生权益介绍', href: 'stu-rights'}, {title: '我要验证身份', href: 'stu-identity'},
                {title: '学生热门单品', href: 'stu-good'}, {title: '更多活动推荐', href: 'stu-activity'}]

            },
周少峰 authored
59 60 61 62 63
            footerTop: true
        };

        // 资源位数据
        if (result[1].code === 200) {
周少峰 authored
64
            Object.assign(responseData.realData, stuHandler.studentResource(result[1].data));
周少峰 authored
65
        }
66 67 68 69 70 71 72 73

        // if (result[2].code === 200) {
            
        // }

        if (result[3].code === 200) {
            Object.assign(responseData.realData, {proItem: stuHandler.stuProducts(result[3].data.product_list)});
        }
周少峰 authored
74
        return responseData;
周少峰 authored
75 76 77
    });
};
周少峰 authored
78 79 80
/**
 * 测试数据
 */
周少峰 authored
81
exports.getTestData = () => {
wenjiekong authored
82
    let respData = {
周少峰 authored
83 84 85 86 87 88
        module: 'product',
        page: 'students',
        headerData: {
            Header: true,
            headerType: 'boys'
        },
wenjiekong authored
89 90
        footerTop: true
    };
wenjiekong authored
91
wenjiekong authored
92 93 94
    respData.realData = {
        mainBanner: {
            list: [{src: 'http://img11.static.yhbimg.com/yhb-img01/2016/06/01/20/' +
wenjiekong authored
95 96 97 98 99 100 101 102
            '01a88a4e626a954eb5ec0302a0470e0b3f.jpg?imageView2/2/w/1920/h/450/q/70',
            url: 'http://www.yohobuy.com'},
            {src: 'http://img11.static.yhbimg.com/yhb-img01/2016/06/01/20/' +
            '01a88a4e626a954eb5ec0302a0470e0b3f.jpg?imageView2/2/w/1920/h/450/q/70',
            url: 'http://www.yohobuy.com'},
            {src: 'http://img11.static.yhbimg.com/yhb-img01/2016/06/01/20/' +
            '01a88a4e626a954eb5ec0302a0470e0b3f.jpg?imageView2/2/w/1920/h/450/q/70',
            url: 'http://www.yohobuy.com'}]
周少峰 authored
103
        },
wenjiekong authored
104
        sortItem: [{title: '学生权益介绍', href: 'stu-rights'}, {title: '我要验证身份', href: 'stu-identity'},
wenjiekong authored
105
                {title: '学生热门单品', href: 'stu-good'}, {title: '更多活动推荐', href: 'stu-activity'}],
106 107 108 109 110 111 112 113
        rightsItem: [{src: '//img12.static.yhbimg.com/goodsimg/2015/12/02/10/' +
                '0256adbb54c5a9b657485b972cc94ceb99.jpg?imageView/1/w/235/h/314', title: '1、原价商品享9折优惠'},
                    {src: '//img12.static.yhbimg.com/goodsimg/2015/12/02/10/' +
                '0256adbb54c5a9b657485b972cc94ceb99.jpg?imageView/1/w/235/h/314', title: '2、满100元返100个有货币'},
                    {src: '//img12.static.yhbimg.com/goodsimg/2015/12/02/10/' +
                '0256adbb54c5a9b657485b972cc94ceb99.jpg?imageView/1/w/235/h/314', title: '3、每月3个免单名额'},
                    {src: '//img12.static.yhbimg.com/goodsimg/2015/12/02/10/' +
                '0256adbb54c5a9b657485b972cc94ceb99.jpg?imageView/1/w/235/h/314', title: '4、不定期学生专享活动'}],
周少峰 authored
114
        proItem: [
wenjiekong authored
115
            {url: '',
wenjiekong authored
116 117
            thumb: 'http://img12.static.yhbimg.com/goodsimg/2015/07/15/07/02a68330998a4a28b67060d349e08d216f.jpg?' +
            'imageView/2/w/280/h/373',
wenjiekong authored
118
            productName: 'Dickies 炫色小脚裤',
wenjiekong authored
119 120
            marketPrice: 12.3,
            salesPrice: 12.3,
wenjiekong authored
121 122
            forStu: true},
            {url: '',
wenjiekong authored
123 124
            thumb: 'http://img12.static.yhbimg.com/goodsimg/2015/07/15/07/02a68330998a4a28b67060d349e08d216f.jpg?' +
            'imageView/2/w/280/h/373',
wenjiekong authored
125
            productName: 'Dickies 炫色小脚裤',
wenjiekong authored
126 127
            marketPrice: 12.3,
            salesPrice: 12.3,
wenjiekong authored
128 129
            forStu: true},
            {url: '',
wenjiekong authored
130 131
            thumb: 'http://img12.static.yhbimg.com/goodsimg/2015/07/15/07/02a68330998a4a28b67060d349e08d216f.jpg?' +
            'imageView/2/w/280/h/373',
wenjiekong authored
132
            productName: 'Dickies 炫色小脚裤',
wenjiekong authored
133 134
            marketPrice: 12.3,
            salesPrice: 12.3,
wenjiekong authored
135 136
            forStu: true},
            {url: '',
wenjiekong authored
137 138
            thumb: 'http://img12.static.yhbimg.com/goodsimg/2015/07/15/07/02a68330998a4a28b67060d349e08d216f.jpg?' +
            'imageView/2/w/280/h/373',
wenjiekong authored
139
            productName: 'Dickies 炫色小脚裤',
wenjiekong authored
140 141
            marketPrice: 12.3,
            salesPrice: 12.3,
wenjiekong authored
142 143
            forStu: true},
            {url: '',
wenjiekong authored
144 145
            thumb: 'http://img12.static.yhbimg.com/goodsimg/2015/07/15/07/02a68330998a4a28b67060d349e08d216f.jpg?' +
            'imageView/2/w/280/h/373',
wenjiekong authored
146
            productName: 'Dickies 炫色小脚裤',
wenjiekong authored
147 148
            marketPrice: 12.3,
            salesPrice: 12.3,
wenjiekong authored
149 150
            forStu: true},
            {url: '',
wenjiekong authored
151 152
            thumb: 'http://img12.static.yhbimg.com/goodsimg/2015/07/15/07/02a68330998a4a28b67060d349e08d216f.jpg?' +
            'imageView/2/w/280/h/373',
wenjiekong authored
153
            productName: 'Dickies 炫色小脚裤',
wenjiekong authored
154 155
            marketPrice: 12.3,
            salesPrice: 12.3,
wenjiekong authored
156 157
            forStu: true},
            {url: '',
wenjiekong authored
158 159
            thumb: 'http://img12.static.yhbimg.com/goodsimg/2015/07/15/07/02a68330998a4a28b67060d349e08d216f.jpg?' +
            'imageView/2/w/280/h/373',
wenjiekong authored
160
            productName: 'Dickies 炫色小脚裤',
wenjiekong authored
161 162
            marketPrice: 12.3,
            salesPrice: 12.3,
wenjiekong authored
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
            forStu: true}],
        couponItem: [
            {
                url: 'http://www.yohobuy.com/coupon/index?contentCode=bb7268bd46dd46d304c2917309814681',
                imgUrl: '//img10.static.yhbimg.com/yhb-img01/2016/07/29/17/01cfa4035101b5c8f46efd9c0fbf8ef0c8.jpg',
                dataId: '优惠券'
            },
            {
                url: 'http://www.yohobuy.com/coupon/index?contentCode=bb7268bd46dd46d304c2917309814681',
                imgUrl: '//img10.static.yhbimg.com/yhb-img01/2016/07/29/17/01cfa4035101b5c8f46efd9c0fbf8ef0c8.jpg',
                dataId: '优惠券'
            },
            {
                url: 'http://www.yohobuy.com/coupon/index?contentCode=bb7268bd46dd46d304c2917309814681',
                imgUrl: '//img10.static.yhbimg.com/yhb-img01/2016/07/29/17/01cfa4035101b5c8f46efd9c0fbf8ef0c8.jpg',
                dataId: '优惠券'
            },
            {
                url: 'http://www.yohobuy.com/coupon/index?contentCode=bb7268bd46dd46d304c2917309814681',
                imgUrl: '//img10.static.yhbimg.com/yhb-img01/2016/07/29/17/01cfa4035101b5c8f46efd9c0fbf8ef0c8.jpg',
                dataId: '优惠券'
            }
        ],
        activityItem: [
            {
                imgUrl: '//img11.static.yhbimg.com/yhb-img01/2016/06/01/20/01a88a4e626a954eb5ec0302a0470e0b3f.jpg?' +
                'imageView2/2/w/1920/h/450/q/70/q/70'
            },
            {
                imgUrl: '//img11.static.yhbimg.com/yhb-img01/2016/06/01/20/01a88a4e626a954eb5ec0302a0470e0b3f.jpg?' +
                'imageView2/2/w/1920/h/450/q/70/q/70'
            },
            {
                imgUrl: '//img11.static.yhbimg.com/yhb-img01/2016/06/01/20/01a88a4e626a954eb5ec0302a0470e0b3f.jpg?' +
                'imageView2/2/w/1920/h/450/q/70/q/70'
            }
        ]
周少峰 authored
200
    };
wenjiekong authored
201 202
    return respData;
周少峰 authored
203
};
周少峰 authored
204 205 206 207 208

/**
 * 获取学校地区数据
 * @return Object 接口数据
 */
wenjiekong authored
209
exports.getSchoolArea = () => {
周少峰 authored
210 211 212
    return studentsApi.getArea().then(result => {
        return result;
    });
wenjiekong authored
213
};
周少峰 authored
214 215 216 217 218 219

/**
 * 根据地区码查询学校列表
 * @params areaCode int 地区码
 * @return Object 接口数据
 */
wenjiekong authored
220
exports.getSchoolList = (areaCode) => {
周少峰 authored
221 222 223
    return studentsApi.getSchool(areaCode).then(result => {
        return result;
    });
wenjiekong authored
224
};
周少峰 authored
225 226 227 228 229 230 231 232 233 234 235

/**
 * 学历层次
 * @params areaCode int 地区码
 * @return Object 接口数据
 */
exports.getEduLevel = () => {
    return studentsApi.getEduLevelList().then(result => {
        return result;
    });
};
周少峰 authored
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259

/**
 * 身份验证
 * @params areaCode int 地区码
 * @return Object 接口数据
 */
exports.verifyIdentity = () => {
    return studentsApi.verifyIdentity().then(result => {
        return result;
    });
};

/**
 * 学生验证
 * @params areaCode int 地区码
 * @return Object 接口数据
 */
exports.verifyStudents = (uid, params) => {
    let pageUrl = '/product/students?';

    return studentsApi.verifyIdentity(uid, params.certNo, params.name, pageUrl).then(result => {
        return result;
    });
};