schangxiang@126.com
2025-05-20 726693db8c69f3dad6e44e7e3755acfabb005292
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
<template>
    <header-page-layout ref="page" :title="title" base-background-color="#f8f8ff" background-color="#f2f2f2" @headerclick="onHeaderClick">
        <template v-slot:headerleft><u-icon name="arrow-left"></u-icon></template>
        <template v-slot:headerright><u-icon name="list"></u-icon></template>
        <slot></slot>
        <template v-slot:footer v-if="$scopedSlots.footer"><slot name="footer"></slot></template>
        
        <easy-picker :visible.sync="actionVisible" :list="actionList" @select="onActionClick"></easy-picker>
    </header-page-layout>
</template>
 
<script>
import HeaderPageLayout from './HeaderPageLayout.vue'
import EasyPicker from './EasyPicker.vue'
import { downloadApk } from '@/static/js/utils/index.js'
export default {
    name:'defaultHeaderPageCompontent',
    emits:['back'],
    components:{HeaderPageLayout,EasyPicker},
    props:{
        title:{
            type:String,
            default:'Title'
        },
        backCustom:{
            type:Boolean,
            default:false
        }
    },
    data(){
        return {
            actionVisible:false,
            actionList:['刷新','首页','退出']
        }
    },
    methods:{
        onHeaderClick(type){
            if (type==='left'){
                if (this.backCustom===true) {
                    this.$emit('back')
                } else {
                    uni.navigateBack({
                      delta: 1
                    });
                }
            } else {
                this.actionVisible = true
            }
        },
        onActionClick(val){
            if (val==='刷新'){
                uni.navigateBack({
                  delta: 0
                });
            } else if (val==='首页') {
                uni.redirectTo({url:this.$config.path.home})
            } else if (val==='退出') {
                uni.redirectTo({url:this.$config.path.login})
            } else if (val==='新版下载') {
                downloadApk(this.$config)
            }
        },
        getBodyHeight(){
            let res = null;
            if (this.$refs.page) {
                res = this.$refs.page.getBodyHeight()
            }
            return res;
        }
    },
    created() {
        if (process.env.NODE_ENV!=='development') {
            this.actionList.push('新版下载')
        }
    }
}
</script>
 
<style scoped lang="scss">
 
</style>