提交 f4389ba7 编写于 作者: Z zhaofengilang

更新 uni.requestMerchantTransfer 插件

上级 dedce1ad
import { RequestMerchantTransfer, RequestMerchantTransferOption, RequestMerchantTransferGeneralCallbackResult } from '../interface.uts'; import { RequestMerchantTransfer, RequestMerchantTransferOptions, RequestMerchantTransferGeneralCallbackResult } from '../interface.uts';
import WXAPIFactory from 'com.tencent.mm.opensdk.openapi.WXAPIFactory' import WXAPIFactory from 'com.tencent.mm.opensdk.openapi.WXAPIFactory'
import URLEncoder from 'java.net.URLEncoder' import URLEncoder from 'java.net.URLEncoder'
import StandardCharsets from 'java.nio.charset.StandardCharsets' import StandardCharsets from 'java.nio.charset.StandardCharsets'
import WXOpenBusinessView from 'com.tencent.mm.opensdk.modelbiz.WXOpenBusinessView' import WXOpenBusinessView from 'com.tencent.mm.opensdk.modelbiz.WXOpenBusinessView'
import Build from 'com.tencent.mm.opensdk.constants.Build' import Build from 'com.tencent.mm.opensdk.constants.Build'
export const requestMerchantTransfer : RequestMerchantTransfer = function (options : RequestMerchantTransferOption) { export const requestMerchantTransfer : RequestMerchantTransfer = function (options : RequestMerchantTransferOptions) {
var appId = options.appId var appId = options.appId
var api = WXAPIFactory.createWXAPI(UTSAndroid.getAppContext(), appId, false) var api = WXAPIFactory.createWXAPI(UTSAndroid.getAppContext(), appId, false)
var wxSdkVersion = api.wxAppSupportAPI var wxSdkVersion = api.wxAppSupportAPI
...@@ -33,19 +33,24 @@ export const requestMerchantTransfer : RequestMerchantTransfer = function (optio ...@@ -33,19 +33,24 @@ export const requestMerchantTransfer : RequestMerchantTransfer = function (optio
req.query = query req.query = query
// 发送请求并检查返回值 // 发送请求并检查返回值
var ret = api.sendReq(req) var ret = api.sendReq(req)
var result : RequestMerchantTransferGeneralCallbackResult = { if (ret) {
errMsg: 'ok' var result : RequestMerchantTransferGeneralCallbackResult = {
} errMsg: 'ok'
console.log(query) }
if (!ret) {
options.success?.(result) options.success?.(result)
options.complete?.(result) options.complete?.(result)
}else{
var result : RequestMerchantTransferGeneralCallbackResult = {
errMsg: 'fail'
}
options.fail?.(result)
options.complete?.(result)
} }
} else { } else {
var result : RequestMerchantTransferGeneralCallbackResult = { var result : RequestMerchantTransferGeneralCallbackResult = {
errMsg: '当前微信版本过低,请升级微信以使用该功能' errMsg: '当前微信版本过低,请升级微信以使用该功能'
} }
options.success?.(result) options.fail?.(result)
options.complete?.(result) options.complete?.(result)
} }
} }
......
import { UIApplication } from "UIKit"; import { UIApplication } from "UIKit";
import { URL, NSUserActivity, Bundle, URLComponents, URLQueryItem, Script } from "Foundation"; import { URL, NSUserActivity, Bundle, URLComponents, URLQueryItem, Script } from "Foundation";
import { RequestMerchantTransfer, RequestMerchantTransferOption, RequestMerchantTransferGeneralCallbackResult } from '../interface.uts'; import { RequestMerchantTransfer, RequestMerchantTransferOptions, RequestMerchantTransferGeneralCallbackResult } from '../interface.uts';
export const requestMerchantTransfer : RequestMerchantTransfer = function (options : RequestMerchantTransferOption) { export const requestMerchantTransfer : RequestMerchantTransfer = function (options : RequestMerchantTransferOptions) {
WxpayManager.requestMerchantTransfer(options) WxpayManager.requestMerchantTransfer(options)
} }
...@@ -28,7 +28,7 @@ export class WxpayManagerHookProxy implements UTSiOSHookProxy { ...@@ -28,7 +28,7 @@ export class WxpayManagerHookProxy implements UTSiOSHookProxy {
class WxpayManager implements WXApiDelegate { class WxpayManager implements WXApiDelegate {
private static shared = new WxpayManager() private static shared = new WxpayManager()
private static options ?: RequestMerchantTransferOption private static options ?: RequestMerchantTransferOptions
@UTSiOS.keyword("fileprivate") @UTSiOS.keyword("fileprivate")
static registerApp() { static registerApp() {
...@@ -60,7 +60,7 @@ class WxpayManager implements WXApiDelegate { ...@@ -60,7 +60,7 @@ class WxpayManager implements WXApiDelegate {
scheme = wechat!['appid'] as string | null scheme = wechat!['appid'] as string | null
} }
} }
return scheme return scheme
} }
...@@ -96,7 +96,7 @@ class WxpayManager implements WXApiDelegate { ...@@ -96,7 +96,7 @@ class WxpayManager implements WXApiDelegate {
return components.percentEncodedQuery return components.percentEncodedQuery
} }
static requestMerchantTransfer(options : RequestMerchantTransferOption) { static requestMerchantTransfer(options : RequestMerchantTransferOptions) {
WxpayManager.options = options WxpayManager.options = options
if (WxpayManager.isWXAppInstalled() == false) { if (WxpayManager.isWXAppInstalled() == false) {
var res : RequestMerchantTransferGeneralCallbackResult = { var res : RequestMerchantTransferGeneralCallbackResult = {
...@@ -178,4 +178,4 @@ class WxpayManager implements WXApiDelegate { ...@@ -178,4 +178,4 @@ class WxpayManager implements WXApiDelegate {
WxpayManager.options?.complete?.(res) WxpayManager.options?.complete?.(res)
} }
} }
} }
\ No newline at end of file
...@@ -60,18 +60,18 @@ export interface Uni { ...@@ -60,18 +60,18 @@ export interface Uni {
"unixVer": "x" "unixVer": "x"
}, },
"jd": { "jd": {
"hostVer": "x", "hostVer": "x",
"uniVer": "x", "uniVer": "x",
"unixVer": "x" "unixVer": "x"
} }
} }
} }
*/ */
requestMerchantTransfer(options : RequestMerchantTransferOption) : void; requestMerchantTransfer(options : RequestMerchantTransferOptions) : void;
} }
export type RequestMerchantTransfer = (options : RequestMerchantTransferOption) => void; export type RequestMerchantTransfer = (options : RequestMerchantTransferOptions) => void;
export type RequestMerchantTransferOption = { export type RequestMerchantTransferOptions = {
/** /**
商户号 商户号
@uniPlatform { @uniPlatform {
...@@ -133,8 +133,8 @@ export type RequestMerchantTransferOption = { ...@@ -133,8 +133,8 @@ export type RequestMerchantTransferOption = {
"unixVer": "x" "unixVer": "x"
}, },
"jd": { "jd": {
"hostVer": "x", "hostVer": "x",
"uniVer": "x", "uniVer": "x",
"unixVer": "x" "unixVer": "x"
} }
} }
...@@ -202,8 +202,8 @@ export type RequestMerchantTransferOption = { ...@@ -202,8 +202,8 @@ export type RequestMerchantTransferOption = {
"unixVer": "x" "unixVer": "x"
}, },
"jd": { "jd": {
"hostVer": "x", "hostVer": "x",
"uniVer": "x", "uniVer": "x",
"unixVer": "x" "unixVer": "x"
} }
} }
...@@ -271,8 +271,8 @@ export type RequestMerchantTransferOption = { ...@@ -271,8 +271,8 @@ export type RequestMerchantTransferOption = {
"unixVer": "x" "unixVer": "x"
}, },
"jd": { "jd": {
"hostVer": "x", "hostVer": "x",
"uniVer": "x", "uniVer": "x",
"unixVer": "x" "unixVer": "x"
} }
} }
...@@ -340,8 +340,8 @@ export type RequestMerchantTransferOption = { ...@@ -340,8 +340,8 @@ export type RequestMerchantTransferOption = {
"unixVer": "x" "unixVer": "x"
}, },
"jd": { "jd": {
"hostVer": "x", "hostVer": "x",
"uniVer": "x", "uniVer": "x",
"unixVer": "x" "unixVer": "x"
} }
} }
...@@ -409,8 +409,8 @@ export type RequestMerchantTransferOption = { ...@@ -409,8 +409,8 @@ export type RequestMerchantTransferOption = {
"unixVer": "x" "unixVer": "x"
}, },
"jd": { "jd": {
"hostVer": "x", "hostVer": "x",
"uniVer": "x", "uniVer": "x",
"unixVer": "x" "unixVer": "x"
} }
} }
...@@ -478,8 +478,8 @@ export type RequestMerchantTransferOption = { ...@@ -478,8 +478,8 @@ export type RequestMerchantTransferOption = {
"unixVer": "x" "unixVer": "x"
}, },
"jd": { "jd": {
"hostVer": "x", "hostVer": "x",
"uniVer": "x", "uniVer": "x",
"unixVer": "x" "unixVer": "x"
} }
} }
...@@ -547,8 +547,8 @@ export type RequestMerchantTransferOption = { ...@@ -547,8 +547,8 @@ export type RequestMerchantTransferOption = {
"unixVer": "x" "unixVer": "x"
}, },
"jd": { "jd": {
"hostVer": "x", "hostVer": "x",
"uniVer": "x", "uniVer": "x",
"unixVer": "x" "unixVer": "x"
} }
} }
...@@ -616,8 +616,8 @@ export type RequestMerchantTransferOption = { ...@@ -616,8 +616,8 @@ export type RequestMerchantTransferOption = {
"unixVer": "x" "unixVer": "x"
}, },
"jd": { "jd": {
"hostVer": "x", "hostVer": "x",
"uniVer": "x", "uniVer": "x",
"unixVer": "x" "unixVer": "x"
} }
} }
...@@ -685,8 +685,8 @@ export type RequestMerchantTransferOption = { ...@@ -685,8 +685,8 @@ export type RequestMerchantTransferOption = {
"unixVer": "x" "unixVer": "x"
}, },
"jd": { "jd": {
"hostVer": "x", "hostVer": "x",
"uniVer": "x", "uniVer": "x",
"unixVer": "x" "unixVer": "x"
} }
} }
...@@ -707,4 +707,4 @@ export type RequestMerchantTransferSuccessCallback = ( ...@@ -707,4 +707,4 @@ export type RequestMerchantTransferSuccessCallback = (
) => void ) => void
export type RequestMerchantTransferGeneralCallbackResult = { export type RequestMerchantTransferGeneralCallbackResult = {
errMsg : string errMsg : string
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册