[仅供测试]重写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

41
App.vue
View File

@ -1,15 +1,35 @@
<script> <script>
/** /**
* vuex管理登录状态具体可以参考官方登录模板示例 * vuex管理登录状态具体可以参考官方登录模板示例
*/ */
import { mapMutations } from "vuex"; import {
mapMutations
} from "vuex";
import APPUpdate from "@/plugins/APPUpdate"; import APPUpdate from "@/plugins/APPUpdate";
import { getClipboardData } from "@/js_sdk/h5-copy/h5-copy.js"; import {
getClipboardData
} from "@/js_sdk/h5-copy/h5-copy.js";
import config from "@/config/config"; import config from "@/config/config";
import storage from "@/utils/storage"; import storage from "@/utils/storage";
//
/**
* 路由监听并删除路由
* 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
export default { export default {
data() { data() {
@ -18,6 +38,7 @@ export default {
}; };
}, },
/** /**
* 监听返回 * 监听返回
*/ */
@ -118,8 +139,7 @@ export default {
//app广 //app广
var w = plus.webview.open( var w = plus.webview.open(
"/hybrid/html/advertise/advertise.html", "/hybrid/html/advertise/advertise.html",
"本地地址", "本地地址", {
{
top: 0, top: 0,
bottom: 0, bottom: 0,
zindex: 999, zindex: 999,
@ -169,7 +189,7 @@ export default {
url: path, url: path,
}); });
} else { } else {
uni.navigateTo({ this.$navigateTo({
url: path, url: path,
}); });
} }
@ -194,7 +214,7 @@ export default {
url: `/${path}`, url: `/${path}`,
}); });
} else { } else {
uni.navigateTo({ this.$navigateTo({
url: `/${path}`, url: `/${path}`,
}); });
} }
@ -219,15 +239,18 @@ export default {
height: auto !important; height: auto !important;
padding-top: 10rpx; padding-top: 10rpx;
} }
// #endif // #endif
body { body {
background-color: $bg-color; background-color: $bg-color;
} }
/************************ */ /************************ */
.w200 { .w200 {
width: 200rpx !important; width: 200rpx !important;
} }
.flex1 { .flex1 {
flex: 1; //flex flex: 1; //flex
} }

View File

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

View File

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

View File

@ -62,7 +62,7 @@ export default {
this.goodsList.push(...goodsList.data.result.content); this.goodsList.push(...goodsList.data.result.content);
}, },
handleClick(item) { handleClick(item) {
uni.navigateTo({ this.$navigateTo({
url: `/pages/product/goods?id=${item.content.id}&goodsId=${item.content.goodsId}`, 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 * as filters from "./utils/filters.js"; // global filter
import uView from "uview-ui"; import uView from "uview-ui";
import store from "./store"; import store from "./store";
import {navigateTo} from '@/utils/navigateRoute.js'
/** /**
* 仅在h5中显示唤醒app功能 * 仅在h5中显示唤醒app功能
@ -27,6 +27,10 @@ Object.keys(filters).forEach((key) => {
// 引入Vuex // 引入Vuex
Vue.prototype.$store = store; Vue.prototype.$store = store;
// // 引入Vuex
Vue.prototype.$navigateTo = navigateTo;
Vue.use(uView); Vue.use(uView);
Vue.config.productionTip = false; Vue.config.productionTip = false;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -45,7 +45,7 @@ export default {
}, },
methods: { methods: {
goDetail(sn,logi_id,ship_no){ 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, url:'/pages/msgTips/packagemsg/logisticsDetail?order_sn=' + sn +'&logi_id='+logi_id+'&ship_no='+ship_no,
}) })
}, },

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -45,14 +45,14 @@ export default {
// }, // },
methods: { methods: {
gotoLink() { gotoLink() {
uni.navigateTo({ this.$navigateTo({
// //
url: url:
"/pages/tabbar/home/web-view?src=https://pc-b2b2c.pickmall.cn/article/detail?id=1371992704333905920", "/pages/tabbar/home/web-view?src=https://pc-b2b2c.pickmall.cn/article/detail?id=1371992704333905920",
}); });
}, },
gotoB() { gotoB() {
uni.navigateTo({ this.$navigateTo({
url: url:
"/pages/tabbar/home/web-view?src=https://pc-b2b2c.pickmall.cn/article/detail?id=1371779927900160000", "/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 * navigator标签现在默认没有转场动画所以用view
*/ */
navigateTo(url) { navigateTo(url) {
uni.navigateTo({ this.$navigateTo({
url, url,
}); });
}, },

View File

@ -73,7 +73,7 @@
}) })
}, },
goDetail(item) { goDetail(item) {
uni.navigateTo({ this.$navigateTo({
url: '/pages/product/goods?id=' + item.content.id + "&goodsId=" +item.content.goodsId 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 { export default {
methods: { methods: {
navigateTo(url) { navigateTo(url) {
uni.navigateTo({ this.$navigateTo({
url, url,
}); });
}, },
@ -78,11 +78,11 @@ export default {
if (res.data.result) { if (res.data.result) {
let type = res.data.result.distributionStatus; let type = res.data.result.distributionStatus;
if (type == "PASS") { if (type == "PASS") {
uni.navigateTo({ this.$navigateTo({
url: "/pages/mine/distribution/home", url: "/pages/mine/distribution/home",
}); });
} else if (type == "REFUSE") { } else if (type == "REFUSE") {
uni.navigateTo({ this.$navigateTo({
url: "/pages/mine/distribution/auth", url: "/pages/mine/distribution/auth",
}); });
} else if (type == "RETREAT") { } else if (type == "RETREAT") {
@ -106,7 +106,7 @@ export default {
}); });
} else { } else {
// //
uni.navigateTo({ this.$navigateTo({
url: "/pages/mine/distribution/auth", 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) { if (jump) {
// #ifdef MP // #ifdef MP
if (attrs['app-id']) { if (attrs['app-id']) {
return uni.navigateToMiniProgram({ return this.$navigateToMiniProgram({
appId: attrs['app-id'], appId: attrs['app-id'],
path: attrs.path path: attrs.path
}) })
@ -241,7 +241,7 @@
}) })
// #endif // #endif
} else } else
uni.navigateTo({ this.$navigateTo({
url: attrs.href, url: attrs.href,
fail() { fail() {
uni.switchTab({ uni.switchTab({

View File

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

View File

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