@uxda/appkit 1.0.0
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/.eslintrc.mjs +8 -0
- package/README.md +147 -0
- package/babel.config.js +12 -0
- package/dist/appkit.css +3 -0
- package/dist/index.js +1755 -0
- package/dist/styles.css +1 -0
- package/package.json +73 -0
- package/project.config.json +15 -0
- package/project.tt.json +13 -0
- package/rollup.config.js +55 -0
- package/src/Appkit.ts +41 -0
- package/src/balance/api/endpoints.ts +108 -0
- package/src/balance/api/index.ts +25 -0
- package/src/balance/components/AccountView.vue +519 -0
- package/src/balance/components/BalanceCard.vue +181 -0
- package/src/balance/components/BalanceReminder.vue +82 -0
- package/src/balance/components/ConsumptionFilter.vue +176 -0
- package/src/balance/components/ConsumptionRules.vue +70 -0
- package/src/balance/components/DateFilter.vue +219 -0
- package/src/balance/components/index.ts +9 -0
- package/src/balance/index.ts +1 -0
- package/src/balance/types.ts +92 -0
- package/src/global.ts +7 -0
- package/src/index.ts +51 -0
- package/src/main.scss +1 -0
- package/src/payment/README.md +0 -0
- package/src/payment/api/config.ts +8 -0
- package/src/payment/api/endpoints.ts +75 -0
- package/src/payment/api/index.ts +25 -0
- package/src/payment/components/AmountPicker.vue +109 -0
- package/src/payment/components/RechargeView.vue +146 -0
- package/src/payment/components/UserAgreement.vue +111 -0
- package/src/payment/components/index.ts +16 -0
- package/src/payment/consts.ts +1 -0
- package/src/payment/index.ts +1 -0
- package/src/payment/services/index.ts +17 -0
- package/src/payment/services/invoke-recharge.ts +25 -0
- package/src/payment/services/request-payment.ts +32 -0
- package/src/payment/types.ts +24 -0
- package/src/shared/components/AppDrawer.vue +53 -0
- package/src/shared/components/PageHeader.vue +75 -0
- package/src/shared/components/index.ts +7 -0
- package/src/shared/http/Http.ts +124 -0
- package/src/shared/http/index.ts +2 -0
- package/src/shared/http/types.ts +100 -0
- package/src/shared/index.ts +3 -0
- package/src/shared/weixin/index.ts +1 -0
- package/src/shared/weixin/payment.ts +37 -0
- package/src/styles/vars.scss +4 -0
- package/tsconfig.json +30 -0
- package/types/global.d.ts +22 -0
- package/types/vue.d.ts +10 -0
package/.eslintrc.mjs
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# AppKit
|
|
2
|
+
|
|
3
|
+
小程序应用开发包
|
|
4
|
+
|
|
5
|
+
向诸小程序提供供用的组件及基础设施
|
|
6
|
+
|
|
7
|
+
模块:
|
|
8
|
+
* payment 支付
|
|
9
|
+
* balance 账户、代币(云豆)余额
|
|
10
|
+
* auth 登录及会话状态 (待定)
|
|
11
|
+
|
|
12
|
+
## 将 AppKit 加入应用项目
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
git clone git@10.1.108.137:fed/appkit.git
|
|
16
|
+
cd appkit
|
|
17
|
+
yarn link
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
然后 cd 到(周转)小程序根目录执行:
|
|
21
|
+
```bash
|
|
22
|
+
yarn link @uxda/appkit
|
|
23
|
+
```
|
|
24
|
+
完成 npm link
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## 用法
|
|
28
|
+
```typescript
|
|
29
|
+
import AppKit from '@uxda/appkit'
|
|
30
|
+
```
|
|
31
|
+
## AppKit 初始化
|
|
32
|
+
|
|
33
|
+
在应用入口页调用(示例)
|
|
34
|
+
```typescript
|
|
35
|
+
const App = createApp({})
|
|
36
|
+
App.use(AppKit, {
|
|
37
|
+
token: () => localStorage.getItem('token'),
|
|
38
|
+
baseUrl: () => process.env.TARO_APP_BASE_URL,
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
为 AppKit 的运行提供必需的 API 参数
|
|
42
|
+
* token: 用户登录态 token
|
|
43
|
+
* baseUrl: 调用 API 的URL域名
|
|
44
|
+
|
|
45
|
+
## UI组件
|
|
46
|
+
### 1️⃣ 充值用户界面 <recharge-view>
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { RechargeView } from '@uxda/appkit'
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<template>
|
|
54
|
+
<recharge-view
|
|
55
|
+
app="crm"
|
|
56
|
+
tenant="1"
|
|
57
|
+
@complete="onRechargeComplete" />
|
|
58
|
+
</template>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### 属性 props
|
|
62
|
+
|
|
63
|
+
#### 事件 emits
|
|
64
|
+
|
|
65
|
+
* @complete: 充值完成时发生
|
|
66
|
+
|
|
67
|
+
### 2️⃣ 账户页 <account-view>
|
|
68
|
+
```
|
|
69
|
+
import { AccountView } from '@uxda/appkit'
|
|
70
|
+
```
|
|
71
|
+
```html
|
|
72
|
+
<template>
|
|
73
|
+
<account-view @recharge=onAccountViewRecharge />
|
|
74
|
+
<template>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### 事件 emits
|
|
78
|
+
* @recharge 点击充值按钮时发生
|
|
79
|
+
|
|
80
|
+
### 3️⃣ 账户卡片 <balance-card>
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { BalanceCard } from '@uxda/appkit'
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```html
|
|
87
|
+
<template>
|
|
88
|
+
<balance-card @dirll="onBalanceCardDrill" @recharge="onBalanceCardRecharge" />
|
|
89
|
+
<template>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### 事件 emits
|
|
93
|
+
* @drill 点击账户详情时发生
|
|
94
|
+
* @recharge 点击充值按钮时发生
|
|
95
|
+
|
|
96
|
+
场景端需定义以上跳转逻辑:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
function onBalanceCardDrill () {
|
|
100
|
+
//...
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function onBalanceCardRecharge () {
|
|
104
|
+
//...
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
### 4️⃣ 余额不足提示框 <balance-reminder>
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { BalanceReminder } from '@uxda/appkit'
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```html
|
|
116
|
+
<balance-reminder v-model="balanceReminderOpen"
|
|
117
|
+
@recharge="onBalanceReminderRecharge" />
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### 事件 emits
|
|
121
|
+
* @recharge 点击充值按钮时发生
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
## 公共API
|
|
125
|
+
### 1️⃣ 唤起充值(跳支付中心小程序) $app.invokeRecharge()
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { useAppKit } from '@uxda/appkit'
|
|
129
|
+
const $app = useAppKit()
|
|
130
|
+
$app.invokeRecharge({
|
|
131
|
+
app: 'crm',
|
|
132
|
+
tenant: '1',
|
|
133
|
+
})
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 2️⃣ 唤起充值(小程序内直接支付、不跳) $app.requestPayment()
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import { useAppKit } from '@uxda/appkit'
|
|
140
|
+
const $app = useAppKit()
|
|
141
|
+
$app.requestPayment({
|
|
142
|
+
app: 'crm',
|
|
143
|
+
tenant: '1',
|
|
144
|
+
amount: 100
|
|
145
|
+
})
|
|
146
|
+
```
|
|
147
|
+
|
package/babel.config.js
ADDED
package/dist/appkit.css
ADDED