@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.
Files changed (52) hide show
  1. package/.eslintrc.mjs +8 -0
  2. package/README.md +147 -0
  3. package/babel.config.js +12 -0
  4. package/dist/appkit.css +3 -0
  5. package/dist/index.js +1755 -0
  6. package/dist/styles.css +1 -0
  7. package/package.json +73 -0
  8. package/project.config.json +15 -0
  9. package/project.tt.json +13 -0
  10. package/rollup.config.js +55 -0
  11. package/src/Appkit.ts +41 -0
  12. package/src/balance/api/endpoints.ts +108 -0
  13. package/src/balance/api/index.ts +25 -0
  14. package/src/balance/components/AccountView.vue +519 -0
  15. package/src/balance/components/BalanceCard.vue +181 -0
  16. package/src/balance/components/BalanceReminder.vue +82 -0
  17. package/src/balance/components/ConsumptionFilter.vue +176 -0
  18. package/src/balance/components/ConsumptionRules.vue +70 -0
  19. package/src/balance/components/DateFilter.vue +219 -0
  20. package/src/balance/components/index.ts +9 -0
  21. package/src/balance/index.ts +1 -0
  22. package/src/balance/types.ts +92 -0
  23. package/src/global.ts +7 -0
  24. package/src/index.ts +51 -0
  25. package/src/main.scss +1 -0
  26. package/src/payment/README.md +0 -0
  27. package/src/payment/api/config.ts +8 -0
  28. package/src/payment/api/endpoints.ts +75 -0
  29. package/src/payment/api/index.ts +25 -0
  30. package/src/payment/components/AmountPicker.vue +109 -0
  31. package/src/payment/components/RechargeView.vue +146 -0
  32. package/src/payment/components/UserAgreement.vue +111 -0
  33. package/src/payment/components/index.ts +16 -0
  34. package/src/payment/consts.ts +1 -0
  35. package/src/payment/index.ts +1 -0
  36. package/src/payment/services/index.ts +17 -0
  37. package/src/payment/services/invoke-recharge.ts +25 -0
  38. package/src/payment/services/request-payment.ts +32 -0
  39. package/src/payment/types.ts +24 -0
  40. package/src/shared/components/AppDrawer.vue +53 -0
  41. package/src/shared/components/PageHeader.vue +75 -0
  42. package/src/shared/components/index.ts +7 -0
  43. package/src/shared/http/Http.ts +124 -0
  44. package/src/shared/http/index.ts +2 -0
  45. package/src/shared/http/types.ts +100 -0
  46. package/src/shared/index.ts +3 -0
  47. package/src/shared/weixin/index.ts +1 -0
  48. package/src/shared/weixin/payment.ts +37 -0
  49. package/src/styles/vars.scss +4 -0
  50. package/tsconfig.json +30 -0
  51. package/types/global.d.ts +22 -0
  52. package/types/vue.d.ts +10 -0
package/.eslintrc.mjs ADDED
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ extends: [
3
+ './.eslintrc-auto-import.json'
4
+ ],
5
+ rules: {
6
+ ident: ['error', 2]
7
+ }
8
+ }
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️⃣ 账户页 &lt;account-view&gt;
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️⃣ 账户卡片 &lt;balance-card&gt;
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️⃣ 余额不足提示框 &lt;balance-reminder&gt;
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
+
@@ -0,0 +1,12 @@
1
+ // babel-preset-taro 更多选项和默认值:
2
+ // https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
3
+ module.exports = {
4
+ presets: [
5
+ ['taro', {
6
+ framework: 'vue3',
7
+ ts: true
8
+ }]
9
+ ],
10
+ plugins: [
11
+ ],
12
+ }
@@ -0,0 +1,3 @@
1
+ var undefined$1 = undefined;
2
+
3
+ export { undefined$1 as default };