Browse Source

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

lipengtao 6 years ago
parent
commit
1f6c396888
5 changed files with 84 additions and 24 deletions
  1. 19 0
      src/api/loginedHome.js
  2. 3 1
      src/store/modules/user.js
  3. 12 0
      src/utils/auth.js
  4. 29 10
      src/views/home/loginedHome.vue
  5. 21 13
      src/views/home/unloginHome.vue

+ 19 - 0
src/api/loginedHome.js

@ -0,0 +1,19 @@
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,5 +1,5 @@
1 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 4
const user = {
5 5
  state: {
@ -52,6 +52,7 @@ const user = {
52 52
                commit('SET_USERID', dataS.id)
53 53
                commit('SET_NAME', dataS.name)
54 54
                setCookiesName(dataS.name)
55
                setCookiesId(dataS.id)
55 56
              }
56 57
            }
57 58
          }
@ -98,6 +99,7 @@ const user = {
98 99
          commit('SET_NAME', '')
99 100
          commit('SET_SESSION', '')
100 101
          removeCookiesName()
102
          removeCookiesId()
101 103
          sessionStorage.removeItem('uType')
102 104
          resolve()
103 105
        }).catch(error => {

+ 12 - 0
src/utils/auth.js

@ -11,3 +11,15 @@ export function setCookiesName(name) {
11 11
export function removeCookiesName() {
12 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,14 +5,14 @@
5 5
    </el-tabs>
6 6
    <el-row :gutter="10">
7 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 13
            <div class="floatModule">
14 14
              <div>
15
                <el-button type="warning" @click="monitor">实时监测</el-button>
15
                <el-button type="warning" @click="monitor(item)">实时监测</el-button>
16 16
              </div>
17 17
              <div>
18 18
                <el-button type="primary" @click="load">下载数据</el-button>
@ -27,18 +27,34 @@
27 27
</template>
28 28
<script>
29 29
  import download from '@/views/timeMonitoring/component/download'
30
  import { getCookiesId } from '@/utils/auth'
31
  import { siteList } from '@/api/loginedHome'
30 32
  export default {
31 33
    data() {
32 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 45
    components: {
37 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 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 59
      load() {
44 60
        this.$refs.downloadModul.dialogTableVisible = true
@ -50,7 +66,7 @@
50 66
<style rel="stylesheet/scss" lang="scss">
51 67
  .site {
52 68
    li {
53
      margin-bottom: 10px;
69
      margin-bottom: 15px;
54 70
      padding: 20px 20px;
55 71
      list-style: none;
56 72
      box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
@ -64,6 +80,9 @@
64 80
      .name {
65 81
        color: #304156;
66 82
        font-size: 18px;
83
        .state {
84
          margin-left: 10px;
85
        }
67 86
      }
68 87
      .floatModule {
69 88
        position: absolute;

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

@ -7,7 +7,7 @@
7 7
        <bm-point-collection :points="points" shape="BMAP_POINT_SHAPE_WATERDROP" color="red" size="BMAP_POINT_SIZE_SMALL"
8 8
          @click="clickHandler">
9 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 11
          @open="infoWindowOpen">
12 12
          <p v-text="infoWindow.contents"></p>
13 13
        </bm-info-window>
@ -56,6 +56,7 @@
56 56
</template>
57 57
58 58
<script>
59
  import { siteAll } from '@/api/loginedHome'
59 60
  export default {
60 61
    data() {
61 62
      return {
@ -63,29 +64,36 @@
63 64
        infoWindow: {
64 65
          show: true,
65 66
          contents: '11',
66
          position: {}
67
          position: {},
68
          title: ''
67 69
        }
68 70
      }
69 71
    },
70 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 89
    methods: {
75 90
      clickHandler(e) {
76 91
        this.infoWindow = {
77 92
          show: true,
78 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 98
      infoWindowClose(e) {
91 99
        this.infoWindow.show = false