|
| 1 | +import Vue from 'vue' |
| 2 | +import Router from 'vue-router' |
| 3 | +import {routerMode} from './config/env' |
| 4 | + |
| 5 | +const home = () => import('../page/home/home') |
| 6 | +const city = () => import('../page/city/city') |
| 7 | +const msite = () => import('../page/msite/msite') |
| 8 | +const search = () => import('../page/search/search') |
| 9 | +const shop = () => import('../page/shop/shop') |
| 10 | +const login = () => import('../page/login/login') |
| 11 | +const profile = () => import('../page/profile/profile') |
| 12 | +const forget = () => import('../page/forget/forget') |
| 13 | +const order = () => import('../page/order/order') |
| 14 | +const orderDetail = () => import('../page/order/children/orderDetail') |
| 15 | +const vipCard = () => import('../page/vipcard/vipCard') |
| 16 | +const invoiceRecord = () => import('../page/vipcard/children/invoiceRecord') |
| 17 | +const useCart = () => import('../page/vipcard/children/useCart') |
| 18 | +const vipDescription = () => import('../page/vipcard/children/vipDescription') |
| 19 | +const food = () => import('../page/food/food') |
| 20 | +const confirmOrder = () => import('../page/confirmOrder/confirmOrder') |
| 21 | +const remark = () => import('../page/confirmOrder/children/remark') |
| 22 | +const payment = () => import('../page/confirmOrder/children/payment') |
| 23 | +const userValidation = () => import('../page/confirmOrder/children/userValidation') |
| 24 | +const invoice = () => import('../page/confirmOrder/children/invoice') |
| 25 | +const chooseAddress = () => import('../page/confirmOrder/children/chooseAddress') |
| 26 | +const addAddress = () => import('../page/confirmOrder/children/children/addAddress') |
| 27 | +const searchAddress = () => import('../page/confirmOrder/children/children/children/searchAddress') |
| 28 | +const foodDetail = () => import('../page/shop/children/foodDetail') |
| 29 | +const shopDetail = () => import('../page/shop/children/shopDetail') |
| 30 | +const shopSafe = () => import('../page/shop/children/children/shopSafe') |
| 31 | +const info = () => import('../page/profile/children/info') |
| 32 | +const setUserName = () => import('../page/profile/children/children/setUserName') |
| 33 | +const address = () => import('../page/profile/children/children/address') |
| 34 | +const add = () => import('../page/profile/children/children/children/add') |
| 35 | +const addDetail = () => import('../page/profile/children/children/children/children/addDetail') |
| 36 | +const balance = () => import('../page/balance/balance') |
| 37 | +const balanceDetail = () => import('../page/balance/children/detail') |
| 38 | +const benefit = () => import('../page/benefit/benefit') |
| 39 | +const coupon = () => import('../page/benefit/children/coupon') |
| 40 | +const hbDescription = () => import('../page/benefit/children/hbDescription') |
| 41 | +const hbHistory = () => import('../page/benefit/children/hbHistory') |
| 42 | +const exchange = () => import('../page/benefit/children/exchange') |
| 43 | +const commend = () => import('../page/benefit/children/commend') |
| 44 | +const points = () => import('../page/points/points') |
| 45 | +const pointsDetail = () => import('../page/points/children/detail') |
| 46 | +const service = () => import('../page/service/service') |
| 47 | +const questionDetail = () => import('../page/service/children/questionDetail') |
| 48 | +const find = () => import('../page/find/find') |
| 49 | +const download = () => import('../page/download/download') |
| 50 | +const notFound = () => import('../components/common/404.vue') |
| 51 | +const notAllow = () => import('../components/common/401.vue') |
| 52 | + |
| 53 | +Vue.use(Router) |
| 54 | + |
| 55 | +const router = new Router ({ |
| 56 | + mode: routerMode, // 默认值: "hash" (浏览器环境) | "abstract" (Node.js 环境)可选值: "hash" | "history" | "abstract" |
| 57 | + // hash: 使用 URL hash 值来作路由。支持所有浏览器,包括不支持 HTML5 History Api 的浏览器 |
| 58 | + // history: 依赖 HTML5 History API 和服务器配置。查看 HTML5 History 模式 |
| 59 | + // abstract: 支持所有 JavaScript 运行环境,如 Node.js 服务器端。如果发现没有浏览器的 API,路由会自动强制进入这个模式 |
| 60 | + scrollBehavior (to, from, savedPosition) { |
| 61 | + if (savedPosition) { |
| 62 | + return savedPosition |
| 63 | + } else { |
| 64 | + if (from.meta.keepAlive) { |
| 65 | + from.meta.savedPosition = document.body.scrollTop |
| 66 | + } |
| 67 | + return { x: 0, y: to.meta.savedPosition || 0 |
| 68 | + } |
| 69 | + } |
| 70 | + }, |
| 71 | + routes: [{ |
| 72 | + path: '/', |
| 73 | + component: App, // 顶层路由,对应index.html |
| 74 | + children: [ // 二级路由。对应App.vue |
| 75 | + // 地址为空时跳转home页面 |
| 76 | + { |
| 77 | + path: '', |
| 78 | + redirect: '/home' |
| 79 | + }, |
| 80 | + // 首页城市列表页 |
| 81 | + { |
| 82 | + path: '/home', |
| 83 | + component: home |
| 84 | + }, |
| 85 | + // 当前选择城市页 |
| 86 | + { |
| 87 | + path: '/city/:cityid', |
| 88 | + component: city |
| 89 | + }, |
| 90 | + // 所有商铺列表页 |
| 91 | + { |
| 92 | + path: '/msite', |
| 93 | + component: msite, |
| 94 | + meta: { keepAlive: true } |
| 95 | + }, |
| 96 | + // 特色商铺列表页 |
| 97 | + { |
| 98 | + path: '/food', |
| 99 | + component: food |
| 100 | + }, |
| 101 | + // 搜索页 |
| 102 | + { |
| 103 | + path: '/search/:geohash', |
| 104 | + component: search |
| 105 | + }, |
| 106 | + // 商铺详情页 |
| 107 | + { |
| 108 | + path: '/shop', |
| 109 | + component: shop, |
| 110 | + children: [{ |
| 111 | + path: 'foodDetail', // 食品详情页 |
| 112 | + component: foodDetail |
| 113 | + }, { |
| 114 | + path: 'shopDetail', // 商铺详情页 |
| 115 | + component: shopDetail, |
| 116 | + children: [{ |
| 117 | + path: 'shopSafe', // 商铺安全认证页 |
| 118 | + component: shopSafe |
| 119 | + }] |
| 120 | + }] |
| 121 | + }, |
| 122 | + //确认订单页 |
| 123 | + { |
| 124 | + path: '/confirmOrder', |
| 125 | + component: confirmOrder, |
| 126 | + children: [{ |
| 127 | + path: 'remark', // 订单备注 |
| 128 | + component: remark |
| 129 | + }, { |
| 130 | + path: 'invoice', // 发票抬头 |
| 131 | + component: invoice |
| 132 | + }, { |
| 133 | + path: 'payment', // 付款页面 |
| 134 | + component: payment |
| 135 | + }, { |
| 136 | + path: 'userValidation', // 用户验证 |
| 137 | + component: userValidation |
| 138 | + }, { |
| 139 | + path: 'chooseAddress', // 选择地址 |
| 140 | + component: chooseAddress, |
| 141 | + children: [{ |
| 142 | + path: 'addAddress', // 添加地址 |
| 143 | + component: addAddress, |
| 144 | + children: [{ |
| 145 | + path: 'searchAddress', // 搜索地址 |
| 146 | + component: searchAddress |
| 147 | + }] |
| 148 | + }] |
| 149 | + }] |
| 150 | + }, |
| 151 | + // 登录注册页 |
| 152 | + { |
| 153 | + path: '/login', |
| 154 | + component: login |
| 155 | + }, |
| 156 | + // 个人信息页 |
| 157 | + { |
| 158 | + path: '/profile', |
| 159 | + component: profile, |
| 160 | + children: [{ |
| 161 | + path: 'info', // 个人信息详情页 |
| 162 | + component: info, |
| 163 | + children: [{ |
| 164 | + path: 'setUserName', |
| 165 | + component: setUserName |
| 166 | + }, { |
| 167 | + path: 'address', |
| 168 | + component: address, // 编辑地址 |
| 169 | + children:[{ |
| 170 | + path:'add', |
| 171 | + component:add, |
| 172 | + children:[{ |
| 173 | + path:'addDetail', |
| 174 | + component:addDetail |
| 175 | + }] |
| 176 | + }] |
| 177 | + }] |
| 178 | + }, |
| 179 | + { |
| 180 | + path: 'service', // 服务中心 |
| 181 | + component: service |
| 182 | + }] |
| 183 | + }, |
| 184 | + // 修改密码页 |
| 185 | + { |
| 186 | + path: '/forget', |
| 187 | + component: forget |
| 188 | + }, |
| 189 | + // 订单列表页 |
| 190 | + { |
| 191 | + path: '/order', |
| 192 | + component: order, |
| 193 | + children: [{ |
| 194 | + path: 'orderDetail', // 订单详情页 |
| 195 | + component: orderDetail |
| 196 | + }] |
| 197 | + }, |
| 198 | + // vip卡页 |
| 199 | + { |
| 200 | + path: '/vipCard', |
| 201 | + component: vipCard, |
| 202 | + children: [{ |
| 203 | + path: 'invoiceRecord', // 开发票 |
| 204 | + component: invoiceRecord |
| 205 | + }, { |
| 206 | + path: 'useCart', // 购买会员卡 |
| 207 | + component: useCart |
| 208 | + }, { |
| 209 | + path: 'vipDescription', // 会员说明 |
| 210 | + component: vipDescription |
| 211 | + }] |
| 212 | + }, |
| 213 | + // 发现页 |
| 214 | + { |
| 215 | + path: '/find', |
| 216 | + component: find |
| 217 | + }, |
| 218 | + // 下载页 |
| 219 | + { |
| 220 | + path: '/download', |
| 221 | + component: download |
| 222 | + }, |
| 223 | + // 服务中心 |
| 224 | + { |
| 225 | + path: '/service', |
| 226 | + component: service, |
| 227 | + children: [{ |
| 228 | + path: 'questionDetail', // 订单详情页 |
| 229 | + component: questionDetail |
| 230 | + }] |
| 231 | + }, |
| 232 | + // 余额 |
| 233 | + { |
| 234 | + path: 'balance', |
| 235 | + component: balance, |
| 236 | + children: [{ |
| 237 | + path: 'detail', // 余额说明 |
| 238 | + component: balanceDetail |
| 239 | + }] |
| 240 | + }, |
| 241 | + // 我的优惠页 |
| 242 | + { |
| 243 | + path: 'benefit', |
| 244 | + component: benefit, |
| 245 | + children: [{ |
| 246 | + path: 'coupon', // 代金券说明 |
| 247 | + component: coupon |
| 248 | + }, { |
| 249 | + path: 'hbDescription', // 红包说明 |
| 250 | + component: hbDescription |
| 251 | + }, { |
| 252 | + path: 'hbHistory', // 历史红包 |
| 253 | + component: hbHistory |
| 254 | + }, { |
| 255 | + path: 'exchange', // 兑换红包 |
| 256 | + component: exchange |
| 257 | + }, { |
| 258 | + path: 'commend', // 推荐有奖 |
| 259 | + component: commend |
| 260 | + }] |
| 261 | + }, |
| 262 | + // 我的积分页 |
| 263 | + { |
| 264 | + path: 'points', |
| 265 | + component: points, |
| 266 | + children: [{ |
| 267 | + path: 'detail', // 积分说明 |
| 268 | + component: pointsDetail |
| 269 | + }] |
| 270 | + }, |
| 271 | + { |
| 272 | + path: '401', |
| 273 | + component: notAllow |
| 274 | + }, |
| 275 | + { |
| 276 | + path: '404', |
| 277 | + component: notFound |
| 278 | + } |
| 279 | + ] |
| 280 | + }] |
| 281 | +}) |
| 282 | +export default router |
0 commit comments