@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/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import url(./styles/vars.scss);
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@uxda/appkit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "小程序应用开发包",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "src/index.ts",
|
|
8
|
+
"moduleResolution": "node",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "rollup -c rollup.config.js --watch",
|
|
11
|
+
"build": "rollup -c rollup.config.js"
|
|
12
|
+
},
|
|
13
|
+
"browserslist": [
|
|
14
|
+
"last 3 versions",
|
|
15
|
+
"Android >= 4.1",
|
|
16
|
+
"ios >= 8"
|
|
17
|
+
],
|
|
18
|
+
"author": "",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@babel/runtime": "^7.7.7",
|
|
21
|
+
"@nutui/icons-vue-taro": "^0.0.9",
|
|
22
|
+
"@nutui/nutui-taro": "^3.3.0",
|
|
23
|
+
"@tarojs/components": "^3.5.6",
|
|
24
|
+
"@tarojs/helper": "^3.5.6",
|
|
25
|
+
"@tarojs/plugin-framework-vue3": "^3.5.6",
|
|
26
|
+
"@tarojs/plugin-html": "^3.5.6",
|
|
27
|
+
"@tarojs/plugin-platform-alipay": "^3.5.6",
|
|
28
|
+
"@tarojs/plugin-platform-jd": "^3.5.6",
|
|
29
|
+
"@tarojs/plugin-platform-qq": "^3.5.6",
|
|
30
|
+
"@tarojs/plugin-platform-swan": "^3.5.6",
|
|
31
|
+
"@tarojs/plugin-platform-tt": "^3.5.6",
|
|
32
|
+
"@tarojs/plugin-platform-weapp": "^3.5.6",
|
|
33
|
+
"@tarojs/router": "^3.5.6",
|
|
34
|
+
"@tarojs/runtime": "^3.5.6",
|
|
35
|
+
"@tarojs/shared": "^3.5.6",
|
|
36
|
+
"@tarojs/taro": "^3.5.6",
|
|
37
|
+
"@tarojs/taro-h5": "^3.5.6",
|
|
38
|
+
"@types/wechat-miniprogram": "^3.4.7",
|
|
39
|
+
"vue": "^3.2.40"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@babel/core": "^7.8.0",
|
|
43
|
+
"@tarojs/cli": "^3.5.6",
|
|
44
|
+
"@tarojs/taro-loader": "^3.5.6",
|
|
45
|
+
"@tarojs/webpack5-runner": "^3.5.6",
|
|
46
|
+
"@types/node": "^18.15.11",
|
|
47
|
+
"@types/webpack-env": "^1.13.6",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
|
49
|
+
"@typescript-eslint/parser": "^5.20.0",
|
|
50
|
+
"@vue/babel-plugin-jsx": "^1.0.6",
|
|
51
|
+
"@vue/compiler-sfc": "^3.2.40",
|
|
52
|
+
"babel-preset-taro": "^3.5.6",
|
|
53
|
+
"css-loader": "3.4.2",
|
|
54
|
+
"eslint": "^8.12.0",
|
|
55
|
+
"eslint-config-taro": "^3.5.6",
|
|
56
|
+
"eslint-plugin-vue": "^8.0.0",
|
|
57
|
+
"postcss": "^8.4.32",
|
|
58
|
+
"rollup": "^4.6.1",
|
|
59
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
60
|
+
"rollup-plugin-esbuild": "^6.1.0",
|
|
61
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
62
|
+
"rollup-plugin-scss": "^4.0.0",
|
|
63
|
+
"rollup-plugin-vue": "^6.0.0",
|
|
64
|
+
"style-loader": "^3.3.3",
|
|
65
|
+
"stylelint": "9.3.0",
|
|
66
|
+
"ts-node": "^10.9.1",
|
|
67
|
+
"typescript": "^5.0.0",
|
|
68
|
+
"unplugin-auto-import": "^0.17.1",
|
|
69
|
+
"unplugin-vue-components": "^0.23.0",
|
|
70
|
+
"vue-loader": "^17.0.0",
|
|
71
|
+
"webpack": "^5.78.0"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"miniprogramRoot": "./dist",
|
|
3
|
+
"projectname": "appkit",
|
|
4
|
+
"description": "",
|
|
5
|
+
"appid": "touristappid",
|
|
6
|
+
"setting": {
|
|
7
|
+
"urlCheck": true,
|
|
8
|
+
"es6": false,
|
|
9
|
+
"enhance": false,
|
|
10
|
+
"compileHotReLoad": false,
|
|
11
|
+
"postcss": false,
|
|
12
|
+
"minified": false
|
|
13
|
+
},
|
|
14
|
+
"compileType": "miniprogram"
|
|
15
|
+
}
|
package/project.tt.json
ADDED
package/rollup.config.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import dts from 'rollup-plugin-dts'
|
|
2
|
+
import vue from 'rollup-plugin-vue'
|
|
3
|
+
import esbuild from 'rollup-plugin-esbuild'
|
|
4
|
+
import scss from 'rollup-plugin-scss'
|
|
5
|
+
import postcss from 'rollup-plugin-postcss'
|
|
6
|
+
import { resolve } from 'path'
|
|
7
|
+
|
|
8
|
+
const nutRegex = /^Nut[A-Z].*$/
|
|
9
|
+
|
|
10
|
+
const NutTaroResolver = (name) => {
|
|
11
|
+
if (nutRegex.test(name)) {
|
|
12
|
+
return {
|
|
13
|
+
name: name.slice(3),
|
|
14
|
+
from: '@nutui/nutui-taro'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default [
|
|
20
|
+
{
|
|
21
|
+
input: 'src/index.ts',
|
|
22
|
+
output: [
|
|
23
|
+
{
|
|
24
|
+
format: 'es',
|
|
25
|
+
dir: 'dist'
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
plugins: [
|
|
29
|
+
vue({
|
|
30
|
+
defaultLang: {
|
|
31
|
+
script: 'ts',
|
|
32
|
+
style: 'scss'
|
|
33
|
+
}
|
|
34
|
+
}),
|
|
35
|
+
postcss({
|
|
36
|
+
include: /\.scss/,
|
|
37
|
+
}),
|
|
38
|
+
esbuild({
|
|
39
|
+
})
|
|
40
|
+
],
|
|
41
|
+
external: ['vue', '@nutui/nutui-taro']
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
input: './src/main.scss',
|
|
45
|
+
output: {
|
|
46
|
+
file: 'dist/appkit.css',
|
|
47
|
+
},
|
|
48
|
+
plugins: [
|
|
49
|
+
postcss({
|
|
50
|
+
use: ['sass'],
|
|
51
|
+
extract: resolve('./dist/styles.css'),
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
]
|
package/src/Appkit.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PaymentParams, RechargeParams } from './payment/types'
|
|
2
|
+
import { globalData } from './global'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* options for useAppKit
|
|
6
|
+
*/
|
|
7
|
+
export type AppKitOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* token 获取方法
|
|
10
|
+
* 由使用场景提供
|
|
11
|
+
*/
|
|
12
|
+
token (): string,
|
|
13
|
+
/**
|
|
14
|
+
* 调用 API 时使用的 base url
|
|
15
|
+
*/
|
|
16
|
+
baseUrl (): string,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type DollarApp = {
|
|
20
|
+
requestPayment: (options: PaymentParams) => void,
|
|
21
|
+
invokeRecharge: (options: RechargeParams) => void,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 用来记忆使用场景传递的 options
|
|
26
|
+
*/
|
|
27
|
+
const appKitOptions: AppKitOptions = {
|
|
28
|
+
token: () => '',
|
|
29
|
+
baseUrl: () => ''
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const useAppKitOptions = () => {
|
|
33
|
+
if (!globalData.$appKitOptions) {
|
|
34
|
+
globalData.$appKitOptions = appKitOptions
|
|
35
|
+
}
|
|
36
|
+
return globalData.$appKitOptions as AppKitOptions
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
useAppKitOptions,
|
|
41
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { HttpEndpoints } from '../../shared/http'
|
|
2
|
+
import { ConsumptionFiltering, ConsumptionGroups, ConsumptionType } from '../types'
|
|
3
|
+
|
|
4
|
+
const typeMappings: Record<string, ConsumptionType> = {
|
|
5
|
+
'CZ': '充值',
|
|
6
|
+
'JF': '缴费',
|
|
7
|
+
'FE': '返额',
|
|
8
|
+
'ZJ': '增加',
|
|
9
|
+
'KJ': '扣减',
|
|
10
|
+
'XH': '消耗',
|
|
11
|
+
'TH': '退回',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const typeMappingsReversed = Object.fromEntries(
|
|
15
|
+
Object.entries(typeMappings).map(([x, y]) => [y, x])
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
const positionMappings = {
|
|
19
|
+
'common': '云豆',
|
|
20
|
+
'rights': '小云豆',
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const positionMappingsReversed = Object.fromEntries(
|
|
24
|
+
Object.entries(positionMappings).map(([x, y]) => [y, x])
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
const directionMappings = {
|
|
28
|
+
0: '收入',
|
|
29
|
+
1: '支出'
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const directionMappingsReversed = Object.fromEntries(
|
|
33
|
+
Object.entries(directionMappings).map(([x, y]) => [y, x])
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
const endpointsList: HttpEndpoints = {
|
|
37
|
+
/**
|
|
38
|
+
* 余额明细
|
|
39
|
+
*/
|
|
40
|
+
getBalance: {
|
|
41
|
+
path: '/ac-app/account/info/detail/app',
|
|
42
|
+
translate: (data: any) => ({
|
|
43
|
+
// appCode: 'fnfundkit',
|
|
44
|
+
// tenantCode: '1665925586953629696',
|
|
45
|
+
}),
|
|
46
|
+
transform (result: any) {
|
|
47
|
+
return {
|
|
48
|
+
total: result.commonAccount,
|
|
49
|
+
privileges: result.rightsAccountBalList.map((r: any) => ({
|
|
50
|
+
title: r.rightsName,
|
|
51
|
+
amount: r.rightsAccount
|
|
52
|
+
}))
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* 账户流水明细
|
|
58
|
+
*/
|
|
59
|
+
getOperations: {
|
|
60
|
+
path: '/ac-app/account/record/detail/mobile',
|
|
61
|
+
translate: (data: ConsumptionFiltering) => {
|
|
62
|
+
return {
|
|
63
|
+
accountType: positionMappingsReversed[data.position] || '',
|
|
64
|
+
inOrOut: directionMappingsReversed[data.direction] || '',
|
|
65
|
+
changeType: typeMappingsReversed[data.type] || '',
|
|
66
|
+
operateTimeEnd: data.dateFrom || '',
|
|
67
|
+
operateTimeStart: data.dateTo || '',
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
transform (result: any) {
|
|
71
|
+
if (!result.accountRecordDetailDailyList) return []
|
|
72
|
+
const data: ConsumptionGroups = {
|
|
73
|
+
from: result.operateTimeStart,
|
|
74
|
+
to: result.operateTimeEnd,
|
|
75
|
+
list: result.accountRecordDetailDailyList.map((r: any) => ({
|
|
76
|
+
date: r.operateTime,
|
|
77
|
+
consumptions: r.accountRecordDetailList.map((d: any) => ({
|
|
78
|
+
position: positionMappings[d.accountTYpe],
|
|
79
|
+
type: typeMappings[d.changeType],
|
|
80
|
+
direction: directionMappings[d.inOrOut],
|
|
81
|
+
amount: d.changeValue,
|
|
82
|
+
title: d.rightsName,
|
|
83
|
+
description: d.remark,
|
|
84
|
+
}))
|
|
85
|
+
}))
|
|
86
|
+
}
|
|
87
|
+
return data
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const endpoints = Object.fromEntries(
|
|
93
|
+
Object.entries(endpointsList).map(([name, def]) => [name, def.path])
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
const translates = Object.fromEntries(
|
|
97
|
+
Object.entries(endpointsList).map(([, def]) => [def.path, def.translate])
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
const transforms = Object.fromEntries(
|
|
101
|
+
Object.entries(endpointsList).map(([, def]) => [def.path, def.transform])
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
endpoints,
|
|
106
|
+
translates,
|
|
107
|
+
transforms,
|
|
108
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useHttp } from '../../shared'
|
|
2
|
+
import { translates, transforms } from './endpoints'
|
|
3
|
+
import { useAppKitOptions } from '../../Appkit'
|
|
4
|
+
|
|
5
|
+
const makeHttp = () => {
|
|
6
|
+
const appkitOptions = useAppKitOptions()
|
|
7
|
+
|
|
8
|
+
const header = {
|
|
9
|
+
Token: appkitOptions.token()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const $http = useHttp({
|
|
13
|
+
baseUrl: appkitOptions.baseUrl(),
|
|
14
|
+
header,
|
|
15
|
+
translates,
|
|
16
|
+
transforms,
|
|
17
|
+
})
|
|
18
|
+
return $http
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
makeHttp
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export * from './endpoints'
|