feat: add frontend
This commit is contained in:
3
frontend/src/views/PlayView.vue
Normal file
3
frontend/src/views/PlayView.vue
Normal file
@@ -0,0 +1,3 @@
|
||||
<template>
|
||||
<h1>Player</h1>
|
||||
</template>
|
||||
17
frontend/src/views/TabView.vue
Normal file
17
frontend/src/views/TabView.vue
Normal file
@@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<RouterView />
|
||||
|
||||
<van-tabbar route v-model="active">
|
||||
<van-tabbar-item replace name="home" icon="home-o" to="/tab/home"
|
||||
>主页
|
||||
</van-tabbar-item>
|
||||
<van-tabbar-item replace name="bought" icon="like-o" to="/tab/bought"
|
||||
>已购</van-tabbar-item
|
||||
>
|
||||
<van-tabbar-item replace name="me" icon="contact-o" to="/tab/me">我</van-tabbar-item>
|
||||
</van-tabbar>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { RouterView } from "vue-router";
|
||||
</script>
|
||||
112
frontend/src/views/tabs/BoughtView.vue
Normal file
112
frontend/src/views/tabs/BoughtView.vue
Normal file
@@ -0,0 +1,112 @@
|
||||
<template>
|
||||
<div class="goods">
|
||||
<van-swipe class="goods-swipe" :autoplay="3000">
|
||||
<van-swipe-item v-for="thumb in goods.thumb" :key="thumb">
|
||||
<img :src="thumb" />
|
||||
</van-swipe-item>
|
||||
</van-swipe>
|
||||
|
||||
<van-cell-group>
|
||||
<van-cell>
|
||||
<template #title>
|
||||
<div class="goods-title">{{ goods.title }}</div>
|
||||
<div class="goods-price">{{ formatPrice(goods.price) }}</div>
|
||||
</template>
|
||||
</van-cell>
|
||||
<van-cell class="goods-express">
|
||||
<template #title>
|
||||
<van-col span="10">运费:{{ goods.express }}</van-col>
|
||||
<van-col span="14">剩余:{{ goods.remain }}</van-col>
|
||||
</template>
|
||||
</van-cell>
|
||||
</van-cell-group>
|
||||
|
||||
<van-cell-group class="goods-cell-group">
|
||||
<van-cell value="进入店铺" icon="shop-o" is-link @click="sorry">
|
||||
<template #title>
|
||||
<span class="van-cell-text">有赞的店</span>
|
||||
<van-tag class="goods-tag" type="danger">官方</van-tag>
|
||||
</template>
|
||||
</van-cell>
|
||||
<van-cell title="线下门店" icon="location-o" is-link @click="sorry" />
|
||||
</van-cell-group>
|
||||
|
||||
<van-cell-group class="goods-cell-group">
|
||||
<van-cell title="查看商品详情" is-link @click="sorry" />
|
||||
</van-cell-group>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
goods: {
|
||||
title: "美国伽力果213(约680g/3个)",
|
||||
price: 2680,
|
||||
express: "免运费",
|
||||
remain: 19,
|
||||
thumb: [
|
||||
"https://img.yzcdn.cn/public_files/2017/10/24/e5a5a02309a41f9f5def56684808d9ae.jpeg",
|
||||
"https://img.yzcdn.cn/public_files/2017/10/24/1791ba14088f9c2be8c610d0a6cc0f93.jpeg",
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
formatPrice() {
|
||||
return "¥" + (this.goods.price / 100).toFixed(2);
|
||||
},
|
||||
|
||||
onClickCart() {
|
||||
this.$router.push("cart");
|
||||
},
|
||||
|
||||
sorry() {
|
||||
showToast("暂无后续逻辑~");
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
body {
|
||||
font-size: 16px;
|
||||
background-color: #f8f8f8;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
.goods {
|
||||
padding-bottom: 50px;
|
||||
|
||||
&-swipe {
|
||||
img {
|
||||
width: 100%;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
&-title {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
&-price {
|
||||
color: #f44;
|
||||
}
|
||||
|
||||
&-express {
|
||||
color: #999;
|
||||
font-size: 12px;
|
||||
padding: 5px 15px;
|
||||
}
|
||||
|
||||
&-cell-group {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
&-tag {
|
||||
margin-left: 5px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
65
frontend/src/views/tabs/HomeView.vue
Normal file
65
frontend/src/views/tabs/HomeView.vue
Normal file
@@ -0,0 +1,65 @@
|
||||
<template>
|
||||
<van-search v-model="search" placeholder="请输入搜索关键词" />
|
||||
|
||||
<van-list
|
||||
v-model:loading="loading"
|
||||
:finished="finished"
|
||||
finished-text="没有更多了"
|
||||
@load="onLoad"
|
||||
>
|
||||
<van-card
|
||||
v-for="item in list"
|
||||
:key="item"
|
||||
price="2.00"
|
||||
desc="描述信息"
|
||||
title="商品标题"
|
||||
thumb="https://fastly.jsdelivr.net/van-listt/assets/ipad.jpeg"
|
||||
lazy-load="true"
|
||||
@click="play(item)"
|
||||
>
|
||||
<template #tags>
|
||||
<van-space>
|
||||
<van-tag plain type="primary">视频</van-tag>
|
||||
<van-tag plain type="primary">音频</van-tag>
|
||||
<van-tag plain type="primary">PDF</van-tag>
|
||||
</van-space>
|
||||
</template>
|
||||
</van-card>
|
||||
</van-list>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const search = ref("");
|
||||
const list = ref([]);
|
||||
const loading = ref(false);
|
||||
const finished = ref(false);
|
||||
|
||||
const onLoad = () => {
|
||||
// 异步更新数据
|
||||
// setTimeout 仅做示例,真实场景中一般为 ajax 请求
|
||||
setTimeout(() => {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
list.value.push(list.value.length + 1);
|
||||
}
|
||||
|
||||
// 加载状态结束
|
||||
loading.value = false;
|
||||
|
||||
// 数据全部加载完成
|
||||
if (list.value.length >= 40) {
|
||||
finished.value = true;
|
||||
}
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const play = (item) => {
|
||||
// vue router goto play view
|
||||
console.log("play", item);
|
||||
router.push({ name: "play", params: { id: item } });
|
||||
};
|
||||
</script>
|
||||
5
frontend/src/views/tabs/MeView.vue
Normal file
5
frontend/src/views/tabs/MeView.vue
Normal file
@@ -0,0 +1,5 @@
|
||||
<template>
|
||||
<div class="about">
|
||||
<h1>This is an about page</h1>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user