This commit is contained in:
魏啾
2024-07-26 11:16:27 +08:00
2 changed files with 22 additions and 8 deletions

View File

@@ -18,6 +18,7 @@ const baseUrlwws = 'ws://cashier.sxczgkj.cn/cashierService'
// #ifdef APP || MP-WEIXIN // #ifdef APP || MP-WEIXIN
const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.cn/cashierService' // 线上 const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.cn/cashierService' // 线上
const baseUrlwws = debug ? proxyApiwws : 'wss://cashier.sxczgkj.cn/netty' // 线上 const baseUrlwws = debug ? proxyApiwws : 'wss://cashier.sxczgkj.cn/netty' // 线上
// const baseUrl = 'https://cashier.sxczgkj.cn/cashierService' // 线上 // const baseUrl = 'https://cashier.sxczgkj.cn/cashierService' // 线上
// const baseUrlwws = 'wss://cashier.sxczgkj.cn/netty' // 线上/ // const baseUrlwws = 'wss://cashier.sxczgkj.cn/netty' // 线上/
// #endif // #endif

View File

@@ -48,7 +48,7 @@
<view class="left" <view class="left"
:style="{ top: `${menuInfo.top + menuInfo.height + paddingBtmSize + tabHeadHeight}px` }"> :style="{ top: `${menuInfo.top + menuInfo.height + paddingBtmSize + tabHeadHeight}px` }">
<view class="item" v-for="(item, index) in shopList.productInfo" :key="item.id" <view class="item" v-for="(item, index) in shopList.productInfo" :key="item.id"
:class="{ active: titleTopNumIndex == index }" @click="titleClickHandle(item.id)"> :class="{ active: titleTopNumIndex == index }" @click="titleClickHandle(item.id,index)">
<text>{{ item.name }}</text> <text>{{ item.name }}</text>
</view> </view>
</view> </view>
@@ -267,6 +267,8 @@
showShopInfo: false, showShopInfo: false,
showShopsku: false, showShopsku: false,
titleTopNumIndex: 0, titleTopNumIndex: 0,
titleTopNumIndexFalg: true,
timer: null,
titleTopNums: [], titleTopNums: [],
showCart: false, showCart: false,
tableCode: '', //code tableCode: '', //code
@@ -300,6 +302,7 @@
backgroundColor: '#000000' backgroundColor: '#000000'
}); });
} }
this.countScrollTitle(e.scrollTop); this.countScrollTitle(e.scrollTop);
}, },
onLoad(e) { onLoad(e) {
@@ -424,7 +427,7 @@
break; break;
case 'addcart': case 'addcart':
this.cartLists = msg this.cartLists = msg
console.log(msg, 1111) // console.log(msg, 1111)
this.productqueryProduct() //list 数据 this.productqueryProduct() //list 数据
try { try {
if (msg.data.length != 0) { if (msg.data.length != 0) {
@@ -452,7 +455,7 @@
} }
break; break;
} }
console.log(this.cartLists.data, 1111111) // console.log(this.cartLists.data, 1111111)
this.cartListsdatashow = this.cartLists.data.length == 0 ? false : true this.cartListsdatashow = this.cartLists.data.length == 0 ? false : true
} }
} catch (e) { } catch (e) {
@@ -664,7 +667,9 @@
}); });
}, },
// 点击菜单商品滚动到指定为止 // 点击菜单商品滚动到指定为止
titleClickHandle(id) { titleClickHandle(id,index) {
this.titleTopNumIndexFalg = false;
this.titleTopNumIndex = index;
uni.createSelectorQuery() uni.createSelectorQuery()
.select('#wrapper') .select('#wrapper')
.boundingClientRect((data) => { .boundingClientRect((data) => {
@@ -687,7 +692,8 @@
}, },
// 计算滚动到那个标题 // 计算滚动到那个标题
countScrollTitle: _.throttle(function(top) { countScrollTitle: _.throttle(function(top) {
if (this.titleTopNums.length > 1) {
if (this.titleTopNums.length > 1 && this.titleTopNumIndexFalg) {
for (let i = 0; i <= this.titleTopNums.length - 1; i++) { for (let i = 0; i <= this.titleTopNums.length - 1; i++) {
if (top >= this.titleTopNums[i] && top < this.titleTopNums[i + 1]) { if (top >= this.titleTopNums[i] && top < this.titleTopNums[i + 1]) {
this.titleTopNumIndex = i; this.titleTopNumIndex = i;
@@ -697,6 +703,13 @@
this.titleTopNumIndex = this.titleTopNums.length - 1; this.titleTopNumIndex = this.titleTopNums.length - 1;
} }
} }
//这里必须要每次滚动前 清除一次
clearTimeout(this.timer)
// 如果停留则表示滚动结束 一旦空了1s就判定为滚动结束
this.timer = setTimeout(() => {
this.titleTopNumIndexFalg = true;
// console.log('结束滚动')
}, 1000)
}, 100), }, 100),
// 统计每个标题到顶部的距离 // 统计每个标题到顶部的距离
countTitleTopNum() { countTitleTopNum() {
@@ -705,9 +718,9 @@
uni.createSelectorQuery() uni.createSelectorQuery()
.select(`#title${i.id}`) .select(`#title${i.id}`)
.boundingClientRect((res) => { .boundingClientRect((res) => {
topNums.push(res.top + this.menuInfo.top + this.menuInfo.height + this topNums.push(res.top - this.menuInfo.top - this.menuInfo.height - this
.paddingBtmSize - .paddingBtmSize*8 -
this.tabHeadHeight - this.tabHeadHeight / 2); this.tabHeadHeight + 40);
}) })
.exec(); .exec();
} }