zhaojs
2023-06-25 afb7bcf6e31979be352bfcf14812d52339478cef
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
<template>
    <view class="setNickname-wrapper wrapperLayer">
        <titleBar :titleText="'昵称'" :pageForm='"setNickname"'></titleBar>
        <view class="input-container pd30 rowCenBet">
            <input class="ipt" type="text" v-model="nickname" placeholder="请输入昵称" placeholder-class="plc"/>
            <view class="iconfont rowCenSta clear" @tap="clearInp()" v-if="nickname">
                &#xe641;
            </view>
        </view>
        <view class="btn-content pd30 rowCenCen" @tap="submit()">
            <view class="cfm-btn rowCenCen"><view>确认修改</view></view>
        </view>
    </view>
</template>
 
<script>
    import util from '../../../utils/utils.js'
    import titleBar from '@/components/backTitlebar.vue'
    export default {
        components: {
            titleBar
        },
        data(){
            return{
                nickname:''
            }
        },
        onLoad(options) {
            this.nickname = options.nickName
        },
        methods:{
            submit(){
                var that = this;
                if(this.nickname){
                    this.$u.api.profile({
                        nickname: this.nickname
                    }).then(e => {
                        if(e.code == 1)return that.$alert(e.msg);
                        var user = uni.getStorageSync('userInfo');
                        user.nickname = this.nickname;
                        util.setCache('userInfo', user)
                        uni.navigateBack({
                            delta:1
                        })
                    }).catch(function (err) {
                        console.log(err)
                    })
                }else{
                    uni.showToast({
                        icon:'none',
                        title: '用户昵称不能为空!'
                    })
                }
            },
            clearInp(){
                this.nickname = ''
            }
        }
    }
</script>
 
<style lang="scss">
    .setNickname-wrapper{
        width: 100%;
        .input-container{
            width: 100%;
            height: 86rpx;
            margin-top: 20rpx;
            background: #FFFFFF;
            .ipt{
                width: 100%;
                height: 100%;
                font-size: 28rpx;
                font-weight: 500;
                color: #333333;
            }
            .clear{
                width: 50rpx;
                height: 100%;
                white-space: nowrap;
            }
        }
        
        .btn-content{
            width: 100%;
            height: 86rpx;
            margin-top: 46rpx;
            .cfm-btn{
                width: 100%;
                height: 86rpx;
                background: #FD002F;
                border-radius: 43rpx;
                font-size: 30rpx;
                font-weight: 500;
                color: #FFFFFF;
            }
        }
    }
</style>