diff --git a/common/common.js b/common/common.js index e940acd..1d9636d 100644 --- a/common/common.js +++ b/common/common.js @@ -5,6 +5,7 @@ */ import Vue from 'vue' import config from '@/common/config.js' +import { navigateTo as routerNavigateTo, navigateBack as routerNavigateBack } from '@/common/router.js' // 防止处理多次点击 function noMultipleClicks(methods, info) { @@ -444,27 +445,35 @@ export default { return } - if (Object.keys(query).length > 0) { - url += this.qs(query) + // 确定跳转类型 + let navigationType = 'navigateTo'; + switch (type) { + case 2: + navigationType = 'redirectTo'; + break; + case 3: + navigationType = 'switchTab'; + break; + case 4: + navigationType = 'reLaunch'; + break; + default: + navigationType = 'navigateTo'; } - - const opt = { - url, - success, - fail, - complete - } - - const dic = { - 1: uni.navigateTo, - 2: uni.redirectTo, - 3: uni.switchTab, - 4: uni.reLaunch - } - - const action = dic[type] - - action(opt) + + // 使用导入的路由方法而不是this.$router + return routerNavigateTo(url, query, navigationType) + .then(res => { + if (typeof success === 'function') success(res); + return res; + }) + .catch(err => { + if (typeof fail === 'function') fail(err); + throw err; + }) + .finally(() => { + if (typeof complete === 'function') complete(); + }); }, /** @@ -474,32 +483,17 @@ export default { */ back(e) { /* 判断传入的是否是数字 */ - let pages = getCurrentPages() - console.log('pgaes', pages) - if (pages.length >= 2) { - if (typeof e === 'number' && !isNaN(e)) { - /* 如果要跳转的长度小于页面栈数量 */ - if (e < pages.length) { - uni.navigateBack({ - delta: e - }) - /* 否则回首页 */ - } else { - uni.switchTab({ - url: '/pages/shouye/index' - }) - } - /* 默认返回上一级 */ - } else { - uni.navigateBack({ - delta: 1 - }) - } - } else { - uni.switchTab({ - url: '/pages/shouye/index' - }) + let delta = 1; + if (typeof e === 'number' && !isNaN(e)) { + delta = e; } + + // 使用导入的routerNavigateBack而不是this.$router + routerNavigateBack(delta) + .catch(() => { + // 如果返回失败,则回到首页 + routerNavigateTo('/pages/shouye/index', {}, 'switchTab'); + }); }, /** @@ -519,14 +513,11 @@ export default { $navBack(num = 1, time = 0) { // 页面返回 setTimeout(() => { - uni.navigateBack({ - delta: num, - fail: () => { - uni.reLaunch({ - url: '/pages/shouye/index' - }) - } - }) + routerNavigateBack(num) + .catch(() => { + // 如果返回失败,则回到首页 + routerNavigateTo('/pages/shouye/index', {}, 'reLaunch'); + }); }, time * 1000) }, /** @@ -617,14 +608,27 @@ export default { // #endif }, nav(url) { - uni.navigateTo({ - url: url, - fail: () => { - uni.switchTab({ - url: url + // 解析URL和参数 + let urlPath = url; + let params = {}; + + if (url.includes('?')) { + const parts = url.split('?'); + urlPath = parts[0]; + + // 解析参数 + if (parts[1]) { + parts[1].split('&').forEach(param => { + const keyValue = param.split('='); + if (keyValue.length === 2) { + params[keyValue[0]] = decodeURIComponent(keyValue[1]); + } }); } - }) + } + + // 使用导入的路由方法 + return routerNavigateTo(urlPath, params); }, red(url) { uni.redirectTo({ diff --git a/common/config.js b/common/config.js index 51fc8de..83c2e07 100644 --- a/common/config.js +++ b/common/config.js @@ -9,6 +9,35 @@ let configData = null; let isLoading = false; let loadPromise = null; const wx_version = "104"; + +// 白名单页面(不需要登录即可访问) +export const whiteList = [ + "pages/shouye/index", // 首页 + "pages/shouye/detail", // 详情页 + "pages/shouye/huanxiang", // 换箱页面 + "pages/mall/index", // 商城首页 + "pages/shouye/detail_wuxian", // 无限详情页 + "pages/sangdai/sangdai", // 盒柜页面 + "pages/infinite/index", // 福利首页 + "pages/user/index", // 用户中心 + "pages/infinite/daily_check_in", // 每日签到 + "pages/infinite/bonus_house", // 福利屋 + "pages/other/prize_draw", // 每日奖品抽取 + "pages/shouye/danye", // 单页 + "pages/guize/guize", // 规则页面 + "pages/shouye/dada_ranking", // 达达排行榜 + "pages/shouye/yaoqing_ranking", // 邀请排行榜 + "pages/user/login" // 登录页面 +]; + +// API白名单(不需要登录即可访问的API) +export const apiWhiteList = [ + 'login_record', + 'api/warehouse_index', + 'api/user', + 'api/warehouse_send_record' +]; + const defaultConfig = { "good_type": [{ "value": 0, "sort_order": 0, "is_show": 1, "name": "全部", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 1, "sort_order": 1, "is_show": 0, "name": "一番赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 2, "sort_order": 2, "is_show": 1, "name": "无限赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 3, "sort_order": 3, "is_show": 0, "name": "擂台赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 5, "sort_order": 4, "is_show": 0, "name": "积分赏", "pay_wechat": 0, "pay_balance": 0, "pay_currency": 0, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 0 }, { "value": 6, "sort_order": 5, "is_show": 1, "name": "限时活动", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 8, "sort_order": 6, "is_show": 1, "name": "领主赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 9, "sort_order": 7, "is_show": 0, "name": "连击赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 10, "sort_order": 8, "is_show": 0, "name": "商城赏", "pay_wechat": 1, "pay_balance": 0, "pay_currency": 0, "pay_currency2": 1, "pay_coupon": 0, "is_deduction": 0 }, { "value": 11, "sort_order": 9, "is_show": 0, "name": "自制赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 15, "sort_order": 15, "is_show": 0, "name": "福利屋", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 0, "pay_currency2": 0, "pay_coupon": 0, "is_deduction": 0 }, { "value": 16, "sort_order": 16, "is_show": 1, "name": "翻倍赏", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 1, "pay_currency2": 1, "pay_coupon": 1, "is_deduction": 1 }, { "value": 17, "sort_order": 17, "is_show": 0, "name": "外卖盒子", "pay_wechat": 1, "pay_balance": 1, "pay_currency": 0, "pay_currency2": 0, "pay_coupon": 0, "is_deduction": 0 }], "app_setting": { diff --git a/common/gotopage.js b/common/gotopage.js index 93232e6..6f83803 100644 --- a/common/gotopage.js +++ b/common/gotopage.js @@ -1,4 +1,7 @@ // import config from '../config.js' +// 导入路由模块 +import { navigateTo as routerNavigateTo } from '@/common/router.js'; + /*导航菜单白名单*/ const tabBarLinks = [ '/pages/index/index', @@ -28,27 +31,33 @@ export const gotopage = (url, type) => { return false; } + // 从URL中提取路径和参数 + let path = url; + let params = {}; - // tabBar页面 - if (type == 'switch') { - uni.reLaunch({ - url: url - }); - } else { + if (url.includes('?')) { + const [basePath, queryString] = url.split('?'); + path = basePath; - if(type == 'redirect'){ - uni.redirectTo({ - url: url - }); - } - if(type == 'reLaunch'){ - uni.reLaunch({ - url: url - }); - } - // 普通页面 - uni.navigateTo({ - url: url + // 解析参数 + queryString.split('&').forEach(param => { + const [key, value] = param.split('='); + if (key && value) { + params[key] = decodeURIComponent(value); + } }); } + + // 使用新的路由方法进行导航 + let navigationType = 'navigateTo'; + if (type === 'switch') { + navigationType = 'reLaunch'; + } else if (type === 'redirect') { + navigationType = 'redirectTo'; + } else if (type === 'reLaunch') { + navigationType = 'reLaunch'; + } + + // 使用导入的路由方法 + return routerNavigateTo(path, params, navigationType); } diff --git a/common/request.js b/common/request.js index a2885de..016cc5b 100644 --- a/common/request.js +++ b/common/request.js @@ -6,7 +6,8 @@ import EnvConfig from '@/common/env.js' import md5 from 'js-md5' import ConfigManager from '@/common/config.js' - +import { apiWhiteList } from '@/common/config.js' +import RouterManager from '@/common/router.js' class RequestManager { /** * 判断URL是否在白名单中 @@ -14,26 +15,16 @@ class RequestManager { * @returns {Boolean} 是否在白名单中 */ static isUrlInWhitelist(url) { - // 白名单URL列表 - const whitelistUrls = [ - 'login_record', - 'api/warehouse_index', - 'api/user', - 'api/warehouse_send_record' - ] - - - // 白名单URL列表 - const whitelistUrls2 = [ - 'login_record', - ] - let iswx = ConfigManager.GetVersion(); + // let iswx = ConfigManager.GetVersion(); + + // // 根据版本使用不同的白名单 + // if (!iswx) { + // // 非微信版本只允许 login_record + // return apiWhiteList.includes('login_record') && url.indexOf('login_record') > -1; + // } - if (!iswx) { - return whitelistUrls2.some(whiteItem => url.indexOf(whiteItem) > -1) - } // 检查URL是否包含白名单中的任一项 - return whitelistUrls.some(whiteItem => url.indexOf(whiteItem) > -1) + return apiWhiteList.some(whiteItem => url.indexOf(whiteItem) > -1); } /** @@ -208,6 +199,7 @@ class RequestManager { data: data, success: res => { console.log("res.data.status", res.data.status) + var pages = getCurrentPages() if (res.data.status == 1) { // 请求成功 resolve(res.data) @@ -245,19 +237,37 @@ class RequestManager { icon: 'none' }) }, 100) + reject(res.data) } else if (res.data.status < 0) { var pages = getCurrentPages() - for (var a = 0; a < pages.length; a++) { - console.log(pages[a].route) - if (pages[a].route == 'pages/user/index') { - uni.setStorageSync('lgurl', pages[a].route) - uni.setStorageSync('lgurldata', JSON.stringify(pages[a].options)) + // 获取当前页面路径和参数 + var currentPage = pages[pages.length - 1]; + if (currentPage) { + var currentRoute = currentPage.route; + var currentParams = currentPage.options || {}; + + // 只有非登录页面才保存重定向信息 + if (currentRoute && currentRoute !== 'pages/user/login') { + // 构建完整的重定向URL + var redirectPath = '/' + currentRoute; + + // 如果有参数,拼接参数 + if (Object.keys(currentParams).length > 0) { + var paramString = Object.keys(currentParams) + .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(currentParams[key])}`) + .join('&'); + redirectPath += '?' + paramString; + } + + // 保存重定向URL到缓存 + console.log('保存重定向URL:', redirectPath); + uni.setStorageSync('redirect', redirectPath); } } + console.log(requestUrl); if (RequestManager.isUrlInWhitelist(requestUrl)) { - reject(res.data) return; } @@ -267,11 +277,13 @@ class RequestManager { icon: 'none' }) }, 100) - uni.redirectTo({ - url: '/pages/user/login', - // animationType: 'pop-in', - // animationDuration: 500 - }) + + // 使用新的路由守卫方法进行跳转 + RouterManager.navigateTo('/pages/user/login', {}, 'navigateTo') + .catch(err => { + console.error('登录页面跳转失败:', err); + }); + reject(res.data) } else { reject(res.data) diff --git a/common/router.js b/common/router.js new file mode 100644 index 0000000..c6a1b9e --- /dev/null +++ b/common/router.js @@ -0,0 +1,253 @@ +/** + * 通用路由守卫 + */ + +import { whiteList } from '@/common/config.js' + +/** + * 判断用户是否已登录 + * @returns {Boolean} true表示已登录,false表示未登录 + */ +function isLogin() { + // 从本地存储获取用户token或其他登录凭证 + const token = uni.getStorageSync('token'); + return !!token; +} + +/** + * 判断URL是否在白名单中 + * @param {String} url 需要检查的URL + * @returns {Boolean} 是否在白名单中 + */ +function isInWhiteList(url) { + if (!url) return false; + + // 去除URL开头的斜杠,以便与白名单匹配 + const cleanUrl = url.startsWith('/') ? url.substring(1) : url; + + // 提取路径部分(不含参数) + const pathPart = cleanUrl.split('?')[0]; + + // 检查是否在白名单中 + return whiteList.some(item => { + // 确保白名单项目不带/开头,以实现一致的比较 + const cleanItem = item.startsWith('/') ? item.substring(1) : item; + return pathPart === cleanItem || pathPart.startsWith(cleanItem + '/') || pathPart.startsWith(cleanItem + '?'); + }); +} + +/** + * 返回上一页,如果上一页是登录页则跳过它 + * @returns {Promise} 返回操作结果的Promise + */ +export function navigateBack(delta = 1) { + return new Promise((resolve, reject) => { + const pages = getCurrentPages(); + + // 如果页面栈不足,直接返回首页 + if (pages.length <= 1) { + return navigateTo('/pages/shouye/index', {}, 'reLaunch') + .then(resolve) + .catch(reject); + } + + // 查看前一个页面是否是登录页 + if (pages.length > 1 && pages[pages.length - 2].route === 'pages/user/login') { + // 如果前一个页面是登录页,则返回两步 + uni.navigateBack({ + delta: 2, + success: resolve, + fail: reject + }); + } else { + // 正常返回 + uni.navigateBack({ + delta, + success: resolve, + fail: reject + }); + } + }); +} + +/** + * 通用路由跳转方法 + * @param {Object} options 跳转配置 + * @param {String} options.url 跳转地址 + * @param {Object} options.params 请求参数,可选 + * @param {String} options.type 跳转方式,可选:navigateTo(默认)、switchTab、redirectTo、reLaunch + * @returns {Promise} 返回一个Promise对象 + */ +export function routerTo(options) { + return new Promise((resolve, reject) => { + // 处理参数 + let { url, params, type } = options; + + // 判断url是否存在 + if (!url || url.length === 0) { + reject('跳转地址不能为空'); + return; + } + + // 拼接参数 + if (params && Object.keys(params).length > 0) { + const queryString = Object.keys(params) + .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(params[key])}`) + .join('&'); + + url += (url.indexOf('?') === -1 ? '?' : '&') + queryString; + } + + // 检查是否需要登录 + const needLogin = !isInWhiteList(url); + + if (needLogin && !isLogin()) { + // 需要登录但未登录,跳转到登录页面 + // 先保存当前URL用于登录后重定向 + uni.setStorageSync('redirect', url); + + // 使用navigateTo而非redirectTo,保留页面栈 + uni.navigateTo({ + url: '/pages/user/login', + success: () => { + console.log('跳转到登录页面成功,保存的重定向地址:', url); + }, + fail: (err) => { + console.error('跳转到登录页面失败:', err); + reject(err); + } + }); + + // 拒绝当前的导航请求 + return reject(new Error('需要登录')); + } + + // 根据type选择跳转方式 + if (type) { + // 指定了跳转方式,直接使用 + switch (type) { + case 'switchTab': + uni.switchTab({ + url, + success: resolve, + fail: reject + }); + break; + case 'redirectTo': + uni.redirectTo({ + url, + success: resolve, + fail: reject + }); + break; + case 'reLaunch': + uni.reLaunch({ + url, + success: resolve, + fail: reject + }); + break; + case 'navigateTo': + default: + uni.navigateTo({ + url, + success: resolve, + fail: reject + }); + break; + } + } else { + // 未指定跳转方式,先尝试navigateTo,失败后尝试switchTab + uni.navigateTo({ + url, + success: resolve, + fail: (err) => { + // navigateTo失败,尝试switchTab + uni.switchTab({ + url, + success: resolve, + fail: (switchErr) => { + // 两种方式都失败,返回错误 + reject(switchErr); + } + }); + } + }); + } + }); +} + +/** + * 简化版路由跳转方法 + * @param {String} url 跳转地址 + * @param {Object} params 请求参数,可选 + * @param {String} type 跳转方式,可选 + * @returns {Promise} 返回Promise对象 + */ +export function navigateTo(url, params = {}, type = '') { + return routerTo({ + url, + params, + type + }); +} + +/** + * 收集白名单路径 + * @param {String} path 需要添加到白名单的路径 + * @returns {Array} 返回更新后的白名单数组 + */ +export function collectWhitePath(path) { + // 缓存的键名 + const WHITELIST_CACHE_KEY = 'APP_WHITELIST_PATHS'; + + // 从缓存中获取现有白名单 + let cachedWhitelist = uni.getStorageSync(WHITELIST_CACHE_KEY) || []; + + // 如果不是数组,则初始化为空数组 + if (!Array.isArray(cachedWhitelist)) { + cachedWhitelist = []; + } + + // 检查路径是否已存在于白名单中 + if (path && path.trim() && !cachedWhitelist.includes(path)) { + // 添加新路径到白名单 + cachedWhitelist.push(path); + + // 保存更新后的白名单到缓存 + uni.setStorageSync(WHITELIST_CACHE_KEY, cachedWhitelist); + + console.log('添加白名单路径成功:', path); + } + + return cachedWhitelist; +} + +/** + * 获取已收集的白名单路径 + * @returns {Array} 返回缓存中的白名单数组 + */ +export function getCollectedWhitePaths() { + const WHITELIST_CACHE_KEY = 'APP_WHITELIST_PATHS'; + return uni.getStorageSync(WHITELIST_CACHE_KEY) || []; +} + +/** + * 清空已收集的白名单路径 + * @returns {Boolean} 返回操作结果 + */ +export function clearCollectedWhitePaths() { + const WHITELIST_CACHE_KEY = 'APP_WHITELIST_PATHS'; + uni.setStorageSync(WHITELIST_CACHE_KEY, []); + return true; +} + +// 更新默认导出 +export default { + routerTo, + navigateTo, + navigateBack, + collectWhitePath, + getCollectedWhitePaths, + clearCollectedWhitePaths +}; \ No newline at end of file diff --git a/components/nav-header/nav-header.vue b/components/nav-header/nav-header.vue index e3200ca..ebc29a7 100644 --- a/components/nav-header/nav-header.vue +++ b/components/nav-header/nav-header.vue @@ -1,16 +1,51 @@ @@ -18,16 +53,46 @@ export default { name: 'NavHeader', props: { + // 是否暗黑模式 + dark: { + type: Boolean, + default: false + }, // 标题文字 title: { type: String, default: '' }, + // 左侧文字 + leftText: { + type: String, + default: '' + }, + // 右侧文字 + rightText: { + type: String, + default: '' + }, + // 左侧图标 + leftIcon: { + type: String, + default: '' + }, + // 右侧图标 + rightIcon: { + type: String, + default: '' + }, // 是否显示返回按钮 showBack: { type: Boolean, default: false }, + // 是否显示返回文字 + showBackText: { + type: Boolean, + default: false + }, // 返回页面路径,不传则返回上一页 backUrl: { type: String, @@ -36,12 +101,12 @@ export default { // 文字颜色 color: { type: String, - default: '#000000' + default: '' }, // 背景颜色 backgroundColor: { type: String, - default: 'transparent' + default: '' }, // 是否固定在顶部 fixed: { @@ -53,36 +118,97 @@ export default { type: Boolean, default: true }, - // 是否显示底部边框 - border: { + // 是否显示阴影 + shadow: { type: Boolean, default: false + }, + // 导航栏高度 + height: { + type: [Number, String], + default: 44 + }, + // 左侧宽度 + leftWidth: { + type: [Number, String], + default: 60 + }, + // 右侧宽度 + rightWidth: { + type: [Number, String], + default: 60 + } + }, + data() { + return { + statusBarHeight: 20, // 默认状态栏高度 + innerTitle: '', // 内部使用的标题 + navbarHeight: 44 // 导航栏高度 + } + }, + computed: { + // 导航栏主题背景色 + themeBgColor() { + if (this.dark) { + if (this.backgroundColor) { + return this.backgroundColor; + } else { + return this.dark ? '#333' : '#FFF'; + } + } + return this.backgroundColor || '#FFF'; + }, + // 导航栏主题文字色 + themeColor() { + if (this.dark) { + if (this.color) { + return this.color; + } else { + return this.dark ? '#fff' : '#333'; + } + } + return this.color || '#333'; + } + }, + created() { + this.getStatusBarHeight(); + this.innerTitle = this.title; + + // 转换导航栏高度 + this.navbarHeight = typeof this.height === 'number' ? this.height : parseInt(this.height); + }, + watch: { + title(newVal) { + this.innerTitle = newVal; } }, methods: { + // 获取状态栏高度 + getStatusBarHeight() { + uni.getSystemInfo({ + success: (res) => { + this.statusBarHeight = res.statusBarHeight || 20; + } + }); + }, // 返回页面 goBack() { + this.onClickLeft(); + }, + // 点击左侧按钮 + onClickLeft() { + this.$emit('clickLeft'); + if (this.backUrl) { // 如果指定了返回页面路径,则跳转到指定页面 - uni.redirectTo({ - url: this.backUrl, - success: () => { - - }, - fail: (err) => { + this.$router.navigateTo(this.backUrl, {}, 'redirectTo') + .catch(err => { console.log('返回页面失败', err); - uni.switchTab({ - url: this.backUrl, - success: () => { - - }, - fail: (err) => { + this.$router.navigateTo(this.backUrl, {}, 'switchTab') + .catch(err => { console.log('返回页面失败1', err); - } - }); - } - }); - + }); + }); } else { var pages = getCurrentPages(); if (pages.length > 1) { @@ -93,23 +219,155 @@ export default { } }); } else { - uni.switchTab({ - url: '/pages/shouye/index', - }); + this.$router.navigateTo('/pages/shouye/index', {}, 'switchTab'); } } + }, + // 点击右侧按钮 + onClickRight() { + this.$emit('clickRight'); + }, + // 点击标题 + onClickTitle() { + this.$emit('clickTitle'); } } } \ No newline at end of file diff --git a/components/page-container/page-container.vue b/components/page-container/page-container.vue index 7474b3c..8e41a11 100644 --- a/components/page-container/page-container.vue +++ b/components/page-container/page-container.vue @@ -1,9 +1,28 @@ \ No newline at end of file diff --git a/pages/other/order_list.vue b/pages/other/order_list.vue index 64769a4..0294861 100644 --- a/pages/other/order_list.vue +++ b/pages/other/order_list.vue @@ -89,9 +89,7 @@ export default { }, goOrderDetail(item) { - uni.navigateTo({ - url: `/pages/other/order_info?order_num=${item.order_num}` - }); + this.$router.navigateTo('/pages/other/order_info', { order_num: item.order_num }); } } } diff --git a/pages/shop/detail.vue b/pages/shop/detail.vue index b682952..6a8bf83 100644 --- a/pages/shop/detail.vue +++ b/pages/shop/detail.vue @@ -229,9 +229,7 @@ setTimeout(() => { that.$refs.order_show.close() //去订单 - uni.redirectTo({ - url: '/pages/miaosha/shop_order' - }) + that.$router.navigateTo('/pages/miaosha/shop_order', {}, 'redirectTo'); }, 1500) } } @@ -245,9 +243,7 @@ setTimeout(() => { that.$refs.order_show.close() //去订单 - uni.redirectTo({ - url: '/pages/miaosha/shop_order' - }) + that.$router.navigateTo('/pages/miaosha/shop_order', {}, 'redirectTo'); }, 1500) } } else { diff --git a/pages/shop/index.vue b/pages/shop/index.vue index 7ab99bc..778be16 100644 --- a/pages/shop/index.vue +++ b/pages/shop/index.vue @@ -100,21 +100,14 @@ }, openUrl(e) { if (e.target == 1) { - uni.navigateTo({ - url: '../shouye/detail?id=' + e.goods_id - }) + this.$router.navigateTo('../shouye/detail', { id: e.goods_id }); } if (e.target == 2) { - uni.navigateTo({ - url: 'detail?goods_id=' + e.product_id - }) + this.$router.navigateTo('detail', { goods_id: e.product_id }); } if (e.target == 3) { - uni.navigateTo({ - url: '../web-view?url=' + e.url - }) + this.$router.navigateTo('../web-view', { url: e.url }); } - }, diff --git a/pages/shouye/detail_wuxian.vue b/pages/shouye/detail_wuxian.vue index 2f9e184..98b2ce7 100644 --- a/pages/shouye/detail_wuxian.vue +++ b/pages/shouye/detail_wuxian.vue @@ -1,5 +1,5 @@