智慧农业大数据平台
shuishen
2022-08-05 13313f7a3d725783e08a7e6c9727c88ca9486010
设置token,卷帘
5 files modified
190 ■■■■■ changed files
src/components/selectTime/index.vue 102 ●●●●● patch | view | raw | blame | history
src/router/axios.js 4 ●●●● patch | view | raw | blame | history
src/store/modules/user.js 10 ●●●● patch | view | raw | blame | history
src/utils/auth.js 8 ●●●●● patch | view | raw | blame | history
src/views/login/index.vue 66 ●●●● patch | view | raw | blame | history
src/components/selectTime/index.vue
@@ -2,7 +2,7 @@
    <!--时间线-->
    <div>
        <div class="current-select" @click="listFlag = !listFlag">
            <div class="title">2019-2M第一季度</div>
            <div class="title">{{ currentTitle }}</div>
            <i class="el-icon-caret-bottom"></i>
        </div>
@@ -43,13 +43,14 @@
    methods: {
        init () {
            this.currentTitle = this.selectList[0].title
            this.currentIndex = 0
            if (this.leftOrRight == 'left') {
                this.leftAddLayer()
                this.currentTitle = this.selectList[0].title
                this.currentIndex = 0
                this.leftAddLayer(this.selectList[0])
            } else {
                this.rightAddLayer()
                this.currentTitle = this.selectList[1].title
                this.currentIndex = 1
                this.rightAddLayer(this.selectList[1])
            }
        },
@@ -61,76 +62,32 @@
            }
        },
        leftAddLayer () {
        leftAddLayer (params) {
            leftCurrentLayer = global.viewer.imageryLayers.addImageryProvider(
                new global.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
                    url: 'http://arcgis.jxpskj.com:6080/arcgis/rest/services/nanchengyjjddom/MapServer/WMTS',
                    // url: 'http://arcgis.jxpskj.com:6080/arcgis/rest/services/nanchengdom/MapServer/WMTS',
                    layer: 'nanchengyjjddom',
                    style: 'default',
                    tileMatrixSetID: 'default028mm',
                    format: 'image/png',
                    tilingScheme: new global.DC.Namespace.Cesium.GeographicTilingScheme(),
                    maximumLevel: 19,
                    tileMatrixLabels: [
                        '0',
                        '1',
                        '2',
                        '3',
                        '4',
                        '5',
                        '6',
                        '7',
                        '8',
                        '9',
                        '10',
                        '11',
                        '12',
                        '13',
                        '14',
                        '15',
                        '16',
                        '17',
                        '18',
                        '19'
                    ]
                    url: params.url,
                    layer: params.layer,
                    style: params.style,
                    tileMatrixSetID: params.tileMatrixSetID,
                    format: params.format,
                    tilingScheme: params.tilingScheme,
                    maximumLevel: params.maximumLevel,
                    tileMatrixLabels: params.tileMatrixLabels
                }), 10
            )
        },
        rightAddLayer () {
        rightAddLayer (params) {
            rightCurrentLayer = global.viewer.mapSplit.addBaseLayer(
                new global.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({
                    url: 'http://arcgis.jxpskj.com:6080/arcgis/rest/services/nanchengdom/MapServer/WMTS',
                    // url: 'http://arcgis.jxpskj.com:6080/arcgis/rest/services/nanchengdom/MapServer/WMTS',
                    layer: 'nanchengdom',
                    style: 'default',
                    tileMatrixSetID: 'default028mm',
                    format: 'image/png',
                    tilingScheme: new global.DC.Namespace.Cesium.GeographicTilingScheme(),
                    maximumLevel: 19,
                    tileMatrixLabels: [
                        '0',
                        '1',
                        '2',
                        '3',
                        '4',
                        '5',
                        '6',
                        '7',
                        '8',
                        '9',
                        '10',
                        '11',
                        '12',
                        '13',
                        '14',
                        '15',
                        '16',
                        '17',
                        '18',
                        '19'
                    ]
                    url: params.url,
                    layer: params.layer,
                    style: params.style,
                    tileMatrixSetID: params.tileMatrixSetID,
                    format: params.format,
                    tilingScheme: params.tilingScheme,
                    maximumLevel: params.maximumLevel,
                    tileMatrixLabels: params.tileMatrixLabels
                }), 21
            )
        },
@@ -200,12 +157,15 @@
            }
            if (this.leftOrRight) {
                this.currentTitle = item.title
                this.currentIndex = index
                if (this.leftOrRight == 'left') {
                    this.removeLeftAddLayer()
                    this.leftAddLayer()
                    this.leftAddLayer(item)
                } else {
                    this.removeRightAddLayer()
                    this.rightAddLayer()
                    this.rightAddLayer(item)
                }
                this.listFlag = false
@@ -279,6 +239,8 @@
    li {
        line-height: 30px;
        text-align: center;
        cursor: pointer;
    }
}
</style>
src/router/axios.js
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-07-29 15:19:13
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2022-08-05 10:38:40
 * @LastEditTime: 2022-08-05 10:51:10
 * @FilePath: \zhny-dsj\src\router\axios.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
