4.2.47 • Published 1 month ago

@uxda/appkit v4.2.47

Weekly downloads
-
License
-
Repository
-
Last release
1 month ago

AppKit

小程序应用开发包

向诸小程序提供供用的组件及基础设施

模块:

  • payment 支付
  • balance 账户、代币(云豆)余额
  • auth 登录及会话状态 (待定)

将 AppKit 加入应用项目

git clone git@10.1.108.137:fed/appkit.git
cd appkit
yarn link

然后 cd 到(周转)小程序根目录执行:

yarn link @uxda/appkit

完成 npm link

用法

import AppKit from '@uxda/appkit'
import '@uxda/appkit/appkit.css'

AppKit 初始化

在应用入口页调用(示例)

const App = createApp({})
App.use(AppKit, {
  app: () => 'cloudkitPro',
  tenant: () => '1',
  token: () => localStorage.getItem('token'),
  baseUrl: () => process.env.TARO_APP_BASE_URL,
  401: () => {
    // 登录态丢失时的处理
  }
})

为 AppKit 的运行提供必需的 API 参数

  • app: 当前的 app code (嵌入接口调用的 header 参数)
  • tenant: 租户ID 需要提供以便调用接口
  • token: 用户登录态 token
  • baseUrl: 调用 API 的URL域名
  • 401: 登录态丢失异常处理 (通常要跳转登录页)

UI组件

1️⃣ 充值用户界面 <recharge-view>

import { RechargeView } from '@uxda/appkit'
<template>
  <recharge-view
    app="crm"
    tenant="1"
    @complete="onRechargeComplete" />
</template>

属性 props

事件 emits

  • @complete: 充值完成时发生

2️⃣ 账户页 <account-view>

import { AccountView } from '@uxda/appkit'
<template>
  <account-view app="crm" @recharge=onAccountViewRecharge />
<template>

事件 emits

  • @recharge 点击充值按钮时发生

3️⃣ 账户卡片 <balance-card>

import { BalanceCard } from '@uxda/appkit'
<template>
  <balance-card app="crm" @drill="onBalanceCardDrill" @recharge="onBalanceCardRecharge" />
<template>

事件 emits

  • app 配置到组件上的 app code
  • @drill 点击账户详情时发生
  • @recharge 点击充值按钮时发生

场景端需定义以上跳转逻辑:

function onBalanceCardDrill () {
  //...
}

function onBalanceCardRecharge () {
  //...
}

方法 methods

  • reload() 刷新数据

4️⃣ 余额不足提示框 <balance-reminder>

import { BalanceReminder } from '@uxda/appkit'
<balance-reminder v-model="balanceReminderOpen" 
  @recharge="onBalanceReminderRecharge" />

事件 emits

  • @recharge 点击充值按钮时发生

公共API

1️⃣ 唤起充值(跳支付中心小程序) $app.invokeRecharge()

import { useAppKit } from '@uxda/appkit'
const $app = useAppKit()
$app.invokeRecharge({
  app: 'crm',
  tenant: '1',
})

2️⃣ 唤起充值(小程序内直接支付、不跳) $app.requestPayment()

import { useAppKit } from '@uxda/appkit'
const $app = useAppKit()
$app.requestPayment({
  app: 'crm',
  tenant: '1',
  amount: 100,
  user: '' // wx.login 之后得到的用户临时凭证
})

Hooks (Vue Composables)

useTabbar

用于获取或设置 custom tab bar

import { useTabbar } from '@uxda/appkit-next'

onMounted(() => {
  const { setTab } = useTabbar()
  setTab('home')
})

以上代码用于切换到 /pages/home/index 时, 设置 tab bar 选中项为 'home' 在 custom-tab-bar/index.vue 需要做以下设置

import { useSafeArea, useTabbar } from '@uxda/appkit-next'

const { onTabChange } = useTabbar()
onTabChange((value: string) => {
  selected.value = value
})

以上代码设置响应页面内的 setTab() 动作

4.2.42

1 month ago

4.2.44

1 month ago

4.2.40

1 month ago

4.2.46

1 month ago

4.2.47

1 month ago

4.2.34

1 month ago

4.2.36

1 month ago

4.2.38

1 month ago

4.2.28

2 months ago

4.2.26

2 months ago

4.2.32

2 months ago

