linwe
2024-07-29 9b476a2eb0dd47d941672f79cfc333b2fccf461f
代码优化
11 files modified
3 files added
377 ■■■■■ changed files
api/place/place.js 9 ●●●●● patch | view | raw | blame | history
common/common.js 36 ●●●●● patch | view | raw | blame | history
manifest.json 6 ●●●●● patch | view | raw | blame | history
pages.json 15 ●●●●● patch | view | raw | blame | history
pages/circle/index.vue 4 ●●●● patch | view | raw | blame | history
pages/home/index.vue 9 ●●●●● patch | view | raw | blame | history
pages/myMap/myMap.vue 273 ●●●●● patch | view | raw | blame | history
pages/statistics/index.vue 6 ●●●● patch | view | raw | blame | history
pages/user/center.vue 9 ●●●●● patch | view | raw | blame | history
static/img/tabbar-09-selected.png patch | view | raw | blame | history
static/img/tabbar-09.png patch | view | raw | blame | history
subPackage/house/houseNumber/siteInspect.vue 4 ●●●● patch | view | raw | blame | history
subPackage/label/check.vue 3 ●●●●● patch | view | raw | blame | history
subPackage/school/security.vue 3 ●●●●● patch | view | raw | blame | history
api/place/place.js
@@ -104,4 +104,13 @@
        method: 'GET',
        params
    })
}
export const getNearbyPlaceList = (params) => {
    return http.request({
        url: '/blade-place/place/getNearbyPlaceList',
        method: 'GET',
        params
    })
}
common/common.js
@@ -105,7 +105,13 @@
                url: '/pages/home/index'
            },
            {
                name: '圈子',
                name: '周边',
                iconPathSelected: '/static/img/tabbar-09-selected.png',
                iconPath: '/static/img/tabbar-09.png',
                url: '/pages/myMap/myMap'
            },
            {
                name: '邻里圈',
                iconPathSelected: '/static/img/tabbar-02-selected.png',
                iconPath: '/static/img/tabbar-02.png',
                url: '/pages/circle/index'
@@ -125,7 +131,13 @@
                url: '/pages/home/index'
            },
            {
                name: '圈子',
                name: '周边',
                iconPathSelected: '/static/img/tabbar-09-selected.png',
                iconPath: '/static/img/tabbar-09.png',
                url: '/pages/myMap/myMap'
            },
            {
                name: '协同圈',
                iconPathSelected: '/static/img/tabbar-08-selected.png',
                iconPath: '/static/img/tabbar-08.png',
                url: '/pages/circle/index'
@@ -153,7 +165,13 @@
                url: '/pages/home/index'
            },
            {
                name: '圈子',
                name: '周边',
                iconPathSelected: '/static/img/tabbar-09-selected.png',
                iconPath: '/static/img/tabbar-09.png',
                url: '/pages/myMap/myMap'
            },
            {
                name: '协同圈',
                iconPathSelected: '/static/img/tabbar-02-selected.png',
                iconPath: '/static/img/tabbar-02.png',
                url: '/pages/circle/index'
@@ -180,6 +198,12 @@
                url: '/pages/home/index'
            },
            {
                name: '周边',
                iconPathSelected: '/static/img/tabbar-09-selected.png',
                iconPath: '/static/img/tabbar-09.png',
                url: '/pages/myMap/myMap'
            },
            {
                name: '圈子',
                iconPathSelected: '/static/img/tabbar-02-selected.png',
                iconPath: '/static/img/tabbar-02.png',
@@ -206,6 +230,12 @@
                url: '/pages/home/index'
            },
            {
                name: '周边',
                iconPathSelected: '/static/img/tabbar-09-selected.png',
                iconPath: '/static/img/tabbar-09.png',
                url: '/pages/myMap/myMap'
            },
            {
                name: '我的',
                iconPathSelected: '/static/img/tabbar-03-selected.png',
                iconPath: '/static/img/tabbar-03.png',
manifest.json
@@ -230,10 +230,8 @@
        },
        "sdkConfigs" : {
            "maps" : {
                "amap" : {
                    "key" : "7fa69abe1defd5888bb85bc736cda874",
                    "securityJsCode" : "8ac9e5f522c62ed6e3a5800a87b0d140",
                    "serviceHost" : ""
                "qqmap" : {
                    "key" : "EG5BZ-FTCKW-SEMRD-3CVLI-X6MNH-QKBLS"
                }
            }
        },
pages.json
@@ -84,6 +84,13 @@
                "navigationBarBackgroundColor": "#fff",
                "navigationBarTextStyle": "black"
            }
        },
        {
            "path": "pages/myMap/myMap",
            "style": {
                "navigationBarTitleText": "地图",
                "enablePullDownRefresh": false
            }
        }
    ],
    "subPackages": [
@@ -1392,9 +1399,15 @@
                "text": "首页"
            },
            {
                "pagePath": "pages/circle/index",
                "pagePath": "pages/myMap/myMap",
                "iconPath": "static/img/tabbar-02.png",
                "selectedIconPath": "static/img/tabbar-02-selected.png",
                "text": "周边"
            },
            {
                "pagePath": "pages/circle/index",
                "iconPath": "static/img/tabbar-09.png",
                "selectedIconPath": "static/img/tabbar-09-selected.png",
                "text": "圈子"
            },
            {
pages/circle/index.vue
@@ -93,7 +93,7 @@
            </view>
        </z-paging>
        <tabBar :current="1" :list="tabList" />
        <tabBar :current="2" :list="tabList" />
    </view>
@@ -475,4 +475,4 @@
        padding: 10rpx 0;
        width: 200rpx;
    }
