[仅供测试]重写navigateTo方法,解决微信小程序中超过10个页面栈时会出现的bug

master
学习很差啦 2022-07-20 18:24:49 +08:00
parent cbd73ae638
commit 09485747a6
58 changed files with 472 additions and 421 deletions

445
App.vue
View File

@ -1,234 +1,257 @@
<script>
/**
* vuex管理登录状态具体可以参考官方登录模板示例
*/
import { mapMutations } from "vuex";
import APPUpdate from "@/plugins/APPUpdate";
import { getClipboardData } from "@/js_sdk/h5-copy/h5-copy.js";
import config from "@/config/config";
import storage from "@/utils/storage";
//
/**
* vuex管理登录状态具体可以参考官方登录模板示例
*/
import {
mapMutations
} from "vuex";
import APPUpdate from "@/plugins/APPUpdate";
import {
getClipboardData
} from "@/js_sdk/h5-copy/h5-copy.js";
import config from "@/config/config";
import storage from "@/utils/storage";
export default {
data() {
return {
config,
};
},
/**
* 监听返回
*/
onBackPress(e) {
if (e.from == "backbutton") {
let routes = getCurrentPages();
let curRoute = routes[routes.length - 1].options;
routes.forEach((item) => {
if (
item.route == "pages/tabbar/cart/cartList" ||
item.route.indexOf("pages/product/goods") != -1
) {
uni.redirectTo({
url: item.route,
});
}
});
if (curRoute.addId) {
uni.reLaunch({
url: "/pages/tabbar/cart/cartList",
});
} else {
uni.navigateBack();
}
return true; //
}
},
methods: {
...mapMutations(["login"]),
},
onLaunch: function () {
// #ifdef APP-PLUS
this.checkArguments(); //
APPUpdate();
/**
* 路由监听并删除路由
* https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.navigateTo.html
* */
// #ifdef MP-WEIXIN
wx.onAppRoute((res) => {
const pages = getCurrentPages();
console.log("pages:" + pages.length,pages);
if (pages.length > 3) {
delete getCurrentPages()[2]
}
console.log('路由监听', {
res
})
})
// #endif
//
plus.globalEvent.addEventListener("newintent", (e) => {
this.checkArguments(); //
});
// #endif
export default {
data() {
return {
config,
};
},
// #ifdef MP-WEIXIN
this.applyUpdateWeChat();
// #endif
},
onShow() {
// #ifndef H5
this.getClipboard();
// #endif
// #ifdef APP-PLUS
/**
* 监听返回
*/
onBackPress(e) {
if (e.from == "backbutton") {
let routes = getCurrentPages();
let curRoute = routes[routes.length - 1].options;
routes.forEach((item) => {
if (
item.route == "pages/tabbar/cart/cartList" ||
item.route.indexOf("pages/product/goods") != -1
) {
uni.redirectTo({
url: item.route,
});
}
});
if (storage.getShow()) {
if(uni.getSystemInfoSync().platform == 'ios'){
this.$u.route("/pages/tabbar/screen/fullScreen");
if (curRoute.addId) {
uni.reLaunch({
url: "/pages/tabbar/cart/cartList",
});
} else {
uni.navigateBack();
}
return true; //
}
},
methods: {
...mapMutations(["login"]),
},
onLaunch: function() {
// #ifdef APP-PLUS
this.checkArguments(); //
APPUpdate();
}
}
// #endif
},
methods: {
/**
* 微信小程序版本提交更新版本 解决缓存问题
*/
applyUpdateWeChat() {
const updateManager = uni.getUpdateManager();
//
plus.globalEvent.addEventListener("newintent", (e) => {
this.checkArguments(); //
});
// #endif
updateManager.onCheckForUpdate(function (res) {
//
});
// #ifdef MP-WEIXIN
this.applyUpdateWeChat();
// #endif
},
updateManager.onUpdateReady(function (res) {
uni.showModal({
title: "更新提示",
content: "发现新版本,是否重启应用?",
success(res) {
if (res.confirm) {
// applyUpdate
updateManager.applyUpdate();
}
},
});
});
updateManager.onUpdateFailed(function (res) {
//
});
},
onShow() {
// #ifndef H5
this.getClipboard();
// #endif
// #ifdef APP-PLUS
// TODO 广
launch() {
try {
// launchFlag 广
const value = uni.getStorageSync("launchFlag");
if (!value) {
// this.$u.route("/pages/index/agreement");
} else {
//app广
var w = plus.webview.open(
"/hybrid/html/advertise/advertise.html",
"本地地址",
{
top: 0,
bottom: 0,
zindex: 999,
},
"fade-in",
500
);
//4s广
setTimeout(function () {
plus.webview.close(w);
APPUpdate();
}, 3000);
}
} catch (e) {
// error
uni.setStorage({
key: "launchFlag",
data: true,
success: function () {
console.log("error时存储launchFlag");
},
});
}
},
if (storage.getShow()) {
if (uni.getSystemInfoSync().platform == 'ios') {
this.$u.route("/pages/tabbar/screen/fullScreen");
/**
* 获取粘贴板数据
*/
async getClipboard() {
let res = await getClipboardData();
}
}
// #endif
},
methods: {
/**
* 微信小程序版本提交更新版本 解决缓存问题
*/
applyUpdateWeChat() {
const updateManager = uni.getUpdateManager();
/**
* 解析粘贴板数据
*/
updateManager.onCheckForUpdate(function(res) {
//
});
if (res.indexOf(config.shareLink) != -1 && (res!= this.$store.state.shareLink)) {
this.$store.state.shareLink = res
uni.showModal({
title: "提示",
content: "检测到一个分享链接是否跳转?",
confirmText: "跳转",
success: function (callback) {
if (callback.confirm) {
const path = res.split(config.shareLink)[1];
if (path.indexOf("tabbar") != -1) {
uni.switchTab({
url: path,
});
} else {
uni.navigateTo({
url: path,
});
}
}
},
});
}
},
updateManager.onUpdateReady(function(res) {
uni.showModal({
title: "更新提示",
content: "发现新版本,是否重启应用?",
success(res) {
if (res.confirm) {
// applyUpdate
updateManager.applyUpdate();
}
},
});
});
updateManager.onUpdateFailed(function(res) {
//
});
},
/**
* h5中打开app获取跳转app的链接并跳转
*/
checkArguments() {
// #ifdef APP-PLUS
setTimeout(() => {
const args = plus.runtime.arguments;
if (args) {
const argsStr = decodeURIComponent(args);
const path = argsStr.split("//")[1];
if (path.indexOf("tabbar") != -1) {
uni.switchTab({
url: `/${path}`,
});
} else {
uni.navigateTo({
url: `/${path}`,
});
}
}
});
// #endif
},
},
};
// TODO 广
launch() {
try {
// launchFlag 广
const value = uni.getStorageSync("launchFlag");
if (!value) {
// this.$u.route("/pages/index/agreement");
} else {
//app广
var w = plus.webview.open(
"/hybrid/html/advertise/advertise.html",
"本地地址", {
top: 0,
bottom: 0,
zindex: 999,
},
"fade-in",
500
);
//4s广
setTimeout(function() {
plus.webview.close(w);
APPUpdate();
}, 3000);
}
} catch (e) {
// error
uni.setStorage({
key: "launchFlag",
data: true,
success: function() {
console.log("error时存储launchFlag");
},
});
}
},
/**
* 获取粘贴板数据
*/
async getClipboard() {
let res = await getClipboardData();
/**
* 解析粘贴板数据
*/
if (res.indexOf(config.shareLink) != -1 && (res != this.$store.state.shareLink)) {
this.$store.state.shareLink = res
uni.showModal({
title: "提示",
content: "检测到一个分享链接是否跳转?",
confirmText: "跳转",
success: function(callback) {
if (callback.confirm) {
const path = res.split(config.shareLink)[1];
if (path.indexOf("tabbar") != -1) {
uni.switchTab({
url: path,
});
} else {
this.$navigateTo({
url: path,
});
}
}
},
});
}
},
/**
* h5中打开app获取跳转app的链接并跳转
*/
checkArguments() {
// #ifdef APP-PLUS
setTimeout(() => {
const args = plus.runtime.arguments;
if (args) {
const argsStr = decodeURIComponent(args);
const path = argsStr.split("//")[1];
if (path.indexOf("tabbar") != -1) {
uni.switchTab({
url: `/${path}`,
});
} else {
this.$navigateTo({
url: `/${path}`,
});
}
}
});
// #endif
},
},
};
</script>
<style lang="scss">
@import "uview-ui/index.scss";
@import "uview-ui/index.scss";
// ------- x
// ------- x
// #ifdef MP-WEIXIN
.mp-iphonex-bottom {
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
box-sizing: content-box;
height: auto !important;
padding-top: 10rpx;
}
// #endif
// #ifdef MP-WEIXIN
.mp-iphonex-bottom {
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
box-sizing: content-box;
height: auto !important;
padding-top: 10rpx;
}
body {
background-color: $bg-color;
}
/************************ */
.w200 {
width: 200rpx !important;
}
.flex1 {
flex: 1; //flex
}
// #endif
body {
background-color: $bg-color;
}
/************************ */
.w200 {
width: 200rpx !important;
}
.flex1 {
flex: 1; //flex
}
</style>

