联调接口

This commit is contained in:
xuli3099
2025-08-13 18:15:04 +08:00
parent 0728d92094
commit 28f24a90fd
18 changed files with 516 additions and 280 deletions

View File

@@ -46,25 +46,58 @@ import { onLoad } from '@dcloudio/uni-app';
import customHeader from '@/components/customHeader.vue'
import MescrollUni from 'mescroll-uni/mescroll-uni.vue';
import { getNavBarPaddingTop} from '@/utils/system.js'
import { businessList } from '@/api/business.js';
import { businessList,bizFavoriteSetting } from '@/api/business.js';
import { getUserFavorite } from '@/api/home.js';
import {showLoading,hideLoading,showAlert} from '@/utils/message.js'
import { initTree } from '@/utils/common.js'
// 初始化加载
onLoad(async(opt) => {
uni.setStorageSync('page_cache',true);
try {
showLoading("加载中...")
getList();
hideLoading();
} catch (error) {
hideLoading();
}
})
// 获取导航栏高度用于内容区域padding
const navBarPaddingTop = ref(0);
onMounted(() => {
navBarPaddingTop.value = getNavBarPaddingTop()*2;
getList();
})
// 查询列表
let list = ref([]);
let count = ref(7);
let count = ref(0);
let getList = async()=>{
let res = await businessList({});
let arr = res.list || [];
arr.forEach(item => {
let arrNew = [];
let res = await businessList({});//查询所有业务
let arr = res || [];
let res2 = await getUserFavorite({});//查询当前用户的常用服务
let bizIdListStr = res2.bizIdList || '';
let arr2 = bizIdListStr.split(",");
count.value = arr2.length;
arr.forEach(item=>{
item.isDaily=false;
arr2.forEach(item2=>{
if(item2==item.bizId){
item.isDaily=true;
}
})
arrNew.push(item)
})
let bizList = initTree(arrNew,0,'bizId');//递归获取数组处理
bizList.forEach(item => {
item.expandFlag = false;
});
list.value = arr;
list.value = bizList;
console.log("list=>",list.value)
}
// 下拉刷新
@@ -94,20 +127,35 @@ const downCallback = async (mescroll) => {
}
}
let bizIds = ref([]);
// 选择常用
const handleCheck=(item)=>{
item.isDaily = !item.isDaily;
if(item.isDaily){
count.value++;
bizIds.value.push(item.bizId);
}else{
count.value--;
const index = bizIds.value.findIndex(item2 => item2.bizId === item.bizId);
if (index !== -1) {
bizIds.value.splice(index, 1);
}
}
console.log("bizIds=>",bizIds.value)
}
// 提交
const handleSubmit=(item)=>{
const handleSubmit= async()=>{
try {
showLoading("加载中...")
console.log("bizIds=>",bizIds.value)
await bizFavoriteSetting({bizIds:bizIds.value.join(",")});
showAlert("操作成功")
hideLoading();
} catch (error) {
hideLoading();
}
}
</script>