</style>
</style>
pages/home/index.vue
@@ -279,6 +279,8 @@
                                    </view>
                                </u-grid-item>
                            </block>
                            <u-grid-item v-if="roleName == 'xyzt'"
                                @click="navigatorPage('/subPackage/school/troubleTaskList')">
@@ -648,7 +650,6 @@
                            }
                        ]
                    },
                ],
@@ -931,7 +932,7 @@
            },
            changeTabs(e) {
                // console.log(item);
                console.log("******eeeee**********", e);
                this.tabIndex = e
            },
@@ -1211,7 +1212,7 @@
                this.liveList = this.setLiveMenu(this.hasMenu('生活'));
                this.jobList = this.hasMenu('工作台')
                this.sectionList = this.hasMenu('首页菜单')
                let taskMenuList = this.hasMenu('待办事项菜单')
                let taskMenuList = this.hasMenu('待办事项')
                if (this.menuList.length) {
                    this.getContactMenu();
                    this.getHouseMenu();
@@ -1661,4 +1662,4 @@
<style lang="scss">
    @import "./index.scss";
</style>
</style>
pages/myMap/myMap.vue
New file
@@ -0,0 +1,273 @@
<template>
    <view class="base_body">
        <map :markers="markers" @tap="regionchange" :circles="circles" :show-compass="true" :scale="scale" id="map1"
            style="width: 100%; height: 100%;" :latitude="latitude" :longitude="longitude">
            <cover-view slot="callout">
                <block v-for="(item,index) in markers" :key="index">
                    <cover-view class="customCallout" :marker-id="item.id" v-if="item.title">
                        <cover-view class="content">
                            <!-- <view>随意指定</view> -->
                            {{item.title}}
                        </cover-view>
                    </cover-view>
                </block>
            </cover-view>
            <view class="home-icon" @click="backMyLocation">
                <u-icon name="home" color="#000" size="28px"></u-icon>
                <text style="font-size: 12px;">我的位置</text>
            </view>
        </map>
        <tabBar :current="1" :list="tabbarList" />
    </view>
</template>
<script>
    import tabBar from "@/components/tabBar/tabBar.vue"
    import {
        getTabbarList
    } from "@/common/common.js"
    import {
        getNearbyPlaceList
    } from '@/api/place/place.js'
    export default {
        components: {
            tabBar
        },
        data() {
            return {
                roleType: 1,
                addressType: 1,
                user_info: {},
                color: "#017BFC",
                tabbarList: [],
                map: '',
                scale: 18,
                latitude: '', // 地图默认显示的维度
                longitude: '', // 地图默认显示的纬度
                markers: [],
                //在地图上显示圈
                circles: [{
                    longitude: 116.2529,
                    latitude: 39.542,
                    color: '#DEDEF8',
                    fillColor: '#DEDEF8', // 填充颜色
                    radius: 150, // 圆半径
                    strokeWidth: 1 // 边
                }],
            }
        },
        onLoad() {
        },
        onReady() {},
        onShow() {
            let role = uni.getStorageSync('activeRole')
            if (role.roleName == "居民" || role.roleName == '无诈') {
                this.tabbarList = getTabbarList(1)
                this.roleType = 1
                this.color = "#017BFC"
                // this.tabbarIndex = 1;
                this.tabbarIndex = 2
            } else if (role.roleName == "民警") {
                this.tabbarList = getTabbarList(2)
                this.roleType = 2;
                this.color = "#003399"
                // this.tabbarIndex = 2;
                this.tabbarIndex = 3;
            } else if (role.roleName == "系统管理员") {
                this.tabbarList = getTabbarList(4)
                this.roleType = 1
                this.color = "#017BFC";
                // this.tabbarIndex = 2;
                this.tabbarIndex = 3;
            } else if (role.roleName == "网格员") {
                this.tabbarList = getTabbarList(3)
                this.roleType = 1
                this.color = "#017BFC";
                // this.tabbarIndex = 2;
                this.tabbarIndex = 3;
            } else if (role.roleName == '校园主体' || role.roleName == '校园通用') {
                this.tabbarList = getTabbarList(5);
                this.roleType = 5
            } else {
                this.tabbarList = getTabbarList(1)
                this.roleType = 1
                this.color = "#017BFC"
                // this.tabbarIndex = 1;
                this.tabbarIndex = 2
            }
            if (uni.getStorageSync("siteInfo")) {
                this.addressType = uni.getStorageSync("siteInfo").addressType;
            }
            this.getLocations()
        },
        methods: {
            backMyLocation() {
                this.getLocations()
            },
            async getLocations() {
                let param
                let that = this
                await uni.getLocation({
                    type: 'gcj02',
                    isHighAccuracy: true,
                    success: function(res) {
                        console.log('当前位置的经度:' + res.longitude);
                        console.log('当前位置的纬度:' + res.latitude);
                        that.latitude = res.latitude
                        that.longitude = res.longitude
                        that.getList()
                    }
                });
            },
            regionchange(e) {
                console.log("****************", e)
                this.latitude = e.detail.latitude
                this.longitude = e.detail.longitude
                this.markers = []
                // if (this.latitude || this.longitude) {
                //     return
                // }
                this.getList()
            },
            getList() {
                this.markers.push({
                    id: 999,
                    latitude: this.latitude,
                    longitude: this.longitude,
                    title: '',
                    joinCluster: false,
                    width: '36px', //设置宽高
                    height: '46px',
                    customCallout: {
                        anchorY: 0, // Y轴偏移量
                        anchorX: 50, // X轴偏移量
                        display: "ALWAYS" // 一直展示
                    },
                    label: {
                        content: '当前位置',
                        color: '#fff',
                        fontSize: 12,
                        borderRadius: 5,
                        padding: 5,
                        textAlign: 'center',
                        bgColor: '#2979ff',
                    }
                })
                getNearbyPlaceList({
                    lat: this.latitude,
                    lng: this.longitude
                }).then(res => {
                    let data = res.data;
                    for (var i = 0; i < data.length; i++) {
                        this.markers.push({
                            id: i,
                            latitude: data[i].lat,
                            longitude: data[i].lng,
                            title: data[i].placeName,
                            joinCluster: true,
                            width: '26px', //设置宽高
                            height: '36px',
                            customCallout: {
                                anchorY: 0, // Y轴偏移量
                                anchorX: 50, // X轴偏移量
                                display: "ALWAYS" // 一直展示
                            },
                        })
                    }
                    console.log("*********", data)
                })
            }
        }
    }
</script>
<style>
    .base_body {
        width: 100%;
        height: 100%;
        position: absolute;
    }
    /* 水平,垂直居中 */
    .base_all_center {
        justify-content: center;
        align-items: center;
    }
    /* 垂直居中 */
    .base_center_vertical {
        display: flex;
        align-items: center;
    }
    /* 水平居中 */
    .base_center_horizontal {
        display: flex;
        justify-content: center;
    }
    /* 垂直布局 */
    .base_column {
        display: flex;
        flex-direction: column;
    }
    /* 横向布局 */
    .base_row {
        display: flex;
        flex-direction: row;
    }
    /* 基础dialog */
    .base_dialog {
        width: 100%;
        height: 80%;
        position: absolute;
        top: 0px;
        background: rgba(0, 0, 0, 0.5);
    }
    /* *************************************** */
    .customCallout {
        box-sizing: border-box;
        background-color: #fff;
        border: 1px solid #ccc;
        border-radius: 30px;
        /* width: 150px; */
        /* height: 40px; */
        display: inline-flex;
        padding: 5px 10px;
        justify-content: center;
        align-items: center;
    }
    .content {
        flex: 0 1 auto;
        margin: 0 10px;
        font-size: 14px;
    }
    .home-icon {
        border-radius: 10px;
        position: absolute;
        bottom: 120px;
        left: 83%;
        color: black;
        background-color: #fff;
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 55px;
        height: 55px;
    }
</style>
pages/statistics/index.vue
@@ -330,17 +330,17 @@
            if (roleName == "网格员") {
                this.tabList = getTabbarList(3);
                // this.tabbarIndex = 1;
                this.tabbarIndex = 2;
                this.tabbarIndex = 3;
            }
            if (roleName == "民警") {
                this.tabList = getTabbarList(2);
                // this.tabbarIndex = 1;
                this.tabbarIndex = 2;
                this.tabbarIndex = 3;
            }
            if (roleName == "系统管理员") {
                this.tabList = getTabbarList(4);
                // this.tabbarIndex = 1;
                this.tabbarIndex = 2;
                this.tabbarIndex = 3;
            }
            this.refreshData();
        },
pages/user/center.vue
@@ -128,7 +128,7 @@
                user_info: {},
                color: "#017BFC",
                tabbarList: [],
                tabbarIndex: 2
                tabbarIndex: 3
            };
        },
@@ -140,19 +140,19 @@
                this.roleType = 1
                this.color = "#017BFC"
                // this.tabbarIndex = 1;
                this.tabbarIndex = 2
                this.tabbarIndex = 3
            } else if (role.roleName == "民警") {
                this.tabbarList = getTabbarList(2)
                this.roleType = 2;
                this.color = "#003399"
                // this.tabbarIndex = 2;
                this.tabbarIndex = 3;
                this.tabbarIndex = 4;
            } else if (role.roleName == "系统管理员") {
                this.tabbarList = getTabbarList(4)
                this.roleType = 1
                this.color = "#017BFC";
                // this.tabbarIndex = 2;
                this.tabbarIndex = 3;
                this.tabbarIndex = 4;
            } else if (role.roleName == "网格员") {
                this.tabbarList = getTabbarList(3)
                this.roleType = 1
@@ -161,6 +161,7 @@
                this.tabbarIndex = 3;
            } else if (role.roleName == '校园主体' || role.roleName == '校园通用') {
                this.tabbarList = getTabbarList(5);
                this.tabbarIndex = 2;
                this.roleType = 5
            } else {
                this.tabbarList = getTabbarList(1)
static/img/tabbar-09-selected.png
static/img/tabbar-09.png
subPackage/house/houseNumber/siteInspect.vue
@@ -381,6 +381,10 @@
                        arr.push(i);
                        for (let k = 0, kk = data[i].children.length; k < kk; k++) {
                            // this.info.patrolRecordVOList.push(obj);
                            for (var j = 0; j < data[i].children.length; j++) {
                                data[i].children[j].state = 1
                            }
                            count += 1;
                        }
                    }
subPackage/label/check.vue
@@ -225,6 +225,9 @@
                        arr.push(i);
                        for (let k = 0, kk = data[i].children.length; k < kk; k++) {
                            // this.info.patrolRecordVOList.push(obj);
                            for (var j = 0; j < data[i].children.length; j++) {
                                data[i].children[j].state = 1
                            }
                            count += 1;
                        }
                    }
subPackage/school/security.vue
@@ -323,6 +323,9 @@
                        arr.push(i);
                        for (let k = 0, kk = data[i].children.length; k < kk; k++) {
                            // this.info.patrolRecordVOList.push(obj);
                            for (var j = 0; j < data[i].children.length; j++) {
                                data[i].children[j].state = 1
                            }
                            count += 1;
                        }
                    }