feat(custom): \!
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-05 16:41:26 +08:00
parent 962d7a2b19
commit 94b6a9da10
23 changed files with 311 additions and 721 deletions

View File

@@ -1,10 +1,10 @@
<script setup lang="ts">
import {ref} from 'vue';
import { ref } from 'vue';
import Taro from '@tarojs/taro';
import {addCart, getCart, clearCart} from '@/api/cart';
import {Plus, Minus} from '@nutui/icons-vue-taro';
import {createActiveOrder} from '@/api/goods';
import {createAfterOrder, getUserPoint} from '@/api/admin';
import { addCart, getCart, clearCart } from '@/api/cart';
import { Plus, Minus } from '@nutui/icons-vue-taro';
import { createActiveOrder } from '@/api/goods';
import { createAfterOrder, getUserPoint } from '@/api/admin';
import Pay from '@/components/Pay.vue';
interface CardList {
@@ -13,6 +13,7 @@ interface CardList {
bid: string;
gid: string;
number: string;
discount_price: string;
price: number;
exchange: number;
discount_integral: number;
@@ -77,6 +78,7 @@ const card_list = ref<CardList[]>([]);
const cartInfo = ref({
count: 0,
price: 0,
discount_price: 0,
exchange: 0,
discount_integral: 0,
});
@@ -86,17 +88,17 @@ const get_cart_list = async (bid: string = props.merInfo.bid) => {
const res = await getCart({
Bid: bid,
});
card_list.value = res.data.data || [];
cartInfo.value = {
count: 0,
price: 0,
discount_price: 0,
exchange: 0,
discount_integral: 0,
};
card_list.value.forEach((item: CardList) => {
cartInfo.value.count += Number(item.number);
cartInfo.value.price += Number(item.price);
cartInfo.value.discount_price += Number(item.price);
cartInfo.value.exchange += Number(item.exchange);
cartInfo.value.discount_integral += Number(item.discount_integral);
});
@@ -199,39 +201,28 @@ defineExpose({
<view class="container flex items-center">
<!-- <view>购物车数量: {{ cartInfo.count }}</view> -->
<view class="cardImg">
<image
src="http://p1.meituan.net/csc/929f447a96a44b09a09b2e0055433222717.png">
<image src="http://p1.meituan.net/csc/929f447a96a44b09a09b2e0055433222717.png">
</image>
<view class="count-text" v-if="cartInfo.count > 0">
<text>{{ cartInfo.count }}</text>
</view>
</view>
<view class="ml-1 text-[25px]">
<text>总金额: {{ cartInfo.price.toFixed(2) }}</text>
<text v-if="!IsPendingOrder"
>积分抵扣: {{ cartInfo.discount_integral.toFixed(2) }}
<text>总金额: {{ cartInfo.discount_price.toFixed(2) }}</text>
<text v-if="!IsPendingOrder">积分抵扣: {{ cartInfo.discount_integral.toFixed(2) }}
</text>
</view>
</view>
<view v-if="cartInfo.count > 0" class="payBtn" @click.stop="create_order"
>去结算
<view v-if="cartInfo.count > 0" class="payBtn" @click.stop="create_order">去结算
</view>
</view>
<!-- 购物车弹窗 -->
<nut-popup
:style="{padding: '15px'}"
round
position="bottom"
z-index="1"
:catch-move="true"
:safe-area-inset-bottom="true"
v-model:visible="show">
<nut-popup :style="{ padding: '15px' }" round position="bottom" z-index="1" :catch-move="true"
:safe-area-inset-bottom="true" v-model:visible="show">
<view class="list-header">
<view class="left" @click.stop="clear_cart">
<!-- <Del2 color="#666666" /> -->
<image
class="w-[20px] h-[20px]"
src="http://p0.meituan.net/csc/db4d11fd744b69435c6ffdc6bfc868c5684.png" />
<image class="w-[20px] h-[20px]" src="http://p0.meituan.net/csc/db4d11fd744b69435c6ffdc6bfc868c5684.png" />
<text class="text-[20px]" style="color: #666666">清空购物车</text>
</view>
</view>
@@ -248,11 +239,7 @@ defineExpose({
</view>
</view>
</view>
<nut-input-number
v-model="item.number"
readonly
:min="-1"
@add="() => onAdd(item)"
<nut-input-number v-model="item.number" readonly :min="-1" @add="() => onAdd(item)"
@reduce="() => onReduce(item)">
<template #left-icon>
<view class="btn" @click.stop="onReduce(item)">
@@ -270,11 +257,7 @@ defineExpose({
<view style="height: 140px"></view>
</nut-popup>
<!-- 支付 -->
<Pay
:is-show-pay="isShowPay"
v-model:jfInfo="orderData"
@closePay="closePay"
@successPay="closePay" />
<Pay :is-show-pay="isShowPay" v-model:jfInfo="orderData" @closePay="closePay" @successPay="closePay" />
</view>
</template>