import Taro, { Component, Config } from '@tarojs/taro'; import Index from './pages/index'; // import 'taro-ui/dist/style/index.scss' import './assets/iconfont/iconfont.css'; import './app.scss'; import { setGlobalData } from './utils/global-data'; import { STORAGE_KEY } from './utils/storage-key'; // 如果需要在 h5 环境中开启 React Devtools // 取消以下注释: // if (process.env.NODE_ENV !== 'production' && process.env.TARO_ENV === 'h5') { // require('nerv-devtools') // } class App extends Component { componentDidMount() { if (Taro.getUpdateManager) { const updateManager = Taro.getUpdateManager(); updateManager.onCheckForUpdate(function(res) { // 请求完新版本信息的回调 console.log('是否有更新:', res.hasUpdate); }); updateManager.onUpdateReady(function() { Taro.showModal({ title: '更新提示', content: '新版本已经准备好,是否重启应用?', success: (res) => { if (res.confirm) { // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 updateManager.applyUpdate(); } }, }); }); updateManager.onUpdateFailed(function() { // 新的版本下载失败 console.log('更新失败'); }); } else { // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示 Taro.showModal({ title: '提示', content: '当前微信版本过低,为了确保所有功能可用请更新微信至最新版本。', }); } const SDKVersionArr = Taro.getSystemInfoSync().SDKVersion.split('.'); console.log('SDKVersionArr: ', SDKVersionArr); const SDKVersion = SDKVersionArr[1]; console.log('SDKVersion: ', SDKVersion); if (Number(SDKVersionArr[0]) < 2) { if (Number(SDKVersion) < 5) { Taro.showModal({ title: '提示', content: '当前微信版本过低,为了确保所有功能可用请更新微信至最新版本。', }); } } setGlobalData( 'activityLaunchOption', Taro.getStorageSync(STORAGE_KEY.ACTIVITY_LAUNCH_OPTION) || null ); if (this.$router.params.referrerInfo.extraData != undefined) { setGlobalData( 'laborUnion', this.$router.params.referrerInfo.extraData ); }else{ console.log('没传'); } } /** * 指定config的类型声明为: Taro.Config * * 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型 * 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string * 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型 */ config: Config = { __usePrivacyCheck__: true, pages: [ 'pages/start/start', 'pages/index/index', 'pages/map/map', 'pages/login/login', 'pages/login-by-phone/login-by-phone', 'pages/count-down/count-down', 'pages/charging/charging', 'pages/order-list/order-list', 'pages/order-detail/order-detail', 'pages/station-detail/station-detail', 'pages/station-detail/equipment/equipment', 'pages/confirm-fee/confirm-fee', 'pages/star-station/star-station', 'pages/my-car/my-car', 'pages/add-car/add-car', 'pages/choose-car-model/choose-car-model', 'pages/setting/setting', 'pages/activity-image/activity-image', 'pages/enterprise-order/index', 'pages/labor-union/labor-union', 'pages/labor-union-login/labor-union-login', 'pages/test/test', ], subPackages: [ { root: 'user-package', name: 'userPackage', pages: [ 'pages/recharge/recharge', 'pages/coupon/coupon', 'pages/invalid-coupon/invalid-coupon', 'pages/invoice-record/invoice-record', 'pages/invoice-form/invoice-form', 'pages/invoice/invoice', 'pages/wallet/wallet', 'pages/refund/refund', 'pages/feedback/feedback', 'pages/help/help', 'pages/h5/h5', 'pages/station-lock/station-lock', ], }, ], preloadRule: { 'pages/index/index': { network: 'all', packages: ['userPackage'], }, }, window: { backgroundTextStyle: 'light', navigationBarBackgroundColor: '#fff', navigationBarTitleText: '驿来特PLUS', navigationBarTextStyle: 'black', }, permission: { 'scope.userLocation': { desc: '你的位置信息将用于小程序位置接口的效果展示', // 高速公路行驶持续后台定位 }, }, requiredPrivateInfos: ['getLocation'], }; // 在 App 类中的 render() 函数没有实际作用 // 请勿修改此函数 render() { return ; } } Taro.render(, document.getElementById('app'));