Commit 04a9a692 by 程默

fix

parent a0102052
...@@ -20,86 +20,89 @@ import { serialize, getQueryVariable, DFSImg } from "@/utils/index"; ...@@ -20,86 +20,89 @@ import { serialize, getQueryVariable, DFSImg } from "@/utils/index";
import login from "@/api/login"; import login from "@/api/login";
import indexApi from "@/api/index"; import indexApi from "@/api/index";
export default { export default {
data(){ data() {
return{ return {
link : '', link: "",
shareShopName: '',//分享名称 shareShopName: "", //分享名称
shareLogoUrl: '',//分享图片url shareLogoUrl: "", //分享图片url
newWindowHref: '',//分享页面url newWindowHref: "", //分享页面url
} };
}, },
async onLoad(options){ async onLoad(options) {
console.log(options,66667777777) console.log(options, '第三方页面');
if(options.scene) { /**
* scene=sso 第三方需要登录的页面
* login=1 jwt需要登录(临时方案)
*/
if (options.scene) {
//扫码 //扫码
let data = await this.getParams(options.scene); let data = await this.getParams(options.scene);
console.log(data,888999,wx.getStorageSync("sessionid"))
// debugger
if (data.sso) { if (data.sso) {
if (!wx.getStorageSync("sessionid")) { if (!wx.getStorageSync("sessionid")) {
wx.redirectTo({ wx.redirectTo({
url: `../login/main?scene=sso&back=${data.link}`, url: `../login/main?scene=sso&back=${data.link}`,
}); });
}else{ } else {
this.getSsoBcakUrl(decodeURIComponent(data.link)) this.getSsoBcakUrl(decodeURIComponent(data.link));
// let link = decodeURIComponent(data.link).replace(
// "${token}",
// wx.getStorageSync("sessionid")
// );
// this.link = decodeURIComponent(link);
} }
} }
}else if(options.link){ } else if (options.link) {
if(getUrlKey(decodeURIComponent(options.link),'scene') == 'sso') { if (getUrlKey(decodeURIComponent(options.link), "scene") == "sso") {
this.getSsoBcakUrl(decodeURIComponent(options.link)) if (!wx.getStorageSync("sessionid")) {
}else if(getUrlKey(decodeURIComponent(options.link),'login') != '1') { wx.redirectTo({
this.link = decodeURIComponent(options.link) url: `../login/main?scene=sso&back=${options.link}`,
}else { });
if(wx.getStorageSync("sessionid")) { } else {
this.link = forUrlAddKey( this.getSsoBcakUrl(decodeURIComponent(options.link));
decodeURIComponent(options.link), }
{ } else 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"), token: wx.getStorageSync("sessionid"),
jwt: 1 jwt: 1,
} });
) } else {
}else {
let url = `/pages/login/main?scene=sso&back=${options.link}`; let url = `/pages/login/main?scene=sso&back=${options.link}`;
wx.navigateTo({ wx.navigateTo({
url url,
}) });
} }
} }
} }
}, },
async onShareAppMessage(res) { async onShareAppMessage(res) {
let url = '' let url = "";
console.log(this.newWindowHref + 'this.newWindowHref') console.log(this.newWindowHref + "this.newWindowHref");
//分享路径 //分享路径
if(this.newWindowHref){ if (this.newWindowHref) {
url = this.newWindowHref; url = this.newWindowHref;
}else{ } else {
url = res.webViewUrl; url = res.webViewUrl;
} }
url = removeUrlKey(url,['token']) 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;
} }
this.shareUrl = url ; this.shareUrl = url;
console.log(this.shareUrl, "index12"); console.log(this.shareUrl, "index12");
console.log(`/pages/index/main?link=${encodeURIComponent(this.shareUrl)}`, '测试直播分享相关') console.log(
`/pages/index/main?link=${encodeURIComponent(this.shareUrl)}`,
"测试直播分享相关"
);
return { return {
title: this.shareShopName, // 默认是小程序的名称 title: this.shareShopName, // 默认是小程序的名称
path: `/pages/wxArticle/main?link=${encodeURIComponent(this.shareUrl)}`, // 默认是当前页面 path: `/pages/wxArticle/main?link=${encodeURIComponent(this.shareUrl)}`, // 默认是当前页面
imageUrl: this.shareLogoUrl, imageUrl: this.shareLogoUrl,
success: function(res) { success: function (res) {
// 转发成功之后的回调 // 转发成功之后的回调
if (res.errMsg == "shareAppMessage:ok") { if (res.errMsg == "shareAppMessage:ok") {
console.log(res, "分享成功"); console.log(res, "分享成功");
} }
}, },
fail: function() { fail: function () {
// 转发失败之后的回调 // 转发失败之后的回调
if (res.errMsg == "shareAppMessage:fail cancel") { if (res.errMsg == "shareAppMessage:fail cancel") {
// 用户取消转发 // 用户取消转发
...@@ -108,9 +111,9 @@ export default { ...@@ -108,9 +111,9 @@ export default {
// 转发失败,其中 detail message 为详细失败信息 // 转发失败,其中 detail message 为详细失败信息
} }
}, },
complete: function() { complete: function () {
// 转发结束之后的回调(转发成不成功都会执行) // 转发结束之后的回调(转发成不成功都会执行)
} },
}; };
}, },
methods: { methods: {
...@@ -121,14 +124,14 @@ export default { ...@@ -121,14 +124,14 @@ export default {
fromAppid: "VsEOuDJqBnGNyXZJWCQS", fromAppid: "VsEOuDJqBnGNyXZJWCQS",
// mobilephone: '15821335747',hgFTLLhgnBmeOyCkcbyv // mobilephone: '15821335747',hgFTLLhgnBmeOyCkcbyv
// toAppid: 'hgFTLLhgnBmeOyCkcbyv', // toAppid: 'hgFTLLhgnBmeOyCkcbyv',
toAppid: getUrlKey(link,'toAppid'),//道可 toAppid: getUrlKey(link, "toAppid"), //道可
wxAvatarUrl: this.$store.state.userInfo.avatarUrl, wxAvatarUrl: this.$store.state.userInfo.avatarUrl,
}; };
login.getSsoBcakUrl(op).then((res) => { login.getSsoBcakUrl(op).then((res) => {
console.log(res,this.link,555444) console.log(res, this.link, 555444);
if(res.data.code == '200') { if (res.data.code == "200") {
this.link = res.data.data; this.link = res.data.data;
}else { } else {
wx.showToast({ title: res.data.msg, icon: "none" }); wx.showToast({ title: res.data.msg, icon: "none" });
} }
}); });
...@@ -155,19 +158,23 @@ export default { ...@@ -155,19 +158,23 @@ export default {
let len = res.target.data.length - 1; let len = res.target.data.length - 1;
console.log(res, "h5消息", res.target.data[len]); console.log(res, "h5消息", res.target.data[len]);
this.shareShopName = res.target.data[len].shareShopName || ""; this.shareShopName = res.target.data[len].shareShopName || "";
if(res.target.data[len].shareLogoUrl) { if (res.target.data[len].shareLogoUrl) {
this.shareLogoUrl = DFSImg(res.target.data[len].shareLogoUrl, 500, 400); this.shareLogoUrl = DFSImg(res.target.data[len].shareLogoUrl, 500, 400);
} }
this.newWindowHref = res.target.data[len].shareImgUrl;// + '&fromVisitorOpenId=' + wx.getStorageSync("openid") this.newWindowHref = res.target.data[len].shareImgUrl; // + '&fromVisitorOpenId=' + wx.getStorageSync("openid")
console.log("分享信息:", this.shareLogoUrl, this.shareShopName,1111111,res); console.log(
"分享信息:",
this.shareLogoUrl,
this.shareShopName,
1111111,
res
);
}, },
handleError(data) { handleError(data) {
wx.showLoading({ wx.showLoading({
title: "网页加载失败 请右上角刷新", title: "网页加载失败 请右上角刷新",
}); });
}, },
} },
}; };
</script> </script>
<style lang="scss" scoped></style>
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