@zhangcf233/pay 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/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ @charset "UTF-8";.pay-error-container[data-v-0817c014]{position:relative}.pay-error-container .loading[data-v-0817c014]{width:100%;height:100%;position:absolute;background:#fff;z-index:1;transition:all .3s;justify-content:center;align-items:center}.pay-error-container .message[data-v-0817c014]{font-size:.1rem}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-75290345]{font-family:WeChat-Bold}.root[data-v-75290345]{text-align:center}.cell[data-v-be539772]{display:flex;align-items:center;justify-content:space-between;height:.3rem}.cell .name[data-v-be539772]{width:30vw;color:gray;font-size:.14rem;display:flex;align-items:center;justify-content:end}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-ea027830]{font-family:WeChat-Bold}.custom-price .input[data-v-ea027830]{font-size:.2rem}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-68d98a5c]{font-family:WeChat-Bold}.price-root[data-v-68d98a5c]{position:relative;text-align:center;background:#f3f3f3;border-radius:.08rem;padding:.1rem 0;display:flex;flex-direction:column;height:.6rem;box-sizing:border-box;justify-content:space-between;align-items:center}.price-root .gift[data-v-68d98a5c]{position:absolute;top:-.1rem;right:-.05rem;background:linear-gradient(248.45deg,#fa1e1e,#ff7752 99.44%);padding:0 .05rem;border-radius:.1rem .1rem .1rem 0;font-size:.1rem;border-width:.02rem;border-color:#fff;border-style:solid;box-sizing:border-box;color:#fff}.price-root .token-count[data-v-68d98a5c]{display:flex;justify-content:center;align-items:center;font-size:.2rem}.price-root .token-count img[data-v-68d98a5c]{width:.16rem;height:.16rem;margin-right:.02rem}.price-root .price[data-v-68d98a5c]{font-size:.14rem}.only-price[data-v-68d98a5c]{align-items:center;justify-content:center}.only-price .price[data-v-68d98a5c]{font-size:.2rem}.content[data-v-76333b1f]{width:100%;margin:.2rem 0;display:grid;grid-template-columns:repeat(3,1fr);gap:.1rem;box-sizing:border-box;font-weight:500}.loading[data-v-76333b1f]{display:flex;justify-content:center;align-items:center}.select[data-v-76333b1f]{color:#fff}@font-face{font-family:WeChat-Bold;src:url(https://shangrao-qqzh.oss-cn-hangzhou.aliyuncs.com/pay/fonts/WeChatSansStd-Bold.ttf)}.wechat-font[data-v-20ed35e0]{font-family:WeChat-Bold}.pay-popup[data-v-20ed35e0]{display:flex;flex-direction:column;width:100vw;box-sizing:border-box;overflow:hidden;padding:0 .15rem .2rem;transition:all .3s}.title[data-v-20ed35e0]{text-align:center;margin:.16rem 0}
@@ -0,0 +1,6 @@
1
+ export interface Api {
2
+ /** 获取余额接口*/
3
+ money: string;
4
+ /** 获取支付渠道接口*/
5
+ channels: string;
6
+ }
@@ -0,0 +1,26 @@
1
+ /** 接口返回的支付渠道内容*/
2
+ export interface ApiChannel {
3
+ /** 支付渠道id*/
4
+ Id: number;
5
+ /** 费率说明 或 小程序 appid*/
6
+ AgentDescribe: string;
7
+ /** 图标*/
8
+ PaymentIcon: string;
9
+ /** 渠道唯一标识 例如 P2214_WX_001*/
10
+ PaymentName: string;
11
+ /** 渠道名称 例如:微信(1.4)*/
12
+ PaymentValue: string;
13
+ }
14
+ /** 支付渠道类型*/
15
+ export type ChannelType = "alipay" | "wechat" | "unknow";
16
+ /** 支付渠道*/
17
+ export interface Channel {
18
+ /** id*/
19
+ id: number;
20
+ /** 图标*/
21
+ icon: string;
22
+ /** 名称*/
23
+ name: string;
24
+ /** 类型*/
25
+ type: ChannelType;
26
+ }
@@ -0,0 +1,47 @@
1
+ import { Price } from "./price";
2
+ export type PayCreateType = "agent" | "vip";
3
+ export type PayAllConfigType = {
4
+ [key in PayCreateType]: Config;
5
+ };
6
+ export type Config = {
7
+ /** 配置名称*/
8
+ name: string;
9
+ /** 是否需要传入id*/
10
+ needId: boolean;
11
+ /** 钱包信息*/
12
+ balance: {
13
+ /** 是否关闭*/
14
+ disabled: boolean;
15
+ /** 获取钱包信息接口*/
16
+ api?: string;
17
+ /** 余额的 key*/
18
+ key?: string;
19
+ };
20
+ /** 价目表*/
21
+ price: {
22
+ /** 是否关闭价目表*/
23
+ disabled: boolean;
24
+ /** 是否允许定制*/
25
+ custom?: true;
26
+ /** 是否要远程加载*/
27
+ online?: true;
28
+ /** 本地价目表*/
29
+ prices?: Array<Price>;
30
+ /** 远程加载方法*/
31
+ load?: () => Promise<Array<Price>>;
32
+ };
33
+ /** 渠道*/
34
+ channel: {
35
+ /** 加载渠道地址*/
36
+ api: string;
37
+ };
38
+ /** 支付参数*/
39
+ pay: {
40
+ /** 分类的 key*/
41
+ key: string;
42
+ /** 接口前缀*/
43
+ prefix?: string;
44
+ };
45
+ /** 主体色*/
46
+ theme?: string;
47
+ };
@@ -0,0 +1,5 @@
1
+ import { PayAllConfig } from "../config";
2
+ import { PayCreateType } from "./config";
3
+ export type VoidCallback = () => void;
4
+ export type PayCreateArg<T extends PayCreateType> = typeof PayAllConfig[T]['needId'] extends true ? [id: string] : [];
5
+ export type PayCreate = <T extends PayCreateType>(type: T, ...args: PayCreateArg<T>) => void;
@@ -0,0 +1,4 @@
1
+ export * from './channel';
2
+ export * from "./config";
3
+ export * from './post';
4
+ export * from './price';
@@ -0,0 +1,4 @@
1
+ /** 接口返回的钱包信息*/
2
+ export interface ApiMoney {
3
+ Money: number;
4
+ }
@@ -0,0 +1,8 @@
1
+ export type PayPost = (url: string, params?: {
2
+ [key: string]: any;
3
+ }) => Promise<any>;
4
+ export interface ApiResult<T = string> {
5
+ Status: boolean;
6
+ Message: string;
7
+ Data?: T;
8
+ }
@@ -0,0 +1,11 @@
1
+ /** 售价配置 */
2
+ export interface Price {
3
+ /** 售价(单位:分,例如 600) */
4
+ price: number;
5
+ /** 代币数量(例如 60) */
6
+ count?: number;
7
+ /** 赠送代币数量(例如 10) */
8
+ giftCount?: number;
9
+ /** 附加赠品描述(例如“首充赠送”) */
10
+ giftExten?: string;
11
+ }
@@ -0,0 +1,9 @@
1
+ import { BasePayOptions } from "./pay";
2
+ /** 支付宝支付
3
+ * @param api 接口地址
4
+ * @param options 参数
5
+ */
6
+ export declare const alipay: (options: BasePayOptions) => Promise<{
7
+ status: boolean;
8
+ message: string;
9
+ } | undefined>;
@@ -0,0 +1,4 @@
1
+ export declare const fail: (message: string, title?: string) => {
2
+ status: boolean;
3
+ message: string;
4
+ };
@@ -0,0 +1,3 @@
1
+ import { Channel } from "../@types";
2
+ /** 统一的获取渠道方法*/
3
+ export declare const getPayChannels: (url: string) => Promise<Channel[]>;
@@ -0,0 +1 @@
1
+ export declare const getPayMoney: (url: string, key: string) => Promise<number>;
@@ -0,0 +1,4 @@
1
+ export * from './fail';
2
+ export * from './request';
3
+ export * from './success';
4
+ export declare const PayApi: {};
@@ -0,0 +1,26 @@
1
+ import { Channel } from "../@types";
2
+ export interface BasePayOptions {
3
+ /** 渠道 id*/
4
+ id: number;
5
+ /** 类型 key*/
6
+ key: string;
7
+ /** 类型值*/
8
+ value: string;
9
+ /** 接口前缀*/
10
+ prefix?: string;
11
+ }
12
+ export interface SendPayOptions {
13
+ /** 支付渠道*/
14
+ channel: Channel;
15
+ /** 类型 key*/
16
+ key: string;
17
+ /** 类型值*/
18
+ value: string;
19
+ /** 接口前缀*/
20
+ prefix?: string;
21
+ }
22
+ /** 发送充值请求*/
23
+ export declare const sendPay: ({ channel, key, value, prefix }: SendPayOptions) => Promise<{
24
+ status: boolean;
25
+ message: string;
26
+ } | undefined>;
@@ -0,0 +1,8 @@
1
+ export interface PayPostResult<T = null> {
2
+ status: boolean;
3
+ message: string;
4
+ data?: T;
5
+ }
6
+ export declare const payRequest: <T>(url: string, data?: {
7
+ [key: string]: any;
8
+ }, method?: "POST" | "GET") => Promise<T>;
@@ -0,0 +1,5 @@
1
+ export declare const success: <T>(data?: T) => {
2
+ status: boolean;
3
+ message: string;
4
+ data: T | undefined;
5
+ };
@@ -0,0 +1,9 @@
1
+ import Vue from 'vue';
2
+ import { Config } from '../../@types';
3
+ export default class Balance extends Vue {
4
+ config: Config;
5
+ value: number;
6
+ load(): Promise<number>;
7
+ onBalanceLoad(money: number): void;
8
+ __VLS_template: () => void;
9
+ }
@@ -0,0 +1,19 @@
1
+ import Vue from 'vue';
2
+ import { Channel, Config } from '../../@types';
3
+ interface Action {
4
+ text: string;
5
+ id: number;
6
+ }
7
+ export default class Channels extends Vue {
8
+ config: Config;
9
+ channels: Array<Channel>;
10
+ select: number;
11
+ get actions(): Action[];
12
+ showPopover: boolean;
13
+ onSelect(action: Action, index: number): void;
14
+ get name(): string;
15
+ load(): Promise<Channel[]>;
16
+ onLoadChannels(data: Channel[]): void;
17
+ __VLS_template: () => void;
18
+ }
19
+ export {};
@@ -0,0 +1,11 @@
1
+ import { Vue } from 'vue-property-decorator';
2
+ export default class PayError extends Vue {
3
+ load: () => Promise<any>;
4
+ loading: boolean;
5
+ message: string;
6
+ get showLoading(): string | true;
7
+ mounted(): Promise<void>;
8
+ test(): void;
9
+ retry(): Promise<void>;
10
+ __VLS_template: () => void;
11
+ }
@@ -0,0 +1,28 @@
1
+ import Vue from 'vue';
2
+ import { Channel, Config, Price } from '../@types';
3
+ export default class PayPopup extends Vue {
4
+ config: Config;
5
+ id?: string;
6
+ baseTheme: string;
7
+ visible: boolean;
8
+ balance: number;
9
+ price: Price;
10
+ channel: Channel | null;
11
+ loading: {
12
+ balance: boolean;
13
+ price: boolean;
14
+ channel: boolean;
15
+ };
16
+ mounted(): Promise<void>;
17
+ initLoad(): void;
18
+ onClose(): void;
19
+ onTopup(): Promise<void>;
20
+ /** 余额变动*/
21
+ onBanlanceChange(money: number): void;
22
+ onChannelChange(channel: Channel): void;
23
+ onPriceChange(price: Price): void;
24
+ get finalPrice(): number;
25
+ get disable(): boolean;
26
+ get title(): string;
27
+ __VLS_template: () => void;
28
+ }
@@ -0,0 +1,19 @@
1
+ import Vue from 'vue';
2
+ import { Config, Price } from '../../@types';
3
+ export default class PriceContainer extends Vue {
4
+ config: Config;
5
+ value: number;
6
+ prices: Price[];
7
+ customPrice: number;
8
+ loading: boolean;
9
+ message: string;
10
+ mounted(): Promise<void>;
11
+ /** 载入价目表*/
12
+ load(): (() => Promise<Array<Price>>) | Promise<unknown> | undefined;
13
+ /** 价目表加载成功*/
14
+ onLoadPrices(prices: Price[]): void;
15
+ /** 切换价格*/
16
+ changePrice(index: number): void;
17
+ onCustomPriceChange(n: number): void;
18
+ __VLS_template: () => void;
19
+ }
@@ -0,0 +1,7 @@
1
+ import Vue from 'vue';
2
+ export default class PriceCustom extends Vue {
3
+ customPrice: null | number;
4
+ value: null | number;
5
+ onChange(val: string): void;
6
+ __VLS_template: () => void;
7
+ }
@@ -0,0 +1,9 @@
1
+ import Vue from 'vue';
2
+ import { Price } from '../../@types';
3
+ export default class PriceItem extends Vue {
4
+ price: Price;
5
+ get realPrice(): number;
6
+ /** 是否仅有售价*/
7
+ get onlyPrice(): boolean;
8
+ __VLS_template: () => void;
9
+ }
@@ -0,0 +1,4 @@
1
+ import Vue from 'vue';
2
+ export default class Template extends Vue {
3
+ __VLS_template: () => void;
4
+ }
@@ -0,0 +1,23 @@
1
+ import { Config } from "./@types";
2
+ export declare const BaseTheme = "orange";
3
+ export declare const AgentConfig: Config;
4
+ export declare const VipConfig: Config;
5
+ /** 完整支付配置*/
6
+ export declare const PayAllConfig: {
7
+ readonly agent: Config;
8
+ readonly vip: {
9
+ readonly needId: true;
10
+ readonly balance: {
11
+ readonly disabled: true;
12
+ };
13
+ readonly price: {
14
+ readonly disabled: true;
15
+ };
16
+ readonly channel: {
17
+ readonly api: "/SystemPayment/GetVipList";
18
+ };
19
+ readonly pay: {
20
+ readonly key: "vipId";
21
+ };
22
+ };
23
+ };
@@ -0,0 +1,9 @@
1
+ import { PayCreate } from './@types/create';
2
+ export { default as PayPlugin } from './plugin';
3
+ declare module 'vue/types/vue' {
4
+ interface Vue {
5
+ $pay: {
6
+ create: PayCreate;
7
+ };
8
+ }
9
+ }
@@ -0,0 +1,6 @@
1
+ import Vue from "vue";
2
+ /** 插件*/
3
+ declare const _default: {
4
+ install(vue: typeof Vue): void;
5
+ };
6
+ export default _default;
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@zhangcf233/pay",
3
+ "version": "1.0.0",
4
+ "main": "dist/pay.umd.js",
5
+ "module": "dist/pay.es.js",
6
+ "types": "dist/types/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build:types": "vue-tsc --emitDeclarationOnly --declaration --declarationDir dist/types",
12
+ "build": " vite build && npm run build:types"
13
+ },
14
+ "peerDependencies": {
15
+ "vant": "^2.13.9"
16
+ },
17
+ "devDependencies": {
18
+ "sass": "^1.89.2",
19
+ "sass-loader": "^12.0.0",
20
+ "typescript": "^5.9.2",
21
+ "vite": "^4.0.0",
22
+ "vite-plugin-vue2": "^2.0.0",
23
+ "vue-class-component": "^7.2.3",
24
+ "vue-property-decorator": "^9.1.2",
25
+ "vue-template-compiler": "^2.6.14",
26
+ "vue-tsc": "^3.0.5"
27
+ },
28
+ "dependencies": {
29
+ "vue": "^2.7.16"
30
+ },
31
+ "exports": {
32
+ ".": {
33
+ "import": "./dist/index.js",
34
+ "require": "./dist/index.js",
35
+ "types": "./dist/types/index.d.ts"
36
+ }
37
+ }
38
+ }