Authored by huangyi

活动sdk 修改登录h5的url

@@ -366,15 +366,15 @@ @@ -366,15 +366,15 @@
366 /*!****************************!*\ 366 /*!****************************!*\
367 !*** ./src/public/base.js ***! 367 !*** ./src/public/base.js ***!
368 \****************************/ 368 \****************************/
369 -/*! no static exports found */function(e,o,r){"use strict";Object.defineProperty(o,"__esModule",{value:!0});var n=l(r(/*! babel-runtime/core-js/json/stringify */"./node_modules/babel-runtime/core-js/json/stringify.js")),t=l(r(/*! ../utils/jsonp */"./src/utils/jsonp.js")),s=l(r(/*! ../utils/cookie */"./src/utils/cookie.js")),i=r(/*! ../utils/common */"./src/utils/common.js"),u=l(r(/*! promise-polyfill */"./node_modules/promise-polyfill/src/index.js"));function l(e){return e&&e.__esModule?e:{default:e}}var c="";o.default={env:function(){var e=window.__wxjs_environment;return c=!e&&navigator.userAgent.match(/yohobuy/i)?(document.addEventListener("deviceready",function(){}),"app"):!e&&navigator.userAgent.match(/miniProgram/i)||"miniprogram"===e?"miniprogram":"https://www.yohobuy.com"===location.origin?"pc":"h5"},loginUrl:function(){var e=void 0,o=location.href;return"app"===c?(e="http://m.yohobuy.com/signin.html?refer="+encodeURIComponent(o),o=function(e){var o={},r=void 0,n=void 0,t=void 0;if((r=((e=(e||"").split("?"))[1]||"").split("&"))&&r.length)for(t=0;t<r.length;t++)o[(n=r[t].split("="))[0]]=n[1];return{path:e[0],query:o}}(o),/Android/i.test(navigator.userAgent||"")?(e.indexOf("?")<0&&(e+="?appLogin=1"),0<=location.href.indexOf("&openby")&&(e=e.substring(0,e.indexOf("&openby"))),e+="&"):(0<=location.href.indexOf("#openby")&&(e=e.substring(0,e.indexOf("#openby"))),e+="#"),e+="openby:yohobuy="+(0,n.default)({action:"go.weblogin",params:{priority:"N",jumpurl:{url:o.path,param:o.query},needlogout:"Y"}})):e="pc"===c?"https://www.yoho/signin.html?refer="+encodeURIComponent(location.href):"miniprogram"===c?"/pages/userCenter/userCenter":(o.indexOf("?")<0?o+="?skcall=1":o+="&skcall=1","http://m.yohobuy.com/signin.html?refer="+encodeURIComponent(o)),e},getUid:function(){return new u.default(function(r){if("h5"===c||"pc"===c)(0,t.default)("https://m.yohobuy.com/passport/login/user").then(function(e){var o=0;200===e.code&&(o=Number(e.data)),r(o)});else{var e=Number(s.default.cookie("app_uid"))||Number((0,i.getQueryObj)().uid)||0;r(e)}})}}},"./src/public/goto.js": 369 +/*! no static exports found */function(e,o,r){"use strict";Object.defineProperty(o,"__esModule",{value:!0});var n=l(r(/*! babel-runtime/core-js/json/stringify */"./node_modules/babel-runtime/core-js/json/stringify.js")),t=l(r(/*! ../utils/jsonp */"./src/utils/jsonp.js")),s=l(r(/*! ../utils/cookie */"./src/utils/cookie.js")),i=r(/*! ../utils/common */"./src/utils/common.js"),u=l(r(/*! promise-polyfill */"./node_modules/promise-polyfill/src/index.js"));function l(e){return e&&e.__esModule?e:{default:e}}var c="";o.default={env:function(){var e=window.__wxjs_environment;return c=!e&&navigator.userAgent.match(/yohobuy/i)?(document.addEventListener("deviceready",function(){}),"app"):!e&&navigator.userAgent.match(/miniProgram/i)||"miniprogram"===e?"miniprogram":"https://www.yohobuy.com"===location.origin?"pc":"h5"},loginUrl:function(){var e=void 0,o=location.href;return"app"===c?(e="http://m.yohobuy.com/signin.html?refer="+encodeURIComponent(o),o=function(e){var o={},r=void 0,n=void 0,t=void 0;if((r=((e=(e||"").split("?"))[1]||"").split("&"))&&r.length)for(t=0;t<r.length;t++)o[(n=r[t].split("="))[0]]=n[1];return{path:e[0],query:o}}(o),/Android/i.test(navigator.userAgent||"")?(e.indexOf("?")<0&&(e+="?appLogin=1"),0<=location.href.indexOf("&openby")&&(e=e.substring(0,e.indexOf("&openby"))),e+="&"):(0<=location.href.indexOf("#openby")&&(e=e.substring(0,e.indexOf("#openby"))),e+="#"),e+="openby:yohobuy="+(0,n.default)({action:"go.weblogin",params:{priority:"N",jumpurl:{url:o.path,param:o.query},needlogout:"Y"}})):e="pc"===c?"https://www.yoho/signin.html?refer="+encodeURIComponent(location.href):"miniprogram"===c?"/pages/userCenter/userCenter":(o.indexOf("?")<0?o+="?skcall=1":o+="&skcall=1","http://m.yohobuy.com/signin.html?refer="+encodeURIComponent(o)),e},getUid:function(){return new u.default(function(r){if("h5"===c||"pc"===c)(0,t.default)("//m.yohobuy.com/passport/login/user").then(function(e){var o=0;200===e.code&&(o=Number(e.data)),r(o)});else{var e=Number(s.default.cookie("app_uid"))||Number((0,i.getQueryObj)().uid)||0;r(e)}})}}},"./src/public/goto.js":
370 /*!****************************!*\ 370 /*!****************************!*\
371 !*** ./src/public/goto.js ***! 371 !*** ./src/public/goto.js ***!
372 \****************************/ 372 \****************************/
373 -/*! no static exports found */function(e,o,r){"use strict";Object.defineProperty(o,"__esModule",{value:!0});var n=i(r(/*! babel-runtime/helpers/classCallCheck */"./node_modules/babel-runtime/helpers/classCallCheck.js")),t=i(r(/*! babel-runtime/helpers/createClass */"./node_modules/babel-runtime/helpers/createClass.js")),s=i(r(/*! weixin-js-sdk */"./node_modules/weixin-js-sdk/index.js")),l=r(/*! ../utils/common */"./src/utils/common.js");function i(e){return e&&e.__esModule?e:{default:e}}var u=function(){function o(e){(0,n.default)(this,o),this.env=e}return(0,t.default)(o,[{key:"link",value:function(e){var o=e.currentTarget,r=o.getAttribute("data-type")||"other",n=o.getAttribute("data-id")||"",t=o.getAttribute("data-url")||"",s=o.getAttribute("data-name")||"",i="";if("miniprogram"===this.env)return i="product"===r?"/pages/goodsDetail/goodsDetail?productSkn="+n+"&page_name=goodsList&page_param=5":"brand"===r?"/pages/goodsList/brandStore?shop_id="+n+"&shop_name="+s:t.split("?")[0],(0,l.linkToMiniApp)(i,r);if(i="pc"===this.env?"product"===r?"https://www.yohobuy.com/product/"+n+".html":"brand"===r?"https://www.yohobuy.com/shop/"+s+"-"+n+".html":t:"product"===r?"https://m.yohobuy.com/product/"+n+'.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'+n+"}}":"brand"===r?"https://m.yohobuy.com/product/index/brand?shop_id="+n+'&openby:yohobuy={"action":"go.shop","params":{"shop_id":"'+n+'","shop_template_type":"1","shop_name":"'+s+'","is_red_shop":"1"}}':t,"app"===this.env){var u=document.getElementById("yosdk-goto");return u?u.setAttribute("href",i):u=(0,l.createLinkButton)(i,"yosdk-goto"),u.click()}window.location.href=i}},{key:"goBack",value:function(){"app"===this.env?(0,l.invokeMethod)({method:"go.back"}):"miniprogram"===this.env?s.default.miniProgram.navigateBack():history.go(-1)}}]),o}();o.default=u},"./src/public/login.js": 373 +/*! no static exports found */function(e,o,r){"use strict";Object.defineProperty(o,"__esModule",{value:!0});var n=i(r(/*! babel-runtime/helpers/classCallCheck */"./node_modules/babel-runtime/helpers/classCallCheck.js")),t=i(r(/*! babel-runtime/helpers/createClass */"./node_modules/babel-runtime/helpers/createClass.js")),s=i(r(/*! weixin-js-sdk */"./node_modules/weixin-js-sdk/index.js")),l=r(/*! ../utils/common */"./src/utils/common.js");function i(e){return e&&e.__esModule?e:{default:e}}var u=function(){function o(e){(0,n.default)(this,o),this.env=e}return(0,t.default)(o,[{key:"link",value:function(e){var o=e.currentTarget,r=o.getAttribute("data-type")||"other",n=o.getAttribute("data-id")||"",t=o.getAttribute("data-url")||"",s=o.getAttribute("data-name")||"",i="";if("miniprogram"===this.env)return i="product"===r?"/pages/goodsDetail/goodsDetail?productSkn="+n+"&page_name=goodsList&page_param=5":"brand"===r?"/pages/goodsList/brandStore?shop_id="+n+"&shop_name="+s:t,(0,l.linkToMiniApp)(i,r);if(i="pc"===this.env?"product"===r?"https://www.yohobuy.com/product/"+n+".html":"brand"===r?"https://www.yohobuy.com/shop/"+s+"-"+n+".html":t:"product"===r?"//m.yohobuy.com/product/"+n+'.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":'+n+"}}":"brand"===r?"//m.yohobuy.com/product/index/brand?shop_id="+n+'&openby:yohobuy={"action":"go.shop","params":{"shop_id":"'+n+'","shop_template_type":"1","shop_name":"'+s+'","is_red_shop":"1"}}':t,"app"===this.env){var u=document.getElementById("yosdk-goto");return u?u.setAttribute("href",i):u=(0,l.createLinkButton)(i,"yosdk-goto"),u.click()}window.location.href=i}},{key:"goBack",value:function(){"app"===this.env?(0,l.invokeMethod)({method:"go.back"}):"miniprogram"===this.env?s.default.miniProgram.navigateBack():history.go(-1)}}]),o}();o.default=u},"./src/public/login.js":
374 /*!*****************************!*\ 374 /*!*****************************!*\
375 !*** ./src/public/login.js ***! 375 !*** ./src/public/login.js ***!
376 \*****************************/ 376 \*****************************/
377 -/*! no static exports found */function(e,o,r){"use strict";Object.defineProperty(o,"__esModule",{value:!0});var n=l(r(/*! babel-runtime/helpers/classCallCheck */"./node_modules/babel-runtime/helpers/classCallCheck.js")),t=l(r(/*! babel-runtime/helpers/createClass */"./node_modules/babel-runtime/helpers/createClass.js")),s=l(r(/*! weixin-js-sdk */"./node_modules/weixin-js-sdk/index.js")),i=r(/*! ../utils/common */"./src/utils/common.js"),u=l(r(/*! ./base */"./src/public/base.js"));function l(e){return e&&e.__esModule?e:{default:e}}var c=function(){function o(e){(0,n.default)(this,o),this.env=e.env,this.url=e.loginUrl}return(0,t.default)(o,[{key:"auth",value:function(){var r=this;u.default.getUid().then(function(e){if(!e){var o=document.querySelectorAll(".auth");if(o.length)return o.forEach(function(e){e.onclick=function(e){e.preventDefault(),console.log(r),r.goLogin()}}),!0}})}},{key:"goLogin",value:function(){if("miniprogram"===this.env)s.default.miniProgram.switchTab({url:this.url});else if("app"===this.env){var e=document.getElementById("yosdk-login");e||(e=(0,i.createLinkButton)(this.url,"yosdk-login")),e.click()}else window.location.href=this.url;return!1}}]),o}();o.default=c},"./src/public/share.js": 377 +/*! no static exports found */function(e,o,r){"use strict";Object.defineProperty(o,"__esModule",{value:!0});var n=l(r(/*! babel-runtime/helpers/classCallCheck */"./node_modules/babel-runtime/helpers/classCallCheck.js")),t=l(r(/*! babel-runtime/helpers/createClass */"./node_modules/babel-runtime/helpers/createClass.js")),s=l(r(/*! weixin-js-sdk */"./node_modules/weixin-js-sdk/index.js")),i=r(/*! ../utils/common */"./src/utils/common.js"),u=l(r(/*! ./base */"./src/public/base.js"));function l(e){return e&&e.__esModule?e:{default:e}}var c=function(){function o(e){(0,n.default)(this,o),this.env=e.env,this.url=e.loginUrl}return(0,t.default)(o,[{key:"auth",value:function(){var r=this;u.default.getUid().then(function(e){if(!e){var o=document.querySelectorAll(".auth");if(o.length)return o.forEach(function(e){e.onclick=function(e){e.preventDefault(),r.goLogin()}}),!0}})}},{key:"goLogin",value:function(){if("miniprogram"===this.env)s.default.miniProgram.switchTab({url:this.url});else if("app"===this.env){var e=document.getElementById("yosdk-login");e||(e=(0,i.createLinkButton)(this.url,"yosdk-login")),e.click()}else window.location.href=this.url;return!1}}]),o}();o.default=c},"./src/public/share.js":
378 /*!*****************************!*\ 378 /*!*****************************!*\
379 !*** ./src/public/share.js ***! 379 !*** ./src/public/share.js ***!
380 \*****************************/ 380 \*****************************/
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 <a class="auth" href="http://www.baidu.com">123123</a> 12 <a class="auth" href="http://www.baidu.com">123123</a>
13 <div id="uid"></div> 13 <div id="uid"></div>
14 <div id="url"></div> 14 <div id="url"></div>
15 -<script src="http://ad.yoho.cn/build/sdk.js"></script> 15 +<script src="../build/sdk.js"></script>
16 <script> 16 <script>
17 window.yo_sdk.auth(); 17 window.yo_sdk.auth();
18 document.getElementById('aaa').onclick = function (event) { 18 document.getElementById('aaa').onclick = function (event) {
@@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
20 console.log(uid); 20 console.log(uid);
21 document.getElementById('uid').innerText = uid; 21 document.getElementById('uid').innerText = uid;
22 }) 22 })
  23 + window.yo_sdk.goLogin();
