Commit b32c2621 by 张卓

第三方页面扫码登录,商城点击登录兼容

parent 1f3e66a1
...@@ -15,6 +15,10 @@ console.log(process.env,'-----------------config------') ...@@ -15,6 +15,10 @@ console.log(process.env,'-----------------config------')
//check unionid //check unionid
checkUnionid(options){ checkUnionid(options){
return requestGET(`${process.env.OLSHOP_URL}/wx/mini_check_union_id`,options) return requestGET(`${process.env.OLSHOP_URL}/wx/mini_check_union_id`,options)
},
// sso登录
getSsoBcakUrl(options) {
return requestPOST(`${process.env.OLSHOP_URL}/common/getSsoCallbackUrl`,options)
} }
} }
\ No newline at end of file
...@@ -13,13 +13,12 @@ ...@@ -13,13 +13,12 @@
</template> </template>
<script> <script>
let forUrlAddKey; let forUrlAddKey = require("mayi-front-tools/forUrlAddKey").default;
let getUrlKey; let getUrlKey = require("mayi-front-tools/getUrlKey").default;
if(process.browser) { let removeUrlKey = require("mayi-front-tools/removeUrlKey").default;
forUrlAddKey = require("mayi-front-tools/forUrlAddKey").default
getUrlKey = require("mayi-front-tools/getUrlKey").default
}
import { serialize, getQueryVariable, DFSImg } from "@/utils/index"; import { serialize, getQueryVariable, DFSImg } from "@/utils/index";
import login from "@/api/login";
import indexApi from "@/api/index";
export default { export default {
data(){ data(){
return{ return{
...@@ -29,9 +28,32 @@ export default { ...@@ -29,9 +28,32 @@ export default {
newWindowHref: '',//分享页面url newWindowHref: '',//分享页面url
} }
}, },
onLoad(options){ async onLoad(options){
console.log(decodeURIComponent(options.link),'地址',wx.getStorageSync("sessionid"),forUrlAddKey(decodeURIComponent(options.link),{token: wx.getStorageSync("sessionid"),jwt: 1})) // this.link = 'https://www.baidu.com/?token=550e48f594414525a1bd0dfda431e370&scene=sso'
if(getUrlKey(decodeURIComponent(options.link),'login') != '1') { // return
if(options.scene) {
//扫码
let data = await this.getParams(options.scene);
console.log(data,888999,wx.getStorageSync("sessionid"))
// debugger
if (data.sso) {
if (!wx.getStorageSync("sessionid")) {
wx.redirectTo({
url: `../login/main?scene=sso&back=${data.link}`,
});
}else{
this.getSsoBcakUrl(decodeURIComponent(data.link))
// let link = decodeURIComponent(data.link).replace(
// "${token}",
// wx.getStorageSync("sessionid")
// );
// this.link = decodeURIComponent(link);
}
}
}else if(options.link){
if(getUrlKey(decodeURIComponent(options.link),'scene') == 'sso') {
this.getSsoBcakUrl(decodeURIComponent(options.link))
}else if(getUrlKey(decodeURIComponent(options.link),'login') != '1') {
this.link = decodeURIComponent(options.link) this.link = decodeURIComponent(options.link)
}else { }else {
if(wx.getStorageSync("sessionid")) { if(wx.getStorageSync("sessionid")) {
...@@ -49,6 +71,7 @@ export default { ...@@ -49,6 +71,7 @@ export default {
}) })
} }
} }
}
}, },
async onShareAppMessage(res) { async onShareAppMessage(res) {
let url = '' let url = ''
...@@ -59,6 +82,7 @@ export default { ...@@ -59,6 +82,7 @@ export default {
}else{ }else{
url = res.webViewUrl; url = res.webViewUrl;
} }
url = removeUrlKey(url,['token'])
//分享页面去掉登录态 //分享页面去掉登录态
if (url.indexOf("sessionid") > -1) { if (url.indexOf("sessionid") > -1) {
url = url.split("?")[0] + "?mixid=" + this.shopId; url = url.split("?")[0] + "?mixid=" + this.shopId;
...@@ -91,6 +115,34 @@ export default { ...@@ -91,6 +115,34 @@ export default {
}; };
}, },
methods: { methods: {
getSsoBcakUrl(link) {
let op = {
callbackUrl: link,
email: "",
fromAppid: "VsEOuDJqBnGNyXZJWCQS",
// mobilephone: '15821335747',hgFTLLhgnBmeOyCkcbyv
toAppid: 'hgFTLLhgnBmeOyCkcbyv',
// toAppid: getUrlKey(link,'toAppid'),//道可
wxAvatarUrl: this.$store.state.userInfo.avatarUrl,
};
login.getSsoBcakUrl(op).then((res) => {
this.link = res.data.data;
console.log(res,this.link,555444)
});
},
getParams(options) {
return new Promise((resolve, reject) => {
indexApi
.getShareSceneRecord(options)
.then((res) => {
if (res.data.code == "200") {
let scene = JSON.parse(res.data.data.scene);
resolve(scene);
}
})
.catch((err) => {});
});
},
//加载成功 //加载成功
handleLoad() { handleLoad() {
console.log("网页加载成功"); console.log("网页加载成功");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment