@tplc/business 0.1.2 → 0.1.4

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,17 @@ 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
+ getUser: () => void
38
+ }
34
39
  }
35
40
 
36
41
  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 */
@@ -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,5 @@
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
-
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')
@@ -13,27 +13,21 @@
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-bind="{
19
+ width: transformValueUnit(photoSize),
20
+ height: transformValueUnit(photoSize),
21
+ round: photoRound,
22
+ src:
23
+ userStore?.userInfo?.avatarUrl ||
24
+ 'https://lycs.eluying.com/material/icon/1/20240925185540/userPhoto.jpg',
25
+ }"
26
+ custom-class="mr-40rpx bg-#eee"
27
+ />
28
+ </lcb-action-view>
35
29
  <view class="flex-1">
36
- <lcb-action-view :jumpType="88" @phone="getPhone">
30
+ <lcb-action-view :jumpType="88" @phone="getPhone" v-if="!userStore?.userInfo?.phone">
37
31
  <view
38
32
  class="font-bold"
39
33
  :style="{
@@ -44,21 +38,26 @@
44
38
  授权登录
45
39
  </view>
46
40
  </lcb-action-view>
47
- <view class="flex" v-if="editBtn">
48
- <view
49
- class="flex flex-content-center flex-items-center mt-5px border-style-solid"
50
- :style="{
51
- color: textColor,
52
- borderWidth: editBorder ? transformValueUnit(1) : 0,
53
- borderColor: textColor,
54
- padding: editBorder ? `2px ${editSize / 2.5}px 2px ${editSize / 2.5}px` : '',
55
- borderRadius: transformValueUnit(30),
56
- fontSize: transformValueUnit(editSize),
57
- }"
58
- >
59
- <view>{{ editText }}</view>
41
+ <template v-else>
42
+ <view class="text-32rpx font-#333 font-bold mb-20rpx">
43
+ {{ userStore?.userInfo?.nickName || '微信用户' }}
60
44
  </view>
61
- </view>
45
+ <view class="flex">
46
+ <view
47
+ class="flex flex-content-center flex-items-center mt-5px border-style-solid"
48
+ :style="{
49
+ color: textColor,
50
+ borderWidth: editBorder ? transformValueUnit(1) : 0,
51
+ borderColor: textColor,
52
+ padding: editBorder ? `2px ${editSize / 2.5}px 2px ${editSize / 2.5}px` : '',
53
+ borderRadius: transformValueUnit(30),
54
+ fontSize: transformValueUnit(editSize),
55
+ }"
56
+ >
57
+ <view>{{ editText }}</view>
58
+ </view>
59
+ </view>
60
+ </template>
62
61
  </view>
63
62
  <!-- 右边按钮 -->
64
63
  <lcb-action-view v-if="moreIcon" v-bind="rightIconLink">
@@ -103,10 +102,9 @@
103
102
  import { LcbUserTopProps } from './types'
104
103
  import { transformValueUnit } from '../../utils/transform'
105
104
  import Nums from './Nums/index.vue'
106
- import { computed, inject } from 'vue'
105
+ import { computed } from 'vue'
107
106
  import { addUnit } from '@tplc/wot/components/common/util'
108
- import { PAGE_PROVIDE_KEY } from '../../constants'
109
- import { getUserInfo, getUserPhone } from './api'
107
+ import { getUserPhone } from './api'
110
108
  const { statusBarHeight } = uni.getSystemInfoSync()
111
109
  defineOptions({
112
110
  name: 'LcbUserTop',
@@ -116,9 +114,7 @@ defineOptions({
116
114
  styleIsolation: 'shared',
117
115
  },
118
116
  })
119
- const pageInfo = inject(PAGE_PROVIDE_KEY)
120
- const photoUrl = ''
121
- const editBtn = ''
117
+ const userStore = uni.$lcb.userStore?.()
122
118
  withDefaults(defineProps<LcbUserTopProps>(), {
123
119
  photoSize: 100,
124
120
  paddingLeft: 35,
@@ -140,9 +136,22 @@ const padTop = computed(() => {
140
136
  return addUnit(statusBarHeight || 0)
141
137
  })
142
138
  const getPhone = async (e) => {
143
- await getUserPhone(e.detail)
139
+ uni.login({
140
+ provider: 'weixin',
141
+ success: async (res) => {
142
+ const { code } = res
143
+ await getUserPhone({
144
+ ...e.detail,
145
+ code,
146
+ })
147
+ },
148
+ })
149
+ }
150
+ const onAvatar = (avatarUrl) => {
151
+ userStore?.updateUser({
152
+ avatarUrl,
153
+ })
144
154
  }
145
- getUserInfo()
146
155
  </script>
147
156
  <style lang="scss" scoped>
148
157
  .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.2",
3
+ "version": "0.1.4",
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 */
@@ -3,8 +3,3 @@ export declare const getUserPhone: (data: {
3
3
  iv: string
4
4
  code?: string
5
5
  }) => Promise<import('../../../action').IResData<unknown>>
6
- export declare const saveUserInfo: (data: {
7
- nickName?: string
8
- avatarUrl?: string
9
- }) => Promise<import('../../../action').IResData<unknown>>
10
- export declare const getUserInfo: () => Promise<import('../../../action').IResData<unknown>>