feat: 添加移动端页面组件和图片资源

This commit is contained in:
wangqiao
2025-09-03 17:06:39 +08:00
parent 7f2edb91e4
commit b1d2378cec
37 changed files with 2426 additions and 56 deletions

View File

@ -0,0 +1,181 @@
<template>
<view class="design-list">
<view class="design-item" v-for="(item, index) in items" :key="index">
<view class="design-preview">
<image :src="item.image" mode="aspectFit"></image>
</view>
<view class="design-info">
<view class="design-title">{{ item.title }}</view>
<view class="design-author">by:{{ item.author }}</view>
<view class="design-stats">
<view class="stat-item">
<text class="iconfont">👁</text>
<text>{{ item.views }}</text>
</view>
<view class="stat-item">
<text class="iconfont">👍</text>
<text>{{ item.likes }}</text>
</view>
<view class="stat-item">
<text class="iconfont">💬</text>
<text>{{ item.comments }}</text>
</view>
</view>
</view>
<view class="design-action">
<button class="view-btn">查看</button>
</view>
</view>
</view>
</template>
<script>
export default {
name: "RecommendItem",
props: {
currentTab: {
type: Number,
default: 0,
},
},
data() {
return {
items: [
{
id: 1,
title: "高压细水雾灭火推车描述",
author: "赵其",
image: "/static/images/activity1.png",
views: 128,
likes: 16,
comments: 35,
url: "/pages/drawings/detail?id=1",
},
{
id: 2,
title: "高压细水雾灭火推车描述",
author: "赵其",
image: "/static/images/activity2.png",
views: 128,
likes: 16,
comments: 35,
url: "/pages/drawings/detail?id=2",
},
{
id: 1,
title: "室内CAD模型设计室内CAD模型设计",
author: "张泽",
image: "/static/images/activity1.png",
views: 95,
likes: 12,
comments: 28,
url: "/pages/models/detail?id=1",
},
{
id: 1,
title: "CAD设计规范文档",
author: "李华",
image: "/static/images/activity2.png",
views: 156,
likes: 23,
comments: 42,
url: "/pages/documents/detail?id=1",
},
],
};
},
methods: {
viewDetail(item) {
console.log("View detail for:", item.title);
uni.navigateTo({
url: item.url,
});
},
},
};
</script>
<style lang="scss" scoped>
// 变量定义
$primary-color: #007aff;
$text-color: #333;
$secondary-text: #666;
$light-text: #999;
$bg-color: #f0f4f9;
$white: #fff;
$border-color: #eee;
$border-radius: 15rpx;
.design-list {
// padding: 10rpx 20rpx;
.design-item {
display: flex;
margin-bottom: 20rpx;
background-color: $white;
border-radius: $border-radius;
border: 1px solid $border-color;
padding: 17rpx 10rpx;
box-sizing: border-box;
position: relative;
box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
.design-preview {
width: 220rpx;
height: 168rpx;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
}
.design-info {
flex: 1;
padding: 0 20rpx;
.design-title {
font-size: 27rpx;
margin-bottom: 10rpx;
}
.design-author {
font-size: 25rpx;
color: $light-text;
margin-bottom: 30rpx;
}
}
.design-stats {
display: flex;
.stat-item {
display: flex;
align-items: center;
margin-right: 20rpx;
font-size: 24rpx;
color: $light-text;
.iconfont {
margin-right: 5rpx;
}
}
}
.design-action {
position: absolute;
right: 20rpx;
bottom: 20rpx;
.view-btn {
background-color: $primary-color;
color: $white;
font-size: 25rpx;
padding: 0rpx 25rpx !important;
border-radius: 5rpx;
}
}
}
}
</style>

View File

@ -0,0 +1,16 @@
<template>
<div class="works">
<RecommendList />
</div>
</template>
<script setup lang="ts">
defineOptions({ name: 'Works' })
import RecommendList from "~/components/m/RecommendItem/index.vue";
</script>
<style lang="scss" scoped>
.works {
width: 100%;
}
</style>

