#
whycq
2023-11-20 f14e736c5448da6a5433da12be8f7e64617cf0f7
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
<template>
    <view>
        <view class="status_bar">
            <!-- 这里是状态栏 -->
        </view>
        <uni-nav-bar left-icon="left" title="合同管理" @clickLeft="back" @clickRight="scan"  :fixed="true"
            :border="false" rightWidth="160rpx" leftWidth="160rpx"
            >
            <block slot="right">
                <view class="city">
                    <view>
                        <text class="uni-nav-bar-text">{{user.username}}</text>
                    </view>
                    <uni-icons type="arrowdown" color="#333333" size="20" />
                </view>
            </block>
         </uni-nav-bar>
    </view>
</template>
 
<script>
    import user from '@/pages/api/user/user.js'
    export default {
        data() {
            return {
                user: {
                    username: '',
                    id: 0,
                    type: ''
                },
                falg: true
            }
        },
        onShow() {
            let that = this
            uni.$on('isRefresh',function(data){
                console.log(data);
                that.user.username = data.title
                that.user.id = data.id
                that.user.type = data.key
                that.falg = false
            })
            setTimeout(()=> {
                // this.getCsmtr1()
            },50)
            if (this.falg) {
                this.getDetail()
            }
        },
        methods: {
            async getDetail() {
                let res = await user.getDetail()
                console.log(res);
                if (res.code === 200) {
                    this.user.username = res.data.username
                    this.user.id = res.data.id
                } else if (res.code === 403) {
                    this.backLogin(res)
                }
            },
            backLogin(res) {
                uni.showToast({title: res.msg, icon: "none", position: 'top'})
                setTimeout(() => {
                    uni.reLaunch({
                        url: '../../login/login'
                    });
                }, 1000);
            },
            back() {
                uni.navigateBack({
                })
            },
            scan() {
                uni.navigateTo({
                    url: '/pages/authority/authority'
                })
            },
        }
    }
</script>
 
<style>
 
</style>