import { wait } from '../../utils/tools'; import { calWeatherContour24H, calWeatherContourRadar, calWeatherContourTm24H } from '../rcview/calculator'; function initState() { return { overallType: '24h', // 24h, radar }; } const shyjview = { state: initState(), reducers: { setOverallType(state, val) { return { ...state, overallType: val } }, reset() { return initState(); } }, effects: dispatch => ({ async showWeather24h(_, state) { /*const progress = (idx) => { dispatch.runtime.setCalculating([idx, 25]); return wait(100); } await progress(0);*/ dispatch.runtime.setCalculating(true); await wait(100); try { //const contour = await calWeatherContour24H(progress); // const contour = await calWeatherContour24H(null,1); const contour = await calWeatherContourTm24H(null,1); //console.log("showWeather24h 32++++++++++++++",contour); dispatch.runtime.setLayerSetting({ contour, dem: false }); dispatch.map.setLayerVisible({ ContourLayer: true }); } finally { dispatch.runtime.setCalculating(false); } // dispatch.runtime.setHome(); }, async showWeather24h1(_, state) { const progress = (idx) => { dispatch.runtime.setCalculating([idx, 25]); return wait(100); } await progress(0); dispatch.runtime.setCalculating(true); await wait(100); try { const contour = await calWeatherContour24H(progress,2); //console.log("showWeather24h 32++++++++++++++",contour); dispatch.runtime.setLayerSettingLoop({ contour, dem: false }); //dispatch.map.setLayerVisible({ ContourLayerLoop: true }); } finally { dispatch.runtime.setCalculatingLoop(false); } // dispatch.runtime.setHome(); }, //24h面雨量逐时间 async showWeather24h1h({myTm}) { const progress = (idx) => { dispatch.runtime.setCalculating([idx, 24]); return wait(100); } await progress(0); dispatch.runtime.setCalculating(true); await wait(100); try { const contour = await calWeatherContour24H(progress,2,myTm); //console.log("showWeather24h 32++++++++++++++",contour); dispatch.runtime.setLayerSettingLoop({ contour, dem: false }); //dispatch.map.setLayerVisible({ ContourLayerLoop: true }); } finally { dispatch.runtime.setCalculatingLoop(false); } // dispatch.runtime.setHome(); }, async showWeatherRadar({myTm}, state) { dispatch.runtime.setCalculating(true); await wait(100); try { const contour = await calWeatherContourRadar({myTm}); //console.log("showWeatherRadar 47+++++",contour); dispatch.runtime.setLayerSetting({ contour, dem: false }); dispatch.map.setLayerVisible({ ContourLayer: true }); } finally { dispatch.runtime.setCalculating(false); } // dispatch.runtime.setHome(); } }) }; export default shyjview;