import Taro, { Component } from '@tarojs/taro'
import { Provider } from '@tarojs/redux'

import Index from './pages/index'

import configStore from './store'

import 'taro-ui/dist/style/index.scss'
import './app.scss'

import api from './api'
Taro.api = api

import * as tools from './utils/tool'
import * as mixins from './mixins'
Taro.$msg = tools.msgBase
Taro.$CR = tools.configRight
Taro.$msgConfirm = tools.confirmMsgFn
Taro.$AHU = mixins.addHistoryUrl
Taro.$getLvIcon = mixins.getLvIcon
Taro.$initBaseData = mixins.initBaseData

// 如果需要在 h5 环境中开启 React Devtools
// 取消以下注释：
// if (process.env.NODE_ENV !== 'production' && process.env.TARO_ENV === 'h5')  {
//   require('nerv-devtools')
// }

const store = configStore()

class App extends Component {

  config = {
    lazyCodeLoading: "requiredComponents",
    pages: [
      'pages/index/index',
    ],
    subPackages: [
      {
        root: 'pagesHouse/',
        pages: [
          'index',
          'list',
          'indexDtl',
          'indexDtlMore',
          'indexDtlAround',
          // 'indexDtlMap',
          'produceType',
          'vr',
          'vrList',
          'photo',
          'photoin',
          'news',
          'newsEdit',
          'follow',
          'history',
          'search',
          'pkList',
          'pkDtl',
          'pkAdd',
          'price',
          'priceChart',
          'bargain',
          'cooperate',
        ]
      },
      {
        root: 'pagesMore/',
        pages: [
          'news/index',
          'news/list',
          'news/indexDtl',
          'news/tpDtl',
          'news/plan',
          'news/planDtl',
          'center/index',
          'center/group',
          'center/feedback',
          'center/loanCalc',
          'center/webViews',
          // 'center/coupon',
          'center/sxf',
          'center/saleEdit',
          'center/userEdit',
          'center/uploadRoom',
          'center/uploadRoom2',
          'center/uploadRoomHl',
          'comment/add',
          'comment/list',
          'comment/dtl',
          'qa/list',
          'qa/add',
          // 'qa/dtl',
          // 'test/index',
          'score/list',
          'score/edit',
        ]
      },
      {
        root: 'pagesPlan/',
        pages: [
          'apply',
          'apply2',
          'yanfang',
          'discountGroup',
          'queryBuyHouse',
        ]
      },
      {
        root: 'pagesSchool/',
        pages: [
          'index',
          'indexDtl',
          'houseList',
          'class',
          'theme',
          'area',
        ]
      },
      {
        root: 'pagesQa/',
        pages: [
          'index',
          'add',
          'dtl',
          'dtlSub',
          'msg/index',
          'msg/chat',
          'msg/message',
          // 'todayNews',
          'area',
          'areaImg',
          'areaSub',
          'areaEstate',
          'yhBaike',
        ]
      },
      {
        root: 'pagesDesc/',
        pages: [
          'desc',
        ]
      },
      {
        root: 'pagesRoom/',
        pages: [
          'estate',
          'list',
          'list2',
          'listMy',
          'listed',
          'listed2',
          'rentlist',
          'rentdtl',
          'rentUpload',
          'dtl',
          'roomPrice',
          'roomPrice2',
          'roomPriceXk',
          // 'roomPriceEdit',
          'roomPriceImg',
          'roomPriceList',
          // 'card/index',
          'follow/list',
          'follow/user',
          'follow/room',
          'follow/roomAdd',
          'follow/add',
          'follow/history',
          'follow/lineup',
          'follow/lineup2',
          'follow/lineupRecord',
          'follow/lineupRecord2',
          'estateTrend',
          'estateTrendRecord',
          'estateTrendUpdate',
        ]
      },
      {
        root: 'pagesOther/',
        pages: [
          'index',
          'integralRecord',
          'channel/index',
          // 'foodout/index',
          'map/dtl',
          'map/dtl2',
          'map/metro',
          'map/aftermetro',
          'map/vr',
          'map/plan',
          'bankRate/index',
          'brand/index'
        ],
      },
      
    ],
    window: {
      backgroundTextStyle: 'light',
      navigationBarBackgroundColor: '#fff',
      navigationBarTitleText: 'WeChat',
      navigationBarTextStyle: 'black'
    },
    plugins: {
      // "chooseLocation": {
      //   "version": "1.0.9",
      //   "provider": "wx76a9a06e5b4e693e"
      // },
      // "live-player-plugin": {
      //   "version": "1.3.4",
      //   "provider": "wx2b03c6e691cd7370"
      // }
    },
    permission: {
      "scope.userLocation": {
      "desc": "你的位置信息将用于小程序定位"
      }
    }
  }

  componentWillMount () {
    // Taro.loadFontFace({
    //   global: true,
    //   family: 'pf',
    //   source: 'url("http://h5.honglounews.com/PF.TTF")',
    // })
    mixins.initBaseData()
  }

  componentDidMount () {}
  componentDidShow () {}

  componentDidHide () {}

  componentDidCatchError () {}

  // 在 App 类中的 render() 函数没有实际作用
  // 请勿修改此函数
  render () {
    return (
      <Provider store={store}>
        <Index />
      </Provider>
    )
  }
}

Taro.render(<App />, document.getElementById('app'))
