添加geek模板库

This commit is contained in:
D 2023-08-14 20:38:10 +08:00
parent 3185e4a287
commit 14d2c3e579
14 changed files with 867 additions and 522 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
unpackage unpackage
dist dist
node_modules node_modules
manifest.json

View File

@ -0,0 +1,127 @@
<template>
<view class="card" :class="type" @click="$emit('click')">
<image class="img" :src="img"/>
<view class="right">
<view class="title">{{ title }}</view>
<view class="subTitle">{{ subTitle }}</view>
<view class="price"> {{ price }}</view>
</view>
</view>
</template>
<script setup>
const props = defineProps({
img: {
type: String,
default: ''
},
title: {
type: String,
default: ''
},
subTitle: {
type: String,
default: ''
},
price: {
type: Number,
default: 0
},
type: {
type: String,
default: 'line'
}
})
</script>
<style lang="scss" scoped>
.card {
padding: 0;
border-radius: 10px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
height: 240rpx;
width: 700rpx;
padding: 20rpx;
margin: 10rpx;
position: relative;
.img {
height: 200rpx;
width: 200rpx;
}
.right {
position: absolute;
top: 20rpx;
left: 240rpx;
height: 200rpx;
.title {
width: 400rpx;
font-size: 35rpx;
}
.subTitle {
width: 400rpx;
margin-top: 10rpx;
font-size: 20rpx;
color: rgb(87, 87, 87);
}
.price {
position: absolute;
font-size: 40rpx;
color: red;
bottom: 10rpx;
width: 400rpx;
}
}
}
.rect {
border-radius: 10px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
height: 500rpx;
width: 350rpx;
padding: 0px;
margin: 10rpx;
position: relative;
display: inline-block;
.img {
border-radius: 10px 10px 0 0;
height: 350rpx;
width: 350rpx;
}
.right {
padding: 20rpx;
position: absolute;
height: 160rpx;
width: 350rpx;
top: 350rpx;
left: 20rpx;
.title {
width: 330rpx;
font-size: 25rpx;
}
.subTitle {
width: 330rpx;
margin-top: 10rpx;
font-size: 20rpx;
color: rgb(87, 87, 87);
}
.price {
position: absolute;
font-size: 30rpx;
color: red;
bottom: 10rpx;
width: 330rpx;
}
}
}
</style>

View File

@ -1,5 +1,5 @@
<template> <template>
<view class="menu" :style="menuStyle" @click="$emit('click')"> <view class="menu" :class="type" :style="menuStyle" @click="$emit('click')">
<image :src="icon" :style="imageStyle"></image> <image :src="icon" :style="imageStyle"></image>
</view> </view>
<view class="title" :style="titleStype">{{ label }}</view> <view class="title" :style="titleStype">{{ label }}</view>
@ -24,6 +24,10 @@ const props = defineProps({
labelColor: { labelColor: {
type: String, type: String,
default: '#515151' default: '#515151'
},
type: {
type: String,
default: 'circle'
} }
}) })
const menuStyle = computed(() => { const menuStyle = computed(() => {
@ -35,12 +39,12 @@ const menuStyle = computed(() => {
const imageStyle = computed(() => { const imageStyle = computed(() => {
return { return {
width: `${props.size}rpx`, width: `${props.size + (props.type === 'rect' ? 20 : 0)}rpx`,
height: `${props.size}rpx` height: `${props.size + (props.type === 'rect' ? 20 : 0)}rpx`
} }
}) })
const titleStype = computed(()=>{ const titleStype = computed(() => {
return { return {
width: `${props.size + 40}rpx`, width: `${props.size + 40}rpx`,
color: props.labelColor color: props.labelColor
@ -50,9 +54,25 @@ const titleStype = computed(()=>{
<style lang="scss" scoped> <style lang="scss" scoped>
.menu { .menu {
padding: 20rpx;
}
.circle {
padding: 20rpx;
border-radius: 10000px; border-radius: 10000px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
padding: 20rpx;
&:active {
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}
}
.rect {
padding: 0rpx;
&:active {
opacity: 0.5;
}
} }
.title { .title {

View File

@ -0,0 +1,147 @@
<template>
<view class="geek-card" @click="$emit('click')">
<view class="geek-header">
<view class="geek-shop">{{ shop }} > </view>
<view class="geek-status">{{ status }}</view>
</view>
<view class="geek-content">
<image class="geek-img" :src="img"></image>
<view class="geek-label">{{ label }}</view>
</view>
<view class="geek-footer">
<view class="geek-more" @click="$emit('more')">更多</view>
<view class="geek-buttonGroup">
<view class="geek-btn" @click="$emit('sell')">卖了换钱</view>
<view class="geek-btn" @click="$emit('return')">退换/售后</view>
<view class="geek-buy" @click="$emit('again')">再次购买</view>
</view>
</view>
</view>
</template>
<script setup>
const props = defineProps({
shop: {
type: String,
default: ''
},
status: {
type: String,
default: ''
},
img: {
type: String,
default: ''
},
label: {
type: String,
default: ''
},
price: {
type: Number,
default: 0
},
type: {
type: String,
default: 'line'
}
})
</script>
<style lang="scss" scoped>
.geek-card {
border: 1rpx solid rgb(183, 183, 183);
position: relative;
padding: 0;
border-radius: 10px;
height: 320rpx;
width: 700rpx;
padding: 20rpx;
margin: 20rpx;
.geek-header {
.geek-shop {
font-size: 28rpx;
font-weight: 600;
}
.geek-status {
width: 100rpx;
text-align: center;
position: absolute;
top: 30rpx;
right: 30rpx;
font-size: 25rpx;
}
}
.geek-content {
.geek-label {
position: absolute;
top: 100rpx;
width: 500rpx;
left: 180rpx;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.geek-img {
position: absolute;
border-radius: 10px;
height: 160rpx;
width: 160rpx;
top: 70rpx;
left: 10rpx;
}
}
.geek-footer {
width: 660rpx;
position: absolute;
bottom: 10rpx;
font-size: 25rpx;
.geek-more {
margin-bottom: 20rpx;
}
.geek-buttonGroup {
position: absolute;
right: 10rpx;
bottom: 0;
.geek-btn {
border: 1rpx solid black;
width: 150rpx;
height: 50rpx;
border-radius: 100px;
display: inline-block;
margin: 10rpx;
padding: 6rpx;
text-align: center;
}
.geek-buy {
color: red;
border: 1rpx solid red;
width: 150rpx;
height: 50rpx;
border-radius: 100px;
display: inline-block;
margin: 10rpx;
padding: 6rpx;
text-align: center;
}
}
}
}
</style>

View File

@ -7,10 +7,6 @@
import { computed } from 'vue'; import { computed } from 'vue';
const props = defineProps({ const props = defineProps({
icon: {
type: String,
default: ''
},
label: { label: {
type: String, type: String,
default: "订单数量" default: "订单数量"

View File

@ -4,7 +4,9 @@
"^u--(.*)": "uview-plus/components/u-$1/u-$1.vue", "^u--(.*)": "uview-plus/components/u-$1/u-$1.vue",
"^up-(.*)": "uview-plus/components/u-$1/u-$1.vue", "^up-(.*)": "uview-plus/components/u-$1/u-$1.vue",
"^u-([^-].*)": "uview-plus/components/u-$1/u-$1.vue", "^u-([^-].*)": "uview-plus/components/u-$1/u-$1.vue",
"qiun-(.*)": "@/components/qiun-data-charts/components/qiun-$1/qiun-$1.vue" "qiun-(.*)": "@/components/qiun-data-charts/components/qiun-$1/qiun-$1.vue",
"geek-(.*)": "@/components/geek-xd/components/geek-$1/geek-$1.vue",
"gx-(.*)": "@/components/geek-xd/components/geek-$1/geek-$1.vue"
} }
}, },
"pages": [ "pages": [
@ -103,12 +105,6 @@
{ {
"root": "pages_template/pages", "root": "pages_template/pages",
"pages": [ "pages": [
{
"path": "index/index",
"style": {
"pageOrientation": "auto"
}
},
{ {
"path": "wxCenter/index", "path": "wxCenter/index",
"style": { "style": {
@ -230,6 +226,14 @@
} }
} }
] ]
},
{
"root": "pages_geek/pages",
"pages": [
{
"path": "index/index"
}
]
} }
], ],
"tabBar": { "tabBar": {

View File

@ -13,41 +13,35 @@
</view> </view>
</template> </template>
<script> <script setup>
export default { import { ref, onMounted } from 'vue';
data() {
return { const chartData = ref({});
chartData: {},
}; onMounted(() => { getServerData() });
},
onReady() { function getServerData() {
this.getServerData(); //
},
methods: {
getServerData() {
//
setTimeout(() => { setTimeout(() => {
let res = { let res = {
categories: ["2016", "2017", "2018", "2019", "2020", "2021"], categories: ['2016', '2017', '2018', '2019', '2020', '2021'],
series: [ series: [
{ {
name: "目标值", name: '目标值',
data: [35, 36, 31, 33, 13, 34] data: [35, 36, 31, 33, 13, 34],
}, },
{ {
name: "完成量", name: '完成量',
data: [18, 27, 21, 24, 6, 28] data: [18, 27, 21, 24, 6, 28],
}
]
};
this.chartData = JSON.parse(JSON.stringify(res));
}, 500);
}, },
} ],
}; };
chartData.value = JSON.parse(JSON.stringify(res));
}, 500);
}
</script> </script>
<style> <style scoped>
.content { .content {
display: flex; display: flex;
flex-direction: column; flex-direction: column;

View File

@ -1,4 +1,16 @@
export default [ export default [
{
groupName: '组件',
groupName_en: 'Page',
list: [
{
path: '/pages_geek/pages/index/index',
icon: 'wxCenter',
title: '组件展示',
title_en: 'index',
},
]
},
{ {
groupName: '部件', groupName: '部件',
groupName_en: 'Parts', groupName_en: 'Parts',
@ -20,7 +32,13 @@ export default [
icon: 'submitBar', icon: 'submitBar',
title: 'SubmitBar 提交订单栏', title: 'SubmitBar 提交订单栏',
title_en: 'SubmitBar', title_en: 'SubmitBar',
} },
{
path: '/pages_template/pages/keyboardPay/index',
icon: 'keyboardPay',
title: 'KeyboardPay 自定义键盘支付模板',
title_en: 'KeyboardPay',
},
] ]
}, },
{ {
@ -57,24 +75,12 @@ export default [
groupName: '页面', groupName: '页面',
groupName_en: 'Page', groupName_en: 'Page',
list: [ list: [
{
path: '/pages_template/pages/index/index',
icon: 'wxCenter',
title: '组件展示',
title_en: 'index',
},
{ {
path: '/pages_template/pages/wxCenter/index', path: '/pages_template/pages/wxCenter/index',
icon: 'wxCenter', icon: 'wxCenter',
title: 'WxCenter 仿微信个人中心', title: 'WxCenter 仿微信个人中心',
title_en: 'WxCenter', title_en: 'WxCenter',
}, },
{
path: '/pages_template/pages/keyboardPay/index',
icon: 'keyboardPay',
title: 'KeyboardPay 自定义键盘支付模板',
title_en: 'KeyboardPay',
},
{ {
path: '/pages_template/pages/mallMenu/index1', path: '/pages_template/pages/mallMenu/index1',
icon: 'mall_menu_1', icon: 'mall_menu_1',
@ -115,5 +121,5 @@ export default [
title_en: 'Address', title_en: 'Address',
}, },
] ]
} },
] ]

View File

@ -0,0 +1,91 @@
<template>
<uni-section class="mb-10" title="数值板" sub-title="statistic" type="line"></uni-section>
<u-row gutter="0">
<u-col span="6">
<geek-statistic label="订单数量(个)" labelColor="#1f1f1f" :number="0" numberColor="red" />
</u-col>
<u-col span="6">
<geek-statistic label="交易金额(元)" labelColor="#1f1f1f" :number="0" numberColor="red" />
</u-col>
</u-row>
<uni-section class="mb-10" title="菜单" sub-title="menu" type="line"></uni-section>
<u-row>
<u-col :span="2.1" :offset="0.3" v-for="menu, index in menus" :key="index">
<geek-menu :icon="menu.icon" :label="menu.label" :size="60" @click="modal.msg(menu.label)" type="circle" />
</u-col>
</u-row>
<u-row>
<u-col :span="2.1" :offset="0.3" v-for="menu, index in menus" :key="index">
<geek-menu :icon="menu.icon" :label="menu.label" :size="60" @click="modal.msg(menu.label)" type="rect" />
</u-col>
</u-row>
<uni-section class="mb-10" title="商品列表" sub-title="commodity" type="line"></uni-section>
<geek-commodity v-for="item, index in commodityList" :key="index" :price="item.price" :title="item.title"
:sub-title="item.subTitle" :img="item.img" type="line" @click="modal.msg(item.title)" />
<geek-commodity v-for="item, index in commodityList" :key="index" :price="item.price" :title="item.title"
:sub-title="item.subTitle" :img="item.img" type="rect" @click="modal.msg(item.title)" />
<uni-section class="mb-10" title="订单列表" sub-title="order" type="line"></uni-section>
<geek-order v-for="item, index in orderList" :img="item.img" :label="item.title" :shop="item.shop" :status="item.status"
:price="item.price" @more="modal.msg('更多')" @again="modal.msg('再次购买')" @return="modal.msg('退换')"
@sell="modal.msg('卖了换钱')"></geek-order>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue';
import modal from '@/plugins/modal.js'
const menus = reactive([
{ icon: "/static/images/icon/rocket.png", label: '抢单' },
{ icon: "/static/images/icon/phone.png", label: '回访' },
{ icon: "/static/images/icon/message.png", label: '消息' },
{ icon: "/static/images/icon/dialogue.png", label: '公告' },
{ icon: "/static/images/icon/knowledge.png", label: '知识库' }
]);
const commodityList = reactive([
{
img: '/static/images/banner/banner01.jpg',
title: '商品1',
subTitle: '商品1简介',
price: 100,
},
{
img: '/static/images/banner/banner02.jpg',
title: '商品2',
subTitle: '商品2简介',
price: 300,
},
{
img: '/static/images/banner/banner03.jpg',
title: '商品3',
subTitle: '商品3简介',
price: 200,
}
])
const orderList = [
{
shop: 'geek自营旗舰店',
status: '完成',
img: '/static/images/banner/banner01.jpg',
title: '商品1',
subTitle: '商品1简介',
price: 100,
},
{
shop: 'geek自营旗舰店',
status: '已取消',
img: '/static/images/banner/banner03.jpg',
title: '商商商商商商商商商商商商商商商商商商商商商商商商商商商商商商商商商商品3',
subTitle: '商品3简介',
price: 200,
}
]
</script>
<style lang="scss" scoped></style>

View File

@ -45,7 +45,7 @@ export default {
// //
toAllReply() { toAllReply() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/template/comment/reply' url: '/pages_template/pages/comment/reply'
}); });
}, },
// //

View File

@ -1,38 +0,0 @@
<template>
<uni-section class="mb-10" title="数值板" sub-title="statistic" type="line"></uni-section>
<u-row gutter="0">
<u-col span="6">
<statistic label="订单数量(个)" labelColor="#1f1f1f" number="0" numberColor="red" />
</u-col>
<u-col span="6">
<statistic label="交易金额(元)" labelColor="#1f1f1f" number="0" numberColor="red" />
</u-col>
</u-row>
<uni-section class="mb-10" title="圆形菜单" sub-title="circle-menu" type="line"></uni-section>
<u-row>
<u-col :span="2.1" :offset="0.3" v-for="menu, index in menus" :key="index">
<circleMenu :icon="menu.icon" :label="menu.label" :size="60" @click="modal.msg(menu.label)"></circleMenu>
</u-col>
</u-row>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue';
import circleMenu from '../../components/circle-menu'
import statistic from '../../components/statistic.vue';
import modal from '@/plugins/modal.js'
//
const menus = reactive(
[
{ icon: "/static/images/icon/rocket.png", label: '抢单' },
{ icon: "/static/images/icon/phone.png", label: '回访' },
{ icon: "/static/images/icon/message.png", label: '消息' },
{ icon: "/static/images/icon/dialogue.png", label: '公告' },
{ icon: "/static/images/icon/knowledge.png", label: '知识库' }
]);
</script>
<style lang="scss" scoped></style>

View File

@ -36,22 +36,22 @@
<!-- 登录 --> <!-- 登录 -->
<view v-else> <view v-else>
<view class="container"> <view class="container">
<view class="cover slide-top1" :style="'animation-play-state:' + play3"> <view class="cover slide-top1" :style="'animation-play-state:' + play[2]">
<view class="masking slide-top" :class="[collapsedClass, { animating: isAnimating }]" ref="fixedView" <view class="masking slide-top" :class="[collapsedClass, { animating: isAnimating }]" ref="fixedView"
:style="'animation-play-state:' + play1"> :style="'animation-play-state:' + play[0]">
<uni-row> <uni-row>
<text class="text-first">欢迎使用</text> <text class="text-first">欢迎使用</text>
<text class="text-second">校园访客</text> <text class="text-second">校园访客</text>
<text class="text-third">预约系统</text> <text class="text-third">预约系统</text>
<view :class="{ active: isActive === true, button: isActive !== true }" @click="play" <view :class="{ active: isActive === true, button: isActive !== true }" @click="startplay"
:style="'animation-play-state:' + play2"> :style="'animation-play-state:' + play[1]">
<uni-row> <uni-row>
<text class="text-fifth">访客登录</text> <text class="text-fifth">访客登录</text>
</uni-row> </uni-row>
</view> </view>
<view class="shadow1" :style="'animation-play-state:' + play2" /> <view class="shadow1" :style="'animation-play-state:' + play[1]" />
<view class="shadow2" :style="'animation-play-state:' + play2" /> <view class="shadow2" :style="'animation-play-state:' + play[1]" />
<view class="shadow3" :style="'animation-play-state:' + play2" /> <view class="shadow3" :style="'animation-play-state:' + play[1]" />
<image <image
style="width: 100%;height: 1050rpx;opacity: 0.05;border-radius: 0 0 400rpx 400rpx;position: absolute;" style="width: 100%;height: 1050rpx;opacity: 0.05;border-radius: 0 0 400rpx 400rpx;position: absolute;"
@ -80,15 +80,11 @@ export default {
isFixedViewVisible: true, isFixedViewVisible: true,
animationType: "up", // right up animationType: "up", // right up
isAnimating: false, // isAnimating: false, //
play1: "paused", play: ["paused", "paused", "paused"],
play2: "paused",
play3: "paused",
page: "index", page: "index",
codeUrl: "", codeUrl: "",
captchaEnabled: true, captchaEnabled: true,
globalConfig: getApp().globalData.config,
loginForm: { loginForm: {
username: "admin", username: "admin",
password: "admin123", password: "admin123",
@ -107,30 +103,29 @@ export default {
}, },
methods: { methods: {
login() { login() {
this.play3 = "running" this.play[2] = "running"
setTimeout(() => { this.page = 'login' }, 1000) setTimeout(() => { this.page = 'login' }, 1000)
}, },
back() { back() {
this.page = 'index' this.page = 'index'
this.play1 = "paused" this.play[0] = "paused"
this.play2 = "paused" this.play[1] = "paused"
this.play3 = "paused" this.play[2] = "paused"
console.log("index")
}, },
play() { startplay() {
this.play2 = "running" this.play[1] = "running"
this.isActive = true; this.isActive = true;
setTimeout(() => { this.isActive = false; }, 300); setTimeout(() => { this.isActive = false; }, 300);
if (this.isAnimating) { return; } if (this.isAnimating) { return; }
this.isAnimating = false; // this.isAnimating = false; //
this.play1 = "running" this.play[0] = "running"
this.isFixedViewVisible = !this.isFixedViewVisible; this.isFixedViewVisible = !this.isFixedViewVisible;
let fixedView = this.$refs.fixedView; let fixedView = this.$refs.fixedView;
if (fixedView) if (fixedView)
fixedView.addEventListener('transitionend', () => { this.isAnimating = false; }, { once: true }); fixedView.addEventListener('transitionend', () => { this.isAnimating = false; }, { once: true });
setTimeout(() => { uni.navigateBack({delta: 1 }); }, 1000) setTimeout(() => { uni.navigateBack({ delta: 1 }); }, 1000)
}, },

View File

@ -8,22 +8,24 @@
</view> </view>
<view class="u-menu-wrap"> <view class="u-menu-wrap">
<scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="scrollTop"> <scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="scrollTop">
<view v-for="(item,index) in tabbar" :key="index" class="u-tab-item" :class="[current==index ? 'u-tab-item-active' : '']" <view v-for="(item, index) in tabbar" :key="index" class="u-tab-item"
:data-current="index" @tap.stop="swichMenu(index)"> :class="[current == index ? 'u-tab-item-active' : '']" :data-current="index"
<text class="u-line-1">{{item.name}}</text> @tap.stop="swichMenu(index)">
<text class="u-line-1">{{ item.name }}</text>
</view> </view>
</scroll-view> </scroll-view>
<block v-for="(item,index) in tabbar" :key="index"> <block v-for="(item, index) in tabbar" :key="index">
<scroll-view scroll-y class="right-box" v-if="current==index"> <scroll-view scroll-y class="right-box" v-if="current == index">
<view class="page-view"> <view class="page-view">
<view class="class-item"> <view class="class-item">
<view class="item-title"> <view class="item-title">
<text>{{item.name}}</text> <text>{{ item.name }}</text>
</view> </view>
<view class="item-container"> <view class="item-container">
<view class="thumb-box" v-for="(item1, index1) in item.foods" :key="index1"> <view class="thumb-box" v-for="(item1, index1) in item.foods" :key="index1"
@click="clickMenu(item1)">
<image class="item-menu-image" :src="item1.icon" mode=""></image> <image class="item-menu-image" :src="item1.icon" mode=""></image>
<view class="item-menu-name">{{item1.name}}</view> <view class="item-menu-name">{{ item1.name }}</view>
</view> </view>
</view> </view>
</view> </view>
@ -35,8 +37,8 @@
</template> </template>
<script> <script>
import classifyData from "@/pages_template/common/classify.data.js"; import classifyData from "@/pages_template/common/classify.data.js";
export default { export default {
data() { data() {
return { return {
tabbar: classifyData, tabbar: classifyData,
@ -45,20 +47,14 @@
menuHeight: 0, // menuHeight: 0, //
menuItemHeight: 0, // item menuItemHeight: 0, // item
} }
},
computed: {
}, },
methods: { methods: {
getImg() {
return Math.floor(Math.random() * 35);
},
// //
async swichMenu(index) { async swichMenu(index) {
if(index == this.current) return ; if (index == this.current) return;
this.current = index; this.current = index;
// 0 // 0
if(this.menuHeight == 0 || this.menuItemHeight == 0) { if (this.menuHeight == 0 || this.menuItemHeight == 0) {
await this.getElRect('menu-scroll-view', 'menuHeight'); await this.getElRect('menu-scroll-view', 'menuHeight');
await this.getElRect('u-tab-item', 'menuItemHeight'); await this.getElRect('u-tab-item', 'menuItemHeight');
} }
@ -69,62 +65,65 @@
getElRect(elClass, dataVal) { getElRect(elClass, dataVal) {
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
const query = uni.createSelectorQuery().in(this); const query = uni.createSelectorQuery().in(this);
query.select('.' + elClass).fields({size: true},res => { query.select('.' + elClass).fields({ size: true }, res => {
// resnull // resnull
if(!res) { if (!res) {
setTimeout(() => { setTimeout(() => {
this.getElRect(elClass); this.getElRect(elClass);
}, 10); }, 10);
return ; return;
} }
this[dataVal] = res.height; this[dataVal] = res.height;
}).exec(); }).exec();
}) })
},
clickMenu(menu) {
console.log(menu);
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.u-wrap { .u-wrap {
height: calc(100vh); height: calc(100vh);
/* #ifdef H5 */ /* #ifdef H5 */
height: calc(100vh - var(--window-top)); height: calc(100vh - var(--window-top));
/* #endif */ /* #endif */
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.u-search-box { .u-search-box {
padding: 18rpx 30rpx; padding: 18rpx 30rpx;
} }
.u-menu-wrap { .u-menu-wrap {
flex: 1; flex: 1;
display: flex; display: flex;
overflow: hidden; overflow: hidden;
} }
.u-search-inner { .u-search-inner {
background-color: rgb(234, 234, 234); background-color: rgb(234, 234, 234);
border-radius: 100rpx; border-radius: 100rpx;
display: flex; display: flex;
align-items: center; align-items: center;
padding: 10rpx 16rpx; padding: 10rpx 16rpx;
} }
.u-search-text { .u-search-text {
font-size: 26rpx; font-size: 26rpx;
color: $u-tips-color; color: $u-tips-color;
margin-left: 10rpx; margin-left: 10rpx;
} }
.u-tab-view { .u-tab-view {
width: 200rpx; width: 200rpx;
height: 100%; height: 100%;
} }
.u-tab-item { .u-tab-item {
height: 110rpx; height: 110rpx;
background: #f6f6f6; background: #f6f6f6;
box-sizing: border-box; box-sizing: border-box;
@ -135,72 +134,72 @@
color: #444; color: #444;
font-weight: 400; font-weight: 400;
line-height: 1; line-height: 1;
} }
.u-tab-item-active { .u-tab-item-active {
position: relative; position: relative;
color: #000; color: #000;
font-size: 30rpx; font-size: 30rpx;
font-weight: 600; font-weight: 600;
background: #fff; background: #fff;
} }
.u-tab-item-active::before { .u-tab-item-active::before {
content: ""; content: "";
position: absolute; position: absolute;
border-left: 4px solid $u-primary; border-left: 4px solid $u-primary;
height: 32rpx; height: 32rpx;
left: 0; left: 0;
top: 39rpx; top: 39rpx;
} }
.u-tab-view { .u-tab-view {
height: 100%; height: 100%;
} }
.right-box { .right-box {
background-color: rgb(250, 250, 250); background-color: rgb(250, 250, 250);
} }
.page-view { .page-view {
padding: 16rpx; padding: 16rpx;
} }
.class-item { .class-item {
margin-bottom: 30rpx; margin-bottom: 30rpx;
background-color: #fff; background-color: #fff;
padding: 16rpx; padding: 16rpx;
border-radius: 8rpx; border-radius: 8rpx;
} }
.item-title { .item-title {
font-size: 26rpx; font-size: 26rpx;
color: $u-main-color; color: $u-main-color;
font-weight: bold; font-weight: bold;
} }
.item-menu-name { .item-menu-name {
font-weight: normal; font-weight: normal;
font-size: 24rpx; font-size: 24rpx;
color: $u-main-color; color: $u-main-color;
} }
.item-container { .item-container {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
} }
.thumb-box { .thumb-box {
width: 33.333333%; width: 33.333333%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
flex-direction: column; flex-direction: column;
margin-top: 20rpx; margin-top: 20rpx;
} }
.item-menu-image { .item-menu-image {
width: 120rpx; width: 120rpx;
height: 120rpx; height: 120rpx;
} }
</style> </style>

View File

@ -9,21 +9,23 @@
<view class="u-menu-wrap"> <view class="u-menu-wrap">
<scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="scrollTop" <scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="scrollTop"
:scroll-into-view="itemId"> :scroll-into-view="itemId">
<view v-for="(item,index) in tabbar" :key="index" class="u-tab-item" :class="[current == index ? 'u-tab-item-active' : '']" <view v-for="(item, index) in tabbar" :key="index" class="u-tab-item"
@tap.stop="swichMenu(index)"> :class="[current == index ? 'u-tab-item-active' : '']" @tap.stop="swichMenu(index)">
<text class="u-line-1">{{item.name}}</text> <text class="u-line-1">{{ item.name }}</text>
</view> </view>
</scroll-view> </scroll-view>
<scroll-view :scroll-top="scrollRightTop" scroll-y scroll-with-animation class="right-box" @scroll="rightScroll"> <scroll-view :scroll-top="scrollRightTop" scroll-y scroll-with-animation class="right-box"
@scroll="rightScroll">
<view class="page-view"> <view class="page-view">
<view class="class-item" :id="'item' + index" v-for="(item , index) in tabbar" :key="index"> <view class="class-item" :id="'item' + index" v-for="(item, index) in tabbar" :key="index">
<view class="item-title"> <view class="item-title">
<text>{{item.name}}</text> <text>{{ item.name }}</text>
</view> </view>
<view class="item-container"> <view class="item-container">
<view class="thumb-box" v-for="(item1, index1) in item.foods" :key="index1"> <view class="thumb-box" v-for="(item1, index1) in item.foods" :key="index1"
@click="clickMenu(item1)">
<image class="item-menu-image" :src="item1.icon" mode=""></image> <image class="item-menu-image" :src="item1.icon" mode=""></image>
<view class="item-menu-name">{{item1.name}}</view> <view class="item-menu-name">{{ item1.name }}</view>
</view> </view>
</view> </view>
</view> </view>
@ -33,8 +35,8 @@
</view> </view>
</template> </template>
<script> <script>
import classifyData from '@/pages_template/common/classify.data.js'; import classifyData from '@/pages_template/common/classify.data.js';
export default { export default {
data() { data() {
return { return {
scrollTop: 0, //tab scrollTop: 0, //tab
@ -44,15 +46,12 @@
menuItemHeight: 0, // item menuItemHeight: 0, // item
itemId: '', // scroll-viewid itemId: '', // scroll-viewid
tabbar: classifyData, tabbar: classifyData,
menuItemPos: [],
arr: [], arr: [],
scrollRightTop: 0, // scroll-view scrollRightTop: 0, // scroll-view
timer: null, // timer: null, //
} }
},
onLoad() {
}, },
onReady() { onReady() {
this.getMenuItemTop() this.getMenuItemTop()
@ -60,12 +59,12 @@
methods: { methods: {
// //
async swichMenu(index) { async swichMenu(index) {
if(this.arr.length == 0) { if (this.arr.length == 0) {
await this.getMenuItemTop(); await this.getMenuItemTop();
} }
if (index == this.current) return; if (index == this.current) return;
this.scrollRightTop = this.oldScrollTop; this.scrollRightTop = this.oldScrollTop;
this.$nextTick(()=>{ this.$nextTick(() => {
this.scrollRightTop = this.arr[index]; this.scrollRightTop = this.arr[index];
this.current = index; this.current = index;
this.leftMenuStatus(index); this.leftMenuStatus(index);
@ -123,11 +122,11 @@
let selectorQuery = uni.createSelectorQuery(); let selectorQuery = uni.createSelectorQuery();
selectorQuery.selectAll('.class-item').boundingClientRect((rects) => { selectorQuery.selectAll('.class-item').boundingClientRect((rects) => {
// rects[](selectAll) // rects[](selectAll)
if(!rects.length) { if (!rects.length) {
setTimeout(() => { setTimeout(() => {
this.getMenuItemTop(); this.getMenuItemTop();
}, 10); }, 10);
return ; return;
} }
rects.forEach((rect) => { rects.forEach((rect) => {
// rects[0].top() // rects[0].top()
@ -140,11 +139,11 @@
// //
async rightScroll(e) { async rightScroll(e) {
this.oldScrollTop = e.detail.scrollTop; this.oldScrollTop = e.detail.scrollTop;
if(this.arr.length == 0) { if (this.arr.length == 0) {
await this.getMenuItemTop(); await this.getMenuItemTop();
} }
if(this.timer) return ; if (this.timer) return;
if(!this.menuHeight) { if (!this.menuHeight) {
await this.getElRect('menu-scroll-view', 'menuHeight'); await this.getElRect('menu-scroll-view', 'menuHeight');
} }
setTimeout(() => { // setTimeout(() => { //
@ -157,55 +156,58 @@
// height2 // height2
if (!height2 || scrollHeight >= height1 && scrollHeight < height2) { if (!height2 || scrollHeight >= height1 && scrollHeight < height2) {
this.leftMenuStatus(i); this.leftMenuStatus(i);
return ; return;
} }
} }
}, 10) }, 10)
},
clickMenu(menu) {
console.log(menu);
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.u-wrap { .u-wrap {
height: calc(100vh); height: calc(100vh);
/* #ifdef H5 */ /* #ifdef H5 */
height: calc(100vh - var(--window-top)); height: calc(100vh - var(--window-top));
/* #endif */ /* #endif */
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.u-search-box { .u-search-box {
padding: 18rpx 30rpx; padding: 18rpx 30rpx;
} }
.u-menu-wrap { .u-menu-wrap {
flex: 1; flex: 1;
display: flex; display: flex;
overflow: hidden; overflow: hidden;
} }
.u-search-inner { .u-search-inner {
background-color: rgb(234, 234, 234); background-color: rgb(234, 234, 234);
border-radius: 100rpx; border-radius: 100rpx;
display: flex; display: flex;
align-items: center; align-items: center;
padding: 10rpx 16rpx; padding: 10rpx 16rpx;
} }
.u-search-text { .u-search-text {
font-size: 26rpx; font-size: 26rpx;
color: $u-tips-color; color: $u-tips-color;
margin-left: 10rpx; margin-left: 10rpx;
} }
.u-tab-view { .u-tab-view {
width: 200rpx; width: 200rpx;
height: 100%; height: 100%;
} }
.u-tab-item { .u-tab-item {
height: 110rpx; height: 110rpx;
background: #f6f6f6; background: #f6f6f6;
box-sizing: border-box; box-sizing: border-box;
@ -216,76 +218,76 @@
color: #444; color: #444;
font-weight: 400; font-weight: 400;
line-height: 1; line-height: 1;
} }
.u-tab-item-active { .u-tab-item-active {
position: relative; position: relative;
color: #000; color: #000;
font-size: 30rpx; font-size: 30rpx;
font-weight: 600; font-weight: 600;
background: #fff; background: #fff;
} }
.u-tab-item-active::before { .u-tab-item-active::before {
content: ""; content: "";
position: absolute; position: absolute;
border-left: 4px solid $u-primary; border-left: 4px solid $u-primary;
height: 32rpx; height: 32rpx;
left: 0; left: 0;
top: 39rpx; top: 39rpx;
} }
.u-tab-view { .u-tab-view {
height: 100%; height: 100%;
} }
.right-box { .right-box {
background-color: rgb(250, 250, 250); background-color: rgb(250, 250, 250);
} }
.page-view { .page-view {
padding: 16rpx; padding: 16rpx;
} }
.class-item { .class-item {
margin-bottom: 30rpx; margin-bottom: 30rpx;
background-color: #fff; background-color: #fff;
padding: 16rpx; padding: 16rpx;
border-radius: 8rpx; border-radius: 8rpx;
} }
.class-item:last-child { .class-item:last-child {
min-height: 100vh; min-height: 100vh;
} }
.item-title { .item-title {
font-size: 26rpx; font-size: 26rpx;
color: $u-main-color; color: $u-main-color;
font-weight: bold; font-weight: bold;
} }
.item-menu-name { .item-menu-name {
font-weight: normal; font-weight: normal;
font-size: 24rpx; font-size: 24rpx;
color: $u-main-color; color: $u-main-color;
} }
.item-container { .item-container {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
} }
.thumb-box { .thumb-box {
width: 33.333333%; width: 33.333333%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
flex-direction: column; flex-direction: column;
margin-top: 20rpx; margin-top: 20rpx;
} }
.item-menu-image { .item-menu-image {
width: 120rpx; width: 120rpx;
height: 120rpx; height: 120rpx;
} }
</style> </style>