路泰科技体检小程序UI设计新版本
wwl
2025-07-30 4e671437d52dd87946c0e38d334fce7a7c17d8e2
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
<template>
    <view class="container">
        <view class="no-login" v-if="!token">
            <view class="c">
                <text>还没有登录</text>
                <button style="background-color: #a9a9a9" @click="goLogin">去登录</button>
            </view>
        </view>
        <view class="login" v-else>
            <!-- <view class="service-policy">
                <view class="item">30天无忧退货</view>
                <view class="item">48小时快速退款</view>
            </view> -->
            <view class="no-cart" v-if="cartGoods.length <= 0">
                <view class="c">
                    <text>空空如也~</text>
                    <text>去添加点什么吧</text>
                </view>
            </view>
            <view class="cart-view" v-else>
                <view class="list">
                    <view class="group-item">
                        <view class="goods">
                            <view :class="'item ' + (isEditCart ? 'edit' : '')" v-for="(item, index) in cartGoods"
                                :key="index">
 
                                <view class="cart-goods">
 
                                    <checkbox-group @change="checkedItem($event, { itemIndex: index })"
                                        :data-item-index="index">
                                        <checkbox class="checko" :checked="item.checked"></checkbox>
                                    </checkbox-group>
 
                                    <image class="img" :src="item.picUrl"></image>
                                    <view class="info">
                                        <view class="t">
                                            <text class="name">{{ item.goodsName }}</text>
                                            <text class="num">x{{ item.number }}</text>
                                        </view>
                                        <view class="attr">{{ isEditCart ? '已选择:' : '' }}{{ item.specifications || '' }}
                                        </view>
                                        <view class="b">
                                            <text class="price">¥{{ item.price }}</text>
                                            <!-- <view class="selnum">
                                                <view class="cut" @tap="cutNumber" :data-item-index="index">-</view>
                                                <input :value="item.number" class="number" :disabled="true"
                                                    type="number" />
                                                <view class="add" @tap="addNumber" :data-item-index="index">+</view>
                                            </view> -->
                                        </view>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                </view>
                <view class="cart-bottom">
 
                    <checkbox-group class="van-checkbox" @change="checkedAll">
                        <checkbox :checked="checkedAllStatus">全选({{ cartTotal.checkedGoodsCount }})</checkbox>
                    </checkbox-group>
 
                    <view class="total">{{ !isEditCart ? '¥' + cartTotal.checkedGoodsAmount : '' }}</view>
 
                    <view class="action_btn_area">
                        <!-- <view :class="!isEditCart ? 'edit' : 'sure'" @tap="editCart">{{ !isEditCart ? '编辑' : '完成' }}
                        </view> -->
                        <view class="delete" @tap="deleteCart">删除({{ cartTotal.checkedGoodsCount }})
                        </view>
                        <view class="checkout" @tap="checkoutOrder" v-if="!isEditCart">立即预约</view>
 
                    </view>
                </view>
            </view>
        </view>
        <!-- 底部弹窗 -->
        <view class="example-body box">
            <uni-popup ref="popup" type="bottom" background-color="#fff" style="height: 200px;">
                <view class="box2">
                    <view style="font-size: 20px;font-weight: 600;">套餐名称:{{pacById.goodsName}}</view>
                    <view style="display: flex;align-items: flex-end;">
                        <div style="color: black;font-size: 20px">¥{{pacById.price}}</div>
                    </view>
                    <view style="display: flex;">
                        <view class="geren" @click="tiaozhuan(pacById.goodsId)">
                            <view style="margin-top: 4px;margin-left: 4px;">个人预约</view>
                        </view>
                        <view class="tuandui">
                            <view style="margin-top: 4px;margin-left: 4px;">团队预约</view>
                        </view>
                    </view>
                </view>
            </uni-popup>
        </view>
    </view>
</template>
 
