Files
ys-app/src/pages/business/business.vue

185 lines
5.8 KiB
Vue
Raw Normal View History

2025-07-22 11:21:01 +08:00
<template>
2025-08-15 11:16:08 +08:00
<view class="con-body">
<view class="con-bg">
<!-- 头部 -->
<customHeader ref="customHeaderRef" :title="'业务中心'"
2025-08-18 16:11:49 +08:00
:leftFlag="false" :rightFlag="false" v-if="!searchShow"
></customHeader>
<customHeader v-else ref="customHeaderRef" :title="'搜索'"
:leftFlag="true" :rightFlag="false"
@back="handleBack" :searchType="1"
2025-08-15 11:16:08 +08:00
></customHeader>
<!-- 高度来避免头部遮挡 -->
<view class="top-height"></view>
2025-07-22 11:21:01 +08:00
2025-08-15 11:16:08 +08:00
<!-- 搜索 @confirm="handleSearch" -->
2025-08-18 16:11:49 +08:00
<customSearch v-if="searchShow"
:searchKeywords="searchText"
:searchType="searchTypeObj"
@confirm="handleSearchConfirm"
></customSearch>
<view class="search" v-else>
2025-08-15 11:16:08 +08:00
<uni-search-bar class="custom-search" radius="28"
placeholder="请输入您想查询的内容或服务"
clearButton="auto" cancelButton="none"
bgColor="#6FA2F8" textColor="#ffffff"
2025-08-18 16:11:49 +08:00
@focus="handleSearchFocus"
v-model="searchText"
2025-08-15 11:16:08 +08:00
/>
2025-07-22 11:21:01 +08:00
</view>
2025-08-15 11:16:08 +08:00
<!-- 下拉刷新 -->
2025-08-18 16:11:49 +08:00
<mescroll-uni v-if="!searchShow" ref="mescrollRef" @init="mescrollInit"
2025-08-15 11:16:08 +08:00
:down="downOption" @down="downCallback"
:fixed="false" class="scroll-h"
>
<!-- 首页日常服务 -->
<view class="white-bg">
<view class="w-b-title">
首页日常服务
<view type="primary" @click="handleJump('/pages/business/editDaily')" class="btn-edit"> </view>
</view>
2025-07-22 11:21:01 +08:00
</view>
2025-08-15 11:16:08 +08:00
<!-- 业务列表 -->
<view class="white-bg" v-for="(item,index) in list" :key="index">
<view class="w-b-title" @click="handleExpand(item)">{{ item.bizName }}
<text>{{item.expandFlag?'展开':'收起'}}<i :class="{iconfont:true,'icon-up':!item.expandFlag,'icon-down':item.expandFlag}"></i></text>
2025-07-22 11:21:01 +08:00
</view>
2025-08-15 11:16:08 +08:00
<block v-if="!item.expandFlag">
<view class="logo-list" v-if="item.children&&item.children.length>0">
<block v-for="(item2,index2) in item.children">
<view class="l-l-item"
@click="handleJump(item2.bizUrl)">
<img :src="'static/images/business/'+item2.icon+'.png'" />
<text class="font-gray">{{ item2.bizName }}</text>
</view>
</block>
</view>
</block>
</view>
2025-07-22 11:21:01 +08:00
2025-08-15 11:16:08 +08:00
<!-- 底部加高度来避免tabbar遮挡 -->
<view class="bottom-height"></view>
</mescroll-uni>
</view>
2025-07-22 11:21:01 +08:00
</view>
</template>
<script setup>
import { ref,onMounted } from 'vue'
2025-08-15 11:16:08 +08:00
import { onLoad,onShow } from '@dcloudio/uni-app';
2025-08-18 16:11:49 +08:00
import customHeader from '@/components/customHeader.vue';
import customSearch from '@/components/customSearch.vue'
2025-07-22 11:21:01 +08:00
import MescrollUni from 'mescroll-uni/mescroll-uni.vue';
import { getNavBarPaddingTop} from '@/utils/system.js'
2025-08-01 18:12:36 +08:00
import { businessList } from '@/api/business.js';
2025-08-13 18:15:04 +08:00
import {showLoading,hideLoading} from '@/utils/message.js'
2025-08-15 11:16:08 +08:00
import { initTree } from '@/utils/common.js';
2025-08-01 18:12:36 +08:00
onLoad(async(opt) => {
2025-08-15 11:16:08 +08:00
// uni.setStorageSync('page_cache',true);
2025-08-13 18:15:04 +08:00
try {
showLoading("加载中...")
getList();
hideLoading();
} catch (error) {
hideLoading();
}
2025-08-01 18:12:36 +08:00
})
2025-07-22 11:21:01 +08:00
// 获取导航栏高度用于内容区域padding
const navBarPaddingTop = ref(0);
onMounted(() => {
navBarPaddingTop.value = getNavBarPaddingTop()*2;
})
2025-08-18 16:11:49 +08:00
// 搜索处理
let searchShow = ref(false);
let searchText = ref(undefined);
let searchTypeObj = ref({typeId:2});
// 搜索返回操作
const handleBack=()=>{
searchShow.value=false;
}
// 获取input 焦点跳转
const handleSearchFocus=()=>{
searchShow.value = true;
}
// 搜索完返回处理
const handleSearchConfirm = (param1,param2)=>{
// console.log(param1,param2)
searchText.value=param2.value;;
searchShow.value=false;
}
2025-08-01 18:12:36 +08:00
// 查询列表
let list = ref([]);
let getList = async()=>{
2025-08-18 16:11:49 +08:00
let searchValue = searchText.value?searchText.value:undefined;
let res = await businessList({searchValue});//查询所有业务
2025-08-13 18:15:04 +08:00
let arr = res || [];
let bizList = initTree(arr,0,'bizId');//递归获取数组处理
bizList.forEach(item => {
2025-08-01 18:12:36 +08:00
item.expandFlag = false;
});
2025-08-13 18:15:04 +08:00
list.value = bizList;
2025-08-01 18:12:36 +08:00
}
// 右侧展开
let handleExpand = (item)=>{
item.expandFlag = !item.expandFlag;
}
2025-07-22 11:21:01 +08:00
// 下拉刷新
const mescrollRef = ref(null);
const mescrollInit = (mescroll) => {
mescrollRef.value = mescroll;
};
const downOption = ref({
auto: true,
textInOffset: '下拉刷新',
textOutOffset: '释放更新',
textLoading: '刷新中...'
});
// 下拉刷新
const downCallback = async (mescroll) => {
try {
2025-08-13 18:15:04 +08:00
getList();
// setTimeout(async ()=>{
// // mescroll.resetUpScroll();
// },500);
2025-07-22 11:21:01 +08:00
} catch (error) {
mescroll.endErr();
} finally {
setTimeout(async ()=>{
mescroll.endSuccess();
},500);
}
}
// 跳转
let handleJump=(url)=>{
if(url){
uni.navigateTo({ url })
}
}
</script>
<style scope>
.scroll-h{
/* #ifdef APP-PLUS */
height: calc(100vh - 120px) !important;
/* #endif */
/* #ifndef APP-PLUS */
height: calc(100vh - 140px) !important;
/* #endif */
}
:deep(.mescroll-upwarp){
display:none
}
</style>