Commit 71427ba4 by pangchong

feat: 优化全局组件

parent 139fd963
...@@ -51,6 +51,11 @@ const ps = defineProps({ ...@@ -51,6 +51,11 @@ const ps = defineProps({
type: Number, type: Number,
default: 0 default: 0
}, },
//列表的每一项内容是否独立
alone: {
type: Boolean,
default: false
},
//tab数据搜索字段 //tab数据搜索字段
tabValueField: { tabValueField: {
type: String, type: String,
...@@ -132,7 +137,7 @@ const queryList = (pageIndex, pageSize) => { ...@@ -132,7 +137,7 @@ const queryList = (pageIndex, pageSize) => {
params['pageIndex'] = pageIndex params['pageIndex'] = pageIndex
params['pageSize'] = pageSize params['pageSize'] = pageSize
} }
if (ps.tabValue != null) { if (ps.tabValue != null && !ps.alone) {
params[ps.tabValueField] = ps.tabValue params[ps.tabValueField] = ps.tabValue
} }
if (Object.prototype.toString.call(ps.api) == '[object Function]') { if (Object.prototype.toString.call(ps.api) == '[object Function]') {
......
...@@ -11,20 +11,17 @@ ...@@ -11,20 +11,17 @@
<!-- 自定义导航栏 --> <!-- 自定义导航栏 -->
<global-navbar :title="title" v-if="showNavbar" :bgColor="navbgColor" :color="navColor"> <global-navbar :title="title" v-if="showNavbar" :bgColor="navbgColor" :color="navColor">
<template #left v-if="pages.length > 1 && showNavLeft"> <template #left v-if="pages.length > 1 && showNavLeft">
<up-icon v-if="navLeftType == 'icon'" :name="navLeftIcon" size="16" @tap="handleLeftClick" <up-icon v-if="navLeftType == 'icon'" :name="navLeftIcon" size="16" @tap="handleLeftClick" :color="navColor"></up-icon>
:color="navColor"></up-icon>
<view v-if="navLeftType == 'text'" class="cancel" @tap="handleLeftClick">{{ navLeftText }}</view> <view v-if="navLeftType == 'text'" class="cancel" @tap="handleLeftClick">{{ navLeftText }}</view>
</template> </template>
<template #right v-if="showNavRight"> <template #right v-if="showNavRight">
<global-button type="text" size="small" v-if="navRightType == 'text'" @tap="handleRightClick"> <global-button type="text" size="small" v-if="navRightType == 'text'" @tap="handleRightClick">
{{ navRightText }} {{ navRightText }}
</global-button> </global-button>
<global-button type="primary" size="small" v-if="navRightType == 'button'" style="padding: 0 32rpx" <global-button type="primary" size="small" v-if="navRightType == 'button'" style="padding: 0 32rpx" @tap="handleRightClick">
@tap="handleRightClick">
{{ navRightText }} {{ navRightText }}
</global-button> </global-button>
<global-icon v-if="navRightType == 'icon'" :icon="navRightIcon" <global-icon v-if="navRightType == 'icon'" :icon="navRightIcon" @tap="handleRightClick"></global-icon>
@tap="handleRightClick"></global-icon>
</template> </template>
</global-navbar> </global-navbar>
<!-- tab切换 --> <!-- tab切换 -->
...@@ -53,12 +50,13 @@ ...@@ -53,12 +50,13 @@
<global-page-swiper-item <global-page-swiper-item
:ref="(vc) => (pagingArr[index] = vc)" :ref="(vc) => (pagingArr[index] = vc)"
:auto="auto" :auto="auto"
:tabValue="tabList[current][valueKey]"
:tabIndex="index" :tabIndex="index"
:tabValue="tabList[current][valueKey]"
:tabValueField="tabValueField" :tabValueField="tabValueField"
:currentIndex="current" :currentIndex="current"
:params="params" :alone="alone"
:api="api" :params="getParams"
:api="getApi"
:refresher-enabled="refresherEnabled" :refresher-enabled="refresherEnabled"
:refresher-threshold="refresherThreshold" :refresher-threshold="refresherThreshold"
:auto-show-back-to-top="autoShowBackToTop" :auto-show-back-to-top="autoShowBackToTop"
...@@ -100,7 +98,7 @@ ...@@ -100,7 +98,7 @@
import { computed, nextTick, onUnmounted, ref, watch } from 'vue' import { computed, nextTick, onUnmounted, ref, watch } from 'vue'
// 获取屏幕边界到安全区域距离 // 获取屏幕边界到安全区域距离
const {safeAreaInsets} = uni.getSystemInfoSync() const { safeAreaInsets } = uni.getSystemInfoSync()
const es = defineEmits(['handleLeftClick', 'handleRightClick', 'handleFooterClick', 'handleChooseData']) const es = defineEmits(['handleLeftClick', 'handleRightClick', 'handleFooterClick', 'handleChooseData'])
const ps = defineProps({ const ps = defineProps({
background: { background: {
...@@ -120,6 +118,11 @@ const ps = defineProps({ ...@@ -120,6 +118,11 @@ const ps = defineProps({
type: Boolean, type: Boolean,
default: true default: true
}, },
//列表的每一项内容是否独立
alone: {
type: Boolean,
default: false
},
//tab数据 //tab数据
tabList: { tabList: {
type: Array, type: Array,
...@@ -329,6 +332,22 @@ const swiperTransition = (e) => {} ...@@ -329,6 +332,22 @@ const swiperTransition = (e) => {}
const swiperAnimationfinish = (e) => { const swiperAnimationfinish = (e) => {
current.value = e.detail.current current.value = e.detail.current
} }
//获取查询参数
const getParams = computed(() => {
if (ps.alone) {
ps.tabList[current.value].params || {}
} else {
return ps.params
}
})
//获取查询接口
const getApi = computed(() => {
if (ps.alone) {
ps.tabList[current.value].api
} else {
return ps.api
}
})
//消息提示 //消息提示
const uToastRef = ref() const uToastRef = ref()
const openToast = (params) => { const openToast = (params) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment