添加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

4
.gitignore vendored
View File

@ -1,4 +1,6 @@
.hbuilderx
unpackage
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>
<view class="menu" :style="menuStyle" @click="$emit('click')">
<view class="menu" :class="type" :style="menuStyle" @click="$emit('click')">
<image :src="icon" :style="imageStyle"></image>
</view>
<view class="title" :style="titleStype">{{ label }}</view>
@ -24,6 +24,10 @@ const props = defineProps({
labelColor: {
type: String,
default: '#515151'
},
type: {
type: String,
default: 'circle'
}
})
const menuStyle = computed(() => {
@ -35,12 +39,12 @@ const menuStyle = computed(() => {
const imageStyle = computed(() => {
return {
width: `${props.size}rpx`,
height: `${props.size}rpx`
width: `${props.size + (props.type === 'rect' ? 20 : 0)}rpx`,
height: `${props.size + (props.type === 'rect' ? 20 : 0)}rpx`
}
})
const titleStype = computed(()=>{
const titleStype = computed(() => {
return {
width: `${props.size + 40}rpx`,
color: props.labelColor
@ -50,9 +54,25 @@ const titleStype = computed(()=>{
<style lang="scss" scoped>
.menu {
padding: 20rpx;
}
.circle {
padding: 20rpx;
border-radius: 10000px;
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 {

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';
const props = defineProps({
icon: {
type: String,
default: ''
},
label: {
type: String,
default: "订单数量"

View File

@ -4,7 +4,9 @@
"^u--(.*)": "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",
"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": [
@ -103,12 +105,6 @@
{
"root": "pages_template/pages",
"pages": [
{
"path": "index/index",
"style": {
"pageOrientation": "auto"
}
},
{
"path": "wxCenter/index",
"style": {
@ -230,6 +226,14 @@
}
}
]
},
{
"root": "pages_geek/pages",
"pages": [
{
"path": "index/index"
}
]
}
],
"tabBar": {

View File

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

View File

@ -1,4 +1,16 @@
export default [
{
groupName: '组件',
groupName_en: 'Page',
list: [
{
path: '/pages_geek/pages/index/index',
icon: 'wxCenter',
title: '组件展示',
title_en: 'index',
},
]
},
{
groupName: '部件',
groupName_en: 'Parts',
@ -14,13 +26,19 @@ export default [
icon: 'citySelect',
title: 'CitySelect 城市选择',
title_en: 'CitySelect',
},
},
{
path: '/pages_template/pages/submitBar/index',
icon: 'submitBar',
title: '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_en: 'Page',
list: [
{
path: '/pages_template/pages/index/index',
icon: 'wxCenter',
title: '组件展示',
title_en: 'index',
},
{
path: '/pages_template/pages/wxCenter/index',
icon: 'wxCenter',
title: 'WxCenter 仿微信个人中心',
title_en: 'WxCenter',
},
{
path: '/pages_template/pages/keyboardPay/index',
icon: 'keyboardPay',
title: 'KeyboardPay 自定义键盘支付模板',
title_en: 'KeyboardPay',
},
{
path: '/pages_template/pages/mallMenu/index1',
icon: 'mall_menu_1',
@ -115,5 +121,5 @@ export default [
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() {
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 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"
:style="'animation-play-state:' + play1">
:style="'animation-play-state:' + play[0]">
<uni-row>
<text class="text-first">欢迎使用</text>
<text class="text-second">校园访客</text>
<text class="text-third">预约系统</text>
<view :class="{ active: isActive === true, button: isActive !== true }" @click="play"
:style="'animation-play-state:' + play2">
<view :class="{ active: isActive === true, button: isActive !== true }" @click="startplay"
:style="'animation-play-state:' + play[1]">
<uni-row>
<text class="text-fifth">访客登录</text>
</uni-row>
</view>
<view class="shadow1" :style="'animation-play-state:' + play2" />
<view class="shadow2" :style="'animation-play-state:' + play2" />
<view class="shadow3" :style="'animation-play-state:' + play2" />
<view class="shadow1" :style="'animation-play-state:' + play[1]" />
<view class="shadow2" :style="'animation-play-state:' + play[1]" />
<view class="shadow3" :style="'animation-play-state:' + play[1]" />
<image
style="width: 100%;height: 1050rpx;opacity: 0.05;border-radius: 0 0 400rpx 400rpx;position: absolute;"
@ -80,15 +80,11 @@ export default {
isFixedViewVisible: true,
animationType: "up", // right up
isAnimating: false, //
play1: "paused",
play2: "paused",
play3: "paused",
play: ["paused", "paused", "paused"],
page: "index",
codeUrl: "",
captchaEnabled: true,
globalConfig: getApp().globalData.config,
loginForm: {
username: "admin",
password: "admin123",
@ -107,30 +103,29 @@ export default {
},
methods: {
login() {
this.play3 = "running"
this.play[2] = "running"
setTimeout(() => { this.page = 'login' }, 1000)
},
back() {
this.page = 'index'
this.play1 = "paused"
this.play2 = "paused"
this.play3 = "paused"
console.log("index")
this.play[0] = "paused"
this.play[1] = "paused"
this.play[2] = "paused"
},
play() {
this.play2 = "running"
startplay() {
this.play[1] = "running"
this.isActive = true;
setTimeout(() => { this.isActive = false; }, 300);
if (this.isAnimating) { return; }
this.isAnimating = false; //
this.play1 = "running"
this.play[0] = "running"
this.isFixedViewVisible = !this.isFixedViewVisible;
let fixedView = this.$refs.fixedView;
if (fixedView)
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 class="u-menu-wrap">
<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' : '']"
:data-current="index" @tap.stop="swichMenu(index)">
<text class="u-line-1">{{item.name}}</text>
<view v-for="(item, index) in tabbar" :key="index" class="u-tab-item"
:class="[current == index ? 'u-tab-item-active' : '']" :data-current="index"
@tap.stop="swichMenu(index)">
<text class="u-line-1">{{ item.name }}</text>
</view>
</scroll-view>
<block v-for="(item,index) in tabbar" :key="index">
<scroll-view scroll-y class="right-box" v-if="current==index">
<block v-for="(item, index) in tabbar" :key="index">
<scroll-view scroll-y class="right-box" v-if="current == index">
<view class="page-view">
<view class="class-item">
<view class="item-title">
<text>{{item.name}}</text>
<text>{{ item.name }}</text>
</view>
<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>
<view class="item-menu-name">{{item1.name}}</view>
<view class="item-menu-name">{{ item1.name }}</view>
</view>
</view>
</view>
@ -35,172 +37,169 @@
</template>
<script>
import classifyData from "@/pages_template/common/classify.data.js";
export default {
data() {
return {
tabbar: classifyData,
scrollTop: 0, //tab
current: 0, //
menuHeight: 0, //
menuItemHeight: 0, // item
import classifyData from "@/pages_template/common/classify.data.js";
export default {
data() {
return {
tabbar: classifyData,
scrollTop: 0, //tab
current: 0, //
menuHeight: 0, //
menuItemHeight: 0, // item
}
},
methods: {
//
async swichMenu(index) {
if (index == this.current) return;
this.current = index;
// 0
if (this.menuHeight == 0 || this.menuItemHeight == 0) {
await this.getElRect('menu-scroll-view', 'menuHeight');
await this.getElRect('u-tab-item', 'menuItemHeight');
}
// item
this.scrollTop = index * this.menuItemHeight + this.menuItemHeight / 2 - this.menuHeight / 2;
},
computed: {
//
getElRect(elClass, dataVal) {
new Promise((resolve, reject) => {
const query = uni.createSelectorQuery().in(this);
query.select('.' + elClass).fields({ size: true }, res => {
// resnull
if (!res) {
setTimeout(() => {
this.getElRect(elClass);
}, 10);
return;
}
this[dataVal] = res.height;
}).exec();
})
},
methods: {
getImg() {
return Math.floor(Math.random() * 35);
},
//
async swichMenu(index) {
if(index == this.current) return ;
this.current = index;
// 0
if(this.menuHeight == 0 || this.menuItemHeight == 0) {
await this.getElRect('menu-scroll-view', 'menuHeight');
await this.getElRect('u-tab-item', 'menuItemHeight');
}
// item
this.scrollTop = index * this.menuItemHeight + this.menuItemHeight / 2 - this.menuHeight / 2;
},
//
getElRect(elClass, dataVal) {
new Promise((resolve, reject) => {
const query = uni.createSelectorQuery().in(this);
query.select('.' + elClass).fields({size: true},res => {
// resnull
if(!res) {
setTimeout(() => {
this.getElRect(elClass);
}, 10);
return ;
}
this[dataVal] = res.height;
}).exec();
})
}
clickMenu(menu) {
console.log(menu);
}
}
}
</script>
<style lang="scss" scoped>
.u-wrap {
height: calc(100vh);
/* #ifdef H5 */
height: calc(100vh - var(--window-top));
/* #endif */
display: flex;
flex-direction: column;
}
.u-wrap {
height: calc(100vh);
/* #ifdef H5 */
height: calc(100vh - var(--window-top));
/* #endif */
display: flex;
flex-direction: column;
}
.u-search-box {
padding: 18rpx 30rpx;
}
.u-search-box {
padding: 18rpx 30rpx;
}
.u-menu-wrap {
flex: 1;
display: flex;
overflow: hidden;
}
.u-menu-wrap {
flex: 1;
display: flex;
overflow: hidden;
}
.u-search-inner {
background-color: rgb(234, 234, 234);
border-radius: 100rpx;
display: flex;
align-items: center;
padding: 10rpx 16rpx;
}
.u-search-inner {
background-color: rgb(234, 234, 234);
border-radius: 100rpx;
display: flex;
align-items: center;
padding: 10rpx 16rpx;
}
.u-search-text {
font-size: 26rpx;
color: $u-tips-color;
margin-left: 10rpx;
}
.u-search-text {
font-size: 26rpx;
color: $u-tips-color;
margin-left: 10rpx;
}
.u-tab-view {
width: 200rpx;
height: 100%;
}
.u-tab-view {
width: 200rpx;
height: 100%;
}
.u-tab-item {
height: 110rpx;
background: #f6f6f6;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
font-size: 26rpx;
color: #444;
font-weight: 400;
line-height: 1;
}
.u-tab-item-active {
position: relative;
color: #000;
font-size: 30rpx;
font-weight: 600;
background: #fff;
}
.u-tab-item-active::before {
content: "";
position: absolute;
border-left: 4px solid $u-primary;
height: 32rpx;
left: 0;
top: 39rpx;
}
.u-tab-item {
height: 110rpx;
background: #f6f6f6;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
font-size: 26rpx;
color: #444;
font-weight: 400;
line-height: 1;
}
.u-tab-view {
height: 100%;
}
.right-box {
background-color: rgb(250, 250, 250);
}
.page-view {
padding: 16rpx;
}
.class-item {
margin-bottom: 30rpx;
background-color: #fff;
padding: 16rpx;
border-radius: 8rpx;
}
.item-title {
font-size: 26rpx;
color: $u-main-color;
font-weight: bold;
}
.item-menu-name {
font-weight: normal;
font-size: 24rpx;
color: $u-main-color;
}
.item-container {
display: flex;
flex-wrap: wrap;
}
.thumb-box {
width: 33.333333%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
margin-top: 20rpx;
}
.item-menu-image {
width: 120rpx;
height: 120rpx;
}
.u-tab-item-active {
position: relative;
color: #000;
font-size: 30rpx;
font-weight: 600;
background: #fff;
}
.u-tab-item-active::before {
content: "";
position: absolute;
border-left: 4px solid $u-primary;
height: 32rpx;
left: 0;
top: 39rpx;
}
.u-tab-view {
height: 100%;
}
.right-box {
background-color: rgb(250, 250, 250);
}
.page-view {
padding: 16rpx;
}
.class-item {
margin-bottom: 30rpx;
background-color: #fff;
padding: 16rpx;
border-radius: 8rpx;
}
.item-title {
font-size: 26rpx;
color: $u-main-color;
font-weight: bold;
}
.item-menu-name {
font-weight: normal;
font-size: 24rpx;
color: $u-main-color;
}
.item-container {
display: flex;
flex-wrap: wrap;
}
.thumb-box {
width: 33.333333%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
margin-top: 20rpx;
}
.item-menu-image {
width: 120rpx;
height: 120rpx;
}
</style>

View File

@ -8,22 +8,24 @@
</view>
<view class="u-menu-wrap">
<scroll-view scroll-y scroll-with-animation class="u-tab-view menu-scroll-view" :scroll-top="scrollTop"
:scroll-into-view="itemId">
<view v-for="(item,index) in tabbar" :key="index" class="u-tab-item" :class="[current == index ? 'u-tab-item-active' : '']"
@tap.stop="swichMenu(index)">
<text class="u-line-1">{{item.name}}</text>
:scroll-into-view="itemId">
<view v-for="(item, index) in tabbar" :key="index" class="u-tab-item"
:class="[current == index ? 'u-tab-item-active' : '']" @tap.stop="swichMenu(index)">
<text class="u-line-1">{{ item.name }}</text>
</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="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">
<text>{{item.name}}</text>
<text>{{ item.name }}</text>
</view>
<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>
<view class="item-menu-name">{{item1.name}}</view>
<view class="item-menu-name">{{ item1.name }}</view>
</view>
</view>
</view>
@ -33,259 +35,259 @@
</view>
</template>
<script>
import classifyData from '@/pages_template/common/classify.data.js';
export default {
data() {
return {
scrollTop: 0, //tab
oldScrollTop: 0,
current: 0, //
menuHeight: 0, //
menuItemHeight: 0, // item
itemId: '', // scroll-viewid
tabbar: classifyData,
menuItemPos: [],
arr: [],
scrollRightTop: 0, // scroll-view
timer: null, //
import classifyData from '@/pages_template/common/classify.data.js';
export default {
data() {
return {
scrollTop: 0, //tab
oldScrollTop: 0,
current: 0, //
menuHeight: 0, //
menuItemHeight: 0, // item
itemId: '', // scroll-viewid
tabbar: classifyData,
arr: [],
scrollRightTop: 0, // scroll-view
timer: null, //
}
},
onReady() {
this.getMenuItemTop()
},
methods: {
//
async swichMenu(index) {
if (this.arr.length == 0) {
await this.getMenuItemTop();
}
},
onLoad() {
},
onReady() {
this.getMenuItemTop()
},
methods: {
//
async swichMenu(index) {
if(this.arr.length == 0) {
await this.getMenuItemTop();
}
if (index == this.current) return;
this.scrollRightTop = this.oldScrollTop;
this.$nextTick(()=>{
this.scrollRightTop = this.arr[index];
this.current = index;
this.leftMenuStatus(index);
})
},
//
getElRect(elClass, dataVal) {
new Promise((resolve, reject) => {
const query = uni.createSelectorQuery().in(this);
query.select('.' + elClass).fields({
size: true
}, res => {
// resnull
if (!res) {
setTimeout(() => {
this.getElRect(elClass);
}, 10);
return;
}
this[dataVal] = res.height;
resolve();
}).exec();
})
},
//
async observer() {
this.tabbar.map((val, index) => {
let observer = uni.createIntersectionObserver(this);
// scroll-viewiditemxxright-box
// .right-box
observer.relativeTo('.right-box', {
top: 0
}).observe('#item' + index, res => {
if (res.intersectionRatio > 0) {
let id = res.id.substring(4);
this.leftMenuStatus(id);
}
})
})
},
//
async leftMenuStatus(index) {
if (index == this.current) return;
this.scrollRightTop = this.oldScrollTop;
this.$nextTick(() => {
this.scrollRightTop = this.arr[index];
this.current = index;
// 0
if (this.menuHeight == 0 || this.menuItemHeight == 0) {
await this.getElRect('menu-scroll-view', 'menuHeight');
await this.getElRect('u-tab-item', 'menuItemHeight');
}
// item
this.scrollTop = index * this.menuItemHeight + this.menuItemHeight / 2 - this.menuHeight / 2;
},
// item
getMenuItemTop() {
new Promise(resolve => {
let selectorQuery = uni.createSelectorQuery();
selectorQuery.selectAll('.class-item').boundingClientRect((rects) => {
// rects[](selectAll)
if(!rects.length) {
setTimeout(() => {
this.getMenuItemTop();
}, 10);
return ;
}
rects.forEach((rect) => {
// rects[0].top()
this.arr.push(rect.top - rects[0].top);
resolve();
})
}).exec()
})
},
//
async rightScroll(e) {
this.oldScrollTop = e.detail.scrollTop;
if(this.arr.length == 0) {
await this.getMenuItemTop();
}
if(this.timer) return ;
if(!this.menuHeight) {
await this.getElRect('menu-scroll-view', 'menuHeight');
}
setTimeout(() => { //
this.timer = null;
// scrollHeight
let scrollHeight = e.detail.scrollTop + this.menuHeight / 2;
for (let i = 0; i < this.arr.length; i++) {
let height1 = this.arr[i];
let height2 = this.arr[i + 1];
// height2
if (!height2 || scrollHeight >= height1 && scrollHeight < height2) {
this.leftMenuStatus(i);
return ;
}
this.leftMenuStatus(index);
})
},
//
getElRect(elClass, dataVal) {
new Promise((resolve, reject) => {
const query = uni.createSelectorQuery().in(this);
query.select('.' + elClass).fields({
size: true
}, res => {
// resnull
if (!res) {
setTimeout(() => {
this.getElRect(elClass);
}, 10);
return;
}
}, 10)
this[dataVal] = res.height;
resolve();
}).exec();
})
},
//
async observer() {
this.tabbar.map((val, index) => {
let observer = uni.createIntersectionObserver(this);
// scroll-viewiditemxxright-box
// .right-box
observer.relativeTo('.right-box', {
top: 0
}).observe('#item' + index, res => {
if (res.intersectionRatio > 0) {
let id = res.id.substring(4);
this.leftMenuStatus(id);
}
})
})
},
//
async leftMenuStatus(index) {
this.current = index;
// 0
if (this.menuHeight == 0 || this.menuItemHeight == 0) {
await this.getElRect('menu-scroll-view', 'menuHeight');
await this.getElRect('u-tab-item', 'menuItemHeight');
}
// item
this.scrollTop = index * this.menuItemHeight + this.menuItemHeight / 2 - this.menuHeight / 2;
},
// item
getMenuItemTop() {
new Promise(resolve => {
let selectorQuery = uni.createSelectorQuery();
selectorQuery.selectAll('.class-item').boundingClientRect((rects) => {
// rects[](selectAll)
if (!rects.length) {
setTimeout(() => {
this.getMenuItemTop();
}, 10);
return;
}
rects.forEach((rect) => {
// rects[0].top()
this.arr.push(rect.top - rects[0].top);
resolve();
})
}).exec()
})
},
//
async rightScroll(e) {
this.oldScrollTop = e.detail.scrollTop;
if (this.arr.length == 0) {
await this.getMenuItemTop();
}
if (this.timer) return;
if (!this.menuHeight) {
await this.getElRect('menu-scroll-view', 'menuHeight');
}
setTimeout(() => { //
this.timer = null;
// scrollHeight
let scrollHeight = e.detail.scrollTop + this.menuHeight / 2;
for (let i = 0; i < this.arr.length; i++) {
let height1 = this.arr[i];
let height2 = this.arr[i + 1];
// height2
if (!height2 || scrollHeight >= height1 && scrollHeight < height2) {
this.leftMenuStatus(i);
return;
}
}
}, 10)
},
clickMenu(menu) {
console.log(menu);
}
}
}
</script>
<style lang="scss" scoped>
.u-wrap {
height: calc(100vh);
/* #ifdef H5 */
height: calc(100vh - var(--window-top));
/* #endif */
display: flex;
flex-direction: column;
}
.u-wrap {
height: calc(100vh);
/* #ifdef H5 */
height: calc(100vh - var(--window-top));
/* #endif */
display: flex;
flex-direction: column;
}
.u-search-box {
padding: 18rpx 30rpx;
}
.u-search-box {
padding: 18rpx 30rpx;
}
.u-menu-wrap {
flex: 1;
display: flex;
overflow: hidden;
}
.u-menu-wrap {
flex: 1;
display: flex;
overflow: hidden;
}
.u-search-inner {
background-color: rgb(234, 234, 234);
border-radius: 100rpx;
display: flex;
align-items: center;
padding: 10rpx 16rpx;
}
.u-search-inner {
background-color: rgb(234, 234, 234);
border-radius: 100rpx;
display: flex;
align-items: center;
padding: 10rpx 16rpx;
}
.u-search-text {
font-size: 26rpx;
color: $u-tips-color;
margin-left: 10rpx;
}
.u-search-text {
font-size: 26rpx;
color: $u-tips-color;
margin-left: 10rpx;
}
.u-tab-view {
width: 200rpx;
height: 100%;
}
.u-tab-view {
width: 200rpx;
height: 100%;
}
.u-tab-item {
height: 110rpx;
background: #f6f6f6;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
font-size: 26rpx;
color: #444;
font-weight: 400;
line-height: 1;
}
.u-tab-item {
height: 110rpx;
background: #f6f6f6;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
font-size: 26rpx;
color: #444;
font-weight: 400;
line-height: 1;
}
.u-tab-item-active {
position: relative;
color: #000;
font-size: 30rpx;
font-weight: 600;
background: #fff;
}
.u-tab-item-active {
position: relative;
color: #000;
font-size: 30rpx;
font-weight: 600;
background: #fff;
}
.u-tab-item-active::before {
content: "";
position: absolute;
border-left: 4px solid $u-primary;
height: 32rpx;
left: 0;
top: 39rpx;
}
.u-tab-item-active::before {
content: "";
position: absolute;
border-left: 4px solid $u-primary;
height: 32rpx;
left: 0;
top: 39rpx;
}
.u-tab-view {
height: 100%;
}
.u-tab-view {
height: 100%;
}
.right-box {
background-color: rgb(250, 250, 250);
}
.right-box {
background-color: rgb(250, 250, 250);
}
.page-view {
padding: 16rpx;
}
.page-view {
padding: 16rpx;
}
.class-item {
margin-bottom: 30rpx;
background-color: #fff;
padding: 16rpx;
border-radius: 8rpx;
}
.class-item {
margin-bottom: 30rpx;
background-color: #fff;
padding: 16rpx;
border-radius: 8rpx;
}
.class-item:last-child {
min-height: 100vh;
}
.class-item:last-child {
min-height: 100vh;
}
.item-title {
font-size: 26rpx;
color: $u-main-color;
font-weight: bold;
}
.item-title {
font-size: 26rpx;
color: $u-main-color;
font-weight: bold;
}
.item-menu-name {
font-weight: normal;
font-size: 24rpx;
color: $u-main-color;
}
.item-menu-name {
font-weight: normal;
font-size: 24rpx;
color: $u-main-color;
}
.item-container {
display: flex;
flex-wrap: wrap;
}
.item-container {
display: flex;
flex-wrap: wrap;
}
.thumb-box {
width: 33.333333%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
margin-top: 20rpx;
}
.thumb-box {
width: 33.333333%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
margin-top: 20rpx;
}
.item-menu-image {
width: 120rpx;
height: 120rpx;
}
.item-menu-image {
width: 120rpx;
height: 120rpx;
}
</style>