4.2.30

2 months ago

3.2.20

2 months ago

4.2.20

2 months ago

4.2.22

2 months ago

4.2.24

2 months ago

4.2.18

2 months ago

4.2.12

2 months ago

4.2.14

2 months ago

4.2.16

2 months ago

4.2.10

2 months ago

4.2.2

2 months ago

4.2.4

2 months ago

4.2.0

2 months ago

4.2.6

2 months ago

4.2.8

2 months ago

4.1.56

2 months ago

4.1.60

2 months ago

4.1.62

2 months ago

4.1.52

3 months ago

4.1.54

3 months ago

4.1.50

4 months ago

4.1.42

4 months ago

4.1.44

4 months ago

4.1.46

4 months ago

4.1.48

4 months ago

4.1.29

4 months ago

4.1.40

4 months ago

4.1.28

4 months ago

4.1.21

4 months ago

4.1.23

4 months ago

4.1.25

4 months ago

4.1.26

4 months ago

4.1.19

4 months ago

4.1.22

4 months ago

4.1.24

4 months ago

4.1.8

6 months ago

4.1.20

5 months ago

4.0.16

6 months ago

4.0.18

6 months ago

4.0.14

6 months ago

4.1.10

6 months ago

4.1.16

5 months ago

4.1.12

6 months ago

4.1.4

6 months ago

4.1.6

6 months ago

4.1.0

6 months ago

4.1.2

6 months ago

4.0.6

6 months ago

4.0.8

6 months ago

4.0.10

6 months ago

4.0.12

6 months ago

1.2.80

6 months ago

4.0.3

7 months ago

4.0.2

7 months ago

1.2.75

7 months ago

1.2.78

7 months ago

1.2.76

7 months ago

1.2.77

7 months ago

4.0.0

7 months ago

1.2.42

8 months ago

1.2.40

8 months ago

1.2.46

8 months ago

1.2.44

8 months ago

1.2.48

8 months ago

1.2.52

8 months ago

1.2.50

8 months ago

1.2.56

8 months ago

1.2.57

8 months ago

1.2.54

8 months ago

1.2.58

8 months ago

1.2.59

8 months ago

1.2.60

8 months ago

1.2.63

8 months ago

1.2.64

8 months ago

1.2.61

8 months ago

1.2.62

8 months ago

1.2.68

8 months ago

1.2.65

8 months ago

1.2.66

8 months ago

1.2.69

8 months ago

1.2.70

8 months ago

1.2.71

8 months ago

1.2.72

8 months ago

1.2.73

7 months ago

1.2.38

8 months ago

1.2.34

9 months ago

1.2.32

9 months ago

1.2.36

9 months ago

1.2.16

9 months ago

1.2.14

9 months ago

1.2.18

9 months ago

1.2.20

9 months ago

1.2.24

9 months ago

1.2.22

9 months ago

1.2.28

9 months ago

1.2.26

9 months ago

1.2.30

9 months ago

1.2.12

9 months ago

1.2.10

9 months ago

1.2.8

11 months ago

1.2.6

11 months ago

1.2.4

11 months ago

1.2.2

11 months ago

1.2.0

11 months ago

1.1.0

1 year ago

1.1.2

1 year ago

1.0.76

1 year ago

1.0.72

1 year ago

1.0.70

1 year ago

1.0.74

1 year ago

1.0.66

1 year ago

1.0.64

1 year ago

1.0.62

1 year ago

1.0.60

1 year ago

1.0.54

1 year ago

1.0.58

1 year ago

1.0.56

1 year ago

1.0.50

1 year ago

1.0.52

1 year ago

1.0.48

1 year ago

1.0.46

1 year ago

1.0.42

1 year ago

1.0.40

1 year ago

1.0.38

1 year ago

1.0.32

1 year ago

1.0.30

1 year ago

1.0.36

1 year ago

1.0.28

1 year ago

1.0.18

1 year ago

1.0.16

1 year ago

1.0.22

1 year ago

1.0.20

1 year ago

1.0.26

1 year ago

1.0.24

1 year ago

1.0.14

1 year ago

1.0.12

1 year ago

1.0.10

1 year ago

1.0.8

1 year ago

1.0.6

1 year ago

1.0.4

1 year ago

1.0.2

1 year ago

1.0.0

1 year ago