Authored by 郭成尧

Merge branch 'release/newSearch' of git.yoho.cn:fe/yohobuywap-node into release/newSearch

@@ -8,11 +8,13 @@ const co = require('bluebird').coroutine; @@ -8,11 +8,13 @@ const co = require('bluebird').coroutine;
8 8
9 9
10 function humanNum_wan(num) { 10 function humanNum_wan(num) {
11 - if (num > 9999) {  
12 - num = (num / 10000).toFixed(2) + '万'  
13 - }  
14 -  
15 return num; 11 return num;
  12 +
  13 + // if (num > 9999) {
  14 + // num = (num / 10000).toFixed(2) + '万'
  15 + // }
  16 +
  17 + // return num;
16 } 18 }
17 19
18 exports.beforeIn = (req, res, next) => { 20 exports.beforeIn = (req, res, next) => {
@@ -111,7 +113,7 @@ exports.crazyLuck = (req, res, next) => { @@ -111,7 +113,7 @@ exports.crazyLuck = (req, res, next) => {
111 let joinNum = yield vipDayModel.getJoinNum(2); 113 let joinNum = yield vipDayModel.getJoinNum(2);
112 114
113 coins = (coins && coins.data && coins.data.total) || 0; 115 coins = (coins && coins.data && coins.data.total) || 0;
114 - joinNum = (joinNum && joinNum.data) || 0 116 + joinNum = (joinNum && joinNum.data) || 0;
115 117
116 res.render('vip_day/crazy_luck', { 118 res.render('vip_day/crazy_luck', {
117 title: '拼手气', 119 title: '拼手气',
@@ -8,6 +8,7 @@ @@ -8,6 +8,7 @@
8 * 8 *
9 * 希望能与 微信 JS-SDK 一样方便 9 * 希望能与 微信 JS-SDK 一样方便
10 */ 10 */
  11 +var $ = require('yoho-jquery');
11 var tip = require('./plugin/tip'); 12 var tip = require('./plugin/tip');
12 13
13 /* 空方法 */ 14 /* 空方法 */
@@ -16,11 +17,22 @@ var emptyFn = function() { }; @@ -16,11 +17,22 @@ var emptyFn = function() { };
16 /* 提示信息 */ 17 /* 提示信息 */
17 var tipInfo = '暂不支持,请在YOHO!BUY应用中打开'; 18 var tipInfo = '暂不支持,请在YOHO!BUY应用中打开';
18 19
19 -var yoho = { 20 +var qs = window.queryString;
  21 +
  22 +var yoho, $appLink;
  23 +
  24 +$appLink = $('#yoho-app-link');
  25 +
  26 +if (!$appLink.length) {
  27 + $('body').append('<a id="yoho-app-link" href="javascript:;" style="display:none !important;"></a>');
  28 + $appLink = $('#yoho-app-link');
  29 +}
  30 +
  31 +yoho = {
20 /** 32 /**
21 * 判断是否是 APP 33 * 判断是否是 APP
22 */ 34 */
23 - isApp: /YohoBuy/i.test(navigator.userAgent || ''), 35 + isApp: /YohoBuy/i.test(navigator.userAgent || '') || qs.app_version,
24 isiOS: /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(navigator.userAgent || ''), 36 isiOS: /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(navigator.userAgent || ''),
25 isAndroid: /Android/i.test(navigator.userAgent || ''), 37 isAndroid: /Android/i.test(navigator.userAgent || ''),
26 38
@@ -73,12 +85,85 @@ var yoho = { @@ -73,12 +85,85 @@ var yoho = {
73 }, 500); 85 }, 500);
74 }, 86 },
75 87
  88 + parseUrl: function(url) {
  89 + var query = {},
  90 + hashs,
  91 + hash,
  92 + i;
  93 +
  94 + url = (url || '').split('?');
  95 + hashs = url[1].split('&');
  96 +
  97 + if (hashs && hashs.length) {
  98 + for (i = 0; i < hashs.length; i++) {
  99 + hash = hashs[i].split('=');
  100 + console.log(hashs[i]);
  101 + query[hash[0]] = hash[1];
  102 + }
  103 + }
  104 +
  105 + return {
  106 + path: url[0],
  107 + query: query
  108 + };
  109 + },
  110 +
76 getUid: function() { 111 getUid: function() {
77 - if (window.queryString.app_version) {  
78 - return window.queryString.uid || 0; 112 + if (yoho.isApp) {
  113 + return qs.uid;
  114 + }
  115 +
  116 + return window.gitUid();
  117 + },
  118 +
  119 + goLogin: function(refer, data) {
  120 + var url;
  121 +
  122 + url = 'http://m.yohobuy.com/signin.html?refer=' + encodeURIComponent(refer);
  123 + refer = yoho.parseUrl(refer || location.href);
  124 +
  125 + if (yoho.isApp) {
  126 + url = url + '&openby:yohobuy=' + (data || JSON.stringify({
  127 + action: 'go.weblogin',
  128 + params: {
  129 + priority: 'N',
  130 + jumpurl: {
  131 + url: refer.path,
  132 + param: refer.query
  133 + }
  134 + }
  135 + }));
  136 + }
  137 +
  138 + $appLink.attr('href', url);
  139 + $appLink[0].click();
  140 + return false;
  141 + },
  142 +
  143 + goH5: function(link, data) {
  144 + var url = link;
  145 +
  146 + if (!link) {
  147 + return;
  148 + }
  149 + link = yoho.parseUrl(link || location.href);
  150 +
  151 + if (yoho.isApp) {
  152 + url = url + '&openby:yohobuy=' + (data || JSON.stringify({
  153 + action: 'go.h5',
  154 + params: {
  155 + islogin: 'N',
  156 + type: 0,
  157 + updateflag: Date.now() + '',
  158 + url: link.path,
  159 + param: link.query
  160 + }
  161 + }));
79 } 162 }
80 163
81 - return window.getUid() || 0; 164 + $appLink.attr('href', url);
  165 + $appLink[0].click();
  166 + return false;
82 } 167 }
83 }; 168 };
84 169