View File

@ -0,0 +1,73 @@
<template>
<div
class="cert-item"
v-for="(cert, index) in talentInfo.certificates"
:key="index"
>
<div
v-if="index !== talentInfo.certificates.length - 1"
class="border-left"
></div>
<div class="cert-dot"></div>
<div class="cert-info">
<span class="cert-year">{{ cert.year }}</span>
<span class="cert-desc">{{ cert.description }}</span>
</div>
</div>
</template>
<script setup lang="ts">
defineOptions({ name: 'Certificates' })
interface Certificate { year: string; description: string }
interface TalentInfo { certificates: Certificate[] }
defineProps<{ talentInfo: TalentInfo }>()
</script>
<style lang="scss" scoped>
.border-left {
width: 1px;
height: calc(100%);
border-left: 2px dotted #e6f0ff;
position: absolute;
left: 7rpx;
top: 0;
}
// 证书列表
.cert-item {
display: flex;
align-items: flex-start;
position: relative;
}
.cert-dot {
width: 16rpx;
height: 16rpx;
border-radius: 50%;
background-color: #1a65ff;
// margin-top: 12rpx;
margin-right: 20rpx;
flex-shrink: 0;
z-index: 1;
}
.cert-info {
flex: 1;
margin-bottom: 11rpx;
margin-top: -10rpx;
padding-bottom: 32rpx;
}
.cert-year {
font-size: 25rpx;
font-weight: bold;
color: #333;
display: block;
margin-bottom: 8rpx;
}
.cert-desc {
font-size: 21rpx;
color: #666;
}
</style>

View File

@ -0,0 +1,35 @@
<template>
<div class="flex">
<div
class="cert-technicalCertificates"
v-for="(cert, index) in 10"
:key="index"
>
<img
class="cert-image"
:src="`https://picsum.photos/90/90?random=${index}`"
alt="certificate"
/>
</div>
</div>
</template>
<script setup lang="ts">
defineOptions({ name: 'TechnicalCertificates' })
</script>
<style lang="scss" scoped>
.flex {
display: flex;
flex-wrap: wrap;
gap: 50rpx;
}
.cert-technicalCertificates {
width: 135rpx;
height: 191rpx;
.cert-image {
width: 100%;
height: 100%;
}
}
</style>

View File

@ -0,0 +1,108 @@
<template>
<div class="activity-section">
<div class="section-header">
<span class="section-title">最新活动</span>
<a href="/mobile/activity/list" class="view-all">
<span>查看全部</span>
<span class="chevron"></span>
</a>
</div>
<div class="activity-scroll">
<div class="activity-container">
<div
class="activity-card"
v-for="(item, index) in activityList"
:key="index"
@click="goToActivity(item)"
:style="{ marginRight: index === activityList.length - 1 ? '40rpx' : '20rpx' }"
>
<img :src="item.image" class="activity-image" alt="activity" />
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { useRouter } from 'vue-router'
import { ref } from 'vue'
import activity1 from '~/assets/images/activity1.png'
import activity2 from '~/assets/images/activity2.png'
import activity3 from '~/assets/images/activity2.png'
const router = useRouter()
const activityList = ref([
{ id: 1, title: '积分兑换有好礼', image: activity1, url: '/mobile/activity/detail?id=1' },
{ id: 2, title: 'CAD高效学习', image: activity2, url: '/mobile/activity/detail?id=2' },
{ id: 3, title: '学习有奖', image: activity3, url: '/mobile/activity/detail?id=3' },
])
function goToActivity(item: { url: string }) {
router.push(item.url)
}
</script>
<style lang="scss" scoped>
.activity-section {
margin: 21.53rpx 0;
// padding: 0 20rpx;
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
}
.section-title {
font-size: 31rpx;
font-weight: 500;
color: #333;
}
.view-all {
display: flex;
align-items: center;
font-size: 24rpx;
color: #666;
text-decoration: none;
}
.view-all .chevron {
margin-left: 4rpx;
font-size: 20rpx;
}
.activity-scroll {
width: 100%;
overflow-x: auto;
padding-left: 20rpx; // 左侧padding与section对齐
margin-left: -20rpx; // 抵消父容器的padding
}
.activity-container {
display: inline-flex;
padding: 10rpx 0; // 留出阴影空间
}
.activity-card {
width: 330rpx;
height: 160rpx;
border-radius: 12rpx;
overflow: hidden;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
transition: all 0.2s;
&:active {
transform: scale(0.98);
opacity: 0.9;
}
}
.activity-image {
width: 100%;
height: 100%;
object-fit: contain;
}
</style>

