|
|
@@ -1,5 +1,5 @@
|
|
|
import { IBestToast } from '@ibestservices/ibest-ui';
|
|
|
-import { SendAuthReq } from '@tencent/wechat_open_sdk';
|
|
|
+import { PayReq, SendAuthReq } from '@tencent/wechat_open_sdk';
|
|
|
import { ContextHelper } from '../utils/ContextHelper';
|
|
|
import { WechatUtil } from '../utils/wechat/WechatUtil';
|
|
|
|
|
|
@@ -25,7 +25,48 @@ export interface AccessTokenResult {
|
|
|
}
|
|
|
|
|
|
|
|
|
-export class WechatObj {
|
|
|
+/**
|
|
|
+ * 微信支付参数接口
|
|
|
+ */
|
|
|
+interface WeChatPayParams {
|
|
|
+ /**
|
|
|
+ * 应用ID(AppID)
|
|
|
+ */
|
|
|
+ appid: string;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商户号(PartnerID)
|
|
|
+ */
|
|
|
+ partnerid: string;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 预支付交易会话ID
|
|
|
+ */
|
|
|
+ prepayid: string;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 固定值
|
|
|
+ */
|
|
|
+ package: string;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 随机字符串
|
|
|
+ */
|
|
|
+ noncestr: string;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 时间戳(单位:秒)
|
|
|
+ */
|
|
|
+ timestamp: string | number;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 签名,这里用的 MD5 签名
|
|
|
+ */
|
|
|
+ sign: string;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+export class JDBObj {
|
|
|
async handleWeChatLogin(): Promise<void> {
|
|
|
try {
|
|
|
let req = new SendAuthReq();
|
|
|
@@ -35,9 +76,20 @@ export class WechatObj {
|
|
|
req.state = 'none';
|
|
|
req.transaction = 'test123';
|
|
|
let finished = await WechatUtil.getWechatApi().sendReq(ContextHelper.UIAbilityContext, req);
|
|
|
- IBestToast.show({ message: '微信登录成功' });
|
|
|
} catch (error) {
|
|
|
IBestToast.show({ message: '微信登录失败,请重试', type: 'fail' });
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ async handleWeChatPay(param: WeChatPayParams) {
|
|
|
+ let req = new PayReq()
|
|
|
+ req.appId = param.appid
|
|
|
+ req.partnerId = param.partnerid
|
|
|
+ req.prepayId = param.prepayid
|
|
|
+ req.packageValue = param.package
|
|
|
+ req.nonceStr = param.noncestr
|
|
|
+ req.timeStamp = param.timestamp.toString()
|
|
|
+ req.sign = param.sign
|
|
|
+ await WechatUtil.getWechatApi().sendReq(ContextHelper.UIAbilityContext, req)
|
|
|
+ }
|
|
|
}
|