Authored by 徐炜

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	package.json
  1 +'use strict';
  2 +const serviceApi = global.yoho.ServiceAPI;
  3 +const api = global.yoho.API;
  4 +const helpers = global.yoho.helpers;
  5 +const crypto = global.yoho.crypto;
  6 +const queryString = require('querystring');
  7 +const Promise = require('bluebird');
  8 +const co = Promise.coroutine;
  9 +const headerModel = require('../../../doraemon/models/header'); // 头部model
  10 +const _ = require('lodash');
  11 +const productProcess = require(`${utils}/product-process`);
  12 +
  13 +const userAcquireStatus = (uid, couponIds) => {
  14 + if (couponIds != '') {
  15 + return api.get('', {
  16 + method: 'app.coupons.userAcquireStatus',
  17 + uid: uid,
  18 + couponIds: couponIds
  19 + });
  20 + }
  21 +};
  22 +
  23 +/**
  24 + * 查询商品
  25 + * @param id
  26 + * @returns {*}
  27 + */
  28 +const _getRelatedData = (idList) => {
  29 + if (idList != '') {
  30 + return api.get('', {
  31 + productSkn: idList,
  32 + method: 'h5.product.batch'
  33 + }).then((result) => {
  34 +
  35 + let goods = [];
  36 +
  37 + if (result && result.data && result.data.product_list && result.code === 200) {
  38 +
  39 + _.forEach(result.data.product_list, function(val) {
  40 +
  41 + if (!val.student_price) {
  42 + val.student_price = val.vip2_price;
  43 + }
  44 + });
  45 +
  46 + goods = productProcess.processProductList(result.data.product_list);
  47 +
  48 + return goods;
  49 + } else {
  50 + return {};
  51 + }
  52 + });
  53 + }
  54 +};
  55 +
  56 +exports.index = (req, res, next) => {
  57 + let code = 'c9b9639ce2884b768cfbc5cf9e68a53f';
  58 + let uid = req.__USER__.uid;
  59 + let options;
  60 + let noLoginUrl = helpers.urlFormat('/activity/student/register') + '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' + req.__USER__.http + '//m.yohobuy.com/activity/student-market"}}}';
  61 +
  62 + return serviceApi.get('operations/api/v5/resource/get', {
  63 + content_code: code,
  64 + platform: 'iphone'
  65 + }).then((result) => {
  66 +
  67 + let coupons = {},
  68 + activities,
  69 + banner,
  70 + icons,
  71 + link,
  72 + studentGoods,
  73 + idList = [],
  74 + goodShow,
  75 +
  76 + // url,
  77 + // param,
  78 + couponids = [];
  79 +
  80 + (result.data || []).forEach((item) => {
  81 + switch (item.template_name) {
  82 + case 'getCoupon':
  83 + coupons = item;
  84 + break;
  85 + case 'image_list':
  86 + activities = item;
  87 + break;
  88 + case 'focus':
  89 + banner = item;
  90 + break;
  91 + case 'recommend_content_five':
  92 + icons = item;
  93 + break;
  94 + case 'link':
  95 + link = item;
  96 + break;
  97 + case 'goods':
  98 + studentGoods = item;
  99 + break;
  100 + default:
  101 + // other = item;
  102 + break;
  103 + }
  104 + });
  105 +
  106 + if (coupons && coupons.data) {
  107 + coupons.link = link && link.data ? link.data[0].url + (req.__USER__.isApp ? '&app_version=' + req.__USER__.app_version : '') : '';
  108 +
  109 + coupons.data = (coupons.data || []).map((item) => {
  110 + // let url = item.image.url;
  111 + couponids.push(item.couponID);
  112 +
  113 + // if (!req.__USER__.isLogin) {
  114 + // url = 'http://m.yohobuy.com/activity/student/register?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http://m.yohobuy.com/activity/student"}}}';
  115 + // }
  116 + //
  117 + // item.image.noLoginUrl=url;
  118 + return item;
  119 + });
  120 +
  121 + if (coupons.data.length > 2) {
  122 + coupons.data = coupons.data.slice(0, 2);
  123 + }
  124 +
  125 + }
  126 +
  127 + if (studentGoods && studentGoods.data) {
  128 + _.forEach(studentGoods.data, function(obj) {
  129 + idList.push(obj.id);
  130 + });
  131 + }
  132 +
  133 + return Promise.all([userAcquireStatus(uid, couponids.join(',')), _getRelatedData(idList.join(','))]).then(datas => {
  134 + coupons.data = _.get(coupons, 'data', []).map((item)=>{
  135 + item.status = 1;
  136 + (datas[0].data || []).forEach((it) => {
  137 +
  138 + if (+it.couponId === +item.couponID) {
  139 + item.hasNum = it.hasNum;
  140 + item.status = it.status;
  141 + }
  142 + });
  143 + item.couponID = crypto.encryption('yoho9646abcdefgh', item.couponID);
  144 + return item;
  145 + });
  146 +
  147 + options = {
  148 + isApp: req.__USER__.isApp,
  149 + goods: datas[1],
  150 + banner: banner,
  151 + icons: icons,
  152 + coupons: coupons,
  153 + activities: activities,
  154 + isStudent: req.__USER__.isStudent,
  155 + isSupportStudent: req.__USER__.isSupportStudent,
  156 + isLogin: req.__USER__.isLogin,
  157 + title: '有货学生专享优惠',
  158 + http: req.__USER__.http,
  159 + uid: req.__USER__.uid,
  160 + app_version: req.__USER__.app_version,
  161 + isAppNoLogin: req.__USER__.isApp && !req.__USER__.isLogin,
  162 + noLoginUrl: noLoginUrl,
  163 + page: 'student-market',
  164 + showDownloadApp: true
  165 + };
  166 + if (!req.__USER__.isApp) {
  167 + options.pageHeader = headerModel.setNav({
  168 + navTitle: options.title,
  169 + navBtn: true
  170 + });
  171 + }
  172 +
  173 + options.loginUrl = '//m.yohobuy.com/activity/student/register';
  174 + if (options.isApp) {
  175 + if (options.isLogin) {
  176 + options.loginUrl = options.loginUrl + '?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"' + req.__USER__.http + '//m.yohobuy.com/activity/student/register"}}';
  177 + } else {
  178 + // no login
  179 + options.loginUrl = options.loginUrl + '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' + req.__USER__.http + '//m.yohobuy.com/activity/student/register","antarget":"1"}}}';
  180 + }
  181 + }
  182 +
  183 + res.render('student-market', options);
  184 +
  185 + }).catch(next);
  186 + });
  187 +};