23 } 24 }
24 document.getElementById('url').innerText = location.href; 25 document.getElementById('url').innerText = location.href;
25 </script> 26 </script>
1 { 1 {
2 "name": "yoho-activity-sdk", 2 "name": "yoho-activity-sdk",
3 - "version": "1.0.4", 3 + "version": "1.0.7",
4 "description": "YOHO!前端js的功能封装包,主要用于在活动页面中,对主要功能的封装。", 4 "description": "YOHO!前端js的功能封装包,主要用于在活动页面中,对主要功能的封装。",
5 "keywords": [ 5 "keywords": [
6 "YOHO!", 6 "YOHO!",
@@ -91,7 +91,7 @@ export default { @@ -91,7 +91,7 @@ export default {
91 getUid: function () { 91 getUid: function () {
92 return new Promise(function (resolve) { 92 return new Promise(function (resolve) {
93 if (env === 'h5' || env === 'pc') { 93 if (env === 'h5' || env === 'pc') {
94 - jsonp('https://m.yohobuy.com/passport/login/user').then(r => { 94 + jsonp('//m.yohobuy.com/passport/login/user').then(r => {
95 let uid = 0; 95 let uid = 0;
96 if (r.code === 200) { 96 if (r.code === 200) {
97 uid = Number(r.data) 97 uid = Number(r.data)
@@ -19,7 +19,7 @@ export default class { @@ -19,7 +19,7 @@ export default class {
19 } else if (type === 'brand') { 19 } else if (type === 'brand') {
20 linkUrl = '/pages/goodsList/brandStore?shop_id=' + id + '&shop_name=' + name 20 linkUrl = '/pages/goodsList/brandStore?shop_id=' + id + '&shop_name=' + name
21 } else { 21 } else {
22 - linkUrl = url.split('?')[0]; 22 + linkUrl = url
23 } 23 }
24 return linkToMiniApp(linkUrl, type); 24 return linkToMiniApp(linkUrl, type);
25 } else if (this.env === 'pc') { 25 } else if (this.env === 'pc') {
@@ -32,9 +32,9 @@ export default class { @@ -32,9 +32,9 @@ export default class {
32 } 32 }
33 } else { 33 } else {
34 if (type === 'product') { 34 if (type === 'product') {
35 - linkUrl = 'https://m.yohobuy.com/product/' + id + '.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":' + id + '}}' 35 + linkUrl = '//m.yohobuy.com/product/' + id + '.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":' + id + '}}'
36 } else if (type === 'brand') { 36 } else if (type === 'brand') {
37 - linkUrl = 'https://m.yohobuy.com/product/index/brand?shop_id=' + id + '&openby:yohobuy={"action":"go.shop","params":{"shop_id":"' + id + '","shop_template_type":"1","shop_name":"' + name + '","is_red_shop":"1"}}' 37 + linkUrl = '//m.yohobuy.com/product/index/brand?shop_id=' + id + '&openby:yohobuy={"action":"go.shop","params":{"shop_id":"' + id + '","shop_template_type":"1","shop_name":"' + name + '","is_red_shop":"1"}}'
38 } else { 38 } else {
39 linkUrl = url 39 linkUrl = url
40 } 40 }
@@ -16,7 +16,6 @@ export default class { @@ -16,7 +16,6 @@ export default class {
16 list.forEach((value) => { 16 list.forEach((value) => {
17 value.onclick = (event) => { 17 value.onclick = (event) => {
18 event.preventDefault(); 18 event.preventDefault();
19 - console.log(this);  
20 this.goLogin(); 19 this.goLogin();
21 } 20 }
22 }); 21 });