fix
Helius
2021-02-20 45fb4b11ad51bb38306765b11a6747402e382cee
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
<template>
    <!-- 我的信息 -->
    <view class="font-14">
        <view class="center">
            <image class="header-img" 
                :src="formData.photo?formData.photo:'../../static/images/default-avatar.png'"
                @click="showUploadImage"></image>
        </view>
        <view class="mt-20 content">
            <view class="input-group-row">
                <text class="label">姓名<text class="require">*</text></text>
                <input type="text" v-model="formData.name" maxlength="20"  placeholder="姓名" placeholder-class='placeholder'/>
            </view>
            <view class="input-group-row">
                <text class="label">英文名</text>
                <input type="text" v-model="formData.engName" maxlength="100"  placeholder="英文名" placeholder-class='placeholder'/>
            </view>
            <view class="input-group-row">
                <text class="label">手机号码<text class="require">*</text></text>
                <input type="text" v-model="formData.telphone" maxlength="20"  placeholder="手机号码" placeholder-class='placeholder'/>
            </view>
            <view class="input-group-row">
                <text class="label">性别<text class="require">*</text></text>
                <view class="right-text">
                    <radio-group name="sex" @change="sexChange">
                        <label><radio value="男" color="#518EFF"  class="radio" :checked="formData.sex==='男'"/>男</label>
                        <label><radio value="女" color="#518EFF" class="radio" :checked="formData.sex==='女'"/>女</label>
                    </radio-group>
                </view>
            </view>
            <view class="input-group-row">
                <text class="label">生日</text>
                <view class="right-text">
                    <picker mode="date" @change="dateChange" :end="endDate">
                        <text :class="formData.birthday?'':'gray'">{{formData.birthday?formData.birthday:'请选择生日'}}</text>
                    </picker>
                </view>
            </view>
            <view class="input-group-row">
                <text class="label">Eamil</text>
                <input type="text" v-model="formData.email" maxlength="20"  placeholder="请输入Eamil" placeholder-class='placeholder'/>
            </view>
            <view class="input-group-row">
                <text class="label">服务签名</text>
                <input type="text" v-model="formData.serviceSign" maxlength="100"  placeholder="请输入服务签名" placeholder-class='placeholder'/>
            </view>
            <view class="input-group-row">
                <text class="label">住址</text>
                <input type="text" v-model="formData.address" maxlength="100"  placeholder="请输入住址" placeholder-class='placeholder'/>
            </view>
        </view>
        <button class="blue-btn sticky-footer" :disabled="isDisabled" @click="submit">保存</button>
    </view>
</template>
 
<script>
    import imageUploadUtils from '../../common/jssdk/uploadImg.js'
    export default{
        data(){
            return{
                isDisabled: false,
                formData: {
                    sex: '女',
                    photo: ''
                }
            }
        },
        onLoad() {
            this.loadUserInfo()
        },
        computed: {
            endDate() {
                return this.getDate('end');
            }
        },
        methods:{
            loadUserInfo(){
                this.$httpUtils.request('/api/user/findUserInfo').then((res) => {
                    if(res.status == 200){
                        this.formData = res.mapInfo.detail
                    }
                })
            },
            valid(){
                const {name, telphone, sex} = this.formData;
                if(!name){
                    this.$toast.info('请输入姓名');
                    return false;
                }
                if(!this.$utils.checkPhone(telphone)){
                    this.$toast.info('请填写正确的手机号码');
                    return false;
                }
                if(!sex){
                    this.$toast.info('请选择性别');
                    return false;
                }
            },
            submit(){
                if(this.valid() === false){
                    return;
                }
                let roleInfo = this.$httpUtils.getRoleInfo();
                let token = this.$httpUtils.getToken();
                let userFunction = this.$httpUtils.getUserFunction();
                this.isDisabled = true;
                this.$httpUtils.request('/api/user/modifyUserInfo', this.formData, 'POST').then((res) => {
                    if(res.status == 200){
                        if(roleInfo){
                            roleInfo.name = this.formData.name;
                            roleInfo.photo = this.formData.photo;
                            uni.setStorage({
                                key: 'userInfo',
                                data: JSON.stringify({
                                    token: token,
                                    roleInfo: roleInfo,
                                    userFunction: userFunction
                                }),
                                success: () => {
                                    uni.navigateBack()
                                }
                            });
                        }
                        
                    }
                    this.isDisabled = false;
                    this.$toast.info(res.info)
                }).catch((err) => {
                    this.isDisabled = false;
                })
            },
            sexChange(e){
                this.formData.sex = e.detail.value;
            },
            dateChange(e){
                this.formData.birthday = e.detail.value;
            },
            showUploadImage(){
                imageUploadUtils.show((res) => {
                    this.formData.photo = res;
                })
            },
            getDate(type) {
                const date = new Date();
                let year = date.getFullYear();
                let month = date.getMonth() + 1;
                let day = date.getDate();
                
                if (type === 'start') {
                    year = year - 70;
                }
                month = month > 9 ? month : '0' + month;;
                day = day > 9 ? day : '0' + day;
                return `${year}-${month}-${day}`;
            },
        }
    }
</script>
 
<style>
    .header-img{
        width: 70px;
        height: 70px;
        margin-top: 10px;
        border-radius: 50%;
    }
    .content{
        padding: 0 10px;
    }
    .content-row{
        border-bottom: 1px solid #EDEAF4;
        padding-bottom: 5px;
    }
</style>