152 lines
3.6 KiB
Vue
152 lines
3.6 KiB
Vue
<template>
|
|
<div class="cart">
|
|
<div class="cart-header">
|
|
<div>My Cart <span v-if="cartList">( {{ cartList.length }} )</span> <span @click="clearCart">Clear</span></div>
|
|
<div class="close" @click="closeCart">
|
|
<img src="@/assets/img/marketplace/closeicon.png" alt="">
|
|
</div>
|
|
</div>
|
|
<div class="cart-content">
|
|
<div v-if="cartList !== undefined && cartList.length > 0" class="cart-list">
|
|
<li class="cart-item" v-for="(item, index) in cartList" :key="index">
|
|
<div class="cart-item-left">
|
|
<div class="cart-item-left-img">
|
|
<img :src="item.nft.image" alt="">
|
|
</div>
|
|
<div class="cart-item-left-name">{{ item.nft.name }}</div>
|
|
</div>
|
|
<div class="cart-item-right">
|
|
<div class="cart-item-right-price"></div>
|
|
</div>
|
|
</li>
|
|
</div>
|
|
<div v-else class="cart-not">
|
|
<p>You have no items in your cart</p>
|
|
</div>
|
|
<!-- <div class="cart-price">
|
|
<div class="left">Total Price</div>
|
|
<div class="right">
|
|
<div>0.08 <img src="@/assets/img/marketplace/ETHicon.png" alt=""></div>
|
|
<div>≈ {{ 200 }}$</div>
|
|
</div>
|
|
</div> -->
|
|
<div v-if="cartList !== undefined && cartList.length > 0" class="cart-btn">Buy All</div>
|
|
<div v-else class="cart-btn" @click="toMarketplace">Select NFTs to Buy</div>
|
|
</div>
|
|
|
|
</div>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, defineEmits, onMounted } from "vue"
|
|
import { useRouter, useRoute } from "vue-router";
|
|
import { useImmutableStore } from "@/store/immutable"
|
|
import { useMarketplaceStore } from "@/store/marketplace"
|
|
import {
|
|
apiGetCartList,
|
|
apiClearCartList,
|
|
} from "@/utils/marketplace"
|
|
const router = useRouter();
|
|
const emit = defineEmits(['clickStatusChild'])
|
|
const immutableStore = useImmutableStore()
|
|
// const token = immutableStore.accessToken
|
|
|
|
const cartList = ref()
|
|
|
|
const closeCart = () => {
|
|
emit('closeCart')
|
|
}
|
|
|
|
const toMarketplace = () => {
|
|
emit('closeCart')
|
|
router.push('/marketplace');
|
|
}
|
|
|
|
const clearCart = async () => {
|
|
console.log('清楚购物车')
|
|
try {
|
|
let res = await apiClearCartList()
|
|
console.log(res)
|
|
} catch (e) {
|
|
console.log(e)
|
|
}
|
|
}
|
|
|
|
const getCartList = async () => {
|
|
// let token = localStorage.getItem('assessToken')
|
|
// if(token) {
|
|
try {
|
|
// let res = await useMarketplaceStore().cartList
|
|
let res = '-------------------------'
|
|
// cartList.value = res
|
|
console.log(res)
|
|
} catch (e) {
|
|
console.log(e)
|
|
}
|
|
// }
|
|
}
|
|
|
|
onMounted(()=> {
|
|
getCartList()
|
|
})
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.cart {
|
|
width: 570px;
|
|
// height: 100%;
|
|
color: #BB7FFF;
|
|
.cart-header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
padding: 30px;
|
|
padding-bottom: 5px;
|
|
border-bottom: 2px solid #3D4057;
|
|
div {
|
|
font-family: 'Poppins';
|
|
font-weight: bold;
|
|
font-size: 22px;
|
|
color: #fefefe;
|
|
span {
|
|
color: #00FF00;
|
|
margin-left: 10px;
|
|
cursor: pointer;
|
|
}
|
|
}
|
|
.close {
|
|
width: 30px;
|
|
height: 30px;
|
|
cursor: pointer;
|
|
img {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
}
|
|
.cart-content {
|
|
padding: 30px;
|
|
.cart-not {
|
|
text-align: center;
|
|
margin-bottom: 30px;
|
|
font-size: 24px;
|
|
color: #fff;
|
|
}
|
|
.cart-list {}
|
|
.cart-btn {
|
|
width: 100%;
|
|
height: 60px;
|
|
line-height: 60px;
|
|
font-family: 'Poppins';
|
|
font-weight: bold;
|
|
font-size: 30px;
|
|
background: #6336D7;
|
|
color: #fff;
|
|
text-align: center;
|
|
border-radius: 18px;
|
|
cursor: pointer;
|
|
}
|
|
}
|
|
}
|
|
</style> |