@tplc/business 0.1.1 → 0.1.3

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/action.d.ts CHANGED
@@ -25,12 +25,16 @@ export interface LcbGlobal {
25
25
  post<T>(
26
26
  url: string,
27
27
  data?: Record<string, any> | undefined,
28
- query?: Record<string, any> | undefined,
28
+ hideLoadingToast?: boolean,
29
29
  ): Promise<IResData<T>>
30
30
  }
31
31
  loadingStore?: () => {
32
32
  changeLoading: (path: string, loading: boolean) => void
33
33
  }
34
+ userStore?: () => {
35
+ userInfo: Record<string, any>
36
+ updateUser: (data: Record<string, any>) => void
37
+ }
34
38
  }
35
39
 
36
40
  global {
@@ -2,9 +2,9 @@ export interface LcbActionViewProps {
2
2
  /**
3
3
  * 跳转类型 1: 网页 2: 小程序内页 10: 跳转小程序 11: 跳转半屏小程序 12: 小程序客服
4
4
  * 13: 退出登录 14: 小程序弹框 21: 新窗口跳到页面 22: 切换TAB页 23: 重启进入某页面
5
- * 24: 回到上一层 25: 关闭当前页面 26: 关闭当前窗口 30: 拨打电话 88: 授权手机号
5
+ * 24: 回到上一层 25: 关闭当前页面 26: 关闭当前窗口 30: 拨打电话 88: 授权手机号 101 用户头像
6
6
  */
7
- jumpType?: 1 | 2 | 10 | 11 | 12 | 13 | 14 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 88
7
+ jumpType?: 1 | 2 | 10 | 11 | 12 | 13 | 14 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 88 | 101
8
8
  /** 跳转路径 */
9
9
  jumpUrl?: string
10
10
  /** 小程序appid */
@@ -44,7 +44,7 @@
44
44
 
45
45
  <script setup lang="ts">
46
46
  import { LcbCitySelectProps } from '../../../lcb-city-select/types'
47
- import { ChildHotAddress, getHotAddress, HotAddress } from '../../../lcb-city-select/api'
47
+ import { ChildHotAddress, getHotAddress, HotAddress } from '../../api'
48
48
  import { computed, onMounted, ref, watch } from 'vue'
49
49
 
50
50
  defineOptions({
@@ -38,7 +38,7 @@
38
38
  </template>
39
39
 
40
40
  <script setup lang="ts">
41
- import { LcbAddress } from '../../../lcb-city-select/api'
41
+ import { LcbAddress } from '../../api'
42
42
  import { LcbCityListProps } from './types'
43
43
  import { ref } from 'vue'
44
44
 
@@ -1,4 +1,4 @@
1
- import { LcbAddress } from '../../../lcb-city-select/api'
1
+ import { LcbAddress } from '../../api'
2
2
 
3
3
  export interface LcbCityListProps {
4
4
  list: LcbAddress[]
@@ -71,7 +71,7 @@
71
71
  <FilterList v-bind="{ ...info.listInfo, listType, filter, ...attrs }">
72
72
  <template #default="{ items }">
73
73
  <slot name="list" :items="items">
74
- <lcb-product v-bind="{ ...attrs }" :listType="listType" :items="items">
74
+ <!-- <lcb-product v-bind="{ ...attrs }" :listType="listType" :items="items">
75
75
  <template #item="slotContext">
76
76
  <slot name="item" v-bind="slotContext" />
77
77
  </template>
@@ -82,7 +82,7 @@
82
82
  >
83
83
  <slot :name="slotName" v-bind="slotContext" />
84
84
  </template>
85
- </lcb-product>
85
+ </lcb-product> -->
86
86
  </slot>
87
87
  </template>
88
88
  </FilterList>
@@ -1,13 +1,23 @@
1
1
  <template>
2
2
  <View class="">
3
- <view class="font-bold leading-none" :style="{
4
- fontSize: transformValueUnit(numsSize),
5
- color: numsColor,
6
- }">0</view>
7
- <view class="mt-15rpx" :style="{
8
- fontSize: transformValueUnit(titleSize),
9
- color: titleColor,
10
- }">{{ title }}</view>
3
+ <view
4
+ class="font-bold leading-none"
5
+ :style="{
6
+ fontSize: transformValueUnit(numsSize),
7
+ color: numsColor,
8
+ }"
9
+ >
10
+ 0
11
+ </view>
12
+ <view
13
+ class="mt-15rpx"
14
+ :style="{
15
+ fontSize: transformValueUnit(titleSize),
16
+ color: titleColor,
17
+ }"
18
+ >
19
+ {{ title }}
20
+ </view>
11
21
  </View>
12
22
  </template>
13
23
 
@@ -16,5 +26,4 @@ import { NumsItemProps } from '../types'
16
26
  import { transformValueUnit } from '../../../utils/transform'
17
27
 
18
28
  defineProps<NumsItemProps>()
19
-
20
- </script>
29
+ </script>
@@ -1,13 +1,10 @@
1
- const env = import.meta as unknown as { env: Record<string, string> }
2
1
  export const getUserPhone = (data: { encryptedData: string; iv: string; code?: string }) =>
3
2
  uni.$lcb.http.post('/wechatProgram/api/getPhone', {
4
3
  ...data,
5
- appId: env.env.VITE_WX_APPID,
4
+ appId: (import.meta as any).env.VITE_WX_APPID,
6
5
  })
7
6
 
8
7
  export const saveUserInfo = (data: { nickName?: string; avatarUrl?: string }) =>
9
8
  uni.$lcb.http.post('/wechatProgram/saveUserInfo', data)
10
9
 
11
10
  // /api/login/getUserInfo
12
-
13
- export const getUserInfo = () => uni.$lcb.http.post('/login/getUserInfo')
@@ -13,27 +13,29 @@
13
13
  }"
14
14
  />
15
15
  <view class="flex flex-items-center">
16
- <wd-img
17
- v-if="photoUrl"
18
- v-bind="{
19
- width: transformValueUnit(photoSize),
20
- height: transformValueUnit(photoSize),
21
- round: photoRound,
22
- src: photoUrl,
23
- }"
24
- class="mr-20rpx"
25
- />
26
- <view
27
- v-if="!photoUrl"
28
- :style="{
29
- width: transformValueUnit(photoSize),
30
- height: transformValueUnit(photoSize),
31
- borderRadius: photoRound ? '50%' : '',
32
- }"
33
- class="bg-#eee userPlace mr-40rpx"
34
- />
16
+ <lcb-action-view :jump-type="101" @avatar="onAvatar">
17
+ <wd-img
18
+ v-if="userStore?.userInfo?.avatarUrl"
19
+ v-bind="{
20
+ width: transformValueUnit(photoSize),
21
+ height: transformValueUnit(photoSize),
22
+ round: photoRound,
23
+ src: userStore?.userInfo?.avatarUrl,
24
+ }"
25
+ class="mr-20rpx"
26
+ />
27
+ <view
28
+ v-if="!userStore?.userInfo?.avatarUrl"
29
+ :style="{
30
+ width: transformValueUnit(photoSize),
31
+ height: transformValueUnit(photoSize),
32
+ borderRadius: photoRound ? '50%' : '',
33
+ }"
34
+ class="bg-#eee userPlace mr-40rpx"
35
+ />
36
+ </lcb-action-view>
35
37
  <view class="flex-1">
36
- <lcb-action-view :jumpType="88" @phone="getPhone">
38
+ <lcb-action-view :jumpType="88" @phone="getPhone" v-if="!userStore?.userInfo?.phone">
37
39
  <view
38
40
  class="font-bold"
39
41
  :style="{
@@ -44,7 +46,7 @@
44
46
  授权登录
45
47
  </view>
46
48
  </lcb-action-view>
47
- <view class="flex" v-if="editBtn">
49
+ <view class="flex" v-else>
48
50
  <view
49
51
  class="flex flex-content-center flex-items-center mt-5px border-style-solid"
50
52
  :style="{
@@ -103,10 +105,9 @@
103
105
  import { LcbUserTopProps } from './types'
104
106
  import { transformValueUnit } from '../../utils/transform'
105
107
  import Nums from './Nums/index.vue'
106
- import { computed, inject } from 'vue'
108
+ import { computed } from 'vue'
107
109
  import { addUnit } from '@tplc/wot/components/common/util'
