Browse Source

登录后首页及未登录首页地图列表

lipengtao 6 years ago
parent
commit
1f6c396888

+ 19 - 0
src/api/loginedHome.js

1
import request from '@/utils/request'
2
3
/*  登录用户所有有效站点 */
4
export function siteList(params) {
5
  return request({
6
    url: '/ajax/site/user',
7
    method: 'get',
8
    params
9
  })
10
}
11
12
/*  查询所有有效站点 */
13
export function siteAll(params) {
14
  return request({
15
    url: '/ajax/site/all',
16
    method: 'get',
17
    params
18
  })
19
}

+ 3 - 1
src/store/modules/user.js

1
import { login, logout, getInfo } from '@/api/login'
1
import { login, logout, getInfo } from '@/api/login'
2
import { getCookiesName, setCookiesName, removeCookiesName } from '@/utils/auth'
2
import { getCookiesName, setCookiesName, removeCookiesName, setCookiesId, removeCookiesId } from '@/utils/auth'
3
3
4
const user = {
4
const user = {
5
  state: {
5
  state: {
52
                commit('SET_USERID', dataS.id)
52
                commit('SET_USERID', dataS.id)
53
                commit('SET_NAME', dataS.name)
53
                commit('SET_NAME', dataS.name)
54
                setCookiesName(dataS.name)
54
                setCookiesName(dataS.name)
55
                setCookiesId(dataS.id)
55
              }
56
              }
56
            }
57
            }
57
          }
58
          }
98
          commit('SET_NAME', '')
99
          commit('SET_NAME', '')
99
          commit('SET_SESSION', '')
100
          commit('SET_SESSION', '')
100
          removeCookiesName()
101
          removeCookiesName()
102
          removeCookiesId()
101
          sessionStorage.removeItem('uType')
103
          sessionStorage.removeItem('uType')
102
          resolve()
104
          resolve()
