@tplc/business 0.1.2 → 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 */
@@ -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.2",
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 */
@@ -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>>