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
<template>
    <!-- 购物车 -->
    <uni-popup ref="popup" type="bottom">
        <view class="popup-content">
            <view class="popup-header">
                <text class="blue">已选商品</text>
                <view class="flex align-center">
                    <text class="iconfont iconlajixiang_huaban1 gray"></text>
                    <text class="gray font-14" @click="_reset">清空</text>
                </view>
            </view>
            <scroll-view scroll-y="true" class="popup-row-wrap">
                <view class="popup-row" v-for="(item, index) in list">
                    <view class="flex">
                        <image class="popup-row-img" mode="aspectFill" :src="item.img?item.img:'../../../static/images/no-img.png'"></image>
                        <view>
                            <text>{{item.name}}</text>
                            <text class="price">¥{{item.price}}</text>
                        </view>
                    </view>
                    <view v-if="item.isPresent == 1" @click="freeChange(item, index)">
                        <checkbox value="true" :checked="item.isFree" />赠
                    </view>
                    <view class="right">
                        <template v-if="item.num">
                            <text class="iconfont iconjian blue-outline-btn-circle mr-10" 
                                @click.stop="_decreaseGoods(item)"></text>
                                <text>{{item.num}}</text>
                        </template>
                        <text class="iconfont iconjia blue-btn-circle ml-10" 
                            @click.stop="_addGoods(item)"></text>
                    </view>
                </view>
            </scroll-view>
        </view>
    </uni-popup>
</template>
 
<script>
    import uniPopup from '@/components/uni-popup/uni-popup.vue'
    export default{
        components:{
            uniPopup
        },
        props:{
            list: {
                default: []
            }
        },
        data(){
            return{
                isShow: false
            }
        },
        methods:{
            toggle(){
                if(!this.list.length){
                    return;
                }
                this.isShow = !this.isShow;
                if(this.isShow){
                    this.$refs.popup.open();
                }else{
                    this.hide();
                }
            },
            hide(){
                this.$refs.popup.close();
            },
            freeChange(item, index){
                this.$emit('freeChange', {
                    goods: item,
                    index
                });
            },
            _addGoods(item){
                this.$emit('addGoods', item);
            },
            _decreaseGoods(item){
                this.$emit('decreaseGoods', item);
                if(!this.list.length){
                    this.hide()
                }
            },
            _reset(){
                this.$emit('reset');
                this.hide()
            }
        }
    }
</script>
 
<style>
    
    .popup-content{
        background: #FFFFFF;
        border-top-left-radius: 8px;
        border-top-right-radius: 8px;
        padding-bottom: 54px;
    }
    .popup-header{
        display: flex;
        justify-content: space-between;
        padding: 10px;
        border-bottom: 1px solid #EDEAF4;
        font-size: 16px;
    }
    .popup-header .iconfont{
        font-size: 22px;
    }
    .popup-row-wrap{
        max-height: 330px;
        padding: 7px 0;
    }
    .popup-row{
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 7px 10px;
        font-size: 12px;
    }
    .popup-row-img{
        width: 42px;
        height: 42px;
        margin-right: 10px;
    }
    .popup-row .price{
        display: block;
        color: #FA5151;
        font-size: 14px;
        margin-top: 5px;
    }
</style>