View File

@ -263,7 +263,7 @@
buy(data) {
API_trade.addToCart(data).then((res) => {
if (res.data.success) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/order/fillorder?way=${
data.cartType
}&addr=${""}&parentOrder=${encodeURIComponent(
@ -314,7 +314,7 @@
API_trade.addToCart(data).then((res) => {
if (res.data.code == 200) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/order/fillorder?way=${data.cartType}&addr=${
this.addr.id || ""
}&parentOrder=${encodeURIComponent(JSON.stringify(this.parentOrder))}`,

View File

@ -198,13 +198,13 @@
},
//
navigateToDetailPage(item) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/goods?id=${item.content.id}&goodsId=${item.content.goodsId}`,
});
},
//
navigateToStoreDetailPage(item) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/shopPage?id=${item.content.storeId}`,
});
},

View File

@ -62,7 +62,7 @@ export default {
this.goodsList.push(...goodsList.data.result.content);
},
handleClick(item) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/goods?id=${item.content.id}&goodsId=${item.content.goodsId}`,
});
},

View File

@ -3,7 +3,7 @@ import App from "./App";
import * as filters from "./utils/filters.js"; // global filter
import uView from "uview-ui";
import store from "./store";
import {navigateTo} from '@/utils/navigateRoute.js'
/**
* 仅在h5中显示唤醒app功能
@ -27,6 +27,10 @@ Object.keys(filters).forEach((key) => {
// 引入Vuex
Vue.prototype.$store = store;
// // 引入Vuex
Vue.prototype.$navigateTo = navigateTo;
Vue.use(uView);
Vue.config.productionTip = false;

View File

@ -145,7 +145,7 @@
},
},
onNavigationBarButtonTap(e) {
uni.navigateTo({
this.$navigateTo({
url: "/pages/cart/coupon/couponIntro",
});
},

View File

@ -189,7 +189,7 @@ export default {
*/
useItNow(item) {
if (item.storeId && item.storeId!='0') {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/shopPage?id=${item.storeId}`,
});
} else {
@ -203,7 +203,7 @@ export default {
* 优惠券详情
*/
couponDetail(item) {
uni.navigateTo({
this.$navigateTo({
url:
"/pages/cart/coupon/couponDetail?item=" +
encodeURIComponent(JSON.stringify(item)),

View File

@ -120,7 +120,7 @@
* 支付成功后跳转
*/
callback(paymentMethod){
uni.navigateTo({
this.$navigateTo({
url: "/pages/cart/payment/success?paymentMethod=" +
paymentMethod +
"&payPrice=" +

View File

@ -162,7 +162,7 @@ export default {
delete this.form.updateTime;
editAddress(this.form).then((res) => {
if (res.data.success) {
uni.navigateTo({
this.$navigateTo({
url: `/${beforePage.route}`,
});
}

View File

@ -129,7 +129,7 @@ export default {
//
addAddress(id) {
if (id) {
uni.navigateTo({
this.$navigateTo({
url:
"/pages/mine/address/add?id=" +
id +
@ -138,7 +138,7 @@ export default {
"&type=order",
});
} else {
uni.navigateTo({
this.$navigateTo({
url:
"/pages/mine/address/add?way=" + this.routerVal.way + "&type=order",
});

View File

@ -145,7 +145,7 @@ export default {
},
//
addAddress(id) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/mine/address/add${id ? "?id=" + id : ""}`,
});
},