@@ -27,6 +27,8 @@ const shopCollect = require(`${cRoot}/shopCollect`); @@ -27,6 +27,8 @@ const shopCollect = require(`${cRoot}/shopCollect`);
27 const singleDay = require(`${cRoot}/single-day`); 27 const singleDay = require(`${cRoot}/single-day`);
28 const share = require(`${cRoot}/share`); 28 const share = require(`${cRoot}/share`);
29 29
  30 +const studentMarket = require(`${cRoot}/student-market`);
  31 +
30 // routers 32 // routers
31 33
32 router.get('/demo', demo.index); 34 router.get('/demo', demo.index);
@@ -120,4 +122,6 @@ router.post('/vip-day1028/isStudent', vipDay1028.beforeIn, vipDay1028.checkIsStu @@ -120,4 +122,6 @@ router.post('/vip-day1028/isStudent', vipDay1028.beforeIn, vipDay1028.checkIsStu
120 // 获取活动页传来的参数 122 // 获取活动页传来的参数
121 router.get('/wechat/1111', wechat.feature); 123 router.get('/wechat/1111', wechat.feature);
122 124
  125 +router.get('/student-market', student.getUser, studentMarket.index);
  126 +
123 module.exports = router; 127 module.exports = router;
  1 +<div class="mobile-container">
  2 + <div class="mobile-wrap yoho-page student student-market">
  3 + {{! 头部banner}}
  4 + {{#banner}}
  5 + {{> resources/banner-top}}
  6 + {{/banner}}
  7 +
  8 + {{#icons}}
  9 + <section class='s-section clearfix' data-template-id="{{template_id}}">
  10 + <h1>学生权益<a class='more s-quan' href='//m.yohobuy.com/activity/student/detail/quanyi?openby:yohobuy={"action":"go.h5","params":{"islogin":"N","url":"{{../http}}//m.yohobuy.com/activity/student/detail/quanyi"}}'>更多权益</a></h1>
  11 + <div class='s-content'>
  12 + {{#each data.list}}
  13 + <div class='s-section s-dialog'>
  14 + <a href="javascript:void(0)">
  15 + <img src='{{image src 320 149}}' title="{{title}}">
  16 + </a>
  17 + </div>
  18 + {{/each}}
  19 + </div>
  20 + </section>
  21 + {{/icons}}
  22 +
  23 + <div class='sm-layout'>
  24 + 快来认证吧,认证通过即可享受专属优惠!
  25 +
  26 + <a class='s-renzhen' href='{{loginUrl}}'>立即认证</a>
  27 + </div>
  28 +
  29 + {{#coupons}}
  30 + <section class='s-section clearfix' data-template-id="{{template_id}}">
  31 + <h1>领券中心
  32 + <a class='more iconfont' href="{{link}}">&#xe618;</a>
  33 + </h1>
  34 +
  35 + <div class='s-coupon-contain'>
  36 + <style type="text/css">
  37 + .no-bg{
  38 + color: #fff!important;
  39 + background-image: none!important;
  40 + }
  41 + </style>
  42 + {{#each data}}
  43 + <div class="coupon-floor" coupon-id="{{couponID}}">
  44 + <div class="floor-main" style="background-image: url({{image image.src 0 0}});">
  45 + <a href='{{image.url}}' class="main-left"></a>
  46 + {{#isEqual status 1}}
  47 + {{#if @root.isAppNoLogin}}
  48 + <a href='{{@root.noLoginUrl}}' class="main-right-use" >
  49 + <span class="on-receive on-lingqu no-bg">
  50 + <p>点击</p>
  51 + <p>领取</p>
  52 + </span>
  53 + </a>
  54 + {{else}}
  55 + <div class="main-right-use" href='{{../image.url}}'>
  56 + <span class="on-receive on-lingqu no-bg">
  57 + <p>点击</p>
  58 + <p>领取</p>
  59 + </span>
  60 + </div>
  61 +
  62 + {{/if}}
  63 + {{/isEqual}}
  64 +
  65 + {{#isEqual status 2}}
  66 + <a href='{{../image.url}}' class="main-right-use" >
  67 + <span class="zero"></span>
  68 + </a>
  69 + {{/isEqual}}
  70 + {{#isEqual status 3}}
  71 + <a href='{{../image.url}}' class="main-right-use" >
  72 + <span class="received"></span>
  73 + </a>
  74 + {{/isEqual}}
  75 + {{#isEqual status 4}}
  76 + <a href='{{../image.url}}' class="main-right-use" >
  77 + <span class="on-receive no-bg" >
  78 + <p>已经</p>
  79 + <p>过期</p>
  80 + </span>
  81 + </a>
  82 + {{/isEqual}}
  83 + </div>
  84 + </div>
  85 + {{/each}}
  86 + </div>
  87 + </section>
  88 + {{/coupons}}
  89 +
  90 + {{#activities}}
  91 + <section class='s-section clearfix' data-template-id="{{template_id}}">
  92 + <h1>学生专属活动</h1>
  93 + {{#each data.list}}
  94 + <a class='s-activity' href="{{url}}">
  95 + <img src='{{image src 640 200}}' title='{{title}}'>
  96 + </a>
  97 + {{/each}}
  98 + </section>
  99 + {{/activities}}
  100 +
  101 + <section class='s-section clearfix'>
  102 + <h1>学生专享商品<a class="more iconfont" href="//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version={{@root.app_version}}{{/isApp}}?openby:yohobuy={'action':'go.h5','params':{'islogin':'N','url':'{{@root.http}}//search.m.yohobuy.com/','param':{'students':'1','title':'学生专享商品','uid':'{{uid}}'}}}">&#xe618;</a></h1>
  103 + <div class='goods-list clearfix'>
  104 + {{#each goods}}
  105 + <div class="good-info">
  106 + <div class="tag-container clearfix">
  107 + {{# tags}}
  108 + {{# isNew}}
  109 + <p class="good-tag new-tag">NEW</p>
  110 + {{/ isNew}}
  111 + {{# isAdvance}}
  112 + <p class="good-tag renew-tag">再到着</p>
  113 + {{/ isAdvance}}
  114 + {{# isDiscount}}
  115 + <p class="good-tag sale-tag">SALE</p>
  116 + {{/ isDiscount}}
  117 + {{# isYohoood}}
  118 + <p class="good-tag running-man-tag">跑男同款</p>
  119 + {{/ isYohoood}}
  120 + {{# isLimited}}
  121 + <p class="good-tag limit-tag">限量</p>
  122 + {{/ isLimited}}
  123 + {{/ tags}}
  124 + </div>
  125 + <div class="good-detail-img">
  126 + <a class="good-thumb" href="{{url}}">
  127 + <img class="lazy" data-original="{{image default_images 235 314}}">
  128 + </a>
  129 + </div>
  130 + <div class="good-detail-text">
  131 + <div class="name">
  132 + <a href="{{url}}">{{product_name}}</a>
  133 + </div>
  134 + <div class="price">
  135 + <span class="sale-price">¥{{round student_price}} <i class='s-biaoqian'></i></span>
  136 + <p class="s-price-block">
  137 + <span class="market-price">¥{{round sales_price}}</span>
  138 + </p>
  139 + </div>
  140 + </div>
  141 + </div>
  142 + {{/each}}
  143 + </div>
  144 + <a class='s-more' href="//search.m.yohobuy.com/?students=1&title=学生专享商品&uid={{uid}}{{#isApp}}&app_version={{@root.app_version}}{{/isApp}}?openby:yohobuy={'action':'go.h5','params':{'islogin':'N','url':'{{@root.http}}//search.m.yohobuy.com/','param':{'students':'1','title':'学生专享商品','uid':'{{uid}}'}}}">查看更多</a>
  145 + </section>
  146 +
  147 + <div class="float-layer" id="float-layer-app">
  148 + <div class="float-layer-left">
  149 + <span class="yoho-icon iconfont">&#xe60d;</span>
  150 + <p>快来下载Yoho!buy有货<br>即刻享受学生购物优惠</p>
  151 + </div>
  152 + <a href="javascript:void(0);" id="float-layer-close" >
  153 + <i class="close-icon iconfont">&#xe623;</i>
  154 + <div class="circle-rightbottom"></div>
  155 + </a>
  156 + <a href="javascript:void(0);" id="float-layer-btn">
  157 + 立即下载
  158 + </a>
  159 + </div>
  160 +
  161 + <div class="s-replace"></div>
  162 + </div>
  163 +</div>
  164 +
  165 +
@@ -31,10 +31,10 @@ module.exports = { @@ -31,10 +31,10 @@ module.exports = {
31 // service: 'http://192.168.102.205:8080/gateway/', 31 // service: 'http://192.168.102.205:8080/gateway/',
32 // search: 'http://192.168.102.216:8080/yohosearch/' 32 // search: 'http://192.168.102.216:8080/yohosearch/'
33 33
34 - api: 'http://api.yoho.yohoops.org/',  
35 - service: 'http://service.yoho.yohoops.org/',  
36 - liveApi: 'http://api.live.yoho.cn/',  
37 - singleApi: 'http://single.yoho.cn/' 34 + // api: 'http://api.yoho.yohoops.org/',
  35 + // service: 'http://service.yoho.yohoops.org/',
  36 + // liveApi: 'http://api.live.yoho.cn/',
  37 + // singleApi: 'http://single.yoho.cn/'
38 38
39 // api: 'http://dev-api.yohops.com:9999/', 39 // api: 'http://dev-api.yohops.com:9999/',
40 // service: 'http://dev-service.yohops.com:9999/', 40 // service: 'http://dev-service.yohops.com:9999/',
1 { 1 {
2 "name": "m-yohobuy-node", 2 "name": "m-yohobuy-node",
3 - "version": "5.2.7", 3 + "version": "5.2.10",
4 "private": true, 4 "private": true,
5 "description": "A New Yohobuy Project With Express", 5 "description": "A New Yohobuy Project With Express",
6 "repository": { 6 "repository": {
@@ -30,7 +30,6 @@ @@ -30,7 +30,6 @@
30 "feed": "^0.3.0", 30 "feed": "^0.3.0",
31 "lodash": "^4.16.1", 31 "lodash": "^4.16.1",
32 "md5": "^2.1.0", 32 "md5": "^2.1.0",
33 - "memory-cache": "^0.1.6",  
34 "moment": "^2.15.1", 33 "moment": "^2.15.1",
35 "oneapm": "^1.2.20", 34 "oneapm": "^1.2.20",
36 "passport": "^0.3.2", 35 "passport": "^0.3.2",
@@ -42,7 +41,7 @@ @@ -42,7 +41,7 @@
42 "request-promise": "^3.0.0", 41 "request-promise": "^3.0.0",
43 "serve-favicon": "^2.3.0", 42 "serve-favicon": "^2.3.0",
44 "uuid": "^2.0.3", 43 "uuid": "^2.0.3",
45 - "yoho-node-lib": "^0.2.0", 44 + "yoho-node-lib": "0.1.30",
46 "yoho-zookeeper": "^1.0.4" 45 "yoho-zookeeper": "^1.0.4"
47 }, 46 },
48 "devDependencies": { 47 "devDependencies": {
@@ -72,7 +71,6 @@ @@ -72,7 +71,6 @@
72 "postcss-center": "^1.0.0", 71 "postcss-center": "^1.0.0",
73 "postcss-clearfix": "^1.0.0", 72 "postcss-clearfix": "^1.0.0",
74 "postcss-crip": "^2.0.1", 73 "postcss-crip": "^2.0.1",
75 - "postcss-loader": "^1.1.1",  
76 "postcss-position": "^0.5.0", 74 "postcss-position": "^0.5.0",
77 "postcss-pxtorem": "^3.3.1", 75 "postcss-pxtorem": "^3.3.1",
78 "postcss-scss": "^0.3.1", 76 "postcss-scss": "^0.3.1",
@@ -95,7 +93,7 @@ @@ -95,7 +93,7 @@
95 "yoho-handlebars": "^4.0.5", 93 "yoho-handlebars": "^4.0.5",
96 "yoho-iscroll": "^5.2.0", 94 "yoho-iscroll": "^5.2.0",
97 "yoho-jquery": "^2.2.4", 95 "yoho-jquery": "^2.2.4",
98 - "yoho-jquery-lazyload": "^1.9.8", 96 + "yoho-jquery-lazyload": "^1.9.7",
99 "yoho-jquery-qrcode": "^0.14.0", 97 "yoho-jquery-qrcode": "^0.14.0",
100 "yoho-mlellipsis": "0.0.3", 98 "yoho-mlellipsis": "0.0.3",
101 "yoho-qs": "^1.0.1", 99 "yoho-qs": "^1.0.1",
  1 +var $ = require('yoho-jquery'),
  2 + Swiper = require('yoho-swiper'),
  3 + lazyLoad = require('yoho-jquery-lazyload'),
  4 + fastclick = require('yoho-fastclick'),
  5 + tip = require('../plugin/tip'),
  6 + dialog = require('../plugin/dialog'),
  7 + Hammer = require('yoho-hammer');
  8 +
  9 +var _weChatInterface = '//m.yohobuy.com/life/getSignPackage',
  10 + wx = window.wx,
  11 + C_ID,
  12 + getChannel;
  13 +
  14 +
  15 +
  16 +require('../common');
  17 +
  18 +// require('../common/footer');
  19 +
  20 +// 根据ua判断页头
  21 +(function uaHeader() {
  22 + var UALIST = ['MicroMessenger', 'QQ/', 'Weibo'],
  23 + UA = navigator.userAgent,
  24 + i;
  25 +
  26 + for (i = 0; i < UALIST.length; i++) {
  27 + if (UA.indexOf(UALIST[i]) > -1) {
  28 + $('#yoho-header').remove();
  29 + return;
  30 + }
  31 + }
  32 +
  33 +}());
  34 +
  35 +getChannel = function() {
  36 + var name = window.cookie('_Channel');
  37 +
  38 + return {
  39 + boys: 1,
  40 + girls: 2,
  41 + kids: 3,
  42 + lifestyle: 4
  43 + }[name] || 1;
  44 +};
  45 +C_ID = getChannel();
  46 +
  47 +function uuid() {
  48 + var s = [];
  49 + var hexDigits = '0123456789abcdef';
  50 + var id = '';
  51 + var i = 0;
  52 +
  53 + for (i = 0; i < 36; i++) {
  54 + s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  55 + }
  56 + s[14] = '4'; // bits 12-15 of the time_hi_and_version field to 0010
  57 + s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
  58 + s[8] = s[13] = s[18] = s[23] = '-';
  59 +
  60 + id = s.join('');
  61 +
  62 + return id;
  63 +}
  64 +
  65 +
  66 +fastclick.attach(document.body);
  67 +lazyLoad($('img.lazy'));
  68 +
  69 +// 头部banner轮播
  70 +if ($('.banner-swiper').find('li').size() > 1) {
  71 + new Swiper('.banner-swiper', {
  72 + lazyLoading: true,
  73 + lazyLoadingInPrevNext: true,
  74 + loop: true,
  75 + autoplay: 3000,
  76 + autoplayDisableOnInteraction: false,
  77 + paginationClickable: true,
  78 + slideElement: 'li',
  79 + pagination: '.banner-top .pagination-inner'
  80 + });
  81 +}
  82 +
  83 +// 获取url中的参数
  84 +function getUrlParam(name) {
  85 +
  86 + // 构造一个含有目标参数的正则表达式对象
  87 + var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
  88 +
  89 + // 匹配目标参数
  90 + var r = window.location.search.substr(1).match(reg);
  91 +
  92 + // 返回参数值
  93 + if (r !== null) {
  94 + return r[2];
  95 + }
  96 +
  97 + return null;
  98 +}
  99 +
  100 +
  101 +
  102 +$('.on-lingqu', 'div.main-right-use').on('click', function() {
  103 + var $curDom = $(this),
  104 + req = '',
  105 + href = '',
  106 + a = '';
  107 +
  108 + if (getUrlParam('app_version')) {
  109 + req += '&app_version=' + getUrlParam('app_version');
  110 + }
  111 +
  112 + if (getUrlParam('uid')) {
  113 + req += '&uid=' + getUrlParam('uid');
  114 + }
  115 +
  116 +
  117 + if (!$curDom.hasClass('received')) {
  118 + $.ajax({
  119 + url: '//m.yohobuy.com/coupon/receiveCoupon?code=a83b7d55324fb65f96c1f85a3387ebd8' + req,
  120 + data: {
  121 + couponID: $curDom.parents('.coupon-floor').attr('coupon-id')
  122 + },
  123 + dataType: 'json',
  124 + success: function(data) {
  125 + var msg = data.msg,
  126 + status = data.status,
  127 + newUrl = '//m.yohobuy.com/signin.html?refer=' + location.href;
  128 +
  129 +
  130 + if (data.isApp === true) {
  131 + newUrl = data.url;
  132 + }
  133 + if (data.noLogin === true) {
  134 + location.href = newUrl;
  135 + } else {
  136 + if (status) {
  137 + href = $curDom.parent('.main-right-use').attr('href');
  138 + $curDom.parent('.main-right-use').wrap('<a class=\'main-right-use\' href=' + href + '></a>');
  139 + a = $curDom.parent('.main-right-use').parent('a');
  140 + a.html('<span class="received"></span>');
  141 +
  142 + tip.show('领券成功');
  143 + } else {
  144 + tip.show(msg);
  145 + }
  146 + }
  147 + },
  148 + error: function() {
  149 + tip.show('网络异常!');
  150 + }
  151 + });
  152 + return false;
  153 + }
  154 +
  155 +});
  156 +
  157 +
  158 +/**
  159 + * 微信分享
  160 + */
  161 +if (typeof wx !== 'undefined') {
  162 + $.getJSON(_weChatInterface + '?pageurl=' +
  163 + encodeURIComponent(location.href.split('#')[0]) + '&callback=?',
  164 + function(json) {
  165 + var _appId,
  166 + _timestamp,
  167 + _nonceStr,
  168 + _signature;
  169 +
  170 + if (json) {
  171 + _appId = json.appId.toString();
  172 + _timestamp = json.timestamp;
  173 + _nonceStr = json.nonceStr.toString();
  174 + _signature = json.signature.toString();
  175 +
  176 + wx.config({
  177 + debug: false,
  178 + appId: _appId,
  179 + timestamp: _timestamp,
  180 + nonceStr: _nonceStr,
  181 + signature: _signature,
  182 + jsApiList: [
  183 + 'checkJsApi',
  184 + 'onMenuShareTimeline',
  185 + 'onMenuShareAppMessage',
  186 + 'onMenuShareQQ',
  187 + 'onMenuShareWeibo',
  188 + 'hideMenuItems',
  189 + 'showMenuItems',
  190 + 'hideAllNonBaseMenuItem',
  191 + 'showAllNonBaseMenuItem',
  192 + 'translateVoice',
  193 + 'startRecord',
  194 + 'stopRecord',
  195 + 'onRecordEnd',
  196 + 'playVoice',
  197 + 'pauseVoice',
  198 + 'stopVoice',
  199 + 'uploadVoice',
  200 + 'downloadVoice',
  201 + 'chooseImage',
  202 + 'previewImage',
  203 + 'uploadImage',
  204 + 'downloadImage',
  205 + 'getNetworkType',
  206 + 'openLocation',
  207 + 'getLocation',
  208 + 'hideOptionMenu',
  209 + 'showOptionMenu',
  210 + 'closeWindow',
  211 + 'scanQRCode',
  212 + 'chooseWXPay',
  213 + 'openProductSpecificView',
  214 + 'addCard',
  215 + 'chooseCard',
  216 + 'openCard'
  217 + ]
  218 + });
  219 + }
  220 + });
  221 +
  222 + wx.ready(function() {
  223 + var shareData = {
  224 + title: 'YOHO!BUY有货【学生】专享福利大派送!4大特权享不停!',
  225 + desc: '全球1000+潮流品牌每日上新!一起来YOHO!玩潮流!',
  226 + imgUrl: 'http://img12.static.yhbimg.com/brandCertificate/2016/08/10/14/0204d441c737c687fc418b2372d0aba8be.png',
  227 + link: 'https://m.yohobuy.com/activity/student'
  228 + };
  229 +
  230 + // 分享给朋友
  231 + wx.onMenuShareAppMessage(shareData);
  232 +
  233 + // 分享到朋友圈
  234 + wx.onMenuShareTimeline(shareData);
  235 +
  236 + // 分享到QQ
  237 + wx.onMenuShareQQ(shareData);
  238 +
  239 + // 分享到微博
  240 + wx.onMenuShareWeibo(shareData);
  241 + });
  242 +}
  243 +
  244 +setTimeout(function() {
  245 + var len = $('.good-info', '.goods-list').length;
  246 + var ids = [];
  247 + var check = location.pathname.indexOf('quanyi') === -1;
  248 +
  249 + $('.good-info', '.goods-list').each(function() {
  250 + var goodids = $(this).find('.good-thumb').attr('href').match(/"product_skn":([^}]+)/, 'g');
  251 + var goodid = goodids && goodids.length === 2 ? goodids[1] : '';
  252 +
  253 + ids.push(goodid);
  254 + });
  255 +
  256 + if (check && window._yas && window._yas.sendCustomInfo) {
  257 + window._yas.sendCustomInfo({
  258 + op: 'YB_STUDENT_VIP_GDS_LIST',
  259 + param: JSON.stringify({
  260 + C_ID: C_ID,
  261 + PRD_NUM: len,
  262 + PRD_ID: ids.join(','),
  263 + ACTION_ID: 0,
  264 + SORT_TYPE: 4,
  265 + REC_ID: uuid(40) + '0000'
  266 + })
  267 + }, true);
  268 + }
  269 + if ($('.s-verify-fail').size()) {
  270 + if (window._yas && window._yas.sendCustomInfo) {
  271 + window._yas.sendCustomInfo({
  272 + op: 'YB_STUDENT_ATTCT_RESULT',
  273 + param: JSON.stringify({
  274 + C_ID: C_ID,
  275 + SRC_ID: 5,
  276 + ATTCT_RES: 2,
  277 + FAILURE_CAUSE: $('.s-verify-fail').attr('prompt')
  278 + })
  279 + }, true);
  280 + }
  281 + } else if ($('.s-verify-success').size()) {
  282 + if (window._yas && window._yas.sendCustomInfo) {
  283 + window._yas.sendCustomInfo({
  284 + op: 'YB_STUDENT_ATTCT_RESULT',
  285 + param: JSON.stringify({
  286 + C_ID: C_ID,
  287 + SRC_ID: 5,
  288 + ATTCT_RES: 1,
  289 + FAILURE_CAUSE: '',
  290 + ATTCT_INFO: JSON.parse(localStorage.STUDENTCOOKIES)
  291 + })
  292 + }, true);
  293 + }
  294 + } else {
  295 +
  296 + // 埋点 学生营销宣传首页
  297 + // if (window._yas && window._yas.sendCustomInfo) {
  298 + // window._yas.sendCustomInfo({
  299 + // op: 'YB_STUDENT_HOME',
  300 + // param: JSON.stringify({
  301 + // C_ID: C_ID
  302 + // }),
  303 + // }, true);
  304 + // }
  305 + }
  306 +
  307 +}, 3000);
  308 +
  309 +
  310 +
  311 +
  312 +
  313 +$('.swiper-slide', '.banner-top').click(function() {
  314 + var options;
  315 + var url = $(this).find('a').attr('href');
  316 + var index = $(this).index();
  317 + var tid = $(this).parents('.s-section').data('template-id');
  318 +
  319 + options = {
  320 + op: 'YB_STUDENT_VIP_FLR',
  321 + param: JSON.stringify({
  322 + C_ID: C_ID,
  323 + F_ID: tid || 1,
  324 + F_NAME: '焦点图',
  325 + F_URL: encodeURIComponent(url),
  326 + F_INDEX: 1,
  327 + I_INDEX: index
  328 + })
  329 + };
  330 + if (window._yas && window._yas.sendCustomInfo) {
  331 + window._yas.sendCustomInfo(options, true);
  332 + }
  333 +
  334 + // return false;
  335 +});
  336 +
  337 +// 学生活动页楼层埋点
  338 +$('.s-activity, .main-left, .s-quan, .iconfont', '.s-section').click(function() {
  339 + var options;
  340 + var url = $(this).attr('href');
  341 + var index = $(this).index();
  342 + var tid = $(this).parents('.s-section').data('template-id');
  343 + var obj = {
  344 + 's-activity': {
  345 + fname: '学生专属活动',
  346 + findex: 4,
  347 + iindex: index
  348 + },
  349 + 'more iconfont': {
  350 + fname: '领券中心',
  351 + findex: 3,
  352 + iindex: 0
  353 + },
  354 + 'main-left': {
  355 + fname: '领券中心',
  356 + findex: 3,
  357 + iindex: $(this).parent().parent().index()
  358 + },
  359 + 'more s-quan': {
  360 + fname: '学生权益',
  361 + findex: 2,
  362 + iindex: 0
  363 + }
  364 + }[$(this).attr('class')];
  365 +
  366 + options = {
  367 + op: 'YB_STUDENT_VIP_FLR',
  368 + param: JSON.stringify({
  369 + C_ID: C_ID,
  370 + F_ID: tid,
  371 + F_NAME: obj.fname,
  372 + F_URL: encodeURIComponent(url),
  373 + F_INDEX: obj.findex,
  374 + I_INDEX: obj.iindex
  375 + })
  376 + };
  377 + if (window._yas && window._yas.sendCustomInfo) {
  378 + window._yas.sendCustomInfo(options, true);
  379 + }
  380 +});
  381 +$('.good-info', '.goods-list').click(function() {
  382 + var options;
  383 +
  384 + var index = $(this).index();
  385 + var goodids = $(this).find('.good-thumb').attr('href').match(/"product_skn":([^}]+)/, 'g');
  386 + var goodid = goodids && goodids.length === 2 ? goodids[1] : '';
  387 +
  388 + options = {
  389 + op: 'YB_STUDENT_VIP_GDS_LIST',
  390 + param: JSON.stringify({
  391 + C_ID: C_ID,
  392 + PRD_NUM: Number(index) + 1,
  393 + PRD_ID: goodid,
  394 + ACTION_ID: 1,
  395 + REC_ID: uuid(40) + '0000'
  396 + })
  397 + };
  398 + if (window._yas && window._yas.sendCustomInfo) {
  399 + window._yas.sendCustomInfo(options, true);
  400 + }
  401 +});
  402 +$('.s-renzhen').click(function() {
  403 + var options = {
  404 + op: 'YB_STUDENT_ATTCT_INFO',
  405 + param: JSON.stringify({
  406 + C_ID: C_ID,
  407 + SRC_ID: 1
  408 + })
  409 + };
  410 +
  411 + if (window._yas && window._yas.sendCustomInfo) {
  412 + window._yas.sendCustomInfo(options, true);
  413 + }
  414 +});
  415 +
  416 +$('.dialog-wrapper').addClass('s-dialog-wrapper');
  417 +$('.s-dialog').on('click', function() {
  418 + var text = [{
  419 + dialogText: '<h2>权益1: 新品立享9折</h2><p>学生购买指定原价新品时,可立即享受9折优惠,与VIP折扣不可同时享受</p>'
  420 + }, {
  421 + dialogText: '<h2>权益2: 每1元返1个有货币</h2><p>1、学生购买指定商品时,以商品的实际成交金额计算,每1元返1个有货币;</p>' +
  422 + '<p>2、返有货币时间:确认收货7日后,系统将自动将对应数量的有货币返至购买账户;</p>' +
  423 + '<p>3、有货币有效期:获得当日至次年12月31日,逾期自动作废;</p>' +
  424 + '<p>4、查看有货币:登录后,点击“个人中心”在“我的有货币”中可以查看有货币余额及明细。</p>'
  425 + }, {
  426 + dialogText: '<h2>权益3: 免单抽奖</h2><p>1、每月将在累计购物金额最高的学校中,抽取3名幸运学生用户,获得免单资格;</p>' +
  427 + '<p>2、免单用户名单将在每月第1个工作日公布在有货微信公众号上,可关注【有货YOHOBUY】;</p>' +
  428 + '<p>3、免单用户将在中奖次日获得与实付金额等额的现金券,使用时间:中奖当月。</p>'
  429 + }, {
  430 + dialogText: '<h2>权益4: 学生专享活动</h2><p>每月不定期的开展学生专享活动,可打开有货APP推送,及时查收学生专享活动通知。</p>'
  431 + }];
  432 + var dialogBoxHammer, dialogRightBtn;
  433 +
  434 + dialog.showDialog({
  435 + student: true,
  436 + dialogText: text[$(this).index()].dialogText,
  437 + hasFooter: {
  438 + rightBtnText: '我知道了'
  439 + }
  440 + }, function() {
  441 + $('body').css({
  442 + overflow: '',
  443 + position: ''
  444 + });
  445 + dialog.hideDialog();
  446 + }, undefined, true);
  447 +
  448 + $('.dialog-content').css({
  449 + padding: '0 1.5rem 1rem 1.5rem'
  450 + });
  451 +
  452 + $('.dialog-box').css({
  453 + 'border-radius': '0.25rem',
  454 + background: '#fff'
  455 + });
  456 +
  457 + $('.dialog-right-btn').css({
  458 + border: 'none',
  459 + color: '#d0021b'
  460 + });
  461 +
  462 + $('body').css({
  463 + overflow: 'hidden',
  464 + position: 'fixed'
  465 + });
  466 +
  467 + dialogBoxHammer = new Hammer(document.getElementsByClassName('dialog-box')[0]);
  468 + dialogRightBtn = new Hammer(document.getElementsByClassName('dialog-right-btn')[0]);
  469 +
  470 + dialogBoxHammer.on('tap', function(event) {
  471 + event.srcEvent.stopPropagation();
  472 + });
  473 +
  474 + dialogRightBtn.on('tap', function(event) {
  475 + $('body').css({
  476 + overflow: '',
  477 + position: ''
  478 + });
  479 + dialog.hideDialog();
  480 + event.preventDefault();
  481 + event.srcEvent.stopPropagation();
  482 + });
  483 +
  484 + $('.dialog-content').addClass('s-dialog-content');
  485 +});
  486 +
  487 +$('#float-layer-close').on('touchend', function() {
  488 + $('#float-layer-app').hide();
  489 + return false;
  490 +});
  491 +
  492 +if ($('#float-layer-btn') && $('#float-layer-btn')[0]) {
  493 + var floatLayerBtnHammer = new Hammer($('#float-layer-btn')[0]);
  494 + var unionType = window.queryString.union_type || 367;
  495 + floatLayerBtnHammer.on('tap', function(e) {
  496 +
  497 + window.downLoadApp(unionType);
  498 + e.srcEvent.stopPropagation();
  499 + });
  500 +}
@@ -11,8 +11,6 @@ var _weChatInterface = '//m.yohobuy.com/life/getSignPackage', @@ -11,8 +11,6 @@ var _weChatInterface = '//m.yohobuy.com/life/getSignPackage',
11 C_ID, 11 C_ID,
12 getChannel; 12 getChannel;
13 13
14 -  
15 -  
16 require('../common'); 14 require('../common');
17 15
18 // 根据ua判断页头 16 // 根据ua判断页头
@@ -317,12 +317,12 @@ if ($footer.find('.user-name').text().length === 11) { @@ -317,12 +317,12 @@ if ($footer.find('.user-name').text().length === 11) {
317 } 317 }
318 318
319 // 浮层下载APP 319 // 浮层下载APP
320 -function downLoadApp() { 320 +function downLoadApp(unionType) {
321 var appUrl = 'http://union.yoho.cn/union/downapp.html'; 321 var appUrl = 'http://union.yoho.cn/union/downapp.html';
322 var clickedAt = new Date(); 322 var clickedAt = new Date();
323 323
324 setTimeout(function() { 324 setTimeout(function() {
325 - var mkt = queryString().union_type || cookie('unionTypeYas') || false; 325 + var mkt = unionType || queryString().union_type || cookie('unionTypeYas') || false;
326 326
327 if ((new Date()) - clickedAt < 2000) { 327 if ((new Date()) - clickedAt < 2000) {
328 if (mkt) { 328 if (mkt) {
@@ -28,7 +28,7 @@ $('#float-layer-close').on('touchend', function() { @@ -28,7 +28,7 @@ $('#float-layer-close').on('touchend', function() {
28 if ($('#float-layer-btn') && $('#float-layer-btn')[0]) { 28 if ($('#float-layer-btn') && $('#float-layer-btn')[0]) {
29 floatLayerBtnHammer = new Hammer($('#float-layer-btn')[0]); 29 floatLayerBtnHammer = new Hammer($('#float-layer-btn')[0]);
30 floatLayerBtnHammer.on('tap', function(e) { 30 floatLayerBtnHammer.on('tap', function(e) {
31 - window.downLoadApp('bottom'); 31 + window.downLoadApp();
32 e.srcEvent.stopPropagation(); 32 e.srcEvent.stopPropagation();
33 }); 33 });
34 34
@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 @import "market/index"; 5 @import "market/index";
6 @import "shop-collect/shop-collect"; 6 @import "shop-collect/shop-collect";
7 @import "single-day"; 7 @import "single-day";
  8 +@import "student-market";
8 9
9 .receive-coupon-page { 10 .receive-coupon-page {
10 * { 11 * {
  1 +.student-market {
  2 + margin-bottom: 30px;
  3 +
  4 + .sm-layout {
  5 + height: 80px;
  6 + line-height: 80px;
  7 + padding: 0 20px 0 25px;
  8 + border-bottom: 1px solid #e0e0e0;
  9 +
  10 + .s-renzhen {
  11 + font-size: 20px;
  12 + width: 110px;
  13 + height: 48px;
  14 + line-height: 51px;
  15 + color: #fff;
  16 + background-color: #d10922;
  17 + border-radius: 20px;
  18 + text-align: center;
  19 + vertical-align: middle;
  20 + display: block;
  21 + float: right;
  22 + margin-top: 15px;
  23 + }
  24 + }
  25 +
  26 + .s-coupon-contain {
  27 + background-color: #f0f0f0;
  28 + }
  29 +
  30 + .float-layer-left {
  31 + p {
  32 + font-size: 20px;
  33 + line-height: 20PX;
  34 + padding: 3PX 0;
  35 + }
  36 + }
  37 +
  38 + .s-dialog {
  39 + img {
  40 + height: 152px;
  41 + }
  42 + }
  43 +}