103
        }).catch(error => {
105
        }).catch(error => {

+ 12 - 0
src/utils/auth.js

11
export function removeCookiesName() {
11
export function removeCookiesName() {
12
  return Cookies.remove('nameKey')
12
  return Cookies.remove('nameKey')
13
}
13
}
14
15
export function getCookiesId() {
16
  return Cookies.get('id')
17
}
18
19
export function setCookiesId(id) {
20
  return Cookies.set('id', id)
21
}
22
23
export function removeCookiesId() {
24
  return Cookies.remove('id')
25
}

+ 29 - 10
src/views/home/loginedHome.vue

5
    </el-tabs>
5
    </el-tabs>
6
    <el-row :gutter="10">
6
    <el-row :gutter="10">
7
      <el-col :xs="24" :sm="24" :md="24" :lg="22" :xl="20">
7
      <el-col :xs="24" :sm="24" :md="24" :lg="22" :xl="20">
8
        <ul class="site">
9
          <li>
10
            <div class="name">站点名称<span>站点状态</span></div>
11
            <div>站点编号:xxx</div>
12
            <div>站点位置</div>
8
        <ul class="site" v-if="siteList.length">
9
          <li v-for="item in siteList" :key="item.id">
10
            <div class="name">{{item.name}}<span class="state">{{item.open ? '公开' : '未公开'}}</span></div>
11
            <div>站点编号:{{item.code}}</div>
12
            <div>{{item.location}}</div>
13
            <div class="floatModule">
13
            <div class="floatModule">
14
              <div>
14
              <div>
15
                <el-button type="warning" @click="monitor">实时监测</el-button>
15
                <el-button type="warning" @click="monitor(item)">实时监测</el-button>
16
              </div>
16
              </div>
17
              <div>
17
              <div>
18
                <el-button type="primary" @click="load">下载数据</el-button>
18
                <el-button type="primary" @click="load">下载数据</el-button>
27
</template>
27
</template>
28
<script>
28
<script>
29
  import download from '@/views/timeMonitoring/component/download'
29
  import download from '@/views/timeMonitoring/component/download'
30
  import { getCookiesId } from '@/utils/auth'
31
  import { siteList } from '@/api/loginedHome'
30
  export default {
32
  export default {
31
    data() {
33
    data() {
32
      return {
34
      return {
33
        tabPosition: 'top'
35
        tabPosition: 'top',
36
        siteObj: {
37
          uid: getCookiesId('id'),
38
          active: [1],
39
          pageSize: 20,
40
          pageNo: 1
41
        },
42
        siteList: []
34
      }
43
      }
35
    },
44
    },
36
    components: {
45
    components: {
37
      download
46
      download
38
    },
47
    },
48
    created() {
49
      siteList(this.siteObj).then(res => {
50
        if (res.success) {
51
          this.siteList = res.data.data
52
        }
53
      })
54
    },
39
    methods: {
55
    methods: {
40
      monitor() {
41
        this.$router.push({ name: 'realtimeMonitor', query: { title: '站点名称' }})
56
      monitor(data) {
57
        this.$router.push({ name: 'realtimeMonitor', query: { title: data.name, id: data.id }})
42
      },
58
      },
43
      load() {
59
      load() {
44
        this.$refs.downloadModul.dialogTableVisible = true
60
        this.$refs.downloadModul.dialogTableVisible = true
50
<style rel="stylesheet/scss" lang="scss">
66
<style rel="stylesheet/scss" lang="scss">
51
  .site {
67
  .site {
52
    li {
68
    li {
53
      margin-bottom: 10px;
69
      margin-bottom: 15px;
54
      padding: 20px 20px;
70
      padding: 20px 20px;
55
      list-style: none;
71
      list-style: none;
56
      box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
72
      box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
64
      .name {
80
      .name {
65
        color: #304156;
81
        color: #304156;
66
        font-size: 18px;
82
        font-size: 18px;
83
        .state {
84
          margin-left: 10px;
85
        }
67
      }
86
      }
68
      .floatModule {
87
      .floatModule {
69
        position: absolute;
88
        position: absolute;

+ 21 - 13
src/views/home/unloginHome.vue

7
        <bm-point-collection :points="points" shape="BMAP_POINT_SHAPE_WATERDROP" color="red" size="BMAP_POINT_SIZE_SMALL"
7
        <bm-point-collection :points="points" shape="BMAP_POINT_SHAPE_WATERDROP" color="red" size="BMAP_POINT_SIZE_SMALL"
8
          @click="clickHandler">
8
          @click="clickHandler">
9
        </bm-point-collection>
9
        </bm-point-collection>
10
        <bm-info-window :position="infoWindow.position" title="Info Window Title" :show="infoWindow.show" @close="infoWindowClose"
10
        <bm-info-window :position="infoWindow.position" :title="infoWindow.title" :show="infoWindow.show" @close="infoWindowClose"
11
          @open="infoWindowOpen">
11
          @open="infoWindowOpen">
12
          <p v-text="infoWindow.contents"></p>
12
          <p v-text="infoWindow.contents"></p>
13
        </bm-info-window>
13
        </bm-info-window>
56
</template>
56
</template>
57
57
58
<script>
58
<script>
59
  import { siteAll } from '@/api/loginedHome'
59
  export default {
60
  export default {
60
    data() {
61
    data() {
61
      return {
62
      return {
63
        infoWindow: {
64
        infoWindow: {
64
          show: true,
65
          show: true,
65
          contents: '11',
66
          contents: '11',
66
          position: {}
67
          position: {},
68
          title: ''
67
        }
69
        }
68
      }
70
      }
69
    },
71
    },
70
    created() {
72
    created() {
71
      this.addPoints()
72
      this.infoWindow.position = this.points[0]
73
      // this.addPoints()
74
      // this.infoWindow.position = this.points[0]
75
      siteAll({ active: 1, open: [0, 1] }).then(res => {
76
        if (res.success) {
77
          this.points = res.data
78
          if (this.points && this.points.length) {
79
            this.infoWindow = {
80
              show: true,
81
              position: { lng: this.points[0].lng, lat: this.points[0].lat },
82
              contents: this.points[0].location,
83
              title: this.points[0].name
84
            }
85
          }
86
        }
87
      })
73
    },
88
    },
74
    methods: {
89
    methods: {
75
      clickHandler(e) {
90
      clickHandler(e) {
76
        this.infoWindow = {
91
        this.infoWindow = {
77
          show: true,
92
          show: true,
78
          position: { lng: e.point.lng, lat: e.point.lat },
93
          position: { lng: e.point.lng, lat: e.point.lat },
79
          contents: e.point.lat
80
        }
81
      },
82
      addPoints() {
83
        const points = []
84
        for (var i = 0; i < 50; i++) {
85
          const position = { lng: Math.random() * 40 + 85, lat: Math.random() * 30 + 21 }
86
          points.push(position)
94
          contents: e.point.location,
95
          title: e.point.name
87
        }
96
        }
88
        this.points = points
89
      },
97
      },
90
      infoWindowClose(e) {
98
      infoWindowClose(e) {
91
        this.infoWindow.show = false
99
        this.infoWindow.show = false