View File

@ -0,0 +1,98 @@
<template>
<div class="recommend-section">
<div class="tab-navigation">
<div
v-for="(tab, index) in tabs"
:key="index"
class="tab-item"
:class="{ active: currentTab === index }"
@click="switchTab(index)"
>
<span>{{ tab.title }}</span>
</div>
<button class="view-all" @click="viewAll">
<span>查看全部</span>
<span class="icon-right"></span>
</button>
</div>
<!-- 内容区域 -->
<recommend-list />
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const currentTab = ref(0)
const tabs = ref([
{ title: '推荐图纸', type: 'drawings' },
{ title: '推荐模型', type: 'models' },
{ title: '推荐文本', type: 'documents' },
])
function switchTab(index: number) {
currentTab.value = index
}
function viewAll() {
const type = tabs.value[currentTab.value].type
router.push(`/mobile/${type}/list`)
}
</script>
<style lang="scss" scoped>
.recommend-section {
// padding: 0 20rpx;
// margin: 30rpx 0 50rpx;
}
.tab-navigation {
display: flex;
align-items: center;
margin-bottom: 25rpx;
}
.tab-item {
padding: 8rpx 0;
margin-right: 40rpx;
font-size: 29rpx;
color: #333;
position: relative;
transition: all 0.3s ease;
&.active {
color: #2970ff;
position: relative;
&::after {
content: "";
background-image: url("@/static/images/bg-yy.png");
background-size: 100% 100%;
background-repeat: no-repeat;
position: absolute;
bottom: 0rpx;
left: 0;
width: 100%;
height: 8px;
}
}
}
.view-all {
margin-left: auto;
display: flex;
align-items: center;
font-size: 24rpx;
color: #666;
background: transparent;
border: none;
cursor: pointer;
}
.view-all .icon-right {
margin-left: 4rpx;
font-size: 20rpx;
}
</style>

View File

@ -0,0 +1,64 @@
<template>
<div class="search-container">
<div class="search-input">
<span class="icon">🔍</span>
<input
v-model="searchValue"
type="text"
class="input"
placeholder="搜一搜"
@keyup.enter="onSearch"
/>
</div>
<button class="search-btn" @click="onSearch">
<img src="~/assets/images/info.png" alt="info" />
</button>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const searchValue = ref('')
function onSearch() {
console.log('Search for:', searchValue.value)
}
</script>
<style scoped lang="scss">
.search-container {
background-color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
}
.search-input {
display: flex;
align-items: center;
background: #efeff1;
border-radius: 32rpx;
padding: 0 22.11rpx;
flex: 1;
}
.search-input .icon { margin-right: 8px; }
.search-input .input {
flex: 1;
height: 64rpx;
border: none;
outline: none;
background: transparent;
}
.search-btn {
margin-left: 19.44rpx;
width: 43.75rpx;
height: 43.75rpx;
background-color: #fff;
border: none;
padding: 0;
}
.search-btn img {
width: 100%;
height: 100%;
}
</style>

View File