@@ -53,7 +53,7 @@
        console.log(code, 555)
        if (code === -1) {
        if (code == 403 && res.data.data == 'token 验证失败!') {
            sessionStorage.removeItem('token')
            router.push('/login')
        } else {
src/store/modules/user.js
@@ -1,4 +1,11 @@
import * as auth from '@/utils/auth'
/*
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-07-29 15:11:35
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2022-08-05 11:47:57
 * @FilePath: \zhny-dsj\src\store\modules\user.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
const user = {
    state: {
@@ -7,7 +14,6 @@
    mutations: {
        setUser (state, user) {
            state.user = user
            auth.setToken(user.access_token)
        }
    },
    actions: {
src/utils/auth.js
@@ -1,3 +1,11 @@
/*
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-07-28 17:50:14
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2022-08-05 11:45:20
 * @FilePath: \zhny-dsj\src\utils\auth.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
export const getToken = () => {
    return window.sessionStorage.getItem('token')
}
src/views/login/index.vue
@@ -37,53 +37,54 @@
</template>
<script>
import nprogress from "nprogress"
import md5 from "js-md5"
import axios from "axios"
import { EventBus } from "../../eventBus/event-bus"
import nprogress from 'nprogress'
import md5 from 'js-md5'
import axios from 'axios'
import * as auth from '@/utils/auth'
import { EventBus } from '../../eventBus/event-bus'
export default {
    name: "AppRegister",
    name: 'AppRegister',
    data () {
        return {
            user: {
                username: "",
                password: "",
                username: '',
                password: ''
            },
            rules: {
                username: [
                    { required: true, message: "用户名不能为空", trigger: "blur" },
                    { required: true, message: '用户名不能为空', trigger: 'blur' },
                    {
                        min: 3,
                        max: 10,
                        message: "用户账号长度在3~10个字符之间",
                        trigger: "blur",
                    },
                        message: '用户账号长度在3~10个字符之间',
                        trigger: 'blur'
                    }
                ],
                password: [
                    { required: true, message: "密码不能为空", trigger: "blur" },
                    { required: true, message: '密码不能为空', trigger: 'blur' },
                    {
                        min: 3,
                        max: 10,
                        message: "用户密码长度在3~10个字符之间",
                        trigger: "blur",
                    },
                ],
                        message: '用户密码长度在3~10个字符之间',
                        trigger: 'blur'
                    }
                ]
            },
            errors: null,
            newAxios: null,
            newAxios: null
        }
    },
    created () {
        var that = this
        this.newAxios = axios.create({
            baseURL: "http://182.106.212.58:8013/api",
            baseURL: 'http://182.106.212.58:8013/api',
            timeout: 600000,
            headers: {
                Authorization: "Basic c2FiZXI6c2FiZXJfc2VjcmV0",
                "Tenant-Id": "000000",
            },
                Authorization: 'Basic c2FiZXI6c2FiZXJfc2VjcmV0',
                'Tenant-Id': '000000'
            }
        })
        document.onkeydown = (e) => {
@@ -100,30 +101,31 @@
                    nprogress.start()
                    this.newAxios({
                        method: "POST",
                        url: "/blade-auth/oauth/token",
                        method: 'POST',
                        url: '/blade-auth/oauth/token',
                        params: {
                            username: username,
                            password: md5(password),
                            tenantId: "000000",
                        },
                            tenantId: '000000'
                        }
                    }).then((res) => {
                        if (res.data.access_token) {
                            this.$store.commit("setUser", res.data)
                            this.$router.push({ path: "/" })
                            this.$store.commit('setUser', res.data)
                            auth.setToken(res.data.access_token)
                            this.$router.push({ path: '/' })
                        } else {
                            this.$message({
                                type: "warning",
                                message: "用户名或密码不正确,请重新输入",
                                type: 'warning',
                                message: '用户名或密码不正确,请重新输入'
                            })
                        }
                        nprogress.done()
                    })
                }
            })
        },
    },
};
        }
    }
}
</script>
<style scoped lang="scss">