UNPKG

fastchar-appjs

Version:

快速搭建VUE项目工具类的基本库,主要用于每个功能页面独立生成html,不使用vue单页面功能。

1,078 lines (1,077 loc) 40.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FastNative = void 0; const FastHelper_1 = require("./FastHelper"); const FastBaseApp_1 = require("./FastBaseApp"); /** * FastNative 调用Android或IOS原生方法工具 * @author Janesen */ var FastNative; (function (FastNative) { /** * 执行本地方法核心类 */ class Core { static methodInfos = {}; static getKey() { let d = new Date().getTime(); return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { let r = (d + Math.random() * 16) % 16 | 0; d = Math.floor(d / 16); return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); }); } static showError(message) { alert("FastAppJs发生错误:" + message); } /** * 是否是安卓客户端 */ static isAndroid() { return navigator.userAgent.toLowerCase().indexOf('android') > -1; } /** * 是否是ios客户端 */ static isIOS() { return navigator.userAgent.toLowerCase().indexOf('iphone') > -1; } /** * 执行手机客户端原生方法 * @param methodName 方法名称 * @param methodParams 方法参数,Array格式,按照原生方法的参数顺序设置 * @param callBack 回调函数 */ static execute(methodName, methodParams, callBack) { const Base64 = require("js-base64"); const key = this.getKey(); try { if (methodParams == null) { methodParams = []; } if (callBack == null) { callBack = function (result) { }; } let nativeMobileApp = FastBaseApp_1.FastBaseApp.Config.getGlobalConfig("nativeMobileApp"); if (!FastHelper_1.FastHelper.Booleans.parse(nativeMobileApp, true)) { console.warn("FastNative-已阻止原生方法调用!"); callBack({ success: false, message: "已阻止原生方法调用!", data: null }); return; } this.methodInfos[key] = { methodName: methodName, methodParams: methodParams, callBack: callBack }; methodParams.unshift(key); methodParams.forEach(function (value, index) { if (value == null) { methodParams[index] = ""; return true; } if (!(value instanceof Array)) { methodParams[index] = value.toString(); } }); if (this.isAndroid()) { if (window["app"] && window["app"].doJavaScript && typeof (window["app"]).doJavaScript === 'function') { window["app"].doJavaScript(methodName, Base64.encode(JSON.stringify(methodParams))); } else { this.executeAppCallBack(key, Base64.encode(JSON.stringify({ success: false, message: "请在使用【创息浏览器内核】的客户端中调用原生功能!", data: null }))); } } else if (this.isIOS()) { let message = 'window.app.doJavaScript(' + methodName + ',' + Base64.encode(JSON.stringify(methodParams)) + ')'; alert(message); // IOS 使用alert触发程序中的事件,并过滤执行到客户端上的方法 } else { this.executeAppCallBack(key, Base64.encode(JSON.stringify({ success: false, message: "请在使用【创息浏览器内核】的客户端中调用原生功能!", data: null }))); } } catch (e) { console.error(e); this.executeAppCallBack(key, Base64.encode(JSON.stringify({ success: false, message: FastHelper_1.FastHelper.Events.geErrorInfo(e), data: null }))); } } /** * 手机原生方法回执时调用 * @param key 回调函数的唯一标识 * @param result 回调结果 */ static appCallBack(key, result) { this.doAppCallBack(window, key, result); } /** * 递归执行回调,针对同一个浏览器下嵌入iframe问题 * @param targetWindow 目标window * @param key * @param result * @private */ static doAppCallBack(targetWindow, key, result) { if (targetWindow["appJs"]) { targetWindow["appJs"].executeAppCallBack(key, result); } for (let i = 0; i < targetWindow.length; i++) { this.doAppCallBack(targetWindow[i], key, result); } } /** * 手机原生方法回执时调用 * @param key 回调函数的唯一标识 * @param result 回调结果 */ static executeAppCallBack(key, result) { let methodInfo = this.methodInfos[key.toString()]; if (methodInfo) { const Base64 = require("js-base64"); result = Base64.decode(result); const jsonData = JSON.parse(result); try { jsonData.success = FastHelper_1.FastHelper.Booleans.parse(jsonData.success); jsonData.data = jsonData.result; if (methodInfo.callBack && typeof methodInfo.callBack === 'function') { methodInfo.callBack(jsonData); } } catch (e) { console.error(e); if (methodInfo.callBack && typeof methodInfo.callBack === 'function') { methodInfo.callBack({ success: false, message: e.message, data: null }); } } finally { console.info("执行原生方法:", methodInfo.methodName, "方法参数:", methodInfo.methodParams, "执行结果:", jsonData); } } } /** * 手机原生方法执行错误时调用 * @param message 错误信息 */ static error(message) { alert('手机原生端发生错误:' + message); } /** * 可同步或异步执行手机客户端原生方法 * @param methodName 方法名称 * @param methodParams 方法参数,Array格式,按照原生方法的参数顺序设置 * @param callBack 回调函数 */ static async executeByPromise(methodName, methodParams, callBack) { return new Promise(function (resolved, rejected) { FastNative.Core.execute(methodName, methodParams, function (result) { if (callBack) { callBack(result); } resolved(result); }); }); } } FastNative.Core = Core; /** * BaseApp 创息公司封装的常用本地原生APP功能 */ class BaseApp extends Core { /** * 打开指定包名的APP * @param packageName APP的包名 * @param callBack 调用成功后的回调函数 */ static async openApp(packageName, callBack) { return FastNative.Core.executeByPromise("openApp", [packageName], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 打开系统浏览器 * @param url 地址 * @param callBack 调用成功后的回调函数 */ static async openSysBrowser(url, callBack) { return FastNative.Core.executeByPromise("openSysBrowser", [url], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 关闭手机输入键盘 * @param callBack 调用成功后的回调函数 */ static async closeKeyboard(callBack) { return FastNative.Core.executeByPromise("closeKeyboard", [], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 关闭浏览器窗口 * @param callBack 调用成功后的回调函数 */ static async closeWindow(callBack) { return FastNative.Core.executeByPromise("closeWindow", [], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 复制内容到剪贴板中 * @param content 复制的内容 * @param callBack 调用成功后的回调函数 */ static async copy(content, callBack) { return FastNative.Core.executeByPromise("copy", [content], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 下载文件,会弹出下载对话框并显示下载进度 * @param url 文件的网络地址 * @param fileName 文件名,主要用于区别文件的类型,所以建议传参 * @param doneAction 文件下载成功后,操作文件的方式,可选值:share(分享文件)、open(打开文件) * @param callBack 调用成功后的回调函数 */ static async downloadFile(url, fileName, doneAction, callBack) { return FastNative.Core.executeByPromise("downloadFile", [url, fileName, doneAction], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 获取APP的版本描述 * @param callBack 获取成功后的回调函数 */ static async getAppLevel(callBack) { return FastNative.Core.executeByPromise("getAppLevel", [], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } /** * 获取APP的安卓SDK版本号 * @param callBack 获取成功后的回调函数 */ static async getAndroidLevel(callBack) { return FastNative.Core.executeByPromise("getAndroidLevel", [], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } /** * 获取缓存在手机APP中的数据【async】 * @param cacheKey 缓存的Key * @param callBack 获取成功后的回调函数,函数结构:function(success:boolean,message:string,data:string){} */ static async getCache(cacheKey, callBack) { return FastNative.Core.executeByPromise("getCache", [cacheKey], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } /** * 获取手机APP状态栏的高度 * @param callBack 获取成功后的回调函数,函数结构:function(success:boolean,message:string,data:int){} */ static async getStatusHeight(callBack) { return FastNative.Core.executeByPromise("getStatusHeight", [], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } /** * 弹出全局等待框 * @param message 等待的消息 * @param callBack 调用成功后的回调函数 */ static async showLoadingDialog(message, callBack) { return FastNative.Core.executeByPromise("showLoadingDialog", [message], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 关闭全局等待框 * @param callBack 调用成功后的回调函数 */ static async hideLoadingDialog(callBack) { return FastNative.Core.executeByPromise("hideLoadingDialog", [], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 打开系统忽略APP电源设置 * @param callBack 调用成功后的回调函数 */ static async ignoredPower(callBack) { return FastNative.Core.executeByPromise("ignoredPower", [], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 打开APP的系统通知设置 * @param callBack 调用成功后的回调函数 */ static async notifySet(callBack) { return FastNative.Core.executeByPromise("notifySet", [], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 在新的窗口浏览器中打开链接地址 * @param url 链接地址 * @param closeSelf 打开新的窗口后是否关闭当前窗口 * @param callBack 调用成功后的回调函数 */ static async openBrowser(url, closeSelf, callBack) { return FastNative.Core.executeByPromise("openBrowser", [url, closeSelf.toString()], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 打开一个文件,如果是图片类型则调用图片浏览器打开,如果是mp4类型 则打开视频播放器,否则下载成功后打开文件 * @param url 文件地址 * @param fileName 文件名,主要用于区别文件的类型,所以建议传参 * @param callBack 调用成功后的回调函数 */ static async openFile(url, fileName, callBack) { return FastNative.Core.executeByPromise("openFile", [url, fileName], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 打开输入键盘 * @param callBack 调用成功后的回调函数 */ static async openKeyboard(callBack) { return FastNative.Core.executeByPromise("openKeyboard", [], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 打开淘宝的商品链接 * @param url 商品链接 * @param callBack 调用成功后的回调函数 */ static async openTaobaoA(url, callBack) { return FastNative.Core.executeByPromise("openTaobaoA", [url], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 打开淘宝的商家详情页链接 * @param sellerId 商家门店的ID * @param callBack 调用成功后的回调函数 */ static async openTaobaoB(sellerId, callBack) { return FastNative.Core.executeByPromise("openTaobaoB", [sellerId], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 打开淘宝的商品详情页面 * @param numIid 商品ID * @param callBack 调用成功后的回调函数 */ static async openTaobaoC(numIid, callBack) { return FastNative.Core.executeByPromise("openTaobaoC", [numIid], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 打开一个地址,如果地址是http开头则调用浏览器打开,否则调用第三方APP打开,例如:wx:// * @param url 地址 * @param callBack 调用成功后的回调函数 */ static async openUrl(url, callBack) { return FastNative.Core.executeByPromise("openUrl", [url], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 发送全局事件通知到APP原生代码中 * @param notifyName 事件名称 * @param callBack 调用成功后的回调函数 */ static async postNotify(notifyName, callBack) { return FastNative.Core.executeByPromise("postNotify", [notifyName], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 发送网页页面事件,此将会触发页面 {@link FastNative.CrosheInject.onEvent} 函数 * @param eventName 事件名称 * @param callBack 调用成功后的回调函数 */ static async postEvent(eventName, callBack) { return FastNative.Core.executeByPromise("postEvent", [eventName], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 删除缓存在APP中的数据 * @param key 缓存的标识 * @param callBack 调用成功后的回调函数 */ static async removeCache(key, callBack) { return FastNative.Core.executeByPromise("removeCache", [key], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 上报异常信息 * @param error 异常信息 * @param callBack 调用成功后的回调函数 */ static async reportBug(error, callBack) { return FastNative.Core.executeByPromise("reportBug", [error], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 保存图片到手机相册中 * @param url 图片地址 * @param callBack 调用成功后的回调函数 */ static async saveImage(url, callBack) { return FastNative.Core.executeByPromise("saveImage", [url], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 缓存数据到APP中 * @param key 缓存的key * @param data 缓存的数据 * @param callBack 调用成功后的回调函数 */ static async setCache(key, data, callBack) { return FastNative.Core.executeByPromise("setCache", [key, data], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 设置图片为剪切状态,一般在选择图片前调用 * @param crop 是否进行图片剪切 * @param callBack 调用成功后的回调函数 */ static async setCrop(crop, callBack) { return FastNative.Core.executeByPromise("setCrop", [crop.toString()], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 设置当前浏览器的图片集, * @param images 图片集,多个图片以 英文逗号(,)隔开,例如:http://12123/12.png,http://12123/124.png * @param callBack 调用成功后的回调函数 */ static async setImages(images, callBack) { return FastNative.Core.executeByPromise("setImages", [images], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 预设浏览器的标题 * @param title 标题 * @param callBack 调用成功后的回调函数 */ static async setWebTitle(title, callBack) { return FastNative.Core.executeByPromise("setWebTitle", [title], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 弹出提示消息 * @param message 消息内容 * @param callBack 调用成功后的回调函数 */ static async toast(message, callBack) { return FastNative.Core.executeByPromise("toast", [message], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 发起APP支付,命名使用中文规范,为了ios上架 * @param payType 支付类型 1 支付宝支付,2 微信支付 * @param orderPrefix 订单前缀,例如:PY * @param orderTitle 订单标题 * @param orderMoney 订单金额 * @param orderData 订单携带的额外数据 * @param callBack 支付完成回调, */ static async appZF(payType, orderPrefix, orderTitle, orderMoney, orderData, callBack) { if (payType === 1) { try { return NativeZF1(orderPrefix, orderTitle, orderMoney, orderData, callBack); } catch (e) { console.error(e); return new Promise(function (resolved, rejected) { resolved({ success: false, message: "暂不支持!" + e, data: null }); }); } } try { return NativeZF2(orderPrefix, orderTitle, orderMoney, orderData, callBack); } catch (e) { console.error(e); return new Promise(function (resolved, rejected) { resolved({ success: false, message: "暂不支持!" + e, data: null }); }); } } /** * 发起APP登录授权 * @param authorType 授权类型 1 只获取授权码 2 获取授权后的用户信息 * @param appType APP类型 1 支付宝授权,2 微信授权 * @param callBack 授权完成回调 * <br/> * 当授权类型为1时:回调授权码字符串 * <br/> * 当授权类型为2时:微信回调的JSON实体:{@link WXUserInfo},支付宝回调的JSON实体:{@link APUserInfo} */ static async appAuthor(authorType, appType, callBack) { if (appType === 1) { try { if (authorType === 1) { return NativeAuthorCode1(callBack); } else { return NativeAuthor1(callBack); } } catch (e) { console.error(e); return new Promise(function (resolved, rejected) { resolved({ success: false, message: "暂不支持!" + e, data: undefined }); }); } } try { if (authorType === 1) { return NativeAuthorCode2(callBack); } else { return NativeAuthor2(callBack); } } catch (e) { console.error(e); return new Promise(function (resolved, rejected) { resolved({ success: false, message: "暂不支持!" + e, data: undefined }); }); } } /** * 发起苹果支付 * @param productId 产品ID * @param orderPrefix 订单前缀,例如:PY * @param orderTitle 订单标题 * @param orderMoney 订单金额 * @param orderData 订单携带的额外数据 * @param callBack 支付完成回调, */ static async applePay(productId, orderPrefix, orderTitle, orderMoney, orderData, callBack) { return FastNative.Core.executeByPromise("applePay", [productId, orderPrefix, orderTitle, parseFloat(orderMoney.toString()).toFixed(2), orderData], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } /** * 发起分享 * @param url 分享网页地址 * @param title 分享标题 * @param content 分享的内容 * @param imgUrl 网页的缩率图地址 * @param type 分享类型,可选值有:1(微信朋友圈)、2(微信好友)、3(QQ好友)、4(QQ空间) * @param callBack 调用成功后的回调函数 */ static async shareUrl(url, title, content, imgUrl, type, callBack) { return FastNative.Core.executeByPromise("shareUrl", [title, imgUrl, url, type, content], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } /** * 获取当前手机定位 * @param callBack 调用成功后的回调函数 */ static async getLocation(callBack) { return FastNative.Core.executeByPromise("getLocation", [], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } /** * 打开地图选择位置 * @param callBack 调用成功后的回调函数 */ static async selectMap(callBack) { return FastNative.Core.executeByPromise("selectMap", [], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } /** * 在地图上查看位置 * @param lng 经度 * @param lat 纬度 * @param address 详细位置 * @param callBack 调用成功后的回调函数 */ static async showMap(lng, lat, address, callBack) { return FastNative.Core.executeByPromise("showMap", [address, lng, lat], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 开启地图导航 * @param lng 经度 * @param lat 纬度 * @param callBack 调用成功后的回调函数 */ static async startNav(lng, lat, callBack) { return FastNative.Core.executeByPromise("startNav", [lng, lat], function (result) { if (callBack) { callBack(result.success, result.message); } }); } /** * 获取APP配置的全局参数 * @param callBack 获取成功后的回调函数,函数结构:function(success:boolean,message:string,data:string){} */ static async getFinalParams(callBack) { return FastNative.Core.executeByPromise("getFinalParams", [], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } /** * 发起会话聊天 * @param code 会话编号 * @param type 聊天类型 0 单聊 1 群聊 * @param callBack 获取成功后的回调函数,函数结构:function(success:boolean,message:string,data:string){} */ static async chat(code, type, callBack) { return FastNative.Core.executeByPromise("chat", [code, type.toString()], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } /** * 获取聊天配置 * @param code 会话编号 * @param type 枚举值:top 是否置顶 mute 是否静音 * @param callBack */ static async getChatConfig(code, type, callBack) { return FastNative.Core.executeByPromise("getChatConfig", [code, type], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } /** * 设置聊天配置 * @param code 会话编号 * @param type 枚举值:top 是否置顶 mute 是否静音 clear 清除聊天记录 * @param value 配置的值,top和mute配置boolean值 * @param callBack */ static async chatConfig(code, type, value, callBack) { return FastNative.Core.executeByPromise("chatConfig", [code, type, value], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } /** * 发起扫描二维码 * @param callBack 调用成功后的回调函数 */ static async startScanner(callBack) { return FastNative.Core.executeByPromise("startScanner", [], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } /** * 进入发送短信界面 * @param phone 手机号码,多个使用分号(;)分割 * @param content 短信内容 * @param callBack 调用成功后的回调函数 */ static async sendSMS(phone, content, callBack) { return FastNative.Core.executeByPromise("sendSMS", [phone, content], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } /** * 获取本地通讯录数据 * @param callBack 调用成功后的回调函数 */ static async getLocalContact(callBack) { return FastNative.Core.executeByPromise("getLocalContact", [], function (result) { if (callBack) { callBack(result.success, result.message, result.data); } }); } } FastNative.BaseApp = BaseApp; /** * CrosheApp 创息公司APP常用的功能JS调用 */ class CrosheApp extends BaseApp { /** * 判断是否在创息内置安卓浏览器,注意此方法必须在页面加载完毕后判断更准确 */ static isCrosheAndroid() { if (FastNative.Core.isAndroid() && (window["app"]) && (window["app"]).doJavaScript) { if (typeof (window["app"]).doJavaScript === 'function') { return true; } } return false; } /** * 判断是否在创息内置的ios浏览器,注意此方法必须在页面加载完毕后判断更准确 */ static isCrosheIOS() { if (FastNative.Core.isIOS()) { if (FastHelper_1.FastHelper.Booleans.parse(window["fromCroshe"], false)) { return true; } } return false; } /** * 查看图片 * @param url 图片地址 * @param imageList 图片所在的集合 */ static async showImages(url, imageList) { if (imageList) { await this.setImages(imageList.join(",")); } window.location.href = url + "@image"; } /** * 选择图片 * @param crop 是否进行剪裁 * @param multi 是否批量选择图片 * @param callBack 回调函数 */ static async selectImage(crop, multi, callBack) { await FastNative.BaseApp.setCrop(crop); if (FastNative.Core.isIOS()) { crop = FastHelper_1.FastHelper.Booleans.parse(crop, false); multi = FastHelper_1.FastHelper.Booleans.parse(multi, false); FastNative.Core.execute("selectImage", [crop.toString(), multi.toString()], function (result) { if (callBack) { callBack(result.data); } }); } else { let inputElement = document.createElement('input'); let event = new MouseEvent('click'); inputElement.type = "file"; inputElement.accept = "image/*"; if (multi) { inputElement.multiple = true; } inputElement.onchange = function (selectEvent) { if (selectEvent.target) { let target = selectEvent.target; for (let i = 0; i < target.files.length; i++) { const file = target.files.item(i); const fileReader = new FileReader(); fileReader.onload = function (readEvent) { let base64 = readEvent.target.result; if (callBack) { callBack(base64); } }; fileReader.readAsDataURL(file); } } }; inputElement.dispatchEvent(event); } } /** * 弹出评论框 * @param hint 提示语 * @param callBack 回调函数 */ static showComment(hint, callBack) { if (FastHelper_1.FastHelper.Strings.isEmpty(hint)) { hint = "请输入内容"; } FastNative.Core.execute("showComment", [hint], function (result) { if (result.success) { if (callBack) { callBack(result.data); } } else if (!FastNative.CrosheApp.isCrosheAndroid()) { let result = window.prompt(hint); if (callBack && result) { callBack(result); } } }); } /** * 检查APP版本更新 */ static checkLevel() { FastNative.Core.execute("checkLevel", [], function (result) { }); } /** * 退出APP登录 */ static logout() { FastNative.Core.execute("logout", [], function (result) { }); } /** * 清除APP文件缓存 */ static clearCache() { FastNative.Core.execute("clearCache", [], function (result) { }); } } FastNative.CrosheApp = CrosheApp; /** * CrosheInject 由原生调用本地JS页面的方法,【重要:方法的作用域必须是window ,否则无法APP原生代码无法调用】 */ class CrosheInject { } FastNative.CrosheInject = CrosheInject; /** * LocationInfo 获取定位返回的实体信息 */ class LocationInfo { /** * 纬度 */ latitude = 0; /** * 经度 */ longitude = 0; /** * 详情位置 */ address = ""; /** * 省份 */ province = ""; /** * 城市 */ city = ""; /** * 区 */ area = ""; } FastNative.LocationInfo = LocationInfo; /** * AnyInfo 不可预测的实体信息,请根据实际返回数据为准 */ class AnyInfo { } FastNative.AnyInfo = AnyInfo; /** * ContactInfo 通讯录实体信息 */ class ContactInfo { /** * 通讯录唯一标识ID */ contactId; /** * 姓名 */ contactName; /** * 手机号码 */ contactPhone; /** * 姓名的拼音字母 */ allLetter; /** * 通讯录排序的首字母 */ sortKey; } FastNative.ContactInfo = ContactInfo; /** * 微信授权返回的实体信息 */ class WXUserInfo { /** * 普通用户的标识,对当前开发者帐号唯一 */ openid; /** * 普通用户昵称 */ nickname; /** * 普通用户性别,1为男性,2为女性 */ sex; /** * 使用语言 */ language; /** * 所在城市 */ city; /** * 所在省份 */ province; /** * 所在国家 */ country; /** * 用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空 */ headimgurl; /** * 用户统一标识。针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的。 */ unionid; /** * 用户特权信息,json数组,如微信沃卡用户为(chinaunicom) */ privilege; } FastNative.WXUserInfo = WXUserInfo; /** * 支付宝用户实体信息 */ class APUserInfo { /** * 用户头像地址 */ avatar; /** * 所在城市 */ city; /** * 性别。枚举值如下:F:女性;M:男性。 */ gender; /** * 用户昵称 */ nick_name; /** * 所在省份 */ province; /** * 支付宝用户的userId */ user_id; } FastNative.APUserInfo = APUserInfo; //兼容老版本 window["FastNative"] = FastNative; window["appJs"] = FastNative.Core; FastHelper_1.FastHelper.Windows.addFunction("onEvent", function (eventName) { console.log("接收到页面事件:" + eventName, ",如果需要处理事件,请在页面作用域window中定义onEven函数接受事件!"); if (eventName === "onPageFinished") { window["fromCroshe"] = true; } }); })(FastNative = exports.FastNative || (exports.FastNative = {}));