uni-oaview 1.0.31 → 1.0.33

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.
@@ -50,7 +50,7 @@
50
50
  areaList.value = [{ value: 'area-empty', label: '空' }];
51
51
  const areas = cityList.value?.find(({ value }) => value === city)?.children;
52
52
  if (areas?.length) {
53
- areaList.value = [{ value: 'area-empty', label: '空' }, ...areas];
53
+ areaList.value.push(...areas);
54
54
  }
55
55
  state.value = [provinceList.value.findIndex((item) => item.value === province)];
56
56
  if (city) {
@@ -68,7 +68,7 @@
68
68
  areaList.value = [{ value: 'area-empty', label: '空' }];
69
69
  const areas = cityList.value?.[0]?.children;
70
70
  if (areas?.length) {
71
- areaList.value = [{ value: 'area-empty', label: '空' }, ...areas];
71
+ areaList.value.push(...areas);
72
72
  }
73
73
  }
74
74
  };
@@ -103,9 +103,9 @@
103
103
  const selectedProvince = provinceList.value[state.value[0]]; // 获取当前选中的省数据
104
104
  const selectedCity = selectedProvince?.children?.[state.value[1]]; // 获取当前选中的市数据
105
105
  cityList.value = selectedProvince?.children || [{ value: 'city-empty', label: '空' }]; // 根据新的省数据重新赋值市数据
106
- areaList.value = [{ value: 'city-empty', label: '空' }]; // 根据新的市数据重新赋值区数据
106
+ areaList.value = [{ value: 'area-empty', label: '空' }]; // 根据新的市数据重新赋值区数据
107
107
  if (selectedCity?.children?.length) {
108
- areaList.value = [{ value: 'city-empty', label: '空' }, ...selectedCity?.children]; // 根据新的市数据重新赋值区数据
108
+ areaList.value.push(...selectedCity?.children); // 根据新的市数据重新赋值区数据
109
109
  }
110
110
  }, 200);
111
111
  </script>
@@ -86,6 +86,13 @@
86
86
  },
87
87
  },
88
88
  success: (res: any) => {
89
+ if (res?.data?.errno !== 0) {
90
+ uni.showToast({
91
+ title: res.data.errmsg,
92
+ icon: 'none',
93
+ });
94
+ return;
95
+ }
89
96
  const { uuid: id, email, ...otherParams } = res?.data?.data;
90
97
  const userInfo = {
91
98
  ...otherParams,
@@ -8,17 +8,19 @@
8
8
  <text v-if="innerModelValue?.length">({{ innerModelValue?.length }})</text>
9
9
  </view>
10
10
  </view>
11
- <view class="content-box">
12
- <view @click="clickHandler(item)" class="content-item" v-for="item in options" :key="item[valueKey ?? 'value']">
13
- <uni-icons
14
- class="content-item-icon"
15
- :type="innerModelValue?.includes(item[valueKey ?? 'value']) ? 'checkbox-filled' : 'circle'"
16
- size="25"
17
- :color="innerModelValue?.includes(item[valueKey ?? 'value']) ? '#259af5' : '#c5cace'"
18
- ></uni-icons>
19
- <text class="content-item-text" style="margin-left: 8px">{{ item[labelKey ?? 'label'] }}</text>
11
+ <scroll-view style="height: 300px" :scroll-y="true">
12
+ <view class="content-box">
13
+ <view @click="clickHandler(item)" class="content-item" v-for="item in options" :key="item[valueKey ?? 'value']">
14
+ <uni-icons
15
+ class="content-item-icon"
16
+ :type="innerModelValue?.includes(item[valueKey ?? 'value']) ? 'checkbox-filled' : 'circle'"
17
+ size="25"
18
+ :color="innerModelValue?.includes(item[valueKey ?? 'value']) ? '#259af5' : '#c5cace'"
19
+ ></uni-icons>
20
+ <text class="content-item-text" style="margin-left: 8px">{{ item[labelKey ?? 'label'] }}</text>
21
+ </view>
20
22
  </view>
21
- </view>
23
+ </scroll-view>
22
24
  </oa-popup>
23
25
  </template>
24
26
 
@@ -90,8 +92,7 @@
90
92
  }
91
93
  }
