import Vue from 'vue'
import Router from 'vue-router'
import { lan } from "@/utils/config";
Vue.use(Router)
import login from '@/view/login'
import register from '@/view/register'
import findPassword from '@/view/findPassword'

import setting from './setting'
import option from './option'
import bull from './bull'
import promote from './promote'
import copyTrade from './copyTrade'
import abnormal from './abnormal'

import home from '@/view/home'
import market from '@/view/market'
import my from '@/view/my'
import finding from '@/view/finding'
import noticeDetail from '@/view/noticeDetail'

import favoriteView from '@/view/market/favoriteView'
import overview from '@/view/market/overview'
import stock from '@/view/market/stock'
import cfd from '@/view/market/cfd'
import optionList from '@/view/optionView/lists'

import account from '@/view/account'
import accountDetail from '@/view/accountDetail'
import accountOperate from '@/view/accountOperate'
import productDetail from '@/view/productDetail'
import exchange from '@/view/exchange'
import convert from '@/view/convert'
import withdraw from '@/view/withdraw'
import withdrawSuccess from '@/view/withdrawSuccess'
import deposit from '@/view/deposit'
import channelDetail from '@/view/deposit/channelDetail'
import recharge from '@/view/deposit/recharge'
import depositVoucher from '@/view/depositVoucher'
import depositSuccess from '@/view/depositSuccess'
import addPay from '@/view/addPay'
import addPaySuccess from '@/view/addPay/success.vue'
import search from '@/view/search'
import newsDetail from '@/view/newsDetail'
import liveChat from '@/view/liveChat'
import navView from '@/view/home/router/nav'
import inform from '@/view/inform'
import accountRecords from '@/view/accountRecords'
import accountRecordsDetail from '@/view/accountRecords/detail'
import support from '@/view/support'
import workOrder from '@/view/workOrder'
import workOrderAdd from '@/view/workOrderAdd'
import workOrderDetail from '@/view/workOrderDetail'
import transferAccounts from '@/view/transferAccounts'
import thaw from '@/view/thaw'
import feedback from '@/view/feedback'
import feedbacksuccess from '@/view/feedback/success'
import join from '@/view/join'
import joinApply from '@/view/joinApply'
import share from '@/view/share'
import vip from '@/view/vip'
import info from '@/view/info'
import poster from '@/view/poster'
import help from '@/view/help'
import activities from '@/view/activities'
import preActivities from '@/view/activities/pre.vue'
import usdRecords from '@/view/usdRecords'
import usdRecordsDetail from '@/view/usdRecords/detail'
import download from '@/view/download'
import onlinePayment from '@/view/onlinePayment'
import statement from '@/view/statement'
import fit from '@/view/fit'
import couponCenter from '@/view/couponCenter'
import about from '@/view/about'
import aboutMain from '@/view/about/main.vue'
import notices from '@/view/notices'
import noticesList from '@/view/notices/list'

import empty from '@/view/empty'
import ad from '@/view/ad'

