chengkun
2025-08-06 b54e02d98e42ae73071e3c01e59f12671d13d06a
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
var menu_index = $('#menu_index').val();
const sharedMixin = {
    data() {
        return {
            menu_index: '',
            side_menu_collapse: false,
            el_aside_width: "250px",
            side_menu_show_type: 1,/////左侧菜单收放状态,1=展开,2=收缩
            breadcrumbList: [],
            menuList: [],///菜单列表
            url: '',
        }
    },
    mounted() { },
    created() {
        // this.sharedMethod()
        // console.log(this.$data.menu_index);
        this.getMenu();
    },
    methods: {
        sharedMethod() {
            // 共享的方法逻辑
            console.log(1213213123123);
        },
 
        /////切换语言/////
        switchLanguage(type) {
            /////提交保存到数据库默认语言类型/////
 
            /////切换语言//////
            window.switchLanguage(type);
        },
 
        /////左侧菜单跳转/////
        goto_menu(url) {
            window.location.href = url;
        },
 
        /////左侧菜单收放状态
        show_side_menu() {
            if (this.side_menu_show_type == 1) {
                /////设置为收缩状态/////
                this.el_aside_width = "auto";
                this.side_menu_show_type = 2;
                this.side_menu_collapse = true;
            } else {
                /////设置为展开状态/////
                this.el_aside_width = "250px";
                this.side_menu_show_type = 1;
                this.side_menu_collapse = false;
            }
        },
        getMenu() {
            let that = this;
            let url = "/seller/index/getMenu.html"
            postRequest(url, {}).then(res => {
                if (res.data.code == 200) {
                    that.menuList = res.data.data;
                    that.menu_index = menu_index
                    this.url = new URL(window.location.href)
                    let menus = this.getMenus(that.menuList)
                    let home = [{ title: '首页', menu_url: '/seller/index/index.html' }]
                    if (menus !== undefined) {
                        if (this.url.pathname !== '/seller/index/index.html' && this.url.href !== '/seller/index/index.html') {
                            menus = home.concat(menus)
                        }
                    } else {
                        menus = home
                    }
                    this.breadcrumbList = menus
                }
            });
        },
        getMenus(menuList, arr, z) {
            arr = arr || []
            z = z || 0
            for (let i = 0; i < menuList.length; i++) {
                let item = menuList[i]
                arr[z] = item
 
                if (menuList[i].menu_url != null && menuList[i].menu_url != '') {
                    if (this.url.pathname === menuList[i].menu_url || this.url.pathname.includes(menuList[i].menu_url.slice(0, -5))) {
                        return arr.slice(0, z + 1)
                    }
                }
 
                if (menuList[i].children && menuList[i].children.length) {
                    let res = this.getMenus(menuList[i].children, arr, z + 1)
                    if (res) {
                        return res
                    }
                }
            }
        },
    }
}