92
94
  .content-box {
93
- height: 300px;
94
- overflow-y: auto;
95
+ height: 100%;
95
96
  & > .content-item {
96
97
  height: 54px;
97
98
  display: flex;
@@ -10,7 +10,7 @@
10
10
  position: fixed;
11
11
  top: 0;
12
12
  left: 0;
13
- width: 100%;
13
+ width: 100vw;
14
14
  height: 2px;
15
15
  background-color: #ddd;
16
16
  z-index: 9999;
@@ -17,6 +17,7 @@
17
17
  @update:model-value="($event) => emit('update:modelValue', $event)"
18
18
  :options="options"
19
19
  @change="changeHandler"
20
+ @select-change="($event) => emit('change', $event)"
20
21
  >
21
22
  <!-- 透传作用域插槽内容到孙子组件 -->
22
23
  <template v-slot:default="slotProps">
@@ -25,7 +26,7 @@
25
26
  </oa-select-popup>
26
27
  </template>
27
28
  <script lang="ts" setup>
28
- import { ref, watchEffect } from 'vue';
29
+ import { ref } from 'vue';
29
30
  import OaSelectPopup from '../oa-select-popup/oa-select-popup.vue';
30
31
  const props = defineProps<{
31
32
  title?: string;
@@ -36,16 +37,9 @@
36
37
  }>();
37
38
  const popupShow = ref(false);
38
39
  const currentLabel = ref('');
39
- watchEffect(() => {
40
- if (props.modelValue && props.options.length) {
41
- currentLabel.value = props.options.find((item) => item[props.valueKey ?? 'value'] === props.modelValue)[
42
- props.labelKey ?? 'label'
43
- ];
44
- }
45
- });
46
40
  const emit = defineEmits(['change', 'close', 'update:modelValue']);
47
41
  const changeHandler = (val: any) => {
48
- emit('change', val);
42
+ currentLabel.value = val?.[props.labelKey ?? 'label'];
49
43
  };
50
44
  </script>
51
45
  <style lang="scss" scoped>
@@ -28,7 +28,7 @@
28
28
  /** 标题 */
29
29
  title?: string;
30
30
  /** 值,数组 */
31
- modelValue?: string | number | string[] | number[];
31
+ modelValue?: string | number;
32
32
  /** 弹窗显示 */
33
33
  show: boolean;
34
34
  options: Array<any>;
@@ -36,13 +36,32 @@
36
36
  valueKey?: string;
37
37
  }>();
38
38
  const indicatorStyle = `height: 40px;`;
39
- const emit = defineEmits(['change', 'update:modelValue', 'colse', 'update:show']);
39
+ const emit = defineEmits(['change', 'select-change', 'update:modelValue', 'colse', 'update:show']);
40
40
  const indexList = ref<number[]>([]);
41
41
  const currentLabel = ref('');
42
+ /** 为了第一次初始化赋值的时候,也触发change,这样为了方式拿数据 */
43
+ const stopWatch = watch(
44
+ [() => props.modelValue, () => props.options],
45
+ () => {
46
+ setTimeout(() => {
47
+ if ((props.modelValue || props.modelValue === 0) && props.options.length) {
48
+ emit(
49
+ 'change',
50
+ props.options.find((item) => item[props.valueKey ?? 'value'] === props.modelValue),
51
+ );
52
+ stopWatch();
53
+ }
54
+ });
55
+ },
56
+ {
57
+ immediate: true,
58
+ },
59
+ );
42
60
  watch(
43
61
  [() => props.show, () => props.options],
44
62
  () => {
45
63
  if (props.show) {
64
+ stopWatch();
46
65
  indexList.value = [
47
66
  Math.max(
48
67
  0,
@@ -53,6 +72,7 @@
53
72
  },
54
73
  { immediate: true },
55
74
  );
75
+
56
76
  const bindChange = useDebounceFn((e: any) => {
57
77
  const val = e.detail.value;
58
78
  nextTick(() => {
@@ -66,6 +86,7 @@
66
86
  const currentValue = newValue[props.valueKey ?? 'value'];
67
87
  emit('update:modelValue', currentValue);
68
88
  emit('change', newValue);
89
+ emit('select-change', newValue);
69
90
  emit('update:show', false);
70
91
  };
71
92
  const closeHandler = () => {
package/dist/index.d.ts CHANGED
@@ -2,6 +2,14 @@ import { App } from 'vue';
2
2
 
3
3
  declare const _default: {
4
4
  install: (app: App<Element>) => void;
5
- };
5
+ };
6
+ /**
7
+ * 向客户端获取数据
8
+ * @param eventName 事件名称
9
+ * @param params 客户端传递事件的参数
10
+ * @param immediate 是否立即返回
11
+ * @returns
12
+ */
13
+ declare function getDataByApp(eventName: string, params: Record<string, any>, immediate?: boolean): Promise<any>;
6
14
 
7
- export { _default as default };
15
+ export { _default as default, getDataByApp };
package/dist/index.esm.js CHANGED
@@ -1,5 +1,15 @@
1
1
  import { reportLog } from 'uniapp-log-sdk';
2
2
 
3
+ function _typeof(obj) {
4
+ "@babel/helpers - typeof";
5
+
6
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
7
+ return typeof obj;
8
+ } : function (obj) {
9
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
10
+ }, _typeof(obj);
11
+ }
12
+
3
13
  /**
4
14
  * 上报APP启动小程序的时候的入参
5
15
  * @param params
@@ -11,6 +21,7 @@ function sendLaunchAppParamsLog(params) {
11
21
  try {
12
22
  var outputData = JSON.parse(JSON.stringify((_a = params === null || params === void 0 ? void 0 : params.referrerInfo) === null || _a === void 0 ? void 0 : _a.extraData));
13
23
  outputData === null || outputData === void 0 ? true : delete outputData.token;
24
+ outputData === null || outputData === void 0 ? true : delete outputData.loginUserInfo;
14
25
  reportLog(outputData, '小程序启动入参');
15
26
  } catch (error) {
16
27
  console.log(error);
@@ -28,5 +39,34 @@ var install = function install(app) {
28
39
  var index = {
29
40
  install: install
30
41
  };
42
+ /**
43
+ * 向客户端获取数据
44
+ * @param eventName 事件名称
45
+ * @param params 客户端传递事件的参数
46
+ * @param immediate 是否立即返回
47
+ * @returns
48
+ */
49
+ function getDataByApp(eventName, params) {
50
+ var immediate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
51
+ return new Promise(function (res, rej) {
52
+ var timeout = null;
53
+ if (immediate) {
54
+ timeout = setTimeout(rej, 5000);
55
+ }
56
+ if (params && _typeof(params) === 'object') {
57
+ try {
58
+ params = JSON.parse(JSON.stringify(params));
59
+ } catch (error) {
60
+ console.log(error);
61
+ }
62
+ }
63
+ uni.sendNativeEvent(eventName, params !== null && params !== void 0 ? params : {}, function (data) {
64
+ if (immediate) {
65
+ clearTimeout(timeout);
66
+ }
67
+ res(data);
68
+ });
69
+ });
70
+ }
31
71
 
32
- export { index as default };
72
+ export { index as default, getDataByApp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uni-oaview",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "description": "uniapp小程序组件库",
5
5
  "main": "dist/index.esm.js",
6
6
  "typings": "dist/index.d.ts",
@@ -44,16 +44,13 @@
44
44
  "rollup-plugin-typescript2": "^0.27.2",
45
45
  "rollup-plugin-vue": "^6.0.0",
46
46
  "typescript": "^4.0.2",
47
- "uniapp-log-sdk": "^1.2.17",
48
- "uview-plus": "^3.1.30"
47
+ "uniapp-log-sdk": "^1.2.17"
49
48
  },
50
49
  "peerDependencies": {
51
50
  "@dcloudio/uni-ui": "^1.4.26",
52
51
  "@vueuse/core": "^9.12.0",
53
- "clipboard": "^2.0.11",
54
52
  "dayjs": "1.11.7",
55
- "uniapp-log-sdk": "^1.1.1",
56
- "uview-plus": "^3.1.30"
53
+ "uniapp-log-sdk": "^1.1.1"
57
54
  },
58
55
  "dependencies": {
59
56
  "element-china-area-data": "5.0.2"
package/src/index.ts CHANGED
@@ -13,3 +13,32 @@ const install = (app: App<Element>) => {
13
13
  export default {
14
14
  install,
15
15
  };
16
+
17
+ /**
18
+ * 向客户端获取数据
19
+ * @param eventName 事件名称
20
+ * @param params 客户端传递事件的参数
21
+ * @param immediate 是否立即返回
22
+ * @returns
23
+ */
24
+ export function getDataByApp(eventName: string, params: Record<string, any>, immediate: boolean = false): Promise<any> {
25
+ return new Promise((res, rej) => {
26
+ let timeout: any = null;
27
+ if (immediate) {
28
+ timeout = setTimeout(rej, 5000);
29
+ }
30
+ if (params && typeof params === 'object') {
31
+ try {
32
+ params = JSON.parse(JSON.stringify(params));
33
+ } catch (error) {
34
+ console.log(error);
35
+ }
36
+ }
37
+ uni.sendNativeEvent(eventName, params ?? {}, (data: any) => {
38
+ if (immediate) {
39
+ clearTimeout(timeout);
40
+ }
41
+ res(data);
42
+ });
43
+ });
44
+ }
@@ -10,6 +10,7 @@ export function sendLaunchAppParamsLog(params: any) {
10
10
  try {
11
11
  const outputData = JSON.parse(JSON.stringify(params?.referrerInfo?.extraData));
12
12
  delete outputData?.token;
13
+ delete outputData?.loginUserInfo;
13
14
  reportLog(outputData, '小程序启动入参');
14
15
  } catch (error) {
15
16
  console.log(error);
@@ -1,140 +0,0 @@
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
- <slot :columns="columns">
14
- <view class="item" v-for="(item, index) in columns" :key="index">{{ item[labelKey ?? 'label'] }}</view>
15
- </slot>
16
- </picker-view-column>
17
- </picker-view>
18
- </view>
19
- </view>
20
- </u-popup>
21
- </view>
22
- </template>
23
- <script lang="ts" setup>
24
- import { ref, nextTick, watch } from 'vue';
25
- import { useDebounceFn } from '@vueuse/core';
26
- const props = defineProps<{
27
- title?: string;
28
- value?: string;
29
- modelValue: boolean;
30
- columns: Array<any>;
31
- labelKey?: string;
32
- valueKey?: string;
33
- }>();
34
- const title = ref(props.title);
35
- const indicatorStyle = `height: 40px;`;
36
- const emit = defineEmits(['updateValue', 'close', 'update:modelValue']);
37
- const indexList = ref<number[]>([]);
38
- let currentValue: string;
39
- watch(
40
- [() => props.modelValue, () => props.value],
41
- () => {
42
- if (props.modelValue) {
43
- currentValue = props.value as string;
44
- init();
45
- }
46
- },
47
- {
48
- immediate: true,
49
- },
50
- );
51
- const init = () => {
52
- const index = Math.max(
53
- 0,
54
- props.columns.findIndex((item) => item[props.valueKey ?? 'value'] === currentValue),
55
- );
56
- indexList.value = [index];
57
- };
58
- const bindChange = useDebounceFn((e: any) => {
59
- const val = e.detail.value;
60
- nextTick(() => {
61
- indexList.value = val;
62
- });
63
- }, 200);
64
- init();
65
- const submit = () => {
66
- const val = indexList.value;
67
- const newValue = props.columns[val[0]];
68
- currentValue = newValue[props.valueKey ?? 'value'];
69
- emit('updateValue', newValue);
70
- emit('update:modelValue', false);
71
- emit('close');
72
- };
73
- const closeHandler = () => {
74
- emit('update:modelValue', false);
75
- emit('close');
76
- };
77
- watch(
78
- () => props.modelValue,
79
- () => {
80
- if (props.modelValue) {
81
- init();
82
- }
83
- },
84
- );
85
- </script>
86
- <style lang="scss" scoped>
87
- .button-box {
88
- display: flex;
89
- justify-content: space-between;
90
- font-size: 14px;
91
- height: 58px;
92
- text-align: center;
93
- line-height: 36px;
94
- margin: 10px 10px 0 10px;
95
- &-left {
96
- cursor: pointer;
97
- height: 36px;
98
- font-size: 16px;
99
- color: #909193;
100
- }
101
- &-center {
102
- height: 36px;
103
- font-size: 16px;
104
- color: #19242c;
105
- }
106
- &-right {
107
- cursor: pointer;
108
- height: 36px;
109
- font-size: 16px;
110
- color: #119af5;
111
- }
112
- }
113
- .search-box {
114
- padding: 12px 12px 0;
115
- &-item {
116
- margin: 6px;
117
- overflow: hidden;
118
- &-title {
119
- height: 20px;
120
- line-height: 20px;
121
- font-size: 14px;
122
- color: #333333;
123
- }
124
- .picker-view {
125
- width: 100%;
126
- height: 200px;
127
- .flex-two {
128
- flex: 2;
129
- }
130
- }
131
- .item {
132
- height: 40px;
133
- line-height: 40px;
134
- align-items: center;
135
- justify-content: center;
136
- text-align: center;
137
- }
138
- }
139
- }
140
- </style>