Showing
3 changed files
with
21 additions
and
5 deletions
1 | { | 1 | { |
2 | "name": "yas-jssdk", | 2 | "name": "yas-jssdk", |
3 | - "version": "2.0.0", | 3 | + "version": "2.1.0", |
4 | "description": "YOHO!采集系统的前端js的开发包", | 4 | "description": "YOHO!采集系统的前端js的开发包", |
5 | "keywords": ["YOHO!", "Acquisition", "System", "JS-SDK"], | 5 | "keywords": ["YOHO!", "Acquisition", "System", "JS-SDK"], |
6 | "homepage": "", | 6 | "homepage": "", |
1 | /** | 1 | /** |
2 | * 跨域发送信息工具库 | 2 | * 跨域发送信息工具库 |
3 | */ | 3 | */ |
4 | +var util = require('./util'); | ||
4 | var config = require('./config'); | 5 | var config = require('./config'); |
5 | 6 | ||
6 | var yasPath = config.yasPath; | 7 | var yasPath = config.yasPath; |
@@ -22,10 +23,9 @@ var createCORSRequest = function(method, url) { | @@ -22,10 +23,9 @@ var createCORSRequest = function(method, url) { | ||
22 | return xhr; | 23 | return xhr; |
23 | }; | 24 | }; |
24 | 25 | ||
25 | - | ||
26 | //发送图片方式 | 26 | //发送图片方式 |
27 | exports.imgSend = function(param, callback) { | 27 | exports.imgSend = function(param, callback) { |
28 | - var appVer = window.qs.app_version || window.qs.appVersion; | 28 | + var appVer = util.getAppVersion(); |
29 | if (window.appBaseLogs || appVer >= '5.2.1') { | 29 | if (window.appBaseLogs || appVer >= '5.2.1') { |
30 | // 从app中打开的wap页场合,走app的上报逻辑 | 30 | // 从app中打开的wap页场合,走app的上报逻辑 |
31 | return; | 31 | return; |
@@ -138,14 +138,13 @@ exports.getGeo = function(callback) { | @@ -138,14 +138,13 @@ exports.getGeo = function(callback) { | ||
138 | }; | 138 | }; |
139 | 139 | ||
140 | exports.queryString = function() { | 140 | exports.queryString = function() { |
141 | - var vars = [], | 141 | + var vars = {}, |
142 | hash, | 142 | hash, |
143 | i; | 143 | i; |
144 | var hashes = window.location.search.slice(1).split('&'); | 144 | var hashes = window.location.search.slice(1).split('&'); |
145 | 145 | ||
146 | for (i = 0; i < hashes.length; i++) { | 146 | for (i = 0; i < hashes.length; i++) { |
147 | hash = hashes[i].split('='); | 147 | hash = hashes[i].split('='); |
148 | - vars.push(hash[0]); | ||
149 | vars[hash[0]] = hash[1]; | 148 | vars[hash[0]] = hash[1]; |
150 | } | 149 | } |
151 | return vars; | 150 | return vars; |
@@ -175,4 +174,21 @@ exports.getChannel = function() { | @@ -175,4 +174,21 @@ exports.getChannel = function() { | ||
175 | kids: 3, | 174 | kids: 3, |
176 | lifestyle: 4 | 175 | lifestyle: 4 |
177 | }[cookie('_Channel')]; | 176 | }[cookie('_Channel')]; |
177 | +} | ||
178 | + | ||
179 | +var _getAppVersionByUa = function() { | ||
180 | + var vars = navigator.userAgent.split(';') || []; | ||
181 | + for (var i = 0; i < vars.length; i++) { | ||
182 | + if (vars[i].indexOf('app_version') > -1) { | ||
183 | + return vars[i].split('=')[1]; | ||
184 | + } | ||
185 | + } | ||
186 | +} | ||
187 | + | ||
188 | +exports.getAppVersion = function() { | ||
189 | + var appVer = window.qs.app_version || window.qs.appVersion; | ||
190 | + if (!appVer) { | ||
191 | + appVer = _getAppVersionByUa(); | ||
192 | + } | ||
193 | + return appVer; | ||
178 | } | 194 | } |
-
Please register or login to post a comment