|
@@ -45,7 +45,7 @@
|
|
|
<v-btn :disabled="!selectedData.length" color="error" variant="outlined" @click.stop="handleDelete(true)">删除选中的商品</v-btn>
|
|
|
<div class="d-flex align-center">
|
|
|
<div class="color-666 mr-8">共{{ totalCount }}件商品,合计:¥{{ fen2yuan(totalPrice) }}</div>
|
|
|
- <v-btn :disabled="!totalCount" color="primary" @click.stop="handleSettlement">去结算<span v-if="totalCount > 0">({{ totalCount }})</span></v-btn>
|
|
|
+ <v-btn :disabled="!totalCount" color="primary" @click.stop="handleSettlement">结算<span v-if="totalCount > 0">({{ totalCount }})</span></v-btn>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -54,6 +54,10 @@
|
|
|
<v-btn elevation="5" color="primary" @click.stop="router.push('/mall')" size="x-large" width="200">去逛逛</v-btn>
|
|
|
</div>
|
|
|
</v-card>
|
|
|
+ <!-- 结算 -->
|
|
|
+ <CtDialog :visible="showPay" titleClass="text-h6" :widthType="3" title="订单信息" @submit="handleSubmit" @close="handleClose">
|
|
|
+ <confirm ref="confirmRef" :data="skuInfo" @paySuccess="paySuccess"></confirm>
|
|
|
+ </CtDialog>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
@@ -66,6 +70,9 @@ import { fen2yuan } from '@/hooks/web/useGoods'
|
|
|
import GoodsItem from '../components/GoodsItem'
|
|
|
import { updateCartSelected, updateCartCount, deleteCartGoods } from '@/api/mall/cart'
|
|
|
import Snackbar from '@/plugins/snackbar'
|
|
|
+import confirm from '@/views/mall/components/details/order/confirm.vue'
|
|
|
+import Confirm from '@/plugins/confirm'
|
|
|
+import { useI18n } from '@/hooks/web/useI18n'; const { t } = useI18n()
|
|
|
|
|
|
const router = useRouter()
|
|
|
const cartList = ref([])
|
|
@@ -130,9 +137,11 @@ const totalCount = computed(() => {
|
|
|
|
|
|
// 删除购物车中的商品
|
|
|
const handleDelete = async (isAll, id) => {
|
|
|
- const ids = isAll ? selectedData.value.join(',') : id
|
|
|
- await deleteCartGoods(ids)
|
|
|
- await getCartList()
|
|
|
+ Confirm(t('common.confirmTitle'), `是否确定删除${isAll? '选中的' : ''}商品?`).then(async () => {
|
|
|
+ const ids = isAll ? selectedData.value.join(',') : id
|
|
|
+ await deleteCartGoods(ids)
|
|
|
+ await getCartList()
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 商品数量更新
|
|
@@ -141,9 +150,51 @@ const handleChangeCount = async (count, id) => {
|
|
|
await getCartList()
|
|
|
}
|
|
|
|
|
|
-// 去结算
|
|
|
+const confirmRef = ref()
|
|
|
+const handleSubmit = () => {
|
|
|
+ if (confirmRef.value) confirmRef.value.onConfirm()
|
|
|
+}
|
|
|
+
|
|
|
+const handleClose = () => {
|
|
|
+ showPay.value = false
|
|
|
+}
|
|
|
+const paySuccess = () => {
|
|
|
+ // 更新购物车列表
|
|
|
+ showPay.value = false
|
|
|
+ getCartList()
|
|
|
+}
|
|
|
+
|
|
|
+// 结算
|
|
|
+const showPay = ref(false)
|
|
|
+const selectedList = ref([])
|
|
|
+const skuInfo = ref(null) // 购买商品规格信息
|
|
|
const handleSettlement = () => {
|
|
|
- Snackbar.warning('功能开发中...')
|
|
|
+ let items = []
|
|
|
+ let goods_list = [];
|
|
|
+ selectedList.value = cartList.value.filter((item) => selectedData.value.includes(item.id));
|
|
|
+ selectedList.value.map((item) => {
|
|
|
+ // 此处前端做出修改
|
|
|
+ items.push({
|
|
|
+ skuId: item.sku.id,
|
|
|
+ count: item.count,
|
|
|
+ cartId: item.id,
|
|
|
+ categoryId: item.spu.categoryId
|
|
|
+ })
|
|
|
+ goods_list.push({
|
|
|
+ goods_id: item.spu.id,
|
|
|
+ goods_num: item.count,
|
|
|
+ });
|
|
|
+ });
|
|
|
+ // return;
|
|
|
+ if (goods_list.length === 0) {
|
|
|
+ Snackbar.warning('请选择商品')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ skuInfo.value = JSON.stringify({
|
|
|
+ items
|
|
|
+ })
|
|
|
+ showPay.value = true
|
|
|
}
|
|
|
</script>
|
|
|
|