Authored by huangyi

活动sdk 修改登录h5的url

... ... @@ -366,15 +366,15 @@
/*!****************************!*\
!*** ./src/public/base.js ***!
\****************************/
/*! 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":
/*! 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":
/*!****************************!*\
!*** ./src/public/goto.js ***!
\****************************/
/*! 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":
/*! 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":
/*!*****************************!*\
!*** ./src/public/login.js ***!
\*****************************/
/*! 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":
/*! 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":
/*!*****************************!*\
!*** ./src/public/share.js ***!
\*****************************/
... ...
... ... @@ -12,7 +12,7 @@
<a class="auth" href="http://www.baidu.com">123123</a>
<div id="uid"></div>
<div id="url"></div>
<script src="http://ad.yoho.cn/build/sdk.js"></script>
<script src="../build/sdk.js"></script>
<script>
window.yo_sdk.auth();
document.getElementById('aaa').onclick = function (event) {
... ... @@ -20,6 +20,7 @@
console.log(uid);
document.getElementById('uid').innerText = uid;
})
window.yo_sdk.goLogin();
}
document.getElementById('url').innerText = location.href;
</script>
... ...
{
"name": "yoho-activity-sdk",
"version": "1.0.4",
"version": "1.0.7",
"description": "YOHO!前端js的功能封装包,主要用于在活动页面中,对主要功能的封装。",
"keywords": [
"YOHO!",
... ...
... ... @@ -91,7 +91,7 @@ export default {
getUid: function () {
return new Promise(function (resolve) {
if (env === 'h5' || env === 'pc') {
jsonp('https://m.yohobuy.com/passport/login/user').then(r => {
jsonp('//m.yohobuy.com/passport/login/user').then(r => {
let uid = 0;
if (r.code === 200) {
uid = Number(r.data)
... ...
... ... @@ -19,7 +19,7 @@ export default class {
} else if (type === 'brand') {
linkUrl = '/pages/goodsList/brandStore?shop_id=' + id + '&shop_name=' + name
} else {
linkUrl = url.split('?')[0];
linkUrl = url
}
return linkToMiniApp(linkUrl, type);
} else if (this.env === 'pc') {
... ... @@ -32,9 +32,9 @@ export default class {
}
} else {
if (type === 'product') {
linkUrl = 'https://m.yohobuy.com/product/' + id + '.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":' + id + '}}'
linkUrl = '//m.yohobuy.com/product/' + id + '.html?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":' + id + '}}'
} else if (type === 'brand') {
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"}}'
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"}}'
} else {
linkUrl = url
}
... ...
... ... @@ -16,7 +16,6 @@ export default class {
list.forEach((value) => {
value.onclick = (event) => {
event.preventDefault();
console.log(this);
this.goLogin();
}
});
... ...