import Vue from 'vue';
import VueRouter from 'vue-router';
import layout from '@/layout/index.vue';

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};
Vue.use(VueRouter);
const router = new VueRouter({
  // mode:"history",
  // mode:process.env.NODE_ENV !==
  // "production" ? "hash" : "history",
  mode: 'history',
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition;
    } else {
      return { x: 0, y: 0 };
    }
  },
  base: process.env.NODE_ENV === 'development' ? '/releaseMobile/' : '/mobile/',
  // base: '/mobile/',
  routes: [
    {
      path: '/',
      component: layout,
      redirect: '/home',
      children: [
        {
          path: '/home',
          name: 'home',
          component: () => import('@/views/home/index.vue'),
        },
        {
          path: '/reportingRate',
          name: 'reportingRate',
          component: () => import('@/views/home/reportingRate.vue'),
        },
        {
          path: '/err',
          name: 'err',
          component: () => import('@/views/home/err.vue'),
        },
        {
          path: '/login',
          name: 'login',
          component: () => import('@/views/home/login.vue'),
        },
        {
          path: '/logincs',
          name: 'logincs',
          component: () => import('@/views/home/logincs.vue'),
        },
        {
          path: '/noVisit',
          name: 'noVisit',
          meta: { title: '未拜访门店' },
          component: () => import('@/views/home/hintTabPage/noVisit.vue'),
        },
        {
          path: '/hintDetail',
          name: 'hintDetail',
          meta: { title: '提示类-拜访（实时） ' },
          component: () => import('@/views/home/hintTabPage/hintDetail.vue'),
        },
        {
          path: '/pantoneNoGet',
          name: 'pantoneNoGet',
          meta: { title: '提示类-业务员未领取色卡门店 ' },
          component: () => import('@/views/home/hintTabPage/pantoneNoGet.vue'),
        },
        {
          path: '/unCreateStore',
          name: 'unCreateStore',
          meta: { title: '提示类-业务员建店未完成页面' },
          component: () => import('@/views/home/hintTabPage/unCreateStore.vue'),
          meta: {
            title: '提示类-业务员建店未完成页面',
          },
        },
        {
          path: '/warningStore',
          name: 'warningStore',
          meta: { title: '提示类-业务员预警门店页面' },
          component: () => import('@/views/home/hintTabPage/warningStore.vue'),
          meta: {
            title: '提示类-业务员预警门店页面',
          },
        },
      ],
    },
    {
      path: '/storemanagementlist',
      component: layout,
      redirect: '/storemanagement/index',
      children: [
        {
          path: '/storemanagement/index',
          name: 'storeManagement',
          component: () => import('@/views/storeManagement/index.vue'),
        },
        {
          path: '/storeDetail',
          name: 'storeDetail',
          component: () => import('@/views/storeManagement/storeDetail.vue'),
        },
        {
          path: '/storeAdd',
          name: 'storeAdd',
          component: () => import('@/views/storeManagement/storeAdd.vue'),
        },
        {
          path: '/storeAddress',
          name: 'storeAddress',
          component: () => import('@/views/storeManagement/storeAddress.vue'),
        },
        {
          path: '/odersuccess',
          name: 'storeAdd',
          component: () => import('@/views/deviceOutside/oderSuccess.vue'),
        },
        {
          path: '/storeEdit',
          name: 'storeEdit',
          component: () => import('@/views/storeManagement/storeEdit.vue'),
        },
        {
          path: '/success',
          name: 'success',
          component: () => import('@/views/storeManagement/success.vue'),
        },
        {
          path: '/chainMaintain',
          name: 'chainMaintain',
          component: () => import('@/views/storeManagement/chainMaintain.vue'),
        },
        {
          path: '/addDesignerPage',
          name: 'addDesignerPage',
          component: () => import('@/views/storeManagement/addDesignerPage.vue'),
          meta: { title: '设计师招募', keepAlive: true },
        },
        {
          path: '/addDesignerDetail',
          name: 'addDesignerDetail',
          component: () => import('@/views/storeManagement/addDesignerDetail.vue'),
          meta: { title: '设计师招募详情', keepAlive: true },
        },
        {
          path: '/addDesignerEdit',
          name: 'addDesignerEdit',
          component: () => import('@/views/storeManagement/addDesignerEdit.vue'),
          meta: { title: '设计师招募编辑', keepAlive: true },
        },
        {
          path: '/JPattributeEditor',
          name: 'JPattributeEditor',
          component: () => import('@/views/storeManagement/JPattributeEditor.vue'),
          meta: { title: '金牌店档案编辑', keepAlive: true },
        },
        {
          path: '/FSQStoreDetail',
          name: 'FSQStoreDetail',
          component: () => import('@/views/storeManagement/FSQStoreDetail.vue'),
          meta: { title: '仿石漆详情', keepAlive: true },
        },
        {
          path: '/FSQStoreEdit',
          name: 'FSQStoreEdit',
          component: () => import('@/views/storeManagement/FSQStoreEdit.vue'),
          meta: { title: '仿石漆编辑', keepAlive: true },
        },
        {
          path: '/competingStoresAdd',
          name: 'competingStoresAdd',
          component: () => import('@/views/storeManagement/competingStoresAdd.vue'),
          meta: { title: '竞品店添加', keepAlive: true },
        },
        {
          path: '/competingStoresDetail',
          name: 'competingStoresDetail',
          component: () => import('@/views/storeManagement/competingStoresDetail.vue'),
          meta: { title: '竞品门店详情', keepAlive: true },
        },
        {
          path: '/competingStoresEdit',
          name: 'competingStoresEdit',
          component: () => import('@/views/storeManagement/competingStoresEdit.vue'),
          meta: { title: '竞品门店编辑', keepAlive: true },
        },
      ],
    },
    {
      path: '/outsidelist',
      component: layout,
      redirect: '/outsidelist/index',
      children: [
        {
          path: '/outsidelist/index',
          name: 'outsidelist',
          component: () => import('@/views/deviceOutside/index.vue'),
        },
        {
          path: '/ai',
          name: 'ai',
          component: () => import('@/views/intelligence/index.vue'),
        },
        {
          path: '/topStore',
          name: 'topStore',
          component: () => import('@/views/deviceOutside/topStore.vue'),
        },
        {
          path: '/pItem',
          name: 'pItem',
          component: () => import('@/views/deviceOutside/productItem.vue'),
        },
        {
          path: '/suishenbangOutstoreVisit',
          name: 'suishenbangOutstoreVisit',
          component: () => import('@/views/deviceOutside/suishenbangOutstoreVisit.vue'),
        },
        {
          path: '/projectOut',
          name: 'projectOut',
          component: () => import('@/views/deviceOutside/projectOut.vue'),
        },
        {
          path: '/rangeStore',
          name: 'rangeStore',
          component: () => import('@/views/deviceOutside/rangeStore.vue'),
        },
        {
          path: '/outstoreVisit',
          name: 'outstoreVisit',
          component: () => import('@/views/deviceOutside/outstoreVisit.vue'),
        },
        {
          path: '/taskList',
          name: 'taskList',
          component: () => import('@/views/deviceOutside/taskList.vue'),
        },
        {
          path: '/storeGroup',
          name: 'storeGroup',
          component: () => import('@/views/deviceOutside/storeGroup.vue'),
        },
        {
          path: '/outabnormalVisit',
          name: 'outabnormalVisit',
          component: () => import('@/views/deviceOutside/outabnormalVisit.vue'),
        },
      ],
    },
    {
      path: '/historicalVisit',
      component: layout,
      redirect: '/historicalVisit/index',
      children: [
        {
          path: '/historicalVisit/index',
          name: 'historicalVisit',
          component: () => import('@/views/historicalVisit/index.vue'),
        },
        {
          path: '/historAllVisit',
          name: 'historAllVisit',
          component: () => import('@/views/historicalVisit/historAllVisit.vue'),
        },

        {
          path: '/historicalDetails',
          name: 'historicalDetails',
          component: () => import('@/views/historicalVisit/historicalDetails.vue'),
        },
        {
          path: '/perfectStore',
          name: 'perfectStore',
          component: () => import('@/views/historicalVisit/perfectStore.vue'),
        },
        {
          path: '/perfectStoreTask',
          name: 'perfectStoreTask',
          component: () => import('@/views/historicalVisit/perfectStoreTask.vue'),
        },
        {
          path: '/perfectStoreSku',
          name: 'perfectStoreSku',
          component: () => import('@/views/historicalVisit/perfectStoreSku.vue'),
        },
        {
          path: '/historiStoreVisit',
          name: 'historiStoreVisit',
          component: () => import('@/views/historicalVisit/hisvistdeils.vue'),
        },
        {
          path: '/skuRecognize',
          name: 'skuRecognize',
          component: () => import('@/views/historicalVisit/skuRecognize.vue'),
        },
        {
          path: '/perfectStoreSign',
          name: 'perfectStoreSign',
          component: () => import('@/views/historicalVisit/perfectStoreSign.vue'),
        },
        {
          path: '/perfectStoreTSJ',
          name: 'perfectStoreTSJ',
          component: () => import('@/views/historicalVisit/perfectStoreTSJ.vue'),
        },
      ],
    },
    {
      path: '/deviceWithin',
      component: layout,
      redirect: '/deviceWithin/index',
      children: [
        {
          path: '/deviceWithin/index',
          name: 'deviceWithin',
          component: () => import('@/views/deviceWithin/index.vue'),
        },
        {
          path: '/storeVisitpage',
          name: 'storeVisitpage',
          component: () => import('@/views/deviceWithin/storeVisit.vue'),
        },
        {
          path: '/addStoreVisit',
          name: 'addStoreVisit',
          component: () => import('@/views/deviceWithin/addStoreVisit.vue'),
        },
        {
          path: '/taskPhotoTaking',
          name: 'taskPhotoTaking',
          component: () => import('@/views/deviceWithin/taskPhotoTaking.vue'),
        },
        {
          path: '/addStoreVisitd',
          name: 'addStoreVisitd',
          component: () => import('@/views/deviceWithin/addStoreVisitd.vue'),
        },
        {
          path: '/addStoreVisitP',
          name: 'addStoreVisitP',
          component: () => import('@/views/deviceWithin/addStoreVisitP.vue'),
        },
        {
          path: '/abnormalVisit',
          name: 'abnormalVisit',
          component: () => import('@/views/deviceWithin/abnormalVisit.vue'),
        },
        {
          path: '/sign',
          name: 'sign',
          component: () => import('@/views/sign/index.vue'),
        },
        {
          path: '/signApprovalList',
          name: 'signApproval',
          component: () => import('@/views/signApproval/index.vue'),
        },
        {
          path: '/signApproval',
          name: 'signApproval',
          component: () => import('@/views/signApproval/signApproval.vue'),
        },
        // 同城店铺建店审批
        {
          path: '/newStoreApprovalList',
          name: 'newStoreApprovalList',
          component: () => import('@/views/signApproval/newStoreApprovalList.vue'),
        },
        {
          path: '/newStoreApprovalDetail',
          name: 'newStoreApprovalDetail',
          component: () => import('@/views/signApproval/newStoreApprovalDetail.vue'),
        },
      ],
    },

    {
      path: '/My',
      component: layout,
      redirect: '/My/index',
      children: [
        {
          path: '/My/index',
          name: 'MyList',
          component: () => import('@/views/week/index.vue'),
        },
        {
          path: '/myInventory',
          name: 'myInventory',
          component: () => import('@/views/my/myInventory.vue'),
        },
        {
          path: '/material',
          name: 'material',
          component: () => import('@/views/my/material.vue'),
        },
        {
          path: '/subordinateHistoricalDaily',
          name: 'subordinateHistoricalDaily',
          component: () => import('@/views/week/dailyHistorical.vue'),
        },
        {
          path: '/subordinateHistoricalWeekly',
          name: 'subordinateHistoricalWeekly',
          component: () => import('@/views/week/weeklyHistorical.vue'),
        },
        {
          path: '/myHistoricalDaily',
          name: 'myHistoricalDaily',
          component: () => import('@/views/week/myHistoricalDaily.vue'),
        },
        {
          path: '/weeklyApproval',
          name: 'weeklyApproval',
          component: () => import('@/views/week/weeklyApproval.vue'),
        },
        {
          path: '/weeklyApprovalDetils',
          name: 'weeklyApprovalDetils',
          component: () => import('@/views/week/weeklyApprovalDetils.vue'),
        },
        {
          path: '/myComment',
          name: 'myComment',
          component: () => import('@/views/week/myComment.vue'),
        },
        {
          path: '/doubleWeeklyDetils',
          name: 'doubleWeeklyDetils',
          component: () => import('@/views/week/doubleWeeklyDetils.vue'),
        },
        {
          path: '/daily',
          name: 'daily',
          component: () => import('@/views/week/daily.vue'),
        },
        {
          path: '/dailyApprovalList',
          name: 'dailyApprovalList',
          component: () => import('@/views/week/dailyApprovalList.vue'),
        },
        {
          path: '/dailyApproval',
          name: 'dailyApproval',
          component: () => import('@/views/week/dailyApproval.vue'),
        },
        {
          path: '/dailyDetails',
          name: 'dailyDetails',
          component: () => import('@/views/week/dailyDetails.vue'),
        },
        {
          path: '/weeklyApproval',
          name: 'weeklyApproval',
          component: () => import('@/views/week/weeklyApproval.vue'),
        },
        {
          path: '/weekly',
          name: 'weekly',
          component: () => import('@/views/week/weekly.vue'),
        },
        {
          path: '/doubleWeekly',
          name: 'doubleWeekly',
          component: () => import('@/views/week/doubleWeekly.vue'),
        },
        {
          path: '/doubleWeeklyApproval',
          name: 'doubleWeeklyApproval',
          component: () => import('@/views/week/doubleWeeklyApproval.vue'),
        },
        {
          path: '/doubleWeeklyHistorical',
          name: 'doubleWeeklyHistorical',
          component: () => import('@/views/week/doubleWeeklyHistorical.vue'),
        },
        {
          path: '/dailyHistoricalDetails',
          name: 'dailyHistoricalDetails',
          component: () => import('@/views/week/dailyHistoricalDetails.vue'),
        },
        {
          path: '/doubleHistoricalWeeklyDetils',
          name: 'doubleHistoricalWeeklyDetils',
          component: () => import('@/views/week/doubleHistoricalWeeklyDetils.vue'),
        },
        {
          path: '/weeklyHistoricalDetils',
          name: 'weeklyHistoricalDetils',
          component: () => import('@/views/week/weeklyHistoricalDetils.vue'),
        },
        {
          path: '/VisitSummary',
          name: 'VisitSummary',
          component: () => import('@/views/week/VisitSummary.vue'),
        },
        {
          path: '/VisitSummaryMy',
          name: 'VisitSummaryMy',
          component: () => import('@/views/week/VisitSummaryMy.vue'),
        },
        {
          path: '/VisitSummaryAdd',
          name: 'VisitSummaryAdd',
          component: () => import('@/views/week/VisitSummaryAdd.vue'),
        },
        {
          path: '/VisitSummaryDetail',
          name: 'VisitSummaryDetail',
          component: () => import('@/views/week/VisitSummaryDetail.vue'),
        },
        {
          path: '/VisitSummaryStorageDetail',
          name: 'VisitSummaryStorageDetail',
          component: () => import('@/views/week/VisitSummaryStorageDetail.vue'),
        },
        {
          path: '/assignAwait',
          name: 'assignAwait',
          meta: { title: '待分配客资' },
          component: () => import('@/views/week/assignAwait/index.vue'),
        },
        {
          path: '/assignPage',
          name: 'assignPage',
          meta: { title: '分配客资' },
          component: () => import('@/views/week/assignAwait/assignPage.vue'),
        },
        {
          path: '/JZfollowUp',
          name: 'JZfollowUp',
          meta: { title: '客资跟进' },
          component: () => import('@/views/week/assignAwait/JZfollowUp.vue'),
        },
        {
          path: '/systemSettings',
          name: 'systemSettings',
          component: () => import('@/views/week/systemSettings.vue'),
          meta: { title: '设置' },
        },
        {
          path: '/SUPTaskApproval',
          name: 'SUPTaskApproval',
          component: () => import('@/views/week/SUPTaskApproval/index.vue'),
          meta: { title: '主管任务审批', keepAlive: true },
          children: [],
        },
        {
          path: '/SUPTaskApprovalDetail',
          name: 'SUPTaskApprovalDetail',
          component: () => import('@/views/week/SUPTaskApproval/SUPTaskApprovalDetail.vue'),
          meta: { title: '主管任务审批详情', keepAlive: true },
        },
        {
          path: '/changeChain',
          name: 'changeChain',
          component: () => import('@/views/week/changeChain.vue'),
          meta: { title: '切换经销商' },
        },
      ],
    },
    {
      path: '/clew',
      component: layout,
      redirect: '/clew',
      children: [
        {
          path: '/clew',
          name: 'clew',
          component: () => import('@/views/clew/index.vue'),
        },
        {
          path: '/clewent',
          name: 'clewent',
          component: () => import('@/views/clew/clewent.vue'),
        },
        {
          path: '/complaintDetail',
          name: 'complaintDetail',
          meta: { title: '渠道投诉' },
          component: () => import('@/views/clew/complaintDetail/index.vue'),
        },
      ],
    },
    {
      path: '/AIImage',
      component: layout,
      redirect: '/AIImage/list',
      children: [
        {
          path: '/AIImage/list',
          name: 'AIImage',
          component: () => import('@/views/AIImage/list.vue'),
        },
        {
          path: '/AIImageDetail',
          name: 'AIImageDetail',
          component: () => import('@/views/AIImage/AIImageDetail.vue'),
        },
      ],
    },
  ],
});
export default router;
