hailu
2024-12-02 0bbcee731e5259feadd261e8a84c3e27b8387e01
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
<template>
    <view class="container">
        <view class="search-section">
            <input class="search-input" type="text" v-model="companyName" placeholder="请输入公司名称" />
            <button class="save-btn" @click="saveCompany">保存</button>
        </view>
    </view>
</template>
 
<script>
export default {
    components: {
    },
    data() {
        return {
            companyName: uni.getStorageSync('Address') || '',
            userInfo: {},
        };
    },
    onLoad() {
        // 可以在这里调用获取用户信息的方法
        this.getUserInfo();
    },
    methods: {
        saveCompany() {
            // 保存公司名称到本地存储
            let data = {
                Address: this.companyName,
                LoginName: this.userInfo.LoginName,
                Mail: this.userInfo.Mail,
                Mobile: this.userInfo.Mobile,
                QQ: this.userInfo.QQ,
                RealName: this.userInfo.RealName,
                Wechat: this.userInfo.Wechat,
                id: this.userInfo.Id
            }
            this.$http.post('/user/UpdateAccountBasic', data).then(res => {
                if (res.Check) {
                    // uni.showToast({
                    //     title: '保存成功'
                    // });
                    this.$msg('保存成功');
                }
            });
 
        },
        async getUserInfo() {
            let userInfoRes = await this.$http.post('/User/GetUserInfo', {
                token: uni.getStorageSync('token'),
                id: uni.getStorageSync('userId')
            });
            if (userInfoRes.Check) {
                this.userInfo = userInfoRes.Data;
                uni.setStorageSync('Address', this.userInfo.Address);
            }
        }
    }
}
</script>
 
<style lang="scss" scoped>
page {
    background-color: #F7F7F7;
}
 
.search-section {
    display: flex;
    align-items: center;
    padding: 20upx;
 
    .search-input {
        flex: 1;
        height: 80upx;
        padding: 0 20upx;
        background-color: #fff;
        border: 1px solid #ddd;
        border-radius: 10upx;
        margin-right: 20upx;
    }
 
    .save-btn {
        width: 160upx;
        height: 80upx;
        background-color: #1aad19;
        color: #fff;
        border: none;
        border-radius: 10upx;
        font-size: 32upx;
    }
}
</style>