108
- import { PAGE_PROVIDE_KEY } from '../../constants'
109
- import { getUserInfo, getUserPhone } from './api'
110
+ import { getUserPhone } from './api'
110
111
  const { statusBarHeight } = uni.getSystemInfoSync()
111
112
  defineOptions({
112
113
  name: 'LcbUserTop',
@@ -116,9 +117,7 @@ defineOptions({
116
117
  styleIsolation: 'shared',
117
118
  },
118
119
  })
119
- const pageInfo = inject(PAGE_PROVIDE_KEY)
120
- const photoUrl = ''
121
- const editBtn = ''
120
+ const userStore = uni.$lcb.userStore?.()
122
121
  withDefaults(defineProps<LcbUserTopProps>(), {
123
122
  photoSize: 100,
124
123
  paddingLeft: 35,
@@ -140,9 +139,22 @@ const padTop = computed(() => {
140
139
  return addUnit(statusBarHeight || 0)
141
140
  })
142
141
  const getPhone = async (e) => {
143
- await getUserPhone(e.detail)
142
+ uni.login({
143
+ provider: 'weixin',
144
+ success: async (res) => {
145
+ const { code } = res
146
+ await getUserPhone({
147
+ ...e.detail,
148
+ code,
149
+ })
150
+ },
151
+ })
152
+ }
153
+ const onAvatar = (avatarUrl) => {
154
+ userStore?.updateUser({
155
+ avatarUrl,
156
+ })
144
157
  }
145
- getUserInfo()
146
158
  </script>
147
159
  <style lang="scss" scoped>
148
160
  .userPlace {
package/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { LcbGlobal } from 'action'
1
+ import { LcbGlobal } from './action'
2
2
 
3
3
  export const $lcb: LcbGlobal = {} as LcbGlobal
4
4
  uni.$lcb = $lcb
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tplc/business",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "keywords": [
5
5
  "业务组件"
6
6
  ],
@@ -2,9 +2,9 @@ export interface LcbActionViewProps {
2
2
  /**
3
3
  * 跳转类型 1: 网页 2: 小程序内页 10: 跳转小程序 11: 跳转半屏小程序 12: 小程序客服
4
4
  * 13: 退出登录 14: 小程序弹框 21: 新窗口跳到页面 22: 切换TAB页 23: 重启进入某页面
5
- * 24: 回到上一层 25: 关闭当前页面 26: 关闭当前窗口 30: 拨打电话 88: 授权手机号
5
+ * 24: 回到上一层 25: 关闭当前页面 26: 关闭当前窗口 30: 拨打电话 88: 授权手机号 101 用户头像
6
6
  */
7
- jumpType?: 1 | 2 | 10 | 11 | 12 | 13 | 14 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 88
7
+ jumpType?: 1 | 2 | 10 | 11 | 12 | 13 | 14 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 88 | 101
8
8
  /** 跳转路径 */
9
9
  jumpUrl?: string
10
10
  /** 小程序appid */
@@ -1,5 +1,5 @@
1
1
  import { LcbCitySelectProps } from '../../../lcb-city-select/types'
2
- import { ChildHotAddress } from '../../../lcb-city-select/api'
2
+ import { ChildHotAddress } from '../../api'
3
3
  declare let __VLS_typeProps: LcbCitySelectProps
4
4
  type __VLS_PublicProps = {
5
5
  modelValue?: ChildHotAddress
@@ -1,4 +1,4 @@
1
- import { LcbAddress } from '../../../lcb-city-select/api'
1
+ import { LcbAddress } from '../../api'
2
2
  export interface LcbCityListProps {
3
3
  list: LcbAddress[]
4
4
  keyword: string
@@ -1,25 +1,7 @@
1
1
  import { LcbListProps } from './types'
2
2
  import './index.scss'
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
- > & {
3
+ declare function __VLS_template(): {
21
4
  list?(_: { items: any[] }): any
22
- item?(_: any): any
23
5
  }
24
6
  declare const __VLS_component: import('vue').DefineComponent<
25
7
  __VLS_WithDefaults<__VLS_TypePropsToOption<LcbListProps>, any>,
@@ -1,4 +1,4 @@
1
- export declare const getPhone: (data: {
1
+ export declare const getUserPhone: (data: {
2
2
  encryptedData: string
3
3
  iv: string
4
4
  code?: string
@@ -7,4 +7,3 @@ export declare const saveUserInfo: (data: {
7
7
  nickName?: string
8
8
  avatarUrl?: string
9
9
  }) => Promise<import('../../../action').IResData<unknown>>
10
- export declare const getUserInfo: () => Promise<import('../../../action').IResData<unknown>>
@@ -1,67 +0,0 @@
1
- import { FilterTabsProps } from '../components/FilterTabs/type'
2
- import { Option } from '../types'
3
- export interface LcbListInfo {
4
- url: string
5
- baseParam: Record<string, unknown>
6
- }
7
- export interface LcbFilterResult {
8
- btnComponent: BtnComponent
9
- filterTags: FilterTags
10
- filterComponent: FilterComponent[]
11
- listInfo: LcbListInfo
12
- filterTabs?: {
13
- componentProps: FilterTabsProps
14
- valueName: string
15
- defaultValue?: string
16
- }
17
- }
18
-
19
- export interface FilterComponent {
20
- filterName?: string
21
- component: string
22
- defaultValue?: string
23
- defaultName?: string
24
- valueName: string
25
- componentProps: FilterComponentProps
26
- }
27
-
28
- interface FilterComponentProps {
29
- mode?: 'multiple' | 'single'
30
- apiPath?: string
31
- options?: Option[]
32
- componentList?: ComponentList[]
33
- }
34
-
35
- export interface ComponentList {
36
- filterName: string
37
- component: string
38
- valueName: string
39
- defaultValue?: string | string[] | number[]
40
- componentProps: FilterTagsProps
41
- }
42
-
43
- export interface FilterTags {
44
- component: string
45
- valueName: string
46
- defaultValue?: string
47
- defaultName?: string
48
- componentProps: FilterTagsProps
49
- }
50
-
51
- export interface FilterTagsProps {
52
- mode?: 'multiple' | 'single'
53
- max: number
54
- min: number
55
- apiPath: string
56
- options: Option[]
57
- unit?: string
58
- }
59
-
60
- interface BtnComponent {
61
- postRequest: string
62
- }
63
-
64
- export const getFilterDetail = (val: string) =>
65
- uni.$lcb.http.post<LcbFilterResult>('/pageDecoration/list/detail', {
66
- pageListType: val,
67
- })
@@ -1,60 +0,0 @@
1
- import { FilterTabsProps } from '../components/FilterTabs/type'
2
- import { Option } from '../types'
3
- export interface LcbListInfo {
4
- url: string
5
- baseParam: Record<string, unknown>
6
- }
7
- export interface LcbFilterResult {
8
- btnComponent: BtnComponent
9
- filterTags: FilterTags
10
- filterComponent: FilterComponent[]
11
- listInfo: LcbListInfo
12
- filterTabs?: {
13
- componentProps: FilterTabsProps
14
- valueName: string
15
- defaultValue?: string
16
- }
17
- }
18
- export interface FilterComponent {
19
- filterName?: string
20
- component: string
21
- defaultValue?: string
22
- defaultName?: string
23
- valueName: string
24
- componentProps: FilterComponentProps
25
- }
26
- interface FilterComponentProps {
27
- mode?: 'multiple' | 'single'
28
- apiPath?: string
29
- options?: Option[]
30
- componentList?: ComponentList[]
31
- }
32
- export interface ComponentList {
33
- filterName: string
34
- component: string
35
- valueName: string
36
- defaultValue?: string | string[] | number[]
37
- componentProps: FilterTagsProps
38
- }
39
- export interface FilterTags {
40
- component: string
41
- valueName: string
42
- defaultValue?: string
43
- defaultName?: string
44
- componentProps: FilterTagsProps
45
- }
46
- export interface FilterTagsProps {
47
- mode?: 'multiple' | 'single'
48
- max: number
49
- min: number
50
- apiPath: string
51
- options: Option[]
52
- unit?: string
53
- }
54
- interface BtnComponent {
55
- postRequest: string
56
- }
57
- export declare const getFilterDetail: (
58
- val: string,
59
- ) => Promise<import('../../../action').IResData<LcbFilterResult>>
60
- export {}