forked from mevulfmp3/web
parent
b1ed18daec
commit
93c3f6e0c2
@ -0,0 +1,85 @@
|
||||
<template>
|
||||
|
||||
<template v-for="(item,index) in data.list">
|
||||
<card
|
||||
:num="item.num"
|
||||
:price="item.price"
|
||||
:desc="item.desc"
|
||||
:title="item.title"
|
||||
thumb="https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg">
|
||||
<template #footer>
|
||||
<button size="mini" @click="sub(item)">-</button>
|
||||
<button size="mini" @click="add(item)">+</button>
|
||||
</template>
|
||||
</card>
|
||||
</template>
|
||||
|
||||
<submit-bar :price="price*100" button-text="提交订单" @submit="onSubmit">
|
||||
<checkbox v-model="checked">全选</checkbox>
|
||||
<template #tip>
|
||||
你的收货地址不支持配送, <span @click="onClickLink">修改地址</span>
|
||||
</template>
|
||||
</submit-bar>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {ref, reactive} from 'vue'
|
||||
import {showToast, Card, Button, Tag, SubmitBar, Checkbox, CheckboxGroup} from 'vant';
|
||||
import {onMounted, onBeforeMount, onUpdated} from "vue";
|
||||
|
||||
const data = reactive({
|
||||
list: []
|
||||
})
|
||||
const price = ref(0)
|
||||
const sub = (item) => {
|
||||
if (item.num < 1) return
|
||||
else {
|
||||
item.num--
|
||||
price.value -= item.price
|
||||
}
|
||||
}
|
||||
|
||||
const add = (item) => {
|
||||
item.num++
|
||||
price.value += item.price
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
setTimeout(() => {
|
||||
data.list = [{
|
||||
title: "手机",
|
||||
desc: "xxxxxxx",
|
||||
price: 1999,
|
||||
num: 0
|
||||
},
|
||||
{
|
||||
title: "电脑",
|
||||
desc: "xxxxxxx",
|
||||
price: 6999,
|
||||
num: 0
|
||||
},
|
||||
{
|
||||
title: "包包",
|
||||
desc: "xxxxxxx",
|
||||
price: 12999,
|
||||
num: 0
|
||||
}]
|
||||
}, 1200)
|
||||
// axios.get()
|
||||
|
||||
})
|
||||
|
||||
onBeforeMount(() => {
|
||||
console.log("beforeMounted")
|
||||
})
|
||||
|
||||
const checked = ref(false)
|
||||
const onSubmit = () => showToast('点击按钮');
|
||||
const onClickLink = () => showToast('修改地址');
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
Loading…
Reference in new issue