Commit 55553ae5 by 程默

fix 登录返回

parent 67f4b43d
......@@ -11,7 +11,7 @@
import spokesman from "@/api/spokesman.js";
import shop from "@/api/shop.js";
import indexApi from "@/api/index.js";
import { serialize, getQueryVariable, DFSImg } from "@/utils/index";
import { serialize, getQueryVariable, DFSImg,delUrlParam } from "@/utils/index";
import login from "@/api/login";
export default {
data() {
......@@ -23,7 +23,7 @@ export default {
baseUrl: process.env.BASE_URL,
link: this.baseUrl,
page: "/",
location_obj:wx.getStorageSync("location"),
location_obj:encodeURIComponent(wx.getStorageSync("location")),
params: "?mixid=" + this.shopId+`&location_obj=${this.location_obj}`,
userInfo: {
......@@ -100,7 +100,12 @@ export default {
})
},
})
// 移除重复参数
if (options.params) {
let params=decodeURIComponent(options.params)
let location_obj=getQueryVariable(params, "location_obj")
location_obj && (options.params=params.split('&location_obj='+location_obj).join(''))
}
//检测登录态
this.checkLogin();
this.options = options;
......@@ -158,6 +163,9 @@ export default {
//来自小程序登录页面
this.page = decodeURIComponent(options.backpath);
this.params += "&" + decodeURIComponent(options.params);
console.log(this.pageUrl,'1644444444444',this.params,'-----',options)
} else if (options.from && options.from == "logout") {
//来自用户登出
wx.removeStorage({
......
......@@ -97,7 +97,6 @@ export default {
})
},
onLoad(options) {
console.log(options,'login')
Object.assign(this.$data, this.$options.data()); //mpvue 的混合周期 使用小程序生命周期数据未初始化
if (options.back) {
this.backPath = options.back;
......@@ -319,14 +318,13 @@ export default {
}else{
let parseLink=decodeURIComponent(this.backPath);
let isTabbarIndex =checkTabbarPage(parseLink)
console.log('32111',isTabbarIndex,parseLink)
wx.navigateBack()
return
console.log('32111',isTabbarIndex,parseLink,this.backParams)
// wx.navigateBack()
// return
if(isTabbarIndex>-1){
wx.navigateBack()
// wx.switchTab({
// url: parseLink == '/' ? '/pages/home/main' : `/pages/tabBar${isTabbarIndex}/main`,
// })
wx.switchTab({
url: parseLink == '/' ? '/pages/home/main' : `/pages/tabBar${isTabbarIndex}/main`,
})
}else{
wx.redirectTo({
url: `../index/main?from=login&backpath=${
......
......@@ -44,6 +44,29 @@ export function getQueryVariable(query,variable) {
}
return (false);
}
// 删除
export function delUrlParam(url, key) {
let baseUrl = url.split('?')[0] + '?';
let query = url.split('?')[1];
if (query.indexOf(key) > -1) {
let obj = {};
let arr = query.split('&');
for (let i = 0; i < arr.length; i++) {
arr[i] = arr[i].split('=');
obj[arr[i][0]] = arr[i][1];
}
delete obj[key];
let url =
baseUrl +
JSON.stringify(obj)
.replace(/[\"\{\}]/g, '')
.replace(/\:/g, '=')
.replace(/\,/g, '&');
return url;
} else {
return url;
}
}
//补全图片路径
export function DFSImg(path, w, h,type=0) { //
......
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