index.vue 1.85 KB
<template>
  <div class="app-Weather">
    <div class="theme-card">
      <div class="title"><span>PDA设备</span> </div>
      <div class="content"><span>{{ weather_news }}</span></div>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  import httpRequest from '../../api/httpRequest';
  import { mapState, mapActions } from 'vuex'
  export default {
    name: "weather",
    data() {
      return {
        // legendArr: [],
        // color: this.$store.state.color,
        // myChart: {},
        //weather_news: this.$store.state.weatherModule.weather_news
      }
    },

    mounted() {
      this.loadData()
    },
    computed: {
      //weather_news: this.$store.weather.weather_news
      // ...mapState({
      //   weather_news:({weatherModule})=>weatherModule.weather_news
      // })
    },
    methods: {
      //请求天气
      loadData(){
        let params={regionId:130200,indicatorCode:126};
        let url='indicator_exhibition/compare/v1/queryCompareIndicator.json';
        const tmp=this.$store;
        // setTimeout(function () {
        //   tmp.dispatch('weatherModule/act_set_weather_news', '333')
        // },2000);
        //示例
        //this.$store.dispatch("login/changeName", "Jason")//有参
        // this.$store.dispatch("login/alertName")//无参
        //debugger;
        // httpRequest.get(url,params).then(function (res) {
        //   debugger;
        //   tmpStore.weatherModule.commit('set_weather_news','333');
        //   console.log(res.data);
        // })
        //   .catch(function (err) {
        //     //debugger;
        //     console.log(err.message);
        //   });
      },

    }
  }
</script>

<style scoped  lang="scss">
  .app-Weather {
    width: 100%;

    .theme-card{
      height: 100%;
      .content > span{
        color: red;font-size: 12px;text-align: left;
      }
    }

  }
</style>