@ -0,0 +1,201 @@
<template>
<!-- 顶部导航栏 -->
<view class="nav-bar">
<view class="nav-item active">全部</view>
<view class="nav-item">机械设备</view>
<view class="nav-item">零部件模型</view>
<view class="nav-item">交通运输</view>
<view class="nav-item">电子产品</view>
<view class="expand-btn" @tap="toggleCategoryMenu">
<text class="expand-icon"></text>
</view>
</view>
<!-- 全部分类浮窗 -->
<view
class="category-popup"
v-if="showCategoryMenu"
@tap.stop="closeCategoryMenu"
>
<view class="popup-content" @tap.stop>
<view class="category-list">
<view
:key="index"
v-for="(section, index) in categoryList"
class="category-item"
@tap="selectCategory(section)"
>
{{ section.name }}
</view>
</view>
</view>
</view>
<!-- 筛选选项 -->
<view class="filter-bar">
<view class="filter-item"> 软件分类 <text class="icon-down"></text> </view>
<view class="filter-item"> 图纸类型 <text class="icon-down"></text> </view>
</view>
</template>
<script>
export default {
data() {
return {
showCategoryMenu: false,
categoryList: [
{ name: "机械设备", active: false },
{ name: "零部件模型", active: false },
{ name: "交通运输", active: false },
{ name: "电子产品", active: false },
{ name: "机械设备", active: false },
{ name: "零部件模型", active: false },
{ name: "交通运输", active: false },
{ name: "电子产品", active: false },
{ name: "机械设备", active: false },
{ name: "零部件模型", active: false },
{ name: "交通运输", active: false },
{ name: "电子产品", active: false },
],
};
},
methods: {
toggleCategoryMenu() {
this.showCategoryMenu = !this.showCategoryMenu;
},
closeCategoryMenu() {
this.showCategoryMenu = false;
},
selectCategory(section) {
// 演示用显示toast提示
},
},
onLoad(options) {
console.log(options);
// 监听点击事件,点击页面空白处关闭菜单
uni.$on("page-click", () => {
if (this.showCategoryMenu) {
this.closeCategoryMenu();
}
});
},
onUnload() {
// 移除事件监听
uni.$off("page-click");
},
};
</script>
<style scoped lang="scss">
// 变量定义
$primary-color: #007aff;
$text-color: #333;
$secondary-text: #666;
$light-text: #999;
$bg-color: #fff;
$white: #fff;
$border-color: #eee;
$border-radius: 10rpx;
$mask-bg: rgba(0, 0, 0, 0.5);
.nav-bar {
display: flex;
background-color: $white;
padding: 10rpx 0;
position: relative;
padding-right: 60rpx;
.nav-item {
flex: 1;
text-align: center;
font-size: 25rpx;
padding: 15rpx 0;
&.active {
color: $primary-color;
font-weight: bold;
}
}
.expand-btn {
position: absolute;
right: 0;
top: 0;
height: 100%;
width: 80rpx;
display: flex;
align-items: center;
justify-content: center;
.expand-icon {
font-size: 40rpx;
color: $text-color;
}
}
}
// 分类浮窗样式
.category-popup {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: $mask-bg;
z-index: 999;
display: flex;
flex-direction: column;
align-items: center;
.popup-content {
width: 100%;
max-height: 80vh;
background-color: $white;
animation: slideDown 0.3s ease;
overflow-y: auto;
.category-list {
padding: 20rpx;
display: flex;
flex-wrap: wrap;
.category-item {
padding: 8rpx 12.94rpx;
box-sizing: border-box;
margin-right: 3%;
margin-bottom: 20rpx;
text-align: center;
font-size: 25rpx;
background-color: $bg-color;
border-radius: 4rpx;
border: 1px solid $border-color;
color: #666;
}
}
}
}
// 滑入动画
@keyframes slideDown {
from {
transform: translateY(-100%);
opacity: 0.5;
}
to {
transform: translateY(0);
opacity: 1;
}
}
.filter-bar {
display: flex;
padding: 20rpx 30rpx;
.filter-item {
margin-right: 30rpx;
font-size: 25rpx;
color: $secondary-text;
}
.icon-down {
font-size: 24rpx;
}
}
</style>