Commit b32c2621 by 张卓

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

parent 1f3e66a1
......@@ -15,6 +15,10 @@ console.log(process.env,'-----------------config------')
//check unionid
checkUnionid(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 @@
</template>
<script>
let forUrlAddKey;
let getUrlKey;
if(process.browser) {
forUrlAddKey = require("mayi-front-tools/forUrlAddKey").default
getUrlKey = require("mayi-front-tools/getUrlKey").default
}
let forUrlAddKey = require("mayi-front-tools/forUrlAddKey").default;
let getUrlKey = require("mayi-front-tools/getUrlKey").default;
let removeUrlKey = require("mayi-front-tools/removeUrlKey").default;
import { serialize, getQueryVariable, DFSImg } from "@/utils/index";
import login from "@/api/login";
import indexApi from "@/api/index";
export default {
data(){
return{
......@@ -29,24 +28,48 @@ export default {
newWindowHref: '',//分享页面url
}
},
onLoad(options){
console.log(decodeURIComponent(options.link),'地址',wx.getStorageSync("sessionid"),forUrlAddKey(decodeURIComponent(options.link),{token: wx.getStorageSync("sessionid"),jwt: 1}))
if(getUrlKey(decodeURIComponent(options.link),'login') != '1') {
this.link = decodeURIComponent(options.link)
}else {
if(wx.getStorageSync("sessionid")) {
this.link = forUrlAddKey(
decodeURIComponent(options.link),
{
token: wx.getStorageSync("sessionid"),
jwt: 1
}
)
async onLoad(options){
// this.link = 'https://www.baidu.com/?token=550e48f594414525a1bd0dfda431e370&scene=sso'
// 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)
}else {
let url = `/pages/login/main?scene=sso&back=${options.link}`;
wx.navigateTo({
url
})
if(wx.getStorageSync("sessionid")) {
this.link = forUrlAddKey(
decodeURIComponent(options.link),
{
token: wx.getStorageSync("sessionid"),
jwt: 1
}
)
}else {
let url = `/pages/login/main?scene=sso&back=${options.link}`;
wx.navigateTo({
url
})
}
}
}
},
......@@ -59,6 +82,7 @@ export default {
}else{
url = res.webViewUrl;
}
url = removeUrlKey(url,['token'])
//分享页面去掉登录态
if (url.indexOf("sessionid") > -1) {
url = url.split("?")[0] + "?mixid=" + this.shopId;
......@@ -91,6 +115,34 @@ export default {
};
},
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() {
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