gx
queenwuli
2021-01-25 c4246ca910f28014efaace64ebf92f47a673a9cf
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
<template>
    <view>
        <view class="input-group-row">
            <input type="text" maxlength="20" v-model="label" placeholder="请输入标签名称" placeholder-class="placeholder"/>
        </view>
        <view class="tag-wrap">
            <text class="iconfont" v-for="item in list" @click="colorChange(item)"
                :class="item.isCheck?'icontubiao-duoxuandianji':'iconcheckbox-full'" 
                :style="{color: item.color}"></text>
        </view>
        <view class="footer">
            <button class="blue-btn" @click="submit">确认添加</button>
        </view>
        
    </view>
</template>
 
<script>
    export default{
        data(){
            return {
                label: '',
                list: [{
                    color: '#57c5d2',
                    isCheck: false
                },{
                    color: '#e3565e',
                    isCheck: false
                },{
                    color: '#2f343a',
                    isCheck: false
                },{
                    color: '#4d98db',
                    isCheck: false
                },{
                    color: '#4fbc9d',
                    isCheck: false
                },{
                    color: '#eb503e',
                    isCheck: false
                },{
                    color: '#8b47ae',
                    isCheck: false
                },{
                    color: '#555555',
                    isCheck: false
                },{
                    color: '#669bcf',
                    isCheck: false
                },{
                    color: '#f0c93d',
                    isCheck: false
                }]
            }
        },
        methods:{
            colorChange(item){
                if(!item.isCheck){
                    this.list.forEach((op) => {
                        op.isCheck = false;
                    });
                    item.isCheck = true;
                }else{
                    item.isCheck = false;
                }
            },
            submit(){
                let color = '';
                this.list.forEach((item) => {
                    if(item.isCheck){
                        color = item.color;
                    }
                })
                if(!this.label){
                    this.$toast.info('请输入标签名称');
                    return
                }
                if(!color){
                    this.$toast.info('请选择颜色');
                    return
                }
                this.$httpUtils.request('/api/label/addLabel', {
                    color: color,
                    label: this.label
                }, 'POST').then((res) => {
                    if(res.status == 200){
                        uni.navigateBack()
                    }
                    this.$toast.info(res.info);
                })
            }
        }
    }
</script>
 
<style>
    page{
        background: #F6F6F8;
    }
    .input-group-row{
        background: #FFFFFF;
        margin: 10px 0;
        border-bottom: 0;
    }
    .input-group-row input{
        text-align: left;
        padding: 0 10px;
    }
    .tag-wrap{
        display: flex;
        flex-wrap: wrap;
        background: #FFFFFF;
        padding: 10px 10px;
        margin: 0 -10px;
    }
    .iconfont{
        font-size: 38px;
        margin: 5px 10px;
    }
    .footer{
        margin: 20px 10px;
    }
</style>