lxui-uni 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/components/lx-header/lx-header.vue +250 -250
- package/components/lx-hello/lx-hello.vue +25 -25
- package/components/lx-image/index.ts +2 -2
- package/components/lx-image/lx-image.vue +101 -101
- package/components/lx-list/lx-list.vue +103 -163
- package/components/lx-list-state/lx-list-state.vue +92 -92
- package/components/lx-operate-bottom/lx-operate-bottom.vue +116 -116
- package/components/lx-submit-btn/lx-submit-btn.vue +61 -61
- package/components/lx-tabbar/lx-tabbar.vue +99 -99
- package/components/lx-upload/lx-upload.vue +186 -186
- package/index.ts +46 -46
- package/libs/config/index.ts +21 -21
- package/libs/hooks/useListLoadClass/index.ts +145 -143
- package/libs/util/index.ts +294 -294
- package/package.json +13 -13
- package/theme.scss +232 -232
- package/types/components.d.ts +23 -23
- package/types/index.d.ts +25 -25
package/libs/config/index.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
const version = '3'
|
|
2
|
-
|
|
3
|
-
// 开发环境才提示,生产环境不会提示
|
|
4
|
-
if (process.env.NODE_ENV === 'development') {
|
|
5
|
-
console.log(`\n %c lxui-uni V${version} %c https://blog.csdn.net/qq_51091386/article/details/138125947 \n\n`, 'color: #ffffff; background: #3c9cff; padding:5px 0;', 'color: #3c9cff;background: #ffffff; padding:5px 0;');
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export let uploadUrl = '/api/v1.Resources/upload'
|
|
9
|
-
export let uploadBaseUrl = ''
|
|
10
|
-
const setConfig = (config: any) => {
|
|
11
|
-
console.log(config)
|
|
12
|
-
if (config?.uploadUrl) {
|
|
13
|
-
uploadUrl = config.uploadUrl
|
|
14
|
-
}
|
|
15
|
-
if (config?.uploadBaseUrl) {
|
|
16
|
-
uploadBaseUrl = config.uploadBaseUrl
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export default {
|
|
20
|
-
version,
|
|
21
|
-
setConfig
|
|
1
|
+
const version = '3'
|
|
2
|
+
|
|
3
|
+
// 开发环境才提示,生产环境不会提示
|
|
4
|
+
if (process.env.NODE_ENV === 'development') {
|
|
5
|
+
console.log(`\n %c lxui-uni V${version} %c https://blog.csdn.net/qq_51091386/article/details/138125947 \n\n`, 'color: #ffffff; background: #3c9cff; padding:5px 0;', 'color: #3c9cff;background: #ffffff; padding:5px 0;');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export let uploadUrl = '/api/v1.Resources/upload'
|
|
9
|
+
export let uploadBaseUrl = ''
|
|
10
|
+
const setConfig = (config: any) => {
|
|
11
|
+
console.log(config)
|
|
12
|
+
if (config?.uploadUrl) {
|
|
13
|
+
uploadUrl = config.uploadUrl
|
|
14
|
+
}
|
|
15
|
+
if (config?.uploadBaseUrl) {
|
|
16
|
+
uploadBaseUrl = config.uploadBaseUrl
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export default {
|
|
20
|
+
version,
|
|
21
|
+
setConfig
|
|
22
22
|
}
|
|
@@ -1,143 +1,145 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @description: 分页请求
|
|
3
|
-
* @fileName: useListLoadClass.ts
|
|
4
|
-
* @author: lxx
|
|
5
|
-
* @date: 2023-07-08 08:55:52
|
|
6
|
-
* @version: V1.0.0
|
|
7
|
-
*/
|
|
8
|
-
import { reactive, ref, computed } from "vue"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
this.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
*
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
this.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
*
|
|
113
|
-
* @
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
1
|
+
/*
|
|
2
|
+
* @description: 分页请求
|
|
3
|
+
* @fileName: useListLoadClass.ts
|
|
4
|
+
* @author: lxx
|
|
5
|
+
* @date: 2023-07-08 08:55:52
|
|
6
|
+
* @version: V1.0.0
|
|
7
|
+
*/
|
|
8
|
+
import { reactive, ref, computed } from "vue"
|
|
9
|
+
import { onReachBottom } from "@dcloudio/uni-app"
|
|
10
|
+
|
|
11
|
+
class LoadDataClass {
|
|
12
|
+
// 请求参数
|
|
13
|
+
static queryParams = reactive({
|
|
14
|
+
page: 1,
|
|
15
|
+
limit: 10
|
|
16
|
+
})
|
|
17
|
+
// 列表数据
|
|
18
|
+
list = ref<any[]>([])
|
|
19
|
+
total = ref(0)
|
|
20
|
+
// 前置处理方法
|
|
21
|
+
afterLoadData: Function | undefined
|
|
22
|
+
// 请求方法
|
|
23
|
+
Query: Function
|
|
24
|
+
// 加载状态参数
|
|
25
|
+
isLoading = ref(false)
|
|
26
|
+
// 无更多数据了
|
|
27
|
+
isNoData = computed(() => {
|
|
28
|
+
if (LoadDataClass.queryParams.page * LoadDataClass.queryParams.limit >= this.total.value) {
|
|
29
|
+
return true
|
|
30
|
+
} else {
|
|
31
|
+
return false
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
// 显示暂无数据
|
|
35
|
+
isEmpty = computed(() => {
|
|
36
|
+
if (this.total.value === 0) {
|
|
37
|
+
return true
|
|
38
|
+
} else {
|
|
39
|
+
return false
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
constructor(apiFunctions: Function, afterLoadData?: Function, options: any = {}) {
|
|
44
|
+
this.queryParamsReset()
|
|
45
|
+
this.Query = apiFunctions
|
|
46
|
+
this.afterLoadData = afterLoadData
|
|
47
|
+
// console.log('options', options)
|
|
48
|
+
// 存在额外参数拼接
|
|
49
|
+
this.setParams(options)
|
|
50
|
+
}
|
|
51
|
+
// 加载数据
|
|
52
|
+
LoadData = async () => {
|
|
53
|
+
uni.showLoading({
|
|
54
|
+
title: '加载中...'
|
|
55
|
+
})
|
|
56
|
+
this.isLoading.value = true
|
|
57
|
+
const res = await this.Query(LoadDataClass.queryParams)
|
|
58
|
+
this.afterLoadData && this.afterLoadData(res)
|
|
59
|
+
this.total.value = res.data.total
|
|
60
|
+
this.list.value = this.list.value.concat(res.data.items)
|
|
61
|
+
|
|
62
|
+
uni.hideLoading()
|
|
63
|
+
uni.stopPullDownRefresh()
|
|
64
|
+
this.isLoading.value = false
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 添加额外参数刷新
|
|
68
|
+
* @param options: 参数
|
|
69
|
+
* @param isClear: 是否清空数据 false
|
|
70
|
+
*/
|
|
71
|
+
setParams = (options: any, isClear: boolean = false) => {
|
|
72
|
+
if (isClear) {
|
|
73
|
+
this.queryParamsReset()
|
|
74
|
+
} else {
|
|
75
|
+
LoadDataClass.queryParams.page = 1
|
|
76
|
+
}
|
|
77
|
+
this.list.value = []
|
|
78
|
+
LoadDataClass.queryParams = Object.assign(LoadDataClass.queryParams, options)
|
|
79
|
+
// 加载数据
|
|
80
|
+
this.LoadData()
|
|
81
|
+
}
|
|
82
|
+
// 加载更多
|
|
83
|
+
LoadMore = () => {
|
|
84
|
+
if (this.isNoData.value || this.isLoading.value) return // 无数据或者加载中不进行加载
|
|
85
|
+
LoadDataClass.queryParams.page += 1
|
|
86
|
+
this.LoadData()
|
|
87
|
+
}
|
|
88
|
+
// 重置参数
|
|
89
|
+
queryParamsReset = () => {
|
|
90
|
+
LoadDataClass.queryParams = reactive({
|
|
91
|
+
page: 1,
|
|
92
|
+
limit: 10
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 刷新
|
|
98
|
+
* @param isClear: 是否清空数据
|
|
99
|
+
*/
|
|
100
|
+
ReLoad = (isClear: boolean = false) => {
|
|
101
|
+
this.isLoading.value = false
|
|
102
|
+
this.list.value = []
|
|
103
|
+
if (isClear) {
|
|
104
|
+
this.queryParamsReset()
|
|
105
|
+
} else {
|
|
106
|
+
LoadDataClass.queryParams.page = 1
|
|
107
|
+
}
|
|
108
|
+
this.LoadData()
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 分页加载数据方法
|
|
113
|
+
* @param api: ListAPI 方法
|
|
114
|
+
* @param afterLoadData: res数据前置处理方法
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
interface LoadDataInt {
|
|
118
|
+
api: Function
|
|
119
|
+
afterLoadData?: Function
|
|
120
|
+
options?: any
|
|
121
|
+
isNeedReachBottom?: boolean
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function LoadData({ api, afterLoadData, options, isNeedReachBottom = true }: LoadDataInt) {
|
|
125
|
+
const data = new LoadDataClass(api, afterLoadData, options)
|
|
126
|
+
|
|
127
|
+
// 下拉加载
|
|
128
|
+
if (isNeedReachBottom) {
|
|
129
|
+
onReachBottom(() => {
|
|
130
|
+
console.log('onReachBottom')
|
|
131
|
+
data.LoadMore()
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
list: data.list,
|
|
137
|
+
isLoading: data.isLoading,
|
|
138
|
+
isNoData: data.isNoData,
|
|
139
|
+
isEmpty: data.isEmpty,
|
|
140
|
+
ReLoad: data.ReLoad,
|
|
141
|
+
setParams: data.setParams,
|
|
142
|
+
LoadMore: data.LoadMore
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|