View File

@ -50,7 +50,7 @@ export default {
* 跳转
*/
navgition(url) {
uni.navigateTo({
this.$navigateTo({
url,
});
},

View File

@ -38,7 +38,7 @@ export default {
let res = await recharge({ price: this.price });
if (res.data.success) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/cart/payment/payOrder?orderType=RECHARGE&recharge_sn=${res.data.result.rechargeSn}`,
});
}

View File

@ -58,12 +58,12 @@ export default {
},
methods: {
handleClick(url) {
uni.navigateTo({
this.$navigateTo({
url,
});
},
queryGoods(src) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/mine/distribution/${src}`,
});
},

View File

@ -221,7 +221,7 @@ export default {
* 查看图片
*/
handleNavgationGoods(val) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/goods?id=${val.skuId}&goodsId=${val.goodsId}`,
});
},

View File

@ -56,7 +56,7 @@
methods: {
...mapMutations(["logout"]),
navigateTo(url) {
uni.navigateTo({
this.$navigateTo({
url
});
},

View File

@ -45,7 +45,7 @@ export default {
},
methods: {
goDetail(sn,logi_id,ship_no){
uni.navigateTo({
this.$navigateTo({
url:'/pages/msgTips/packagemsg/logisticsDetail?order_sn=' + sn +'&logi_id='+logi_id+'&ship_no='+ship_no,
})
},

View File

@ -174,7 +174,7 @@
*/
goGoodsDetail(val) {
//
uni.navigateTo({
this.$navigateTo({
url: "/pages/product/goods?id=" + val.skuId + "&goodsId=" + val.goodsId,
});
},
@ -184,7 +184,7 @@
*/
goStoreMainPage(id) {
//
uni.navigateTo({
this.$navigateTo({
url: "/pages/product/shopPage?id=" + id,
});
},

View File

@ -84,7 +84,7 @@
* 导航到店铺
*/
navgaiteToStore(val) {
uni.navigateTo({
this.$navigateTo({
url: "/pages/product/shopPage?id=" + val.storeId,
});
},
@ -100,7 +100,7 @@
* 跳转详情
*/
navgaiteToDetail(item) {
uni.navigateTo({
this.$navigateTo({
url: "/pages/product/goods?id=" + item.id + "&goodsId=" + item.goodsId,
});
},

View File

@ -88,7 +88,7 @@ export default {
},
navigateTo(url) {
uni.navigateTo({
this.$navigateTo({
url,
});
},

View File

@ -16,7 +16,7 @@ export default {
methods: {
navigateTo(url) {
uni.navigateTo({
this.$navigateTo({
url: url,
});
},

View File

@ -49,7 +49,7 @@ export default {
if (url == "/pages/set/securityCenter/securityCenter") {
url += `?mobile=${this.userInfo.mobile}`;
}
uni.navigateTo({
this.$navigateTo({
url: url,
});
},

View File

@ -488,13 +488,13 @@ export default {
},
//
navigateToDetailPage(item) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/goods?id=${item.content.id}&goodsId=${item.content.goodsId}`,
});
},
//
navigateToStoreDetailPage(item) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/shopPage?id=${item.content.storeId}`,
});
},

View File

@ -351,7 +351,7 @@ export default {
* 售后详情
*/
afterDetails(order) {
uni.navigateTo({
this.$navigateTo({
url: "./applyDetail?sn=" + order.sn,
});
},
@ -394,7 +394,7 @@ export default {
...sku,
};
storage.setAfterSaleData(data);
uni.navigateTo({
this.$navigateTo({
url: `/pages/order/afterSales/afterSalesSelect?sn=${sn}`,
});
},
@ -410,7 +410,7 @@ export default {
};
storage.setAfterSaleData(data);
uni.navigateTo({
this.$navigateTo({
url: `./afterSalesDetailExpress?serviceSn=${order.sn}`,
});
},
@ -421,13 +421,13 @@ export default {
onDetail(goods, sku) {
//
if (this.current == 0) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/goods?id=${sku.skuId}&goodsId=${
sku.goodsId || sku.goodsId
}`,
});
} else {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/goods?id=${goods.skuId}&goodsId=${
goods.goodsId || goods.goodsId
}`,

View File

@ -94,7 +94,7 @@ export default {
* 跳转到商品信息
*/
navigateToGoodsDetail(id) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/goods?id=${id}&goodsId=${goodsId}`,
});
},

View File

@ -381,7 +381,7 @@ export default {
* 访问商品详情
*/
navgiateToGoodsDetail(item) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`,
});
},
@ -390,7 +390,7 @@ export default {
* 进度
*/
onProgress() {
uni.navigateTo({
this.$navigateTo({
url: `./applyProgress?sn=${
this.serviceDetail.sn
}&createTime=${encodeURIComponent(this.serviceDetail.createTime)}

View File

@ -86,7 +86,7 @@ export default {
methods: {
//
handleToGoods(val) {
uni.navigateTo({
this.$navigateTo({
url: "/pages/product/goods?id=" + val.skuId + "&goodsId=" + val.goodsId,
});
},
@ -120,7 +120,7 @@ export default {
* 查看详情
*/
handleInfo(val) {
uni.navigateTo({
this.$navigateTo({
url: "./complainInfo?id=" + val.id,
});
},

View File

@ -219,7 +219,7 @@ export default {
*/
talkCommont(sku) {
console.log(sku);
uni.navigateTo({
this.$navigateTo({
url: `./releaseEvaluate?sn=${sku.sn}&sku=${encodeURIComponent(
JSON.stringify(sku)
)}`,
@ -270,7 +270,7 @@ export default {
* 评价详情
*/
onDetail(comment) {
uni.navigateTo({
this.$navigateTo({
url:
"./evaluateDetail?comment=" +
encodeURIComponent(JSON.stringify(comment)),

View File

@ -481,7 +481,7 @@ export default {
//
navigateToStore(val) {
uni.navigateTo({
this.$navigateTo({
url: "/pages/product/shopPage?id=" + val.storeId,
});
},
@ -555,7 +555,7 @@ export default {
* 跳转
*/
navigateTo(url) {
uni.navigateTo({
this.$navigateTo({
url,
});
},

View File

@ -364,14 +364,14 @@ export default {
methods: {
//
applyService(order) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/order/afterSales/afterSales?orderSn=${order.sn}`,
});
},
//
navigateToStore(val) {
uni.navigateTo({
this.$navigateTo({
url: "/pages/product/shopPage?id=" + val.storeId,
});
},
@ -423,7 +423,7 @@ export default {
}).pay();
// #endif
// #ifndef MP-WEIXIN
uni.navigateTo({
this.$navigateTo({
url: "/pages/cart/payment/payOrder?order_sn=" + val.sn,
});
// #endif
@ -522,7 +522,7 @@ export default {
* 跳转到订单详情
*/
navigateToOrderDetail(sn) {
uni.navigateTo({
this.$navigateTo({
url: "./orderDetail?sn=" + sn,
});
},
@ -588,7 +588,7 @@ export default {
* 评价商品
*/
onComment(sn) {
uni.navigateTo({
this.$navigateTo({
url: "./evaluate/myEvaluate",
});
},
@ -599,7 +599,7 @@ export default {
reBuy(order) {
console.log(order);
return;
uni.navigateTo({
this.$navigateTo({
url:
"/pages/product/goods?id=" + order.id + "&goodsId=" + order.goodsId,
});
@ -609,7 +609,7 @@ export default {
* 查看物流
*/
navigateToLogistics(order) {
uni.navigateTo({
this.$navigateTo({
url:
"/pages/mine/msgTips/packageMsg/logisticsDetail?order_sn=" + order.sn,
});

View File

@ -277,7 +277,7 @@ export default {
},
methods: {
tostore(val) {
uni.navigateTo({
this.$navigateTo({
url: "/pages/product/shopPage?id=" + val.storeId,
});
},
@ -294,7 +294,7 @@ export default {
},
// #TODO
ByUserMessage(order) {
uni.navigateTo({
this.$navigateTo({
url:
"/pages/cart/payment/shareOrderGoods?sn=" +
order.sn +
@ -318,12 +318,12 @@ export default {
});
},
onReceipt(val) {
uni.navigateTo({
this.$navigateTo({
url: "/pages/order/invoice/invoiceDetail?id=" + val.id,
});
},
gotoGoodsDetail(sku) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/goods?id=${sku.skuId}&goodsId=${sku.goodsId}`,
});
},
@ -363,7 +363,7 @@ export default {
* 投诉
*/
complaint(sku) {
uni.navigateTo({
this.$navigateTo({
url:
"/pages/order/complain/complain?sn=" +
this.sn +
@ -373,7 +373,7 @@ export default {
},
//
onAfterSales(sn, sku) {
uni.navigateTo({
this.$navigateTo({
url: `./afterSales/afterSalesSelect?sn=${sn}&sku=${encodeURIComponent(
JSON.stringify(sku)
)}`,
@ -382,7 +382,7 @@ export default {
//
toPay(val) {
val.sn
? uni.navigateTo({
? this.$navigateTo({
url: "/pages/cart/payment/payOrder?order_sn=" + val.sn,
})
: false;
@ -459,12 +459,12 @@ export default {
},
//
onComment(sn) {
uni.navigateTo({
this.$navigateTo({
url: "./evaluate/myEvaluate",
});
}, //
onLogistics(order) {
uni.navigateTo({
this.$navigateTo({
url:
"/pages/mine/msgTips/packageMsg/logisticsDetail?logi_id=" +
order.logi_id +
@ -480,7 +480,7 @@ export default {
this.reason = reason;
},
reBuy(order) {
uni.navigateTo({
this.$navigateTo({
url:
"/pages/product/goods?id=" + order.id + "&goodsId=" + order.goodsId,
});

View File

@ -545,7 +545,7 @@ export default {
if (user.data.result.mobile) {
whetherNavigate();
} else {
uni.navigateTo({
this.$navigateTo({
url: "/pages/passport/bindUserPhone",
});
}
@ -639,13 +639,13 @@ export default {
},
//
navigateToPrivacy(val) {
uni.navigateTo({
this.$navigateTo({
url: "/pages/mine/help/tips?type=" + val,
});
console.log(val)
},
navigateToPrivacys(val){
uni.navigateTo({
this.$navigateTo({
url:"/pages/mine/help/tips?type="+ val,
})
},

View File

@ -718,13 +718,13 @@ export default {
linkMsgDetail() {
// lili
uni.navigateTo({
this.$navigateTo({
url: `/pages/tabbar/home/web-view?IM=${this.storeDetail.storeId}`,
});
// udesk
// if (this.storeDetail.merchantEuid) {
// uni.navigateTo({
// this.$navigateTo({
// url: `/pages/tabbar/home/web-view?src=${this.IM}`,
// });
// }
@ -744,7 +744,7 @@ export default {
// sign: this.storeDetail.yzfSign,
// mpSign: this.storeDetail.yzfMpSign,
// };
// uni.navigateTo({
// this.$navigateTo({
// url:
// "/pages/product/customerservice/index?params=" +
// encodeURIComponent(JSON.stringify(params)),
@ -752,7 +752,7 @@ export default {
// // #endif
// // #ifndef MP-WEIXIN
// const sign = this.storeDetail.yzfSign;
// uni.navigateTo({
// this.$navigateTo({
// url:
// "/pages/tabbar/home/web-view?src=https://yzf.qq.com/xv/web/static/chat/index.html?sign=" +
// sign,
@ -916,7 +916,7 @@ export default {
* 跳转到店铺页面
*/
navigateToStore(store_id) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/shopPage?id=` + store_id,
});
},

View File

@ -94,7 +94,7 @@ export default {
);
},
toComment(id, grade) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/comment?id=${id}&grade=${grade}`,
});
},

View File

@ -54,7 +54,7 @@ export default {
this.getShippingAddress()
}
else{
uni.navigateTo({
this.$navigateTo({
url: 'pages/passport/login'
});
}
@ -71,7 +71,7 @@ export default {
getpicker() {
// this.$refs.cityPicker.show();
uni.navigateTo({
this.$navigateTo({
url: "/pages/mine/address/add",
});
this.closeAddress();

View File

@ -57,13 +57,13 @@ export default {
},
//
clickGoods(val) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/goods?id=${val.content.id}&goodsId=${val.content.goodsId}`,
});
},
tostorePage(val) {
uni.navigateTo({
this.$navigateTo({
url: "../product/shopPage?id=" + val.storeId,
});
},

View File

@ -74,7 +74,7 @@ export default {
},
methods: {
handleClickStore(val){
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/shopPage?id=${val.id}`
});
},

View File

@ -152,7 +152,7 @@ export default {
methods: {
getStoreLicencePhoto() {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/licencePhoto?id=${this.storeId}`,
});
},
@ -190,7 +190,7 @@ export default {
// sign: this.storeInfo.yzfSign,
// mpSign: this.storeInfo.yzfMpSign,
// };
// uni.navigateTo({
// this.$navigateTo({
// url:
// "/pages/product/customerservice/index?params=" +
// encodeURIComponent(JSON.stringify(params)),
@ -198,14 +198,14 @@ export default {
// // #endif
// // #ifndef MP-WEIXIN
// const sign = this.storeInfo.yzfSign;
// uni.navigateTo({
// this.$navigateTo({
// url:
// "/pages/tabbar/home/web-view?src=https://yzf.qq.com/xv/web/static/chat/index.html?sign=" +
// sign,
// });
// // #endif
uni.navigateTo({
this.$navigateTo({
url: `/pages/tabbar/home/web-view?IM=${this.storeId}`,
});
},
@ -227,7 +227,7 @@ export default {
/**商品分类中商品集合 */
getCategoryGoodsList(val) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/shopPageGoods?title=${val.labelName}&id=${val.id}&storeId=${this.storeId}`,
});
},
@ -237,7 +237,7 @@ export default {
*/
search() {
console.log("点击")
uni.navigateTo({
this.$navigateTo({
url: `/pages/navigation/search/searchPage?storeId=${this.storeId}&keyword=${this.keyword}`,
});
},

View File

@ -74,7 +74,7 @@ export default {
//
navigateToBargainDetail(val) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/promotion/bargain/detail?id=${val.id}`,
});
},

View File

@ -67,7 +67,7 @@ export default {
},
//
navigateToBargainDetail(val) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/promotion/bargain/detail?id=${val.kanjiaActivityGoodsId}`,
});
},

View File

@ -113,7 +113,7 @@ export default {
},
toHref(goods) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/goods?id=${goods.skuId}&goodsId=${goods.goodsId}`,
});
},

View File

@ -229,7 +229,7 @@ export default {
let customParams = encodeURIComponent(
JSON.stringify({ path: "pages/index/index", pid: 1 })
); // 600
uni.navigateTo({
this.$navigateTo({
url:
"plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=" +
roomId +

View File

@ -137,14 +137,14 @@ export default {
methods: {
//
navigateTo(url) {
uni.navigateTo({
this.$navigateTo({
url,
});
},
toGoods(item) {
//
uni.navigateTo({
this.$navigateTo({
url: `/pages/promotion/point/detail?id=${item.id}`,
});
},

View File

@ -151,7 +151,7 @@ export default {
) {
return;
} else {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/goods?id=${item.skuId}&goodsId=${item.goodsId}`,
});
}

View File

@ -343,7 +343,7 @@ export default {
* 跳转到店铺
*/
navigateToStore(val) {
uni.navigateTo({
this.$navigateTo({
url: "/pages/product/shopPage?id=" + val.storeId,
});
},
@ -352,7 +352,7 @@ export default {
* 跳转到优惠券
*/
navigateToConpon(val) {
uni.navigateTo({
this.$navigateTo({
url: "/pages/cart/coupon/couponCenter?storeId=" + val.storeId,
});
},
@ -361,7 +361,7 @@ export default {
* 跳转到商品
*/
navigateToGoods(val) {
uni.navigateTo({
this.$navigateTo({
url:
"/pages/product/goods?id=" +
val.goodsSku.id +
@ -437,7 +437,7 @@ export default {
* 跳转
*/
navigateTo(url) {
uni.navigateTo({
this.$navigateTo({
url,
});
},

View File

@ -57,7 +57,7 @@ export default {
* 查询
*/
search() {
uni.navigateTo({
this.$navigateTo({
url: "/pages/navigation/search/searchPage",
});
},
@ -90,7 +90,7 @@ export default {
},
navigateToList(sid, tid) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/navigation/search/searchPage?category=${tid}`,
});
},

View File

@ -57,7 +57,7 @@ export default {
mounted() {},
methods: {
handleClick(item) {
uni.navigateTo({
this.$navigateTo({
url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`,
});
},

View File

@ -145,22 +145,22 @@ export default {
goToDetail(type) {
switch(type) {
case "SECKILL":
uni.navigateTo({
this.$navigateTo({
url: `/pages/promotion/seckill`,
});
break;
case "PINTUAN":
uni.navigateTo({
this.$navigateTo({
url: `/pages/promotion/joinGroup`,
});
break;
case "LIVE":
uni.navigateTo({
this.$navigateTo({
url: `/pages/promotion/lives`,
});
break;
case "KANJIA":
uni.navigateTo({
this.$navigateTo({
url: `/pages/promotion/bargain/list`,
});
break;

View File

@ -12,7 +12,7 @@ export default {
props: ["res"],
methods: {
handleSearch() {
uni.navigateTo({
this.$navigateTo({
url: "/pages/navigation/search/searchPage",
});
},

View File

@ -149,18 +149,18 @@ export default {
// WX_CODE
if (res.scanType == "WX_CODE") {
console.log(res);
uni.navigateTo({
this.$navigateTo({
url: `/${res.path}`,
});
} else {
config.scanAuthNavigation.forEach((src) => {
if (res.result.indexOf(src) != -1) {
uni.navigateTo({
this.$navigateTo({
url: `/${res.result.substring(src.length)}`,
});
} else {
setTimeout(() => {
uni.navigateTo({
this.$navigateTo({
url: "/pages/tabbar/home/web-view?src=" + path,
});
}, 100);

View File

@ -45,14 +45,14 @@ export default {
// },
methods: {
gotoLink() {
uni.navigateTo({
this.$navigateTo({
//
url:
"/pages/tabbar/home/web-view?src=https://pc-b2b2c.pickmall.cn/article/detail?id=1371992704333905920",
});
},
gotoB() {
uni.navigateTo({
this.$navigateTo({
url:
"/pages/tabbar/home/web-view?src=https://pc-b2b2c.pickmall.cn/article/detail?id=1371779927900160000",
});

View File

@ -122,7 +122,7 @@ export default {
* navigator标签现在默认没有转场动画所以用view
*/
navigateTo(url) {
uni.navigateTo({
this.$navigateTo({
url,
});
},

View File

@ -73,7 +73,7 @@
})
},
goDetail(item) {
uni.navigateTo({
this.$navigateTo({
url: '/pages/product/goods?id=' + item.content.id + "&goodsId=" +item.content.goodsId
})
},

View File

@ -69,7 +69,7 @@ import { distribution } from "@/api/goods";
export default {
methods: {
navigateTo(url) {
uni.navigateTo({
this.$navigateTo({
url,
});
},
@ -78,11 +78,11 @@ export default {
if (res.data.result) {
let type = res.data.result.distributionStatus;
if (type == "PASS") {
uni.navigateTo({
this.$navigateTo({
url: "/pages/mine/distribution/home",
});
} else if (type == "REFUSE") {
uni.navigateTo({
this.$navigateTo({
url: "/pages/mine/distribution/auth",
});
} else if (type == "RETREAT") {
@ -106,7 +106,7 @@ export default {
});
} else {
//
uni.navigateTo({
this.$navigateTo({
url: "/pages/mine/distribution/auth",
});
}

24
utils/navigateRoute.js Normal file
View File

@ -0,0 +1,24 @@
export function navigateTo({url}) {
// #ifdef MP-WEIXIN
//判断当前页面栈的长度
if (getCurrentPages().length >= 8) {
//超过八层的时候跳转销毁当前页面,十层的时候手机应该会很卡;
uni.redirectTo({
url: url,
success: function (res) {},
fail: function (res) {},
complete: function (res) {},
});
} else {
uni.navigateTo({
url: url,
});
}
// #endif
// #ifndef MP-WEIXIN
uni.navigateTo({
url: url,
});
// #endif
}

View File

@ -215,7 +215,7 @@
if (jump) {
// #ifdef MP
if (attrs['app-id']) {
return uni.navigateToMiniProgram({
return this.$navigateToMiniProgram({
appId: attrs['app-id'],
path: attrs.path
})
@ -241,7 +241,7 @@
})
// #endif
} else
uni.navigateTo({
this.$navigateTo({
url: attrs.href,
fail() {
uni.switchTab({

View File

@ -331,7 +331,7 @@
} else if (href.indexOf('http') == 0 || href.indexOf('//') == 0)
return true;
else
uni.navigateTo({
this.$navigateTo({
url: href
})
}
@ -578,7 +578,7 @@
} else if (href.includes('://'))
plus.runtime.openWeb(href);
else
uni.navigateTo({
this.$navigateTo({
url: href
})
}

View File

@ -114,7 +114,7 @@
url: this.config.url
});
} else {
uni.navigateTo({
this.$navigateTo({
url: this.config.url
});
}