<script>
    import {
        getMyCart,
        removeMyCart
    } from "@/api/system/cart";
    export default {
        data() {
            return {
                cartGoods: [],
                checkedadd:[],
                token: "",
                cartTotal: {
                    goodsCount: 0,
                    goodsAmount: 0,
                    checkedGoodsCount: 0,
                    checkedGoodsAmount: 0
                },
                isEditCart: false,
                checkedAllStatus: false,
                editCartList: [],
                hasLogin: false,
                checkedall: [],
                pacById: {}
            };
        },
        onShareAppMessage() { //点亮发送给朋友
 
        },
        onLoad: function(options) {
            console.log(options)
            // 页面初始化 options为页面跳转所带来的参数
        },
        onReady: function() {
            // 页面渲染完成
        },
        onPullDownRefresh() {
            uni.showNavigationBarLoading(); //在标题栏中显示加载
            this.getCartList();
            uni.hideNavigationBarLoading(); //完成停止加载
            uni.stopPullDownRefresh(); //停止下拉刷新
        },
        onShow: function() {
            this.token = this.$store.state.user.token
            if (this.token) {
                this.getCartList();
            }
        },
        onHide: function() {
            // 页面隐藏
        },
        onUnload: function() {
            // 页面关闭
        },
        methods: {
            goLogin() {
                uni.navigateTo({
                    url: '/pages/login'
                });
            },
 
            getCartList: function() {
                getMyCart().then(res => {
                    this.cartGoods = res.data
                    this.checkedadd = []
                    this.cartGoods.forEach(item => {
                        if (item.checked == 1) {
                            this.checkedadd.push(item)
                        }
                    })
                    if (this.checkedadd != []) {
                        this.checkedAllStatus = true
                        this.cartTotal.checkedGoodsAmount = 0
                        this.checkedadd.forEach(item => {
                            this.cartTotal.checkedGoodsAmount += item.price
                        })
                        this.cartTotal.checkedGoodsCount = this.checkedadd.length
                        this.cartTotal.checkedGoodsCount = this.checkedadd.length
                    }
                })
            },
 
            isCheckedAll: function() {
                //判断购物车商品已全选
                return this.cartGoods.every(function(element, index, array) {
                    if (element.checked == true) {
                        return true;
                    } else {
                        return false;
                    }
                });
            },
 
            doCheckedAll: function() {
                //console.log("doCheckedAll")
            },
 
            checkedItem: function(event, _dataset) {
                let itemIndex = event.target.dataset.itemIndex;
                if (this.cartGoods[itemIndex].checked == 1) {
                    this.cartGoods[itemIndex].checked = 0
                    this.checkedAllStatus = false
                    this.checkedall = []
                    this.cartGoods.forEach((item => {
                        if (item.checked == 1) {
                            this.checkedall.push(item)
                        }
                    }))
                    this.cartTotal.checkedGoodsAmount = 0
                    this.checkedall.forEach((item => {
                        this.cartTotal.checkedGoodsAmount += item.price
                    }))
                    this.cartTotal.checkedGoodsCount = this.checkedall.length
                    this.cartTotal.checkedGoodsCount = this.checkedall.length
                } else if (this.cartGoods[itemIndex].checked == 0) {
                    this.cartGoods[itemIndex].checked = 1
                    this.checkedall = []
                    this.cartGoods.forEach((item => {
                        if (item.checked == 1) {
                            this.checkedall.push(item)
                        }
                    }))
                    this.cartTotal.checkedGoodsAmount = 0
                    this.checkedall.forEach((item => {
                        this.cartTotal.checkedGoodsAmount += item.price
                    }))
                    if (this.checkedall.length == this.cartGoods.length) {
                        this.checkedAllStatus = true
                    }
                    this.cartTotal.checkedGoodsCount = this.checkedall.length
                    this.cartTotal.checkedGoodsCount = this.checkedall.length
                }
 
            },
 
            getCheckedGoodsCount: function() {
 
            },
 
            checkedAll: function() {
                let that = this
                if (that.checkedAllStatus == true) {
                    that.checkedAllStatus = false
                    that.cartGoods.forEach(item => {
                        item.checked = 0
                    })
                    that.cartTotal.checkedGoodsCount = 0
                    that.cartTotal.checkedGoodsCount = 0
                    that.cartTotal.checkedGoodsAmount = 0
                } else if (that.checkedAllStatus == false) {
                    that.checkedAllStatus = true
                    that.cartGoods.forEach(item => {
                        item.checked = 1
                        that.cartTotal.checkedGoodsAmount += item.price
                    })
                    that.cartTotal.checkedGoodsCount = that.cartGoods.length
                    that.cartTotal.checkedGoodsCount = that.cartGoods.length
                }
 
            },
 
            editCart: function() {
 
            },
 
            updateCart: function(productId, goodsId, number, id) {
 
            },
 
            cutNumber: function(event) {
 
            },
 
            addNumber: function(event) {
 
            },
 
            checkoutOrder: function() {
                // storage中设置了cartId,则是购物车购买
                try {
                    uni.setStorageSync('cartId', 0);
                    if (this.checkedall.nv_length > 0) {
                        if (this.checkedall.length == 1) {
                            this.checkedall.forEach(item => {
                                this.pacById = item
                            })
                            this.toggle();
                        } else {
                            this.$modal.msgError("请选择一项进行预约")
                        }
                    } else {
                        if (this.checkedadd.length == 1) {
                            this.checkedadd.forEach(item => {
                                this.pacById = item
                            })
                            this.toggle();
                        } else {
                            this.$modal.msgError("请选择一项进行预约")
                        }
                    }
                } catch (e) {}
            },
            toggle(type) {
                this.type = type
                // open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
                this.$refs.popup.open(type)
            },
 
            tiaozhuan(pacId) {
                uni.navigateTo({
                    url: `/pagesA/physicalAppointment/physicalAppointment?pacId=${pacId}`
                })
            },
 
            deleteCart: function() {
                let data = []
                this.cartGoods.forEach(item => {
                    if (item.checked == 1) {
                        data.push(item.id)
                    }
                })
                removeMyCart(data).then(res => {
                    this.$modal.showToast("删除成功")
                    this.getCartList()
                })
            }
 
        }
    };
</script>
 
<style>
    @import './cart.css';
 
    .box2 {
        height: 200px;
        display: flex;
        flex-direction: column;
        justify-content: space-evenly;
        align-items: flex-start;
        margin-left: 10px;
    }
 
    .geren {
        width: 70px;
        height: 30px;
        margin-right: 20px;
        background-color: #ff834c;
        color: #fff;
        border-radius: 10px;
        text-align: center;
        line-height: 20px;
    }
 
    .tuandui {
        width: 70px;
        height: 30px;
        background-color: #ff834c;
        color: #fff;
        border-radius: 10px;
        text-align: center;
        line-height: 20px;
    }
</style>