@tplc/business 0.0.40 → 0.0.47
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/CHANGELOG.md +65 -0
- package/action.d.ts +3 -0
- package/components/lcb-action-view/lcb-action-view.vue +19 -4
- package/components/lcb-dynamic-data/lcb-dynamic-data.vue +5 -2
- package/components/lcb-dynamic-data/types.ts +1 -1
- package/components/lcb-list/components/FilterList/index.vue +1 -5
- package/components/lcb-list/index.scss +5 -0
- package/components/lcb-list/lcb-list.vue +23 -1
- package/components/lcb-list/types.ts +1 -1
- package/components/lcb-nav/lcb-nav.vue +9 -9
- package/components/lcb-product/lcb-product.vue +56 -11
- package/components/lcb-product-item/components/ItemValue.vue +77 -65
- package/components/lcb-product-item/lcb-product-item.vue +69 -15
- package/components/lcb-product-item/types.ts +14 -0
- package/components/lcb-user-top/api/index.ts +13 -0
- package/components/lcb-user-top/lcb-user-top.vue +43 -41
- package/components/lcb-user-top/types.ts +4 -47
- package/constants.ts +2 -0
- package/hooks/useUpload.api.ts +17 -0
- package/hooks/useUpload.ts +111 -0
- package/package.json +2 -2
- package/types/components/lcb-action-view/lcb-action-view.vue.d.ts +22 -2
- package/types/components/lcb-dynamic-data/types.d.ts +1 -1
- package/types/components/lcb-list/components/FilterList/index.vue.d.ts +13 -1
- package/types/components/lcb-list/lcb-list.vue.d.ts +31 -1
- package/types/components/lcb-nav/lcb-nav.vue.d.ts +1 -1
- package/types/components/lcb-product/lcb-product.vue.d.ts +35 -1
- package/types/components/lcb-product-item/components/ItemValue.vue.d.ts +19 -1
- package/types/components/lcb-product-item/lcb-product-item.vue.d.ts +36 -2
- package/types/components/lcb-product-item/types.d.ts +13 -0
- package/types/components/lcb-user-top/api/index.d.ts +10 -0
- package/types/components/lcb-user-top/lcb-user-top.vue.d.ts +3 -0
- package/types/components/lcb-user-top/types.d.ts +4 -3
- package/types/constants.d.ts +2 -0
- package/types/hooks/useUpload.api.d.ts +12 -0
- package/types/hooks/useUpload.d.ts +23 -0
- package/utils/utils.ts +9 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, provide, useAttrs } from 'vue'
|
|
3
|
-
import { LcbProductItemProps } from './types'
|
|
3
|
+
import { lcbProductItemContentTypes, LcbProductItemProps } from './types'
|
|
4
4
|
import ItemValue from './components/ItemValue.vue'
|
|
5
5
|
|
|
6
6
|
defineOptions({
|
|
@@ -32,25 +32,59 @@ const attrs = useAttrs()
|
|
|
32
32
|
|
|
33
33
|
provide('lcb-product-item-props', props)
|
|
34
34
|
|
|
35
|
+
defineSlots<{
|
|
36
|
+
image(): any
|
|
37
|
+
title(): any
|
|
38
|
+
subTitle(): any
|
|
39
|
+
price(): any
|
|
40
|
+
priceUnit(): any
|
|
41
|
+
priceSuffix(): any
|
|
42
|
+
originPrice(): any
|
|
43
|
+
originPriceUnit(): any
|
|
44
|
+
tags(): any
|
|
45
|
+
location(): any
|
|
46
|
+
distance(): any
|
|
47
|
+
}>()
|
|
48
|
+
|
|
35
49
|
// console.log('attrs', attrs)
|
|
36
50
|
</script>
|
|
37
51
|
|
|
38
52
|
<template>
|
|
39
53
|
<!-- 横向布局 -->
|
|
40
54
|
<view v-if="layoutType === 'horizontal'" :class="className" class="flex gap-3 px-2 py-3 bg-white">
|
|
41
|
-
<ItemValue prop="image" className="w-1/3 h-220rpx bg-gray-100 rounded-sm overflow-hidden"
|
|
55
|
+
<ItemValue prop="image" className="w-1/3 h-220rpx bg-gray-100 rounded-sm overflow-hidden">
|
|
56
|
+
<template
|
|
57
|
+
v-for="slotName in lcbProductItemContentTypes"
|
|
58
|
+
:key="slotName"
|
|
59
|
+
#[slotName]="slotContext"
|
|
60
|
+
>
|
|
61
|
+
<slot :name="slotName" v-bind="slotContext" />
|
|
62
|
+
</template>
|
|
63
|
+
</ItemValue>
|
|
42
64
|
<view class="flex flex-col flex-1 gap-2 justify-between text-26rpx overflow-hidden">
|
|
43
65
|
<view class="flex flex-col gap-2 overflow-hidden">
|
|
44
|
-
<ItemValue v-for="prop in ['title', 'location', 'tags']" :prop="prop" :key="prop"
|
|
66
|
+
<ItemValue v-for="prop in ['title', 'location', 'tags']" :prop="prop" :key="prop">
|
|
67
|
+
<template
|
|
68
|
+
v-for="slotName in lcbProductItemContentTypes"
|
|
69
|
+
:key="slotName"
|
|
70
|
+
#[slotName]="slotContext"
|
|
71
|
+
>
|
|
72
|
+
<slot :name="slotName" v-bind="slotContext" />
|
|
73
|
+
</template>
|
|
74
|
+
</ItemValue>
|
|
45
75
|
</view>
|
|
46
76
|
|
|
47
77
|
<view class="flex gap-2">
|
|
48
78
|
<view class="flex gap-[4rpx] items-end">
|
|
49
|
-
<ItemValue
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
79
|
+
<ItemValue v-for="prop in ['priceUnit', 'price', 'priceSuffix']" :prop="prop" :key="prop">
|
|
80
|
+
<template
|
|
81
|
+
v-for="slotName in lcbProductItemContentTypes"
|
|
82
|
+
:key="slotName"
|
|
83
|
+
#[slotName]="slotContext"
|
|
84
|
+
>
|
|
85
|
+
<slot :name="slotName" v-bind="slotContext" />
|
|
86
|
+
</template>
|
|
87
|
+
</ItemValue>
|
|
54
88
|
</view>
|
|
55
89
|
</view>
|
|
56
90
|
</view>
|
|
@@ -58,23 +92,43 @@ provide('lcb-product-item-props', props)
|
|
|
58
92
|
|
|
59
93
|
<!-- 竖向布局 -->
|
|
60
94
|
<view v-if="layoutType === 'vertical'" :class="className" class="flex flex-col gap-2 bg-white">
|
|
61
|
-
<ItemValue prop="image" className="overflow-hidden"
|
|
95
|
+
<ItemValue prop="image" className="overflow-hidden">
|
|
96
|
+
<template
|
|
97
|
+
v-for="slotName in lcbProductItemContentTypes"
|
|
98
|
+
:key="slotName"
|
|
99
|
+
#[slotName]="slotContext"
|
|
100
|
+
>
|
|
101
|
+
<slot :name="slotName" v-bind="slotContext" />
|
|
102
|
+
</template>
|
|
103
|
+
</ItemValue>
|
|
62
104
|
<view
|
|
63
105
|
:class="'p-2'"
|
|
64
106
|
class="flex flex-col flex-1 gap-2 justify-between text-26rpx overflow-hidden"
|
|
65
107
|
>
|
|
66
108
|
<view class="flex flex-col gap-2 overflow-hidden">
|
|
67
109
|
<!-- <ItemValue prop="title"></ItemValue> -->
|
|
68
|
-
<ItemValue v-for="prop in ['title', 'location', 'tags']" :prop="prop" :key="prop"
|
|
110
|
+
<ItemValue v-for="prop in ['title', 'location', 'tags']" :prop="prop" :key="prop">
|
|
111
|
+
<template
|
|
112
|
+
v-for="slotName in lcbProductItemContentTypes"
|
|
113
|
+
:key="slotName"
|
|
114
|
+
#[slotName]="slotContext"
|
|
115
|
+
>
|
|
116
|
+
<slot :name="slotName" v-bind="slotContext" />
|
|
117
|
+
</template>
|
|
118
|
+
</ItemValue>
|
|
69
119
|
</view>
|
|
70
120
|
|
|
71
121
|
<view class="flex gap-2">
|
|
72
122
|
<view class="flex gap-[4rpx] items-end">
|
|
73
|
-
<ItemValue
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
123
|
+
<ItemValue v-for="prop in ['priceUnit', 'price', 'priceSuffix']" :prop="prop" :key="prop">
|
|
124
|
+
<template
|
|
125
|
+
v-for="slotName in lcbProductItemContentTypes"
|
|
126
|
+
:key="slotName"
|
|
127
|
+
#[slotName]="slotContext"
|
|
128
|
+
>
|
|
129
|
+
<slot :name="slotName" v-bind="slotContext" />
|
|
130
|
+
</template>
|
|
131
|
+
</ItemValue>
|
|
78
132
|
</view>
|
|
79
133
|
</view>
|
|
80
134
|
</view>
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { CSSProperties } from 'vue'
|
|
2
2
|
|
|
3
|
+
export const lcbProductItemContentTypes = [
|
|
4
|
+
'image',
|
|
5
|
+
'title',
|
|
6
|
+
'subTitle',
|
|
7
|
+
'price',
|
|
8
|
+
'priceUnit',
|
|
9
|
+
'priceSuffix',
|
|
10
|
+
'originPrice',
|
|
11
|
+
'originPriceUnit',
|
|
12
|
+
'tags',
|
|
13
|
+
'location',
|
|
14
|
+
'distance',
|
|
15
|
+
] as const
|
|
16
|
+
|
|
3
17
|
export interface LcbProductItemProps {
|
|
4
18
|
// Define the component's prop types here
|
|
5
19
|
className?: string
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const env = import.meta as unknown as { env: Record<string, string> }
|
|
2
|
+
export const getPhone = (data: { encryptedData: string; iv: string; code?: string }) =>
|
|
3
|
+
uni.$lcb.http.post('/wechatProgram/api/getPhone', {
|
|
4
|
+
...data,
|
|
5
|
+
appId: env.env.VITE_WX_APPID,
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
export const saveUserInfo = (data: { nickName?: string; avatarUrl?: string }) =>
|
|
9
|
+
uni.$lcb.http.post('/wechatProgram/saveUserInfo', data)
|
|
10
|
+
|
|
11
|
+
// /api/login/getUserInfo
|
|
12
|
+
|
|
13
|
+
export const getUserInfo = () => uni.$lcb.http.post('/login/getUserInfo')
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
/>
|
|
15
15
|
<view class="flex flex-items-center">
|
|
16
16
|
<wd-img
|
|
17
|
-
v-if="
|
|
17
|
+
v-if="photoUrl"
|
|
18
18
|
v-bind="{
|
|
19
19
|
width: transformValueUnit(photoSize),
|
|
20
20
|
height: transformValueUnit(photoSize),
|
|
@@ -31,21 +31,20 @@
|
|
|
31
31
|
borderRadius: photoRound ? '50%' : '',
|
|
32
32
|
}"
|
|
33
33
|
class="bg-#eee userPlace mr-40rpx"
|
|
34
|
-
|
|
35
|
-
<!-- flex justify-center items-center overflow-hidden relative -->
|
|
36
|
-
<!-- <wd-icon name="user" :size="transformValueUnit(photoSize * 0.9)" color="#ddd" class="absolute photoIcon"></wd-icon> -->
|
|
37
|
-
</view>
|
|
34
|
+
/>
|
|
38
35
|
<view class="flex-1">
|
|
39
|
-
<view
|
|
40
|
-
class="font-bold"
|
|
36
|
+
<lcb-action-view
|
|
37
|
+
custom-class="font-bold"
|
|
38
|
+
:jumpType="88"
|
|
41
39
|
:style="{
|
|
42
40
|
fontSize: transformValueUnit(textSize),
|
|
43
41
|
color: textColor,
|
|
44
42
|
}"
|
|
43
|
+
@phone="getPhone"
|
|
45
44
|
>
|
|
46
45
|
授权登录
|
|
47
|
-
</view>
|
|
48
|
-
<view class="flex" v-if="editBtn
|
|
46
|
+
</lcb-action-view>
|
|
47
|
+
<view class="flex" v-if="editBtn">
|
|
49
48
|
<view
|
|
50
49
|
class="flex flex-content-center flex-items-center mt-5px border-style-solid"
|
|
51
50
|
:style="{
|
|
@@ -61,26 +60,27 @@
|
|
|
61
60
|
</view>
|
|
62
61
|
</view>
|
|
63
62
|
</view>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
63
|
+
<!-- 右边按钮 -->
|
|
64
|
+
<lcb-action-view v-if="moreIcon" v-bind="rightIconLink">
|
|
65
|
+
<img
|
|
66
|
+
v-if="iconType === 1"
|
|
67
|
+
:src="iconUpload"
|
|
68
|
+
:style="{
|
|
69
|
+
width: transformValueUnit(rightIconSize),
|
|
70
|
+
color: textColor,
|
|
71
|
+
}"
|
|
72
|
+
mode="widthFix"
|
|
73
|
+
/>
|
|
75
74
|
<wd-icon
|
|
76
75
|
class-prefix="lcb"
|
|
76
|
+
v-else
|
|
77
77
|
v-bind="{
|
|
78
78
|
name: iconName,
|
|
79
|
-
size: transformValueUnit(
|
|
79
|
+
size: transformValueUnit(rightIconSize),
|
|
80
80
|
color: textColor,
|
|
81
81
|
}"
|
|
82
82
|
/>
|
|
83
|
-
</view>
|
|
83
|
+
</lcb-action-view>
|
|
84
84
|
</view>
|
|
85
85
|
<view
|
|
86
86
|
v-if="valuesCard == true || coupons == true || presales == true || memberPoints == true"
|
|
@@ -95,18 +95,6 @@
|
|
|
95
95
|
<Nums v-if="coupons == true" v-bind="$props" title="优惠券" />
|
|
96
96
|
<Nums v-if="presales == true" v-bind="$props" title="预售券" />
|
|
97
97
|
<Nums v-if="memberPoints == true" v-bind="$props" title="会员积分" />
|
|
98
|
-
<!-- <View v-if="coupons == true" class="">
|
|
99
|
-
<view class="text-22px font-bold">0</view>
|
|
100
|
-
<view class="text-12px optName">优惠券</view>
|
|
101
|
-
</View>
|
|
102
|
-
<View v-if="presales == true" class="">
|
|
103
|
-
<view class="text-22px font-bold">0</view>
|
|
104
|
-
<view class="text-12px optName">预售券</view>
|
|
105
|
-
</View>
|
|
106
|
-
<View v-if="memberPoints == true" class="">
|
|
107
|
-
<view class="text-22px font-bold">0</view>
|
|
108
|
-
<view class="text-12px optName">会员积分</view>
|
|
109
|
-
</View> -->
|
|
110
98
|
</view>
|
|
111
99
|
</lcb-block>
|
|
112
100
|
</template>
|
|
@@ -115,9 +103,10 @@
|
|
|
115
103
|
import { LcbUserTopProps } from './types'
|
|
116
104
|
import { transformValueUnit } from '../../utils/transform'
|
|
117
105
|
import Nums from './Nums/index.vue'
|
|
118
|
-
import {
|
|
119
|
-
import { computed } from 'vue'
|
|
106
|
+
import { computed, inject } from 'vue'
|
|
120
107
|
import { addUnit } from '@tplc/wot/components/common/util'
|
|
108
|
+
import { PAGE_PROVIDE_KEY } from '../../constants'
|
|
109
|
+
import { getUserInfo } from './api'
|
|
121
110
|
const { statusBarHeight } = uni.getSystemInfoSync()
|
|
122
111
|
defineOptions({
|
|
123
112
|
name: 'LcbUserTop',
|
|
@@ -127,13 +116,16 @@ defineOptions({
|
|
|
127
116
|
styleIsolation: 'shared',
|
|
128
117
|
},
|
|
129
118
|
})
|
|
119
|
+
const pageInfo = inject(PAGE_PROVIDE_KEY)
|
|
120
|
+
const photoUrl = ''
|
|
121
|
+
const editBtn = ''
|
|
130
122
|
withDefaults(defineProps<LcbUserTopProps>(), {
|
|
131
123
|
photoSize: 100,
|
|
132
124
|
paddingLeft: 35,
|
|
133
125
|
paddingRight: 35,
|
|
134
126
|
paddingTop: 100,
|
|
135
127
|
paddingBottom: 100,
|
|
136
|
-
photoRound:
|
|
128
|
+
photoRound: true,
|
|
137
129
|
textSize: 32,
|
|
138
130
|
textColor: '#333',
|
|
139
131
|
moreIcon: true,
|
|
@@ -141,17 +133,27 @@ withDefaults(defineProps<LcbUserTopProps>(), {
|
|
|
141
133
|
iconName: 'xiayiye',
|
|
142
134
|
editText: '编辑资料',
|
|
143
135
|
editSize: 28,
|
|
136
|
+
rightIconSize: 28,
|
|
144
137
|
bgStyle: 1,
|
|
145
138
|
})
|
|
146
139
|
const padTop = computed(() => {
|
|
147
140
|
return addUnit(statusBarHeight || 0)
|
|
148
141
|
})
|
|
142
|
+
const getPhone = async (e) => {
|
|
143
|
+
uni.login({
|
|
144
|
+
provider: 'weixin',
|
|
145
|
+
success: async (res) => {
|
|
146
|
+
await getPhone({
|
|
147
|
+
code: res.code,
|
|
148
|
+
encryptedData: e.detail.encryptedData,
|
|
149
|
+
iv: e.detail.iv,
|
|
150
|
+
})
|
|
151
|
+
},
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
getUserInfo()
|
|
149
155
|
</script>
|
|
150
156
|
<style lang="scss" scoped>
|
|
151
|
-
// .optName {
|
|
152
|
-
// opacity: 0.7;
|
|
153
|
-
// }
|
|
154
|
-
|
|
155
157
|
.userPlace {
|
|
156
158
|
background-image: url('https://lycs.eluying.com/material/icon/1/20240925185540/userPhoto.jpg');
|
|
157
159
|
background-size: contain;
|
|
@@ -1,52 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { LcbBlockProps } from '
|
|
1
|
+
import { LcbActionViewProps } from '../lcb-action-view/types'
|
|
2
|
+
import { LcbBlockProps } from '../lcb-block/types'
|
|
3
3
|
|
|
4
4
|
export interface LcbUserTopProps extends LcbBlockProps {
|
|
5
|
-
// // items?: Partial<ActionView>[]
|
|
6
|
-
// // imageWidth?: number
|
|
7
|
-
// autoplay?: boolean
|
|
8
|
-
// /** 滚动方向 默认 horizontal */
|
|
9
|
-
// direction?: 'horizontal' | 'vertical'
|
|
10
|
-
// /** 同时显示的滑块数量 默认 1 */
|
|
11
|
-
// displayMultipleItems?: number
|
|
12
|
-
// /** 滑动时长 300ms */
|
|
13
|
-
// duration?: number
|
|
14
|
-
// /** 轮播图高度 默认192 */
|
|
15
|
-
// height?: number
|
|
16
|
-
// /** 轮播间隔时间 5000ms */
|
|
17
|
-
// interval?: number
|
|
18
|
-
// /** 是否循环播放 默认 true */
|
|
19
|
-
// loop?: boolean
|
|
20
|
-
// /** 后边间距 */
|
|
21
|
-
// nextMargin?: number
|
|
22
|
-
// /** 前边间距 */
|
|
23
|
-
// previousMargin?: number
|
|
24
|
-
// /** 指示器位置 bottom */
|
|
25
|
-
// indicatorPosition?:
|
|
26
|
-
// | 'left'
|
|
27
|
-
// | 'top-left'
|
|
28
|
-
// | 'top'
|
|
29
|
-
// | 'top-right'
|
|
30
|
-
// | 'bottom-left'
|
|
31
|
-
// | 'bottom'
|
|
32
|
-
// | 'bottom-right'
|
|
33
|
-
// | 'right'
|
|
34
|
-
// /** 边距是否应用到第一个、最后一个元素 */
|
|
35
|
-
// snapToEdge?: boolean
|
|
36
|
-
// // 图片之间距离
|
|
37
|
-
// itemPadding?: number
|
|
38
|
-
// /** 图片圆角 */
|
|
39
|
-
// imageRadius?: number
|
|
40
|
-
// // 整个banner圆角
|
|
41
|
-
// radius?: number
|
|
42
|
-
// customPrevImageClass?: string
|
|
43
|
-
// customNextImageClass?: string
|
|
44
|
-
// indicator?: 'dots' | 'dots-bar' | 'fraction'
|
|
45
|
-
// /** 滑动样式 1平面 2立体 */
|
|
46
|
-
// slidingStyle?: 1 | 2
|
|
47
|
-
|
|
48
5
|
// paddingRight?: number
|
|
49
|
-
photoUrl?: string
|
|
50
6
|
photoRound?: boolean
|
|
51
7
|
photoSize?: number
|
|
52
8
|
textSize?: number
|
|
@@ -58,7 +14,6 @@ export interface LcbUserTopProps extends LcbBlockProps {
|
|
|
58
14
|
iconName?: string
|
|
59
15
|
iconUpload?: string
|
|
60
16
|
iconType?: 0 | 1
|
|
61
|
-
editBtn?: boolean
|
|
62
17
|
editText?: string
|
|
63
18
|
editBorder?: boolean
|
|
64
19
|
editSize?: number
|
|
@@ -72,6 +27,8 @@ export interface LcbUserTopProps extends LcbBlockProps {
|
|
|
72
27
|
titleColor?: string
|
|
73
28
|
numsMarginTop?: number
|
|
74
29
|
numsPadLR?: number
|
|
30
|
+
rightIconSize?: number
|
|
31
|
+
rightIconLink?: LcbActionViewProps
|
|
75
32
|
}
|
|
76
33
|
|
|
77
34
|
export interface NumsItemProps {
|
package/constants.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface OssUploadResponse {
|
|
2
|
+
fileUrl: string
|
|
3
|
+
ossType: string
|
|
4
|
+
uploadHeaders: UploadHeaders
|
|
5
|
+
uploadUrl: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface UploadHeaders {
|
|
9
|
+
Date: string
|
|
10
|
+
}
|
|
11
|
+
/** 商城文件 */
|
|
12
|
+
export const uploadByUrl = async (fileName: string) => {
|
|
13
|
+
const { data } = await uni.$lcb.http.post<OssUploadResponse>('/ossUpload/uploadByUrl', {
|
|
14
|
+
fileName,
|
|
15
|
+
})
|
|
16
|
+
return data
|
|
17
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Ref, ref } from 'vue'
|
|
2
|
+
import { uploadByUrl } from './useUpload.api'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* useUpload 是一个定制化的请求钩子,用于处理上传图片。
|
|
6
|
+
* @param formData 额外传递给后台的数据,如{name: '菲鸽'}。
|
|
7
|
+
* @returns 返回一个对象{loading, data, run},包含请求的加载状态、错误信息、响应数据和手动触发请求的函数。
|
|
8
|
+
*/
|
|
9
|
+
export default function useUpload(onSuccess?: (url: string) => void) {
|
|
10
|
+
const data = ref<string>('')
|
|
11
|
+
const run = () => {
|
|
12
|
+
// #ifdef MP-WEIXIN
|
|
13
|
+
uni.chooseMedia({
|
|
14
|
+
count: 1,
|
|
15
|
+
mediaType: ['image'],
|
|
16
|
+
success: (res) => {
|
|
17
|
+
const filePath = res.tempFiles[0].tempFilePath
|
|
18
|
+
const name = filePath.split('/').pop() || ''
|
|
19
|
+
uploadFile({ filePath, data, name, onSuccess })
|
|
20
|
+
},
|
|
21
|
+
fail: (err) => {
|
|
22
|
+
console.error('uni.chooseMedia err->', err)
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
// #endif
|
|
26
|
+
// #ifndef MP-WEIXIN
|
|
27
|
+
uni.chooseImage({
|
|
28
|
+
count: 1,
|
|
29
|
+
success: (res) => {
|
|
30
|
+
const name = res.tempFiles[0].name
|
|
31
|
+
const file = res.tempFiles[0]
|
|
32
|
+
uploadFile({ data, name, file, onSuccess })
|
|
33
|
+
},
|
|
34
|
+
fail: (err) => {
|
|
35
|
+
console.error('uni.chooseImage err->', err)
|
|
36
|
+
},
|
|
37
|
+
})
|
|
38
|
+
// #endif
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return { data, run }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function uploadFile({
|
|
45
|
+
filePath,
|
|
46
|
+
file,
|
|
47
|
+
data,
|
|
48
|
+
name,
|
|
49
|
+
onSuccess,
|
|
50
|
+
}: {
|
|
51
|
+
filePath?: string
|
|
52
|
+
file?: File
|
|
53
|
+
data?: Ref<string>
|
|
54
|
+
name: string
|
|
55
|
+
onSuccess?: (url: string) => void
|
|
56
|
+
}) {
|
|
57
|
+
const pageRoute = getCurrentPages().at(-1)?.route || ''
|
|
58
|
+
uni.$lcb.loadingStore?.().changeLoading(pageRoute, true)
|
|
59
|
+
const { uploadUrl, ossType, fileUrl } = await uploadByUrl(`${new Date().getTime()}_${name}`)
|
|
60
|
+
const fun = (fileData) => {
|
|
61
|
+
uni.request({
|
|
62
|
+
url: uploadUrl,
|
|
63
|
+
method: 'PUT',
|
|
64
|
+
data: fileData,
|
|
65
|
+
header:
|
|
66
|
+
ossType === 'tyyun'
|
|
67
|
+
? {
|
|
68
|
+
'x-amz-acl': 'public-read',
|
|
69
|
+
'Content-Type': 'image',
|
|
70
|
+
}
|
|
71
|
+
: {
|
|
72
|
+
'Content-Type': ' ',
|
|
73
|
+
},
|
|
74
|
+
success: () => {
|
|
75
|
+
onSuccess?.(fileUrl)
|
|
76
|
+
if (data) data.value = fileUrl
|
|
77
|
+
uni.$lcb.loadingStore?.().changeLoading(pageRoute, false)
|
|
78
|
+
},
|
|
79
|
+
fail: () => {
|
|
80
|
+
uni.showToast({
|
|
81
|
+
title: '上传失败',
|
|
82
|
+
icon: 'none',
|
|
83
|
+
})
|
|
84
|
+
uni.$lcb.loadingStore?.().changeLoading(pageRoute, false)
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
// #ifdef H5
|
|
89
|
+
fun(file)
|
|
90
|
+
// #endif
|
|
91
|
+
|
|
92
|
+
// #ifndef H5
|
|
93
|
+
if (filePath) {
|
|
94
|
+
const fs = uni.getFileSystemManager()
|
|
95
|
+
fs.readFile({
|
|
96
|
+
filePath,
|
|
97
|
+
success: (fileRes) => {
|
|
98
|
+
fun(fileRes.data)
|
|
99
|
+
},
|
|
100
|
+
fail: () => {
|
|
101
|
+
uni.showToast({
|
|
102
|
+
title: '上传失败',
|
|
103
|
+
icon: 'none',
|
|
104
|
+
})
|
|
105
|
+
uni.$lcb.loadingStore?.().changeLoading(pageRoute, false)
|
|
106
|
+
},
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// #endif
|
|
111
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tplc/business",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.47",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"业务组件"
|
|
6
6
|
],
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"vue": ">=3.2.47",
|
|
14
|
-
"@tplc/wot": "0.1.
|
|
14
|
+
"@tplc/wot": "0.1.20"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
17
|
"node": ">=18",
|
|
@@ -10,10 +10,30 @@ declare const __VLS_component: import('vue').DefineComponent<
|
|
|
10
10
|
{},
|
|
11
11
|
import('vue').ComponentOptionsMixin,
|
|
12
12
|
import('vue').ComponentOptionsMixin,
|
|
13
|
-
{
|
|
13
|
+
{
|
|
14
|
+
phone: (value: {
|
|
15
|
+
detail: {
|
|
16
|
+
errMsg: string
|
|
17
|
+
encryptedData: string
|
|
18
|
+
iv: string
|
|
19
|
+
}
|
|
20
|
+
}) => void
|
|
21
|
+
avatar: (value: string) => void
|
|
22
|
+
},
|
|
14
23
|
string,
|
|
15
24
|
import('vue').PublicProps,
|
|
16
|
-
Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToOption<LcbActionViewProps
|
|
25
|
+
Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToOption<LcbActionViewProps>>> & {
|
|
26
|
+
onPhone?:
|
|
27
|
+
| ((value: {
|
|
28
|
+
detail: {
|
|
29
|
+
errMsg: string
|
|
30
|
+
encryptedData: string
|
|
31
|
+
iv: string
|
|
32
|
+
}
|
|
33
|
+
}) => any)
|
|
34
|
+
| undefined
|
|
35
|
+
onAvatar?: ((value: string) => any) | undefined
|
|
36
|
+
},
|
|
17
37
|
{},
|
|
18
38
|
{}
|
|
19
39
|
>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { LcbFilterListProps } from './type'
|
|
2
|
-
declare
|
|
2
|
+
declare function __VLS_template(): {
|
|
3
|
+
default?(_: { items: any[] }): any
|
|
4
|
+
}
|
|
5
|
+
declare const __VLS_component: import('vue').DefineComponent<
|
|
3
6
|
__VLS_TypePropsToOption<LcbFilterListProps>,
|
|
4
7
|
{},
|
|
5
8
|
unknown,
|
|
@@ -14,7 +17,16 @@ declare const _default: import('vue').DefineComponent<
|
|
|
14
17
|
{},
|
|
15
18
|
{}
|
|
16
19
|
>
|
|
20
|
+
declare const _default: __VLS_WithTemplateSlots<
|
|
21
|
+
typeof __VLS_component,
|
|
22
|
+
ReturnType<typeof __VLS_template>
|
|
23
|
+
>
|
|
17
24
|
export default _default
|
|
25
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
26
|
+
new (): {
|
|
27
|
+
$slots: S
|
|
28
|
+
}
|
|
29
|
+
}
|
|
18
30
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T
|
|
19
31
|
type __VLS_TypePropsToOption<T> = {
|
|
20
32
|
[K in keyof T]-?: {} extends Pick<T, K>
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import { LcbListProps } from './types'
|
|
2
2
|
import './index.scss'
|
|
3
|
-
declare
|
|
3
|
+
declare function __VLS_template(): Partial<
|
|
4
|
+
Record<
|
|
5
|
+
NonNullable<
|
|
6
|
+
| 'image'
|
|
7
|
+
| 'title'
|
|
8
|
+
| 'location'
|
|
9
|
+
| 'subTitle'
|
|
10
|
+
| 'price'
|
|
11
|
+
| 'priceUnit'
|
|
12
|
+
| 'priceSuffix'
|
|
13
|
+
| 'originPrice'
|
|
14
|
+
| 'originPriceUnit'
|
|
15
|
+
| 'tags'
|
|
16
|
+
| 'distance'
|
|
17
|
+
>,
|
|
18
|
+
(_: any) => any
|
|
19
|
+
>
|
|
20
|
+
> & {
|
|
21
|
+
list?(_: { items: any[] }): any
|
|
22
|
+
item?(_: any): any
|
|
23
|
+
}
|
|
24
|
+
declare const __VLS_component: import('vue').DefineComponent<
|
|
4
25
|
__VLS_WithDefaults<__VLS_TypePropsToOption<LcbListProps>, any>,
|
|
5
26
|
{},
|
|
6
27
|
unknown,
|
|
@@ -23,6 +44,10 @@ declare const _default: import('vue').DefineComponent<
|
|
|
23
44
|
},
|
|
24
45
|
{}
|
|
25
46
|
>
|
|
47
|
+
declare const _default: __VLS_WithTemplateSlots<
|
|
48
|
+
typeof __VLS_component,
|
|
49
|
+
ReturnType<typeof __VLS_template>
|
|
50
|
+
>
|
|
26
51
|
export default _default
|
|
27
52
|
type __VLS_WithDefaults<P, D> = {
|
|
28
53
|
[K in keyof Pick<P, keyof P>]: K extends keyof D
|
|
@@ -36,6 +61,11 @@ type __VLS_WithDefaults<P, D> = {
|
|
|
36
61
|
type __VLS_Prettify<T> = {
|
|
37
62
|
[K in keyof T]: T[K]
|
|
38
63
|
} & {}
|
|
64
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
65
|
+
new (): {
|
|
66
|
+
$slots: S
|
|
67
|
+
}
|
|
68
|
+
}
|
|
39
69
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T
|
|
40
70
|
type __VLS_TypePropsToOption<T> = {
|
|
41
71
|
[K in keyof T]-?: {} extends Pick<T, K>
|