cdk
2025-03-24 06e6cf5719a7de9d7919cee2f6fcc3cfc6f9eb9d
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<template>
    <uni-base-page :title="navTitle" :footer="false">
        <view slot="page">
            <view v-if="loginInfo.hasLogin">
                <view class="example-body">
                    <uni-grid :column="col">
                        <uni-grid-item  v-for="(item, index) in userMenu" :index="index" :key="index">
                            <!-- 目录 -->
                            <navigator v-if="item.menuType" class="grid-item-box" hover-class="none" :url="`/pages/BasePages/menuContainer?PRA001=${item.PRA001}&title=${item.PRA003}&parentTitle=${myName}`">
                                <image class="imgMenu" :src="'../../static/img/imgMenu/'+item.PRA009+'.png'" ></image>
                                <uni-notice-bar class="text" v-if="item.titleLength>6" :speed="30" style="padding:0;margin-bottom:0;"  textSize="11px" background-color="#ffffff" color="#000000" :scrollable="item.titleLength>6" :single="true" :text="item.PRA003" />
                                <text v-else class="text">{{ item.PRA003 }}</text>
                            </navigator>
                            <!-- 程序 -->
                            <navigator v-if="!item.menuType"  navigateTo class="grid-item-box" hover-class="none"  :url="`..${item.PRA009}?title=${item.PRA003}`">
                                <image class="imgMenu" :src="'../../static/img/imgMenu/'+item.pic+'.png'" ></image>
                                <uni-notice-bar class="text" v-if="item.titleLength>=6" style="padding:0;margin-bottom:0;" textSize="11px" background-color="#ffffff" color="#000000" :speed="30" :scrollable="true" :single="true" :text="item.PRA003" />
                                <text v-else class="text">{{ item.PRA003 }}</text>
                            </navigator> 
                        </uni-grid-item>
                    </uni-grid>
                </view>
            </view>
            <view v-if="!loginInfo.hasLogin" >
                <view class="title">
                    您好 游客。
                </view>
                <view class="ul">
                    <view>这是 XXMES 首页。</view>
                    <view>在 “我的” 中点击 “登录” 可以 “登录您的账户”</view>
                </view>
            </view>
        </view>
    </uni-base-page>
</template>
 
<script>
    export default {
 
        data() {
            return {
                loginInfo:this.$loginInfo,
                userMenu:this.$userMenu,
                color:this.$defaultColor,
                PRA001:'',
                navTitle:'',//标题
                col:4,//菜单列数
                c:['#00007f','#ff0000','#ffff7f','#0055ff'],
                myName:''
                
            };
        },
        methods: {
            getMenu(isShowMask){
                if(isShowMask) uni.showLoading({mask:true,title:"加载中..."});
                this.$getUserMenu({ 
                    programId: this.PRA001,
                    success:(res)=>{
                        this.userMenu = res;
                        uni.stopPullDownRefresh();
                    },
                    fail:(err)=>{
                        
                    },complete(){
                        if(isShowMask) uni.hideLoading();  
                    }
                });
            },
            getMyName(){
                var pages = getCurrentPages();
                var page = pages[pages.length - 1];  
                var currentPageTitle = page.$holder.navigationBarTitleText;
                this.myName =  currentPageTitle;
                console.log(this.myName);
            }
        },  
        onLoad(option) { 
            this.$setTitle(option);
            if (!this.loginInfo.hasLogin) {
                uni.showModal({
                    title: '未登录',
                    content: '您未登录,需要登录后才能继续',
                    /**
                     * 如果需要强制登录,不显示取消按钮
                     */
                    showCancel: !this.loginInfo.forcedLogin,
                    success: (res) => {
                        if (res.confirm) {
                            /**
                             * 如果需要强制登录,使用reLaunch方式
                             */
                            if (this.loginInfo.forcedLogin) {
                                uni.reLaunch({
                                    url: 'login'
                                });
                            } else {
                                uni.navigateTo({
                                    url: 'login'
                                });
                            }
                        }
                    }
                });
            }else{
                this.PRA001 = option.PRA001 || '';
                this.navTitle= option.PRA003 ||'';
                this.getMenu(); 
            }
        }, 
        mounted:function(){
            // if(this.$route.query.title){ //页面传参,需继承uni-base-page自定义组件
            //     //设置标题信息
            //     alert(this.$route.query.title);
            //     //console.log("页面传参");
            //     uni.setNavigationBarTitle({
            //         title: this.$route.query.title
            //     });
            // }
            // else if(this.$thistitle){ //通过全局参数配置的当前模块的标题,需继承uni-base-page自定义组件
            //     //设置标题信息
            //     //console.log("通过全局参数配置的当前模块的标题");
            //     alert(this.$route.query.title);
            //     uni.setNavigationBarTitle({
            //         title: this.$thistitle
            //     });
            // }else{//默认调用pages.json,无需继承uni-base-page自定义组件
            //     alert("没有标题");
            //     //console.log("默认调用pages.json"); 
            // }
        },
        onBackPress(options) {
            //返回的时候清空当前菜单分组,防止下次打开别的分组时候界面会展示上一次的菜单分组
            if (options.from === 'navigateBack') {  
                return false; 
            } 
            uni.navigateBack({
                delta: 1
            });
            return true;  
        },
        onPullDownRefresh() {
            if (this.loginInfo.hasLogin)
                this.getMenu(true);
        },
    }
</script>
 
<style>
    .text{
        /* color: #ffffff; */
        /* font-size: 15px; */
        font-weight: 900;
    }
    
    .example-body {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 0;
        font-size: 14px;
        background-color: #ffffff;
        width: 100%;
        height: 100%;
    }
        
    .grid-item-box {
        flex: 1;
        /* position: relative; */
        /* #ifndef APP-NVUE */
        display: flex;
        /* #endif */
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 5px 0;
    }
    
    .imgMenu{ 
        width: 100rpx;
        height: 100rpx;
    }
    
    image,
    swiper,
    .img-view {
        width: 100%;
        height: 300rpx;
        margin-bottom: 10rpx;
    }
</style>