TakeOutShop/userserve/clientserve/clientserve.vue
2025-03-13 20:39:25 +08:00

76 lines
2.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="main">
<view class="head" :class="headShow?'head_show':''" :style="{'opacity':headShow?opacity:'1','padding-top':statusBartop+'px'}">
<view class="head_back" @click="handleBack()" :style="{'width': statusHeight+'px','height':statusHeight+'px'}">
<image class="head_back_img" src="https://zhkj1.oss-cn-shanghai.aliyuncs.com/newPD/zhBack.png" mode="widthFix"></image>
</view>
<view class="head_title" :style="{'width':pageWidth+'px','height':statusHeight+'px'}">客户服务</view>
</view>
<view style="height: 2000rpx;"></view>
</view>
</template>
<script setup>
import { computed,ref,onMounted,onUnmounted,getCurrentInstance,nextTick } from 'vue';
import { useCounterStore } from '@/store/counter'; // 引入 Pinia Store
import { storeToRefs } from 'pinia';//实现解构付值
import { onLoad,onShow,onPullDownRefresh,onPageScroll,onReachBottom,onReady } from "@dcloudio/uni-app"
const counterStore = useCounterStore(); // 使用 Store
const { proxy } = getCurrentInstance();
//使用piniastoreToRefs方法包裹(保持响应式更新,不使用视图无法更新)
const {statusHeight,headerHeight,statusBartop,ButtonWidth,ButtonHeight } = storeToRefs(counterStore);
const headShow = ref(false);
const showBack = ref(false);
const pageWidth = ref(0);
// 获取页面宽度
const updatePageWidth = () => {
const systemInfo = uni.getSystemInfoSync();
pageWidth.value = systemInfo.windowWidth;
};
const searchWidth = computed(() => {
return pageWidth.value - statusHeight.value - ButtonWidth.value - 35;
});
// 判断是否有上一页
const getPages = () => {
const pages = getCurrentPages();
return pages.length > 1;
};
const handleBack = () => {
if (getPages()) {
// 如果有上一页,返回上一页
uni.navigateBack();
} else {
// 如果没有上一页,返回首页
uni.switchTab({
url: '/pages/index/index',
});
}
};
onLoad((options) => {
//初始化时判断是否显示返回按钮
showBack.value = getPages();
updatePageWidth();
});
onShow(() => {});
onPageScroll((e)=>{
const top = e.scrollTop;
// 导航条颜色透明渐变
if (top <= 50) {
headShow.value = false
} else {
if( 50 < top && top <= 200 ){
opacity.value = top / 200
}else{
opacity.value = 1
}
headShow.value = true
}
}),
onReady(()=>{})
onPullDownRefresh(()=>{})
onReachBottom(()=>{})
</script>
<style lang="scss">
@import './style.scss';
</style>