This commit is contained in:
GaoHao
2024-08-03 17:50:34 +08:00
2 changed files with 56 additions and 36 deletions

View File

@@ -58,22 +58,26 @@
type: Boolean,
default: false
},
titleshow: {//标题是否显示
titleshow: { //标题是否显示
type: Boolean,
default: false
},
heightshow: {//是否要占位高度
heightshow: { //是否要占位高度
type: Boolean,
default: false
},
iconshow: {//返回键是否显示
iconshow: { //返回键是否显示
type: Boolean,
default: true
},
iconcolor:{//返回键颜色
iconcolor: { //返回键颜色
type: String,
default: '#000'
},
navigateBacknavtitle: {
type: Boolean,
default: false
}
},
computed: {
HeighT() { //手机类型的尺寸
@@ -95,7 +99,11 @@
})
},
clicknavigateBack() {
uni.navigateBack()
if (this.navigateBacknavtitle) {
this.$emit('navigateBacknav')
} else {
uni.navigateBack()
}
}
}

View File

@@ -8,9 +8,11 @@
</view>
<!-- 顶部面板 -->
<view class="top--panel">
<navseat :opacity='opacity' :titleshow='true'></navseat>
<navseat :opacity='opacity' :titleshow='true' @navigateBacknav='navigateBacknav' :navigateBacknavtitle='true'></navseat>
<!-- 顶部面板可添加所需要放在页面顶部的内容代码比如banner图 -->
<image class="panelimgbackground" :src="shopInfo.storeInfo.coverImg||'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/shopDetails/topBanner.png'" mode="aspectFill">
<image class="panelimgbackground"
:src="shopInfo.storeInfo.coverImg||'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/shopDetails/topBanner.png'"
mode="aspectFill">
</image>
<view class="panelone">
{{ shopInfo.storeInfo.shopName }}
@@ -393,6 +395,10 @@
this.fixedtrue = true
},
onShow() {
uni.pageScrollTo({
scrollTop: 0,
duration: 0
});
console.log(!uni.cache.get('token'))
if (!uni.cache.get('token')) {
uni.login({
@@ -427,6 +433,9 @@
}
},
methods: {
navigateBacknav() {
uni.pro.switchTab('index/index')
},
getQueryString(url, name) { //解码
var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
var r = url.substr(1).match(reg)
@@ -469,26 +478,6 @@
}
},
/**
* 获取商品数据
*/
async productqueryProduct() {
let res = await this.api.productqueryProduct({
"shopId": uni.cache.get('shopUser'),
"productGroupId": ''
})
if (res.code == 0) {
this.shopProductList = res.data;
if (this.cartLists && this.cartLists.data && this.cartLists.data.length >= 0) {
this.setNumber()
}
setTimeout(() => {
this.getElementTop();
}, 100);
}
},
/**
* 商品数量增加/减少
* @param {Object} item
@@ -832,18 +821,41 @@
this.socketTicket.send(data);
}
},
/**
* 获取商品数据
*/
async productqueryProduct() {
let res = await this.api.productqueryProduct({
"shopId": uni.cache.get('shopUser'),
"productGroupId": ''
})
if (res.code == 0) {
this.shopProductList = res.data;
if (this.cartLists && this.cartLists.data && this.cartLists.data.length >= 0) {
this.setNumber()
}
this.scrollTopSize = 0
this.scrollHeight = 1000
this.topArr = []
setTimeout(() => {
this.getElementTop();
}, 500);
}
},
/* 获取元素顶部信息 */
getElementTop() {
new Promise((resolve, reject) => {
let view = uni.createSelectorQuery().selectAll('.main-item');
view.boundingClientRect(async data => {
console.log(data, 840)
resolve(data);
}).exec();
this.$u.getRect('.scroll-panel').then(res => {
this.scrollTopSize = res.top; //元素距离顶部的距离
})
}).then((res) => {
console.log(res, 111)
let topArr = res.map((item) => {
return item.top; /* 减去滚动容器距离顶部的距离 加导航栏高度*/
});
@@ -876,14 +888,14 @@
}
}
const lastElement = this.topArr[this.topArr.length - 1];
const currentElement = this.topArr[this.leftIndex];
const currentElement = this.topArr[index];
const diff = lastElement - currentElement;
console.log(diff)
// if (diff > this.scrollHeight) {
this.leftIndex = (index < 0 ? 0 : index);
// } else {
// this.leftIndex = this.leftIndex
// }
if (diff > this.scrollHeight) {
this.leftIndex = (index < 0 ? 0 : index);
} else {
this.leftIndex = this.leftIndex
}
}
},
/* 左侧导航点击 */
@@ -892,9 +904,7 @@
scrollTop: this.topArr[index] - this.HeighT,
duration: 0
});
setTimeout(() => {
this.leftIndex = index
}, 500)
this.leftIndex = index
}
}
}
@@ -957,6 +967,7 @@
font-size: 24rpx;
color: #999999;
padding: 0 20rpx;
.paneltheretext {
font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: 400;
@@ -985,6 +996,7 @@
.panelfive {
width: 100%;
padding: 0 20rpx;
.panelfive_list {
display: flex;
}