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="container">
        <view class="header">
            <image class="header-img" :src="memberInfo.photo?memberInfo.photo:'../../static/images/default-avatar.png'"></image>
            <view>
                <view>
                    <text>{{memberInfo.vipName}}</text>
                    <text class="ml-20">{{memberInfo.phone}}</text>
                </view>
                <text class="font-14 gray mt-5">{{memberInfo.vipLevel || '-'}}</text>
            </view>
        </view>
        <view class="content">
            <view class="list-item" v-for="item in list">
                <view class="flex align-center">
                    <image class="img" mode="aspectFill" :src="item.img?item.img:'../../static/images/no-img.png'"></image>
                    <view>
                        <text>{{item.name}}</text>
                        <text class="gray block mt-5">×{{item.num}}</text>
                    </view>
                </view>
                <view>
                    <text class="font-14">¥{{item.isFree?0:item.price}}</text>
                </view>
            </view>
            <view class="list-footer">
                <text class="blue">共{{totalCount}}件商品</text>
                <text>
                    合计:<text class="price">¥{{totalAmount}}</text>
                </text>
            </view>
        </view>
        <view class="footer">
            <button :disabled="isDisabled" class="blue-btn" @click="createOrder">确认提交</button>
        </view>
    </view>
</template>
 
<script>
    export default{
        data(){
            return{
                memberInfo: {},
                list: [],
                id:'',
                isDisabled: false
            }
        },
        onLoad(options) {
            this.id = options.id;
            this.list = JSON.parse(decodeURIComponent(options.list));
            this.loadMemberInfo();
        },
        computed:{
            // 购物车总数量
            totalCount(){
                let count = 0;
                this.list.forEach((item) => {
                    count += item.num;
                })
                return count;
            },
            // 购物车总金额
            totalAmount(){
                let amount = 0;
                this.list.forEach((item) => {
                    if(!item.isFree){
                        amount += item.price * item.num;
                    }
                })
                return amount;
            }
        },
        methods:{
            loadMemberInfo(){
                this.$httpUtils.request('/api/vip/findVipInfoById/'+this.id).then((res) => {
                    if(res.status == 200){
                        this.memberInfo = res.mapInfo.vipInfo;
                    }
                })
            },
            createOrder(){
                this.isDisabled = true;
                let orderList = this.list.map((item) => {
                    return {
                        "count": item.num,
                        "goodsId": item.id,
                        "goodsType": item.goodsType,
                        "isFree": item.isFree?1:0
                    }
                })
                this.$httpUtils.request('/api/order/createOrder', {
                    items: orderList,
                    vipId: this.id
                }, 'POST').then((res) => {
                    if(res.status == 200){
                        uni.navigateTo({
                            url: './submitSucceed'
                        })
                    }
                    this.$toast.info(res.info);
                    this.isDisabled = false;
                }).catch(() => {
                    this.isDisabled = false;
                })
            }
        }
    }
</script>
 
<style>
    page{
        background: #F6F6F8;
    }
    .container{
        padding-top: 10px;
        padding-bottom: 70px;
    }
    .header{
        display: flex;
        align-items: center;
        border: 1px solid #EDEAF4;
        padding: 10px 10px;
        background: #FFFFFF;
        font-size: 16px;
    }
    .header-img{
        width: 48px;
        height: 48px;
        border-radius: 50%;
        margin-right: 10px;
    }
    .content{
        margin: 10px 10px;
        padding: 0 10px 0;
        background: #FFFFFF;
        border: 1px solid #EDEAF4;
        box-shadow:0 6px 6px rgba(237,234,244,0.5);
        border-radius: 4px;
    }
    .list-item{
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #EDEAF4;
        padding: 12px 5px;
        font-size: 13px;
    }
    .list-item .img{
        width: 40px;
        height: 40px;
        border-radius: 4px;
        margin-right: 10px;
    }
    .list-footer{
        display: flex;
        justify-content: space-between;
        padding: 15px 0;
        font-size: 16px;
    }
    .list-footer .price{
        color: #FA5151;
        font-weight: 700;
    }
    .footer{
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 0;
        padding-bottom: 20px;
        background: #F6F6F8;
    }
</style>