Blame view

src/components/weather/index.vue 1.83 KB
22fb20b3   songchongxian   城市停车运营监控
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
  <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>