import layout from '@/layout'
export const constantRoutes = [
  {
    path: "/:locale" + lan + "?",
    component: layout,
    name: 'layout',
    redirect: '/',
    meta: { keepAlive: true },
    children: [
      {
        path: '/',
        component: home,
        name: 'home',
        meta: { keepAlive: true, socket: true },
        children: [
          {
            path: 'nav',
            component: navView,
            name: 'navView',
            meta: { keepAlive: true, socket: true },
          }
        ]
      },
      {
        path: 'market',
        component: market,
        name: 'market',
        redirect: '/market/overview',
        meta: { keepAlive: true, socket: true },
        children: [
          {
            path: 'optional',
            component: favoriteView,
            name: 'optional',
            meta: { keepAlive: false, socket: true },
          },
          {
            path: 'overview',
            component: overview,
            name: 'overview',
            meta: { keepAlive: false, socket: true },
          },
          {
            path: 'stock/:market?',
            component: stock,
            name: 'stock',
            meta: { keepAlive: false, socket: true },
          },
          {
            path: 'cfd/:market?',
            component: cfd,
            name: 'cfd',
            meta: { keepAlive: false, socket: true },
          },
          {
            path: 'options/:market?',
            component: optionList,
            name: 'options',
            meta: { keepAlive: false },
          },
          {
            path: 'follow/:market?',
            component: () => import(/* webpackChunkName: "follow" */ '@/view/copyTrade/marketview'),
            name: 'follow',
            meta: { keepAlive: true, socket: true },
          }
        ]
      },
      {
        path: 'my',
        component: my,
        name: 'my',
        meta: { keepAlive: true }
      },
      {
        path: 'finding/:type?',
        component: finding,
        name: 'finding',
        meta: { keepAlive: true }
      },
      {
        path: 'account',
        component: account,
        name: 'account',
        meta: { keepAlive: true, mustLogin: true, socket: true }
      },
    ],
  },
  {
    path: '/:locale' + lan + '?/product-detail/:symbol/:type?',
    component: productDetail,
    name: 'productDetail',
    meta: { socket: true }
  },
  {
    path: '/:locale' + lan + '?/empty',
    component: empty,
    name: 'empty',
    meta: {  }
  },
  {
    path: '/:locale' + lan + '?/ad/:code',
    component: ad,
    name: 'ad',
    meta: { }
  },
  {
    path: '/:locale' + lan + '?/exchange/:symbol/:type?/:id?',
    component: exchange,
    name: 'exchange',
    meta: { socket: true }
  },
  {
    path: '/:locale' + lan + '?/convert/:id?',
    component: convert,
    name: 'convert',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/inform',
    component: inform,
    name: 'inform',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/account-records/:type',
    component: accountRecords,
    name: 'accountRecords',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/account-records/detail/:type/:ordernum',
    component: accountRecordsDetail,
    name: 'accountRecordsDetail',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/account-detail/:id',
    component: accountDetail,
    name: 'accountDetail',
    meta: { mustLogin: true, socket: true }
  },
  {
    path: '/:locale' + lan + '?/account-operate/:id',
    component: accountOperate,
    name: 'accountOperate',
    meta: { mustLogin: true, socket: true }
  },
  {
    path: '/:locale' + lan + '?/withdraw',
    component: withdraw,
    name: 'withdraw',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/withdraw-success',
    component: withdrawSuccess,
    name: 'withdrawSuccess',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/deposit/:id?',
    component: deposit,
    name: 'deposit',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/recharge/:id?',
    component: recharge,
    name: 'recharge',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/channel/:id',
    component: channelDetail,
    name: 'channelDetail',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/deposit-voucher/:id/:ordernum',
    component: depositVoucher,
    name: 'depositVoucher',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/deposit-success',
    component: depositSuccess,
    name: 'depositSuccess',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/online-pay/:ordernum',
    component: onlinePayment,
    name: 'onlinePayment',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/add-pay',
    component: addPay,
    name: 'addPay',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/add-pay-success',
    component: addPaySuccess,
    name: 'addPaySuccess',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/search',
    component: search,
    name: 'search',
    meta: { socket: true }
  },
  {
    path: '/:locale' + lan + '?/chat',
    component: liveChat,
    name: 'liveChat',
    meta: { keepAlive: true }
  },
  {
    path: '/:locale' + lan + '?/help',
    component: help,
    name: 'help',
    meta: { keepAlive: true }
  },
  {
    path: '/:locale' + lan + '?/activities/:tab?',
    component: activities,
    name: 'activities',
    meta: { keepAlive: false }
  },
  {
    path: '/:locale' + lan + '?/pre-activities/:tab?',
    component: preActivities,
    name: 'preActivities',
    meta: { keepAlive: false }
  },
  {
    path: '/:locale' + lan + '?/news-detail/:id',
    component: newsDetail,
    name: 'newsDetail',
    meta: { }
  },
  {
    path: '/:locale' + lan + '?/notice-detail/:id',
    component: noticeDetail,
    name: 'noticeDetail',
    meta: { }
  },
  {
    path: '/:locale' + lan + '?/support',
    component: support,
    name: 'support',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/notices',
    component: notices,
    name: 'notices',
    meta: { mustLogin: false, keepAlive: true }
  },
  {
    path: '/:locale' + lan + '?/notice-list/:category',
    component: noticesList,
    name: 'noticesList',
    meta: { mustLogin: false, socket: true }
  },
  {
    path: '/:locale' + lan + '?/work-order/:type?',
    component: workOrder,
    name: 'workOrder',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/work-order-detail/:id',
    component: workOrderDetail,
    name: 'workOrderDetail',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/add-work-order',
    component: workOrderAdd,
    name: 'workOrderAdd',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/transfer-account',
    component: transferAccounts,
    name: 'transferAccounts',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/thaw',
    component: thaw,
    name: 'thaw',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/join/:uid',
    component: join,
    name: 'join',
    meta: { }
  },
  {
    path: '/:locale' + lan + '?/join-apply/:uid',
    component: joinApply,
    name: 'joinApply',
    meta: { }
  },
  {
    path: '/:locale' + lan + '?/feedback',
    component: feedback,
    name: 'feedback',
    meta: {}
  },
  {
    path: '/:locale' + lan + '?/fit',
    component: fit,
    name: 'fit',
    meta: {}
  },
  {
    path: '/:locale' + lan + '?/about',
    component: about,
    name: 'about',
    meta: {}
  },
  {
    path: '/:locale' + lan + '?/about/home',
    component: aboutMain,
    name: 'about1',
    meta: {}
  },
  {
    path: '/:locale' + lan + '?/feedback-success',
    component: feedbacksuccess,
    name: 'feedbacksuccess',
    meta: {}
  },
  {
    path: '/:locale' + lan + '?/download/:uid?',
    component: download,
    name: 'download',
    meta: {}
  },
  {
    path: '/:locale' + lan + '?/share',
    component: share,
    name: 'share',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/vip',
    component: vip,
    name: 'vip',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/info',
    component: info,
    name: 'info',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/poster',
    component: poster,
    name: 'poster',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/usd-record',
    component: usdRecords,
    name: 'usdRecords',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/coupon-center/:type?',
    component: couponCenter,
    name: 'couponCenter',
    meta: { mustLogin: true }
  },
  {
    path: '/:locale' + lan + '?/usd-record-detail/:ordernum',
    component: usdRecordsDetail,
    name: 'usdRecordsDetail',
    meta: { mustLogin: true }
  },
  ...abnormal,
  ...setting,
  ...option,
  ...bull,
  ...promote,
  ...copyTrade,
  {
    path: '/:locale' + lan + '?/login',
    component: login,
    name: 'login',
    meta: { loginHidden: true }
  },
  {
    path: '/:locale' + lan + '?/register',
    component: register,
    name: 'register',
    meta: { loginHidden: true }
  },
  {
    path: '/:locale' + lan + '?/statement/:id?/:sign?',
    component: statement,
    name: 'statement',
    meta: {}
  },
  {
    path: '/:locale' + lan + '?/rf/:code',
    component: register,
    name: 'rt',
    meta: { loginHidden: false }
  },
  {
    path: '/:locale' + lan + '?/find-password',
    component: findPassword,
    name: 'findPassword',
    meta: { loginHidden: true }
  },
  { path: '*', redirect: '/', hidden: true }
]

const createRouter = () => new Router({
  mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()


export default router