uni-oaview 1.0.3 → 1.0.5
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/components/oa-helloworld/oa-helloworld.vue +5 -1
- package/components/oa-image/oa-image.vue +9 -0
- package/components/oa-login/oa-login.vue +109 -0
- package/components/oa-single-select/oa-single-select.vue +127 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.umd.mini.js +24 -0
- package/package.json +5 -3
- package/src/index.ts +7 -0
- package/src/shims-vue.d.ts +4 -0
- package/src/utils/index.ts +19 -0
- package/src/utils/validation.ts +52 -0
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div>我真的是服了 现在已经风湿了{{ a }}</div>
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script lang="ts" setup>
|
|
6
|
+
import { ref } from 'vue';
|
|
7
|
+
import { getAsk } from '../../src';
|
|
8
|
+
|
|
6
9
|
console.log('hello world');
|
|
10
|
+
const a = ref(getAsk());
|
|
7
11
|
</script>
|
|
8
12
|
<style scoped lang="scss"></style>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view style="padding: 0 45px">
|
|
3
|
+
<uni-forms :modelValue="formData" ref="formRef" :rules="rules">
|
|
4
|
+
<uni-forms-item required label="用户名" name="username">
|
|
5
|
+
<uni-easyinput type="text" v-model="formData.username" placeholder="请输入用户名" />
|
|
6
|
+
</uni-forms-item>
|
|
7
|
+
<uni-forms-item name="verificationCode" label="验证码">
|
|
8
|
+
<uni-easyinput type="text" v-model="formData.verificationCode" placeholder="请输入验证码" />
|
|
9
|
+
</uni-forms-item>
|
|
10
|
+
<view style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px">
|
|
11
|
+
<img :src="imageSrc" alt="" />
|
|
12
|
+
<button @click="refresh" type="primary" size="mini" style="margin: 0">刷新</button>
|
|
13
|
+
</view>
|
|
14
|
+
</uni-forms>
|
|
15
|
+
<button @click="submitForm" type="primary">登录</button>
|
|
16
|
+
</view>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
import { ref, reactive } from 'vue';
|
|
21
|
+
const formRef = ref();
|
|
22
|
+
const props = defineProps({
|
|
23
|
+
password: String,
|
|
24
|
+
});
|
|
25
|
+
const emit = defineEmits(['loginSuccess']);
|
|
26
|
+
const formData = reactive({
|
|
27
|
+
username: 'lixd',
|
|
28
|
+
password: props.password,
|
|
29
|
+
verificationCode: 88,
|
|
30
|
+
});
|
|
31
|
+
const rules = ref({
|
|
32
|
+
username: [
|
|
33
|
+
{
|
|
34
|
+
required: true,
|
|
35
|
+
errorMessage: '请输入姓名',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
password: [
|
|
39
|
+
{
|
|
40
|
+
required: true,
|
|
41
|
+
errorMessage: '请输入密码',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
const imageSrc = ref('');
|
|
46
|
+
const ppid = ref();
|
|
47
|
+
let baseUrl = '';
|
|
48
|
+
/** 在真机模拟调试的时候运行 */
|
|
49
|
+
// #ifndef H5
|
|
50
|
+
baseUrl = uni.getStorageSync('baseUrl');
|
|
51
|
+
// #endif
|
|
52
|
+
const refresh = () => {
|
|
53
|
+
uni.request({
|
|
54
|
+
url: `${baseUrl}/api/auth/verification/get?t=${Date.now()}`,
|
|
55
|
+
method: 'POST',
|
|
56
|
+
success: (res: any) => {
|
|
57
|
+
const { pid, image } = res.data.data;
|
|
58
|
+
imageSrc.value = image;
|
|
59
|
+
ppid.value = pid;
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
refresh();
|
|
64
|
+
const submitForm = () => {
|
|
65
|
+
uni.showLoading({
|
|
66
|
+
title: '加载中',
|
|
67
|
+
mask: true,
|
|
68
|
+
});
|
|
69
|
+
uni.request({
|
|
70
|
+
url: `${baseUrl}/api/auth/user/login?t=${Date.now()}`,
|
|
71
|
+
method: 'POST',
|
|
72
|
+
data: {
|
|
73
|
+
username: formData.username,
|
|
74
|
+
password: formData.password,
|
|
75
|
+
verification: {
|
|
76
|
+
code: formData.verificationCode,
|
|
77
|
+
pid: ppid.value,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
success: (res: any) => {
|
|
81
|
+
const { uuid: id, email, ...otherParams } = res.data.data;
|
|
82
|
+
const userInfo = {
|
|
83
|
+
id,
|
|
84
|
+
email,
|
|
85
|
+
...otherParams,
|
|
86
|
+
department: '这是一个很长很长的部门部门321312321312',
|
|
87
|
+
position: '这是一个很长很长的职位321312312321321312',
|
|
88
|
+
};
|
|
89
|
+
uni.request({
|
|
90
|
+
url: `${baseUrl}/api/gatewayproxy/routing/getToken?t=${Date.now()}`,
|
|
91
|
+
method: 'POST',
|
|
92
|
+
success: (res: any) => {
|
|
93
|
+
uni.hideLoading();
|
|
94
|
+
emit('loginSuccess', {
|
|
95
|
+
token: res.data.data,
|
|
96
|
+
userInfo,
|
|
97
|
+
});
|
|
98
|
+
uni.showToast({
|
|
99
|
+
title: '登录成功',
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
complete: () => {
|
|
105
|
+
uni.hideLoading();
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
</script>
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view>
|
|
3
|
+
<u-popup :show="modelValue" mode="bottom" @close="closeHandler" :closeOnClickOverlay="false">
|
|
4
|
+
<view class="button-box">
|
|
5
|
+
<view class="button-box-left" @click="closeHandler">取消</view>
|
|
6
|
+
<view class="button-box-center">{{ title }}</view>
|
|
7
|
+
<view class="button-box-right" @click="submit">确定</view>
|
|
8
|
+
</view>
|
|
9
|
+
<view class="search-box">
|
|
10
|
+
<view class="search-box-item">
|
|
11
|
+
<picker-view :indicator-style="indicatorStyle" :value="indexList" @change="bindChange" class="picker-view">
|
|
12
|
+
<picker-view-column>
|
|
13
|
+
<view class="item" v-for="(item, index) in columns" :key="index">{{ item[labelKey ?? 'label'] }}</view>
|
|
14
|
+
</picker-view-column>
|
|
15
|
+
</picker-view>
|
|
16
|
+
</view>
|
|
17
|
+
</view>
|
|
18
|
+
</u-popup>
|
|
19
|
+
</view>
|
|
20
|
+
</template>
|
|
21
|
+
<script lang="ts" setup>
|
|
22
|
+
import { createDebounceFn } from '../../src/index';
|
|
23
|
+
import { ref, nextTick, watch, watchEffect } from 'vue';
|
|
24
|
+
const props = defineProps<{
|
|
25
|
+
title?: string;
|
|
26
|
+
value?: string;
|
|
27
|
+
modelValue: boolean;
|
|
28
|
+
columns: Array<string>;
|
|
29
|
+
labelKey?: string;
|
|
30
|
+
valueKey?: string;
|
|
31
|
+
}>();
|
|
32
|
+
const title = ref(props.title);
|
|
33
|
+
const indicatorStyle = `height: 40px;`;
|
|
34
|
+
const emit = defineEmits(['updateValue', 'close', 'update:modelValue']);
|
|
35
|
+
const indexList = ref<number[]>([]);
|
|
36
|
+
let currentValue: string;
|
|
37
|
+
watchEffect(() => {
|
|
38
|
+
currentValue = props.value as string;
|
|
39
|
+
});
|
|
40
|
+
const init = () => {
|
|
41
|
+
const index = Math.max(
|
|
42
|
+
0,
|
|
43
|
+
props.columns.findIndex((item) => item[props.valueKey ?? 'value'] === currentValue),
|
|
44
|
+
);
|
|
45
|
+
indexList.value = [index];
|
|
46
|
+
};
|
|
47
|
+
init();
|
|
48
|
+
const bindChange = createDebounceFn((e: any) => {
|
|
49
|
+
const val = e.detail.value;
|
|
50
|
+
nextTick(() => {
|
|
51
|
+
indexList.value = val;
|
|
52
|
+
});
|
|
53
|
+
}, 200);
|
|
54
|
+
const submit = () => {
|
|
55
|
+
const val = indexList.value;
|
|
56
|
+
const newValue = props.columns[val[0]];
|
|
57
|
+
currentValue = newValue[props.valueKey ?? 'value'];
|
|
58
|
+
emit('updateValue', newValue);
|
|
59
|
+
emit('update:modelValue', false);
|
|
60
|
+
emit('close');
|
|
61
|
+
};
|
|
62
|
+
const closeHandler = () => {
|
|
63
|
+
emit('update:modelValue', false);
|
|
64
|
+
emit('close');
|
|
65
|
+
};
|
|
66
|
+
watch(
|
|
67
|
+
() => props.modelValue,
|
|
68
|
+
() => {
|
|
69
|
+
if (props.modelValue) {
|
|
70
|
+
init();
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
</script>
|
|
75
|
+
<style lang="scss" scoped>
|
|
76
|
+
.button-box {
|
|
77
|
+
display: flex;
|
|
78
|
+
justify-content: space-between;
|
|
79
|
+
font-size: 28rpx;
|
|
80
|
+
height: 58px;
|
|
81
|
+
text-align: center;
|
|
82
|
+
line-height: 36px;
|
|
83
|
+
margin: 20rpx 20rpx 0 20rpx;
|
|
84
|
+
&-left {
|
|
85
|
+
height: 36px;
|
|
86
|
+
font-size: 16px;
|
|
87
|
+
color: #909193;
|
|
88
|
+
}
|
|
89
|
+
&-center {
|
|
90
|
+
height: 36px;
|
|
91
|
+
font-size: 16px;
|
|
92
|
+
color: #19242c;
|
|
93
|
+
}
|
|
94
|
+
&-right {
|
|
95
|
+
height: 36px;
|
|
96
|
+
font-size: 16px;
|
|
97
|
+
color: #119af5;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
.search-box {
|
|
101
|
+
padding: 24rpx 24rpx 0;
|
|
102
|
+
&-item {
|
|
103
|
+
margin: 12rpx;
|
|
104
|
+
overflow: hidden;
|
|
105
|
+
&-title {
|
|
106
|
+
height: 40rpx;
|
|
107
|
+
line-height: 40rpx;
|
|
108
|
+
font-size: 28rpx;
|
|
109
|
+
color: #333333;
|
|
110
|
+
}
|
|
111
|
+
.picker-view {
|
|
112
|
+
width: 100%;
|
|
113
|
+
height: 400rpx;
|
|
114
|
+
.flex-two {
|
|
115
|
+
flex: 2;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
.item {
|
|
119
|
+
height: 40px;
|
|
120
|
+
line-height: 40px;
|
|
121
|
+
align-items: center;
|
|
122
|
+
justify-content: center;
|
|
123
|
+
text-align: center;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
</style>
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 防抖函数
|
|
3
|
+
* @param callback
|
|
4
|
+
* @param time
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
declare function createDebounceFn(callback: (...params: any[]) => void, time: number): (...params: any[]) => void;
|
|
8
|
+
declare function getAsk(): string;
|
|
9
|
+
|
|
1
10
|
declare const _default: {
|
|
2
11
|
install: (Vue: any) => void;
|
|
3
12
|
};
|
|
4
13
|
|
|
5
|
-
export { _default as default };
|
|
14
|
+
export { createDebounceFn, _default as default, getAsk };
|
package/dist/index.umd.mini.js
CHANGED
|
@@ -4,12 +4,36 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["UNI-OAVIEW"] = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* 防抖函数
|
|
9
|
+
* @param callback
|
|
10
|
+
* @param time
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
function createDebounceFn(callback, time) {
|
|
14
|
+
var timer = null;
|
|
15
|
+
return function () {
|
|
16
|
+
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
17
|
+
params[_key] = arguments[_key];
|
|
18
|
+
}
|
|
19
|
+
clearTimeout(timer);
|
|
20
|
+
timer = setTimeout(function () {
|
|
21
|
+
callback.apply(void 0, params);
|
|
22
|
+
}, time);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function getAsk() {
|
|
26
|
+
return '我是航帆范德萨范德萨';
|
|
27
|
+
}
|
|
28
|
+
|
|
7
29
|
var install = function install(Vue) {};
|
|
8
30
|
var index = {
|
|
9
31
|
install: install
|
|
10
32
|
};
|
|
11
33
|
|
|
34
|
+
exports.createDebounceFn = createDebounceFn;
|
|
12
35
|
exports["default"] = index;
|
|
36
|
+
exports.getAsk = getAsk;
|
|
13
37
|
|
|
14
38
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
15
39
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uni-oaview",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "uniapp小程序组件库",
|
|
5
5
|
"main": "dist/index.umd.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
|
-
"components"
|
|
10
|
+
"components",
|
|
11
|
+
"src"
|
|
11
12
|
],
|
|
12
13
|
"author": "",
|
|
13
14
|
"license": "ISC",
|
|
@@ -34,9 +35,10 @@
|
|
|
34
35
|
"rollup-plugin-eslint": "^7.0.0",
|
|
35
36
|
"rollup-plugin-terser": "^7.0.2",
|
|
36
37
|
"rollup-plugin-typescript2": "^0.27.2",
|
|
38
|
+
"rollup-plugin-vue": "^6.0.0",
|
|
37
39
|
"typescript": "^4.0.2"
|
|
38
40
|
},
|
|
39
|
-
"
|
|
41
|
+
"peerDependencies": {
|
|
40
42
|
"uniapp-log-sdk": "^1.1.1"
|
|
41
43
|
}
|
|
42
44
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 防抖函数
|
|
3
|
+
* @param callback
|
|
4
|
+
* @param time
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export function createDebounceFn(callback: (...params: any[]) => void, time: number) {
|
|
8
|
+
let timer: any = null;
|
|
9
|
+
return (...params: any[]) => {
|
|
10
|
+
clearTimeout(timer);
|
|
11
|
+
timer = setTimeout(() => {
|
|
12
|
+
callback(...params);
|
|
13
|
+
}, time);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getAsk() {
|
|
18
|
+
return '我是航帆范德萨范德萨';
|
|
19
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断当前参数是否是undefined或者null
|
|
3
|
+
* @param {Object} obj
|
|
4
|
+
*/
|
|
5
|
+
export function isNullOrUndefined(value: any) {
|
|
6
|
+
return typeof value === 'undefined' || value === null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 是否对象
|
|
10
|
+
*/
|
|
11
|
+
export function isObject(value: any) {
|
|
12
|
+
return Object.prototype.toString.call(value) === '[object Object]';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 判断当前参数是否是空, 包括空字符和空对象,空数组,null,undefined
|
|
17
|
+
* @param {Object} obj
|
|
18
|
+
*/
|
|
19
|
+
export function isEmpty(obj: any) {
|
|
20
|
+
if (isNullOrUndefined(obj)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
if (Array.isArray(obj) && obj.length === 0) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if (typeof obj === 'string' && obj === '') {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 验证十进制数字
|
|
33
|
+
*/
|
|
34
|
+
export function isNumber(value: any) {
|
|
35
|
+
return /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 正则校验是否为颜色,支持#FFF,#FFFFFF,#FFFFFFFF格式
|
|
40
|
+
*/
|
|
41
|
+
export function CheckIsColor(color: any) {
|
|
42
|
+
const type = '^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$';
|
|
43
|
+
const reg = new RegExp(type);
|
|
44
|
+
return color.match(reg) !== null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default {
|
|
48
|
+
isNullOrUndefined,
|
|
49
|
+
isObject,
|
|
50
|
+
isEmpty,
|
|
51
|
+
isNumber,
|
|
52
|
+
};
|