Commit 3386bd03 authored by zhengke's avatar zhengke

no message

parent 631e3262
<template> <template>
<div class="goods-box" :class="{ flex: goods.catPosition == 'left' }"> <div class="goods-box" :class="{ flex: goods.catPosition == 'left' }" :style="{'margin-bottom':marginBottom+'rpx'}">
<view :style="{ margin: goods.catStyle == 1 ? '0px' : '10px 5px' }"> <view :style="{ margin: goods.catStyle == 1 ? '0px' : '10px 5px' }">
<u-tabs v-if="goods.showCat && goods.catPosition == 'top' && goods.catList.length > 1" name="menuName" :list="goods.catList" <u-tabs v-if="goods.showCat && goods.catPosition == 'top' && goods.catList.length > 1" name="menuName" :list="goods.catList"
:is-scroll="true" :active-color="mainColor" :current="activeKey" :show-bar="goods.catStyle == 1" :bold="false" :is-scroll="true" :active-color="mainColor" :current="activeKey" :show-bar="goods.catStyle == 1" :bold="false"
...@@ -80,7 +80,8 @@ ...@@ -80,7 +80,8 @@
return { return {
mainColor: '', mainColor: '',
activeKey: 0, activeKey: 0,
currentList: [] currentList: [],
marginBottom:''
}; };
}, },
created() { created() {
...@@ -91,6 +92,23 @@ ...@@ -91,6 +92,23 @@
this.currentList = this.goods.list; this.currentList = this.goods.list;
} }
}, },
mounted(){
let port = uni.getSystemInfoSync().platform
switch (port) {
case 'android':
this.marginBottom = '0'
console.log('运行Android上',port);//android
break;
case 'ios':
this.marginBottom = '54'
console.log('运行iOS上',port);//ios
break;
default:
this.marginBottom = '54'
console.log('运行在开发者工具上');//devtools
break;
}
},
methods: { methods: {
tabChangeHandler(i) { tabChangeHandler(i) {
this.currentList = this.goods.catList[i].goodsList; this.currentList = this.goods.catList[i].goodsList;
......
...@@ -3,12 +3,13 @@ ...@@ -3,12 +3,13 @@
<div class="mynav" style="padding-bottom:5px;min-height: 430px;" :style="{'background-color': navs.backgroundColor}"> <div class="mynav" style="padding-bottom:5px;min-height: 430px;" :style="{'background-color': navs.backgroundColor}">
<swiper v-if="navs.navType==1" :autoplay="false" :style="{'height': height + 'rpx' }"> <swiper v-if="navs.navType==1" :autoplay="false" :style="{'height': height + 'rpx' }">
<swiper-item v-for="(item, index) in cols" :key="index"> <swiper-item v-for="(item, index) in cols" :key="index">
<view :style="[formatStyle]"> <view :style="[formatStyle]" style="height: 100%;">
<u-grid :col="getColumn(navs)" align="left" :border="false"> <u-grid :col="getColumn(navs)" align="left" :border="false" :height="height">
<u-grid-item v-for="(c, i) in item" :key="i" class="grid-text" v-if="c.isShow==1" @click="clickHandler(c)" <u-grid-item v-for="(c, i) in item" :key="i" class="grid-text" v-if="c.isShow==1" @click="clickHandler(c)"
:height="height"
:style="{'background':isTemplateId==c.TemplateId?'url('+getIconLink(c.checkBgImg)+')no-repeat top 0 left 0':'', :style="{'background':isTemplateId==c.TemplateId?'url('+getIconLink(c.checkBgImg)+')no-repeat top 0 left 0':'',
'background-size': '100% 100%'}"> 'background-size': '100% 100%'}">
<image :src="isTemplateId==c.TemplateId?getIconLink(c.checkIcon):getIconLink(c.icon)" mode="widthFix" style="width: 64rpx; height: 64rpx;" /> <image :src="isTemplateId==c.TemplateId?getIconLink(c.checkIcon):getIconLink(c.icon)" mode="widthFix" style="width: 58rpx; height: 58rpx;" />
<text :style="{'color':navs.color}">{{ c.name }}</text> <text :style="{'color':navs.color}">{{ c.name }}</text>
</u-grid-item> </u-grid-item>
</u-grid> </u-grid>
...@@ -91,7 +92,7 @@ ...@@ -91,7 +92,7 @@
isTemplateId:'', isTemplateId:'',
cols: [], cols: [],
formatStyle: "", formatStyle: "",
height: 160, height: 92,//160
bg: "", bg: "",
clickItem: {}, //当前点击的页面 clickItem: {}, //当前点击的页面
showModal:false, showModal:false,
...@@ -109,7 +110,7 @@ ...@@ -109,7 +110,7 @@
// console.log(this.navs) // console.log(this.navs)
this.mainColor = this.$uiConfig.mainColor; this.mainColor = this.$uiConfig.mainColor;
let tempArray = []; let tempArray = [];
this.height = (this.navs.rows * this.height)-21; this.height = (this.navs.rows * this.height);//-21
this.navs.navs.forEach((x, i) => { this.navs.navs.forEach((x, i) => {
tempArray.push(x); tempArray.push(x);
if ( if (
......
<style scoped> <style scoped>
.tabbarMain { .tabbarMain {
height: 100upx; /* height: 150upx; */
position: fixed; position: fixed;
z-index: 50; z-index: 50;
flex: 1; flex: 1;
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
} }
.tabbarMainIphone { .tabbarMainIphone {
height: 156upx; height: 156upx;
padding-bottom: 64upx; /* padding-bottom: 64upx; */
} }
.tabBtnMina { .tabBtnMina {
width: 750upx; width: 750upx;
height: 88upx; /* height: 88upx; */
position: absolute; position: absolute;
z-index: 2; z-index: 2;
bottom: 0; bottom: 0;
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
} }
.tabBtnMinaIphone { .tabBtnMinaIphone {
height: 156upx; height: 156upx;
padding-bottom: 64upx; /* padding-bottom: 64upx; */
} }
.imgse { .imgse {
/* width: 48upx; */ /* width: 48upx; */
...@@ -114,11 +114,13 @@ ...@@ -114,11 +114,13 @@
<view <view
class="tabbarMain" class="tabbarMain"
:class="[flagTypeInfo ? 'tabbarMainIphone' : '']" :class="[flagTypeInfo ? 'tabbarMainIphone' : '']"
:style="{'height':height+'rpx','position':'fixed','left':'0','right':'0'}"
v-if="navs && navs.length > 0" v-if="navs && navs.length > 0"
> >
<view <view
class="tabBtnMina" class="tabBtnMina"
:class="[flagTypeInfo ? 'tabBtnMinaIphone' : '']" :class="[flagTypeInfo ? 'tabBtnMinaIphone' : '']"
:style="{'height':height+'upx','padding-bottom':paddingBottom + 'rpx'}"
mode="" mode=""
> >
<view <view
...@@ -155,6 +157,7 @@ ...@@ -155,6 +157,7 @@
<view <view
class="tabbarMain" class="tabbarMain"
:class="[flagTypeInfo ? 'tabbarMainIphone' : '']" :class="[flagTypeInfo ? 'tabbarMainIphone' : '']"
:style="{'padding-bottom':'64upx'}"
v-if="navs && navs.length > 0" v-if="navs && navs.length > 0"
> >
<view <view
...@@ -206,6 +209,8 @@ export default { ...@@ -206,6 +209,8 @@ export default {
navs: [], navs: [],
crtPath: "", crtPath: "",
isShowIcon: 1, isShowIcon: 1,
paddingBottom:"",
height:""
}; };
}, },
created() { created() {
...@@ -240,6 +245,24 @@ export default { ...@@ -240,6 +245,24 @@ export default {
}, 3000); }, 3000);
} }
this.activeHandler(); this.activeHandler();
let port = uni.getSystemInfoSync().platform
switch (port) {
case 'android':
this.height = '140'
this.paddingBottom = '20'
console.log('运行Android上',port);//android
break;
case 'ios':
this.height = '160'
this.paddingBottom = '58'
console.log('运行iOS上',port);//ios
break;
default:
this.height = '160'
this.paddingBottom = '58'
console.log('运行在开发者工具上');//devtools
break;
}
}, },
// activated(){ // activated(){
// if(uni.getStorageSync("navs")){ // if(uni.getStorageSync("navs")){
......
<template> <template>
<view class="u-grid-item" :class="[showBorder ? 'u-border-right u-border-bottom' : '']" :hover-class="hoverClass" <view class="u-grid-item" :class="[showBorder ? 'u-border-right u-border-bottom' : '']" :hover-class="hoverClass"
:hover-stay-time="200" @tap="click" :style="{ :hover-stay-time="200" @tap="click" :style="[{
background: bgColor, background: bgColor,
width: width + 'px' width: width + 'px'
}"> },{'height':height+'rpx'}]">
<view class="u-grid-item-box"> <view class="u-grid-item-box">
<slot /> <slot />
</view> </view>
...@@ -33,6 +33,10 @@ ...@@ -33,6 +33,10 @@
type: [Number, String], type: [Number, String],
default: '' default: ''
}, },
height:{
type: String,
default: ""
}
}, },
// 父组件通过provide传递过来的整个this // 父组件通过provide传递过来的整个this
inject: ['uGrid'], inject: ['uGrid'],
......
<template> <template>
<view :id="elId" class="u-grid" :class="{'u-border-top u-border-left': border}" :style="[gridStyle]"><slot /></view> <view :id="elId" class="u-grid" :class="{'u-border-top u-border-left': border}" :style="[gridStyle,{'height':height+'rpx'}]"><slot /></view>
</template> </template>
<script> <script>
...@@ -35,6 +35,10 @@ export default { ...@@ -35,6 +35,10 @@ export default {
hoverClass: { hoverClass: {
type: String, type: String,
default: 'u-hover-class' default: 'u-hover-class'
},
height:{
type: String,
default: ""
} }
}, },
data() { data() {
......
<template>
<view class="u-index-anchor-wrapper" :id="$u.guid()" :style="[wrapperStyle]">
<!-- style="position: fixed;top:95rpx;color:#2979ff;z-index: 965;" -->
<view class="u-index-anchor " :class="[active ? 'u-index-anchor--active' : '']"
:style="[customAnchorStyle]" >
<slot v-if="useSlot" />
<block v-else>
<text>{{ index=='*'?'热门品牌':index }}</text>
</block>
</view>
</view>
</template>
<script>
/**
* indexAnchor 索引列表锚点
* @description 通过折叠面板收纳内容区域,搭配<u-index-anchor>使用
* @tutorial https://www.uviewui.com/components/indexList.html#indexanchor-props
* @property {Boolean} use-slot 是否使用自定义内容的插槽(默认false)
* @property {String Number} index 索引字符,如果定义了use-slot,此参数自动失效
* @property {Object} custStyle 自定义样式,对象形式,如"{color: 'red'}"
* @event {Function} default 锚点位置显示内容,默认为索引字符
* @example <u-index-anchor :index="item" />
*/
export default {
name: "u-index-anchor",
props: {
useSlot: {
type: Boolean,
default: false
},
index: {
type: String,
default: ''
},
customStyle: {
type: Object,
default () {
return {}
}
}
},
data() {
return {
active: false,
wrapperStyle: {},
anchorStyle: {}
}
},
inject: ['UIndexList'],
wacth:{
index: {
handler: function (val, oldval) {
console.log(val,'----')
},
deep: true,
},
},
mounted() {
this.UIndexList.children.push(this);
this.UIndexList.updateData();
},
computed: {
customAnchorStyle() {
// return Object.assign(this.anchorStyle, this.customStyle);
}
}
}
</script>
<style lang="scss" scoped>
.u-index-anchor {
box-sizing: border-box;
padding: 14rpx 24rpx;
color: #606266;
width: 100%;
font-weight: 500;
font-size: 28rpx;
line-height: 1.2;
background-color: rgb(245, 245, 245);
}
.u-index-anchor--active {
right: 0;
left: 0;
color: #2979ff;
background-color: #f7f7f7;
}
</style>
<template>
<view class="u-index-bar">
<slot />
<view v-if="showSidebar" class="u-index-bar__sidebar" @touchstart.stop.prevent="onTouchMove" @touchmove.stop.prevent="onTouchMove"
@touchend.stop.prevent="onTouchStop" @touchcancel.stop.prevent="onTouchStop">
<view v-for="(item, index) in indexList" :key="index" class="u-index-bar__index" :style="{zIndex: zIndex + 1, color: activeAnchorIndex === index ? activeColor : ''}"
:data-index="index">
{{ item }}
</view>
</view>
<view class="u-indexed-list-alert" v-if="touchmove && indexList[touchmoveIndex]" :style="{
zIndex: alertZIndex
}">
<text>{{indexList[touchmoveIndex]}}</text>
</view>
</view>
</template>
<script>
var indexList = function() {
var indexList = [];
var charCodeOfA = 'A'.charCodeAt(0)
for (var i = 0; i < 26; i++) {
indexList.push(String.fromCharCode(charCodeOfA + i));
}
indexList.unshift('*')
return indexList;
};
/**
* indexList 索引列表
* @description 通过折叠面板收纳内容区域,搭配<u-index-anchor>使用
* @tutorial https://www.uviewui.com/components/indexList.html#indexanchor-props
* @property {Number String} scroll-top 当前滚动高度,自定义组件无法获得滚动条事件,所以依赖接入方传入
* @property {Array} index-list 索引字符列表,数组(默认A-Z)
* @property {Number String} z-index 锚点吸顶时的层级(默认965)
* @property {Boolean} sticky 是否开启锚点自动吸顶(默认true)
* @property {Number String} offset-top 锚点自动吸顶时与顶部的距离(默认0)
* @property {String} highlight-color 锚点和右边索引字符高亮颜色(默认#2979ff)
* @event {Function} select 选中右边索引字符时触发
* @example <u-index-list :scrollTop="scrollTop"></u-index-list>
*/
export default {
name: "u-index-list",
props: {
sticky: {
type: Boolean,
default: true
},
zIndex: {
type: [Number, String],
default: ''
},
scrollTop: {
type: [Number, String],
default: 0,
},
offsetTop: {
type: [Number, String],
default: 0
},
indexList: {
type: Array,
default () {
return indexList()
}
},
activeColor: {
type: String,
default: '#2979ff'
}
},
created() {
// #ifdef H5
this.stickyOffsetTop = this.offsetTop ? uni.upx2px(this.offsetTop) : 44;
// #endif
// #ifndef H5
this.stickyOffsetTop = this.offsetTop ? uni.upx2px(this.offsetTop) : 0;
// #endif
// 只能在created生命周期定义children,如果在data定义,会因为在子组件中通过provide/inject
// 进行push时而导致的莫名其妙的错误
this.children = [];
},
provide() {
return {
UIndexList: this
}
},
data() {
return {
activeAnchorIndex: 0,
showSidebar: true,
// children: [],
touchmove: false,
touchmoveIndex: 0,
}
},
watch: {
scrollTop() {
this.updateData()
}
},
computed: {
// 弹出toast的z-index值
alertZIndex() {
return this.$u.zIndex.toast;
}
},
methods: {
updateData() {
this.timer && clearTimeout(this.timer);
this.timer = setTimeout(() => {
this.showSidebar = !!this.children.length;
this.setRect().then(() => {
this.onScroll();
});
}, 0);
},
setRect() {
return Promise.all([
this.setAnchorsRect(),
this.setListRect(),
this.setSiderbarRect()
]);
},
setAnchorsRect() {
return Promise.all(this.children.map((anchor, index) => anchor
.$uGetRect('.u-index-anchor-wrapper')
.then((rect) => {
Object.assign(anchor, {
height: rect.height,
top: rect.top
});
})));
},
setListRect() {
return this.$uGetRect('.u-index-bar').then((rect) => {
Object.assign(this, {
height: rect.height,
top: rect.top + this.scrollTop
});
});
},
setSiderbarRect() {
return this.$uGetRect('.u-index-bar__sidebar').then(rect => {
this.sidebar = {
height: rect.height,
top: rect.top
};
});
},
getActiveAnchorIndex() {
const {
children
} = this;
const {
sticky
} = this;
for (let i = this.children.length - 1; i >= 0; i--) {
const preAnchorHeight = i > 0 ? children[i - 1].height : 0;
const reachTop = sticky ? preAnchorHeight : 0;
if (reachTop >= children[i].top) {
return i;
}
}
return -1;
},
onScroll() {
const {
children = []
} = this;
if (!children.length) {
return;
}
const {
sticky,
stickyOffsetTop,
zIndex,
scrollTop,
activeColor
} = this;
const active = this.getActiveAnchorIndex();
this.activeAnchorIndex = active;
if (sticky) {
let isActiveAnchorSticky = false;
if (active !== -1) {
isActiveAnchorSticky =
children[active].top <= 0;
}
children.forEach((item, index) => {
if (index === active) {
let wrapperStyle = '';
let anchorStyle = {
color: `${activeColor}`
};
if (isActiveAnchorSticky) {
wrapperStyle = {
height: `${children[index].height}px`
};
anchorStyle = {
position: 'fixed',
top: `${stickyOffsetTop}px`,
zIndex: `${zIndex ? zIndex : this.$u.zIndex.indexListSticky}`,
color: `${activeColor}`
};
}
item.active = active;
item.wrapperStyle = wrapperStyle;
item.anchorStyle = anchorStyle;
} else if (index === active - 1) {
const currentAnchor = children[index];
const currentOffsetTop = currentAnchor.top;
const targetOffsetTop = index === children.length - 1 ?
this.top :
children[index + 1].top;
const parentOffsetHeight = targetOffsetTop - currentOffsetTop;
const translateY = parentOffsetHeight - currentAnchor.height;
const anchorStyle = {
position: 'relative',
transform: `translate3d(0, ${translateY}px, 0)`,
zIndex: `${zIndex ? zIndex : this.$u.zIndex.indexListSticky}`,
color: `${activeColor}`
};
item.active = active;
item.anchorStyle = anchorStyle;
} else {
item.active = false;
item.anchorStyle = '';
item.wrapperStyle = '';
}
});
}
},
onTouchMove(event) {
this.touchmove = true;
const sidebarLength = this.children.length;
const touch = event.touches[0];
const itemHeight = this.sidebar.height / sidebarLength;
let clientY = 0;
clientY = touch.clientY;
let index = Math.floor((clientY - this.sidebar.top) / itemHeight);
if (index < 0) {
index = 0;
} else if (index > sidebarLength - 1) {
index = sidebarLength - 1;
}
this.touchmoveIndex = index;
this.scrollToAnchor(index);
},
onTouchStop() {
this.touchmove = false;
this.scrollToAnchorIndex = null;
},
scrollToAnchor(index) {
if (this.scrollToAnchorIndex === index) {
return;
}
this.scrollToAnchorIndex = index;
const anchor = this.children.find((item) => item.index === this.indexList[index]);
if (anchor) {
this.$emit('select', anchor.index);
uni.pageScrollTo({
duration: 0,
scrollTop: anchor.top + this.scrollTop
});
}
}
}
};
</script>
<style lang="scss" scoped>
.u-index-bar {
position: relative
}
.u-index-bar__sidebar {
position: fixed;
top: 50%;
right: 0;
display: flex;
flex-direction: column;
text-align: center;
transform: translateY(-50%);
user-select: none;
z-index: 99;
}
.u-index-bar__index {
font-weight: 500;
padding: 8rpx 30rpx;
font-size: 22rpx;
line-height: 1
}
.u-indexed-list-alert {
position: fixed;
width: 120rpx;
height: 120rpx;
right: 90rpx;
top: 50%;
margin-top: -60rpx;
border-radius: 24rpx;
font-size: 50rpx;
color: #fff;
background-color: rgba(0, 0, 0, 0.65);
display: flex;
justify-content: center;
align-items: center;
padding: 0;
z-index: 9999999;
}
.u-indexed-list-alert text {
line-height: 50rpx;
}
</style>
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment