diff --git a/.editorconfig b/.editorconfig index e609180..677def9 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,16 +6,16 @@ insert_final_newline = true charset = utf-8 trim_trailing_whitespace = true -[*.{js,jsx,css,less,scss}] -indent_style = tab -tab_width = 2 -trim_trailing_whitespace = true - -[*.{html,hbr,rt,sass}] +[*.{js,jsx,ts,tsx}] indent_style = space indent_size = 2 trim_trailing_whitespace = true +[*.{html,hbr,rt,css,less,scss}] +indent_style = tab +tab_width = 2 +trim_trailing_whitespace = true + [*.json] indent_style = space indent_size = 2 diff --git a/.eslintrc b/.eslintrc index f63df92..bd3e044 100644 --- a/.eslintrc +++ b/.eslintrc @@ -30,7 +30,7 @@ "comma-dangle": 0, "indent": [ 2, - "tab", + 2, { "SwitchCase": 1 } @@ -78,20 +78,11 @@ "spaced-comment": 0 }, "globals": { - "__DEV__": true, - "__WECHAT__": true, - "__ALIPAY__": true, "App": true, "Page": true, "Component": true, "wx": true, + "getCurrentPages": true, "getApp": true - }, - "settings": { - "import/resolver": { - "webpack": { - "config": "build/webpack.config.babel.js" - } - } } } diff --git a/.stylelintrc b/.stylelintrc index b733d8b..5ea5608 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -15,9 +15,12 @@ "scss/operator-no-newline-before": true, "scss/operator-no-unspaced": true, "scss/selector-no-redundant-nesting-selector": true, + "no-descending-specificity": null, "no-empty-source": true, "selector-list-comma-newline-after": "always-multi-line", - "indentation": "tab", + "indentation": [ + "tab" + ], "at-rule-no-unknown": [ true, { @@ -27,7 +30,8 @@ "include", "if", "else", - "function" + "function", + "each" ] } ], @@ -48,7 +52,8 @@ "picker", "image", "open-data", - "scroll-view" + "scroll-view", + "icon" ] } ] diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..3397c9a --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-architect \ No newline at end of file diff --git a/build/devServer.js b/build/devServer.js deleted file mode 100644 index e38da0c..0000000 --- a/build/devServer.js +++ /dev/null @@ -1,22 +0,0 @@ -const config = require('../config'); - -if (!process.env.NODE_ENV) { - process.env.ENV = JSON.parse(config.dev.env.ENV); -} -const webpack = require('webpack'); -const webpackConfig = require('./webpack.dev'); - -const compiler = webpack(webpackConfig); -const chalk = require('chalk'); - -console.log(chalk.green('> Starting dev compiler...')); - -require('webpack-dev-middleware-hard-disk')(compiler, { - publicPath: webpackConfig.output.publicPath, - quiet: true, - watchOptions: { - ignored: /dist|manifest/, - aggregateTimeout: 300, - poll: true - }, -}); diff --git a/build/utils.js b/build/utils.js deleted file mode 100644 index af02f2e..0000000 --- a/build/utils.js +++ /dev/null @@ -1,13 +0,0 @@ -const path = require('path'); -const config = require('../config'); - -exports.assetsPath = function (_path) { - const assetsSubDirectory = process.env.NODE_ENV === 'production' ? - config.build.assetsSubDirectory : - config.dev.assetsSubDirectory; - return path.posix.join(assetsSubDirectory, _path); -}; - -exports.resolve = function (dir) { - return path.join(__dirname, '../', dir); -} diff --git a/build/webpack.base.js b/build/webpack.base.js deleted file mode 100644 index f57b42a..0000000 --- a/build/webpack.base.js +++ /dev/null @@ -1,108 +0,0 @@ -const StylelintWebpackPlugin = require('stylelint-webpack-plugin'); -const MiniProgramWebpackPlugin = require('miniprogram-webpack-plugin'); -const CopyWebpackPlugin = require('copy-webpack-plugin'); -const webpack = require('webpack'); -const path = require('path'); -const utils = require('./utils'); -const config = require('../config'); - -const srcDir = utils.resolve(path.parse(config.entry).dir); - -module.exports = { - entry: { - app: utils.resolve(config.entry) - }, - output: { - filename: '[name].js', - path: utils.resolve('dist') - }, - //must not be eval - devtool: 'none', - resolve: { - extensions: ['.js', '.ts'], - modules: [srcDir, 'node_modules'], - alias: Object.assign({}, config.alias, { - '@': srcDir, - }), - symlinks: false - }, - module: { - rules: [ - { - test: /\.js$/, - exclude: /node_modules/, - use: [ - { - loader: 'babel-loader', - options: { - cacheDirectory: true - } - }, - { - loader: 'eslint-loader' - } - ] - }, - { - test: /\.ts$/, - exclude: /node_modules/, - use: [ - { - loader: 'ts-loader' - }, - { - loader: 'tslint-loader' - } - ] - }, - { - test: /\.(sa|sc|c|le)ss$/, - exclude: /node_modules/, - use: [ - { - loader: 'file-loader', - options: { - useRelativePath: true, - name: `[name].wxss`, - context: srcDir, - }, - }, - { - loader: 'postcss-loader' - }, - { - loader: 'sass-loader' - } - ], - }, - { - test: /\.(wxss|wxs|wxml|json)\??.*$/, - type: 'javascript/auto', - loader: 'url-loader' - }, - { - test: /\.(woff|woff2|eot|ttf|svg|png|gif|jpeg|jpg)\??.*$/, - loader: 'url-loader', - query: { - limit: 50000, - name: utils.assetsPath('image/[name].[ext]') - } - } - ] - }, - - plugins: [ - new CopyWebpackPlugin( - [{ - from: './', - to: './' - }], { - ignore: ['*.js', '*.css', '*.ts', '*.scss', '*.less', '*.sass', '*.wxss', '.wxml'], - context: srcDir, - } - ), - new MiniProgramWebpackPlugin(), - new webpack.optimize.ModuleConcatenationPlugin(), - new StylelintWebpackPlugin() - ] -}; diff --git a/build/webpack.dev.js b/build/webpack.dev.js deleted file mode 100644 index bf9042d..0000000 --- a/build/webpack.dev.js +++ /dev/null @@ -1,19 +0,0 @@ -const config = require('../config'); -const merge = require('webpack-merge'); -const common = require('./webpack.base'); -const webpack = require('webpack'); -const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin'); - -module.exports = merge(common, - { - mode: 'development', - devtool: 'inline-source-map', - plugins: [ - new webpack.DefinePlugin({ - 'process.env': config.dev.env - }), - new webpack.NoEmitOnErrorsPlugin(), - new FriendlyErrorsPlugin() - ] - } -); diff --git a/build/webpack.pro.js b/build/webpack.pro.js deleted file mode 100644 index 12317ce..0000000 --- a/build/webpack.pro.js +++ /dev/null @@ -1,35 +0,0 @@ -const config = require('../config'); -const webpack = require('webpack'); -const merge = require('webpack-merge'); -const common = require('./webpack.base'); -const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); -const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin'); - -module.exports = merge(common, - { - mode: 'production', - devtool: 'source-map', - optimization: { - minimizer: [ - new UglifyJsPlugin({ - cache: true, - parallel: true, - sourceMap: true // set to true if you want JS source maps - }), - new OptimizeCSSAssetsPlugin({ - assetNameRegExp: /\.wxss\.*(?!.*map)/g, - cssProcessorOptions: { - discardComments: { removeAll: true }, - safe: true, - autoprefixer: true - }, - }) - ] - }, - plugins: [ - new webpack.DefinePlugin({ - 'process.env': config.build.env - }) - ] - } -); diff --git a/config/dev.env.js b/config/dev.env.js index a453709..6de2bf8 100644 --- a/config/dev.env.js +++ b/config/dev.env.js @@ -1,7 +1,4 @@ -const merge = require('webpack-merge'); -const prodEnv = require('./prod.env'); - -module.exports = merge(prodEnv, { +module.exports = { ENV: '"development"', - BASE_API: "'http://localhost:8081'" -}); + BASE_API: "'https://your host'" +}; diff --git a/config/index.js b/config/index.js index bb2f55f..5a67659 100644 --- a/config/index.js +++ b/config/index.js @@ -1,20 +1,16 @@ -const path = require('path'); - module.exports = { - entry: 'src/app.ts', - alias: { - 'style': resolve('src/styles/index.scss') - }, - build: { - env: require('./prod.env'), - assetsSubDirectory: 'static', - }, - dev: { - env: require('./dev.env'), - assetsSubDirectory: 'static', - } -}; - -function resolve(dir) { - return path.join(__dirname, '../', dir); + entry: 'src/app.ts', + alias: { + 'style': 'src/styles/index.scss', + '@S': 'src/services', + '@T': 'src/utils', + '@C': 'src/config', + '@L': 'src/libs' + }, + build: { + env: require('./prod.env') + }, + dev: { + env: require('./dev.env') + } }; diff --git a/config/prod.env.js b/config/prod.env.js index 64d1d09..04c939f 100644 --- a/config/prod.env.js +++ b/config/prod.env.js @@ -1,4 +1,4 @@ module.exports = { ENV: '"production"', - BASE_API: "'http://localhost:8081'" + BASE_API: "'https://your host'" }; diff --git a/package.json b/package.json index 6a5a1e2..09feac1 100644 --- a/package.json +++ b/package.json @@ -1,61 +1,54 @@ { "name": "quickstart-miniprogram", - "version": "0.0.0", - "description": "", + "version": "0.0.1", + "description": "微信小程序模板", "license": "ISC", - "author": "", "main": "index.js", "scripts": { - "build": "npx webpack --process --config ./build/webpack.pro.js", - "build:dev": "npx webpack --process --model=develop --config ./build/webpack.dev.js", + "build": "mpc build", + "start": "mpc serve", + "dev:prod": "cross-env CONF=build mpc serve", + "build:dev": "cross-env CONF=dev GENERATE_SOURCEMAP=false mpc build", + "lint:scss": "stylelint --fix src/**/*.scss", "sort": "npx sort-package-json", - "start": "node ./build/devServer.js", "test": "echo \"Error: no test specified\" && exit 1" }, + "author": "fupengl", + "repository": "fupengl/quickstart-miniprogram", "dependencies": { "miniprogram-navigation-bar": "0.0.4", "miniprogram-recycle-view": "0.0.6", - "miniprogram-slide-view": "0.0.3" + "miniprogram-slide-view": "0.0.3", + "wapp-cli": "^0.0.71" }, "devDependencies": { - "@babel/cli": "^7.0.0", - "@babel/core": "^7.0.0", - "@babel/plugin-proposal-class-properties": "^7.0.0", - "@babel/plugin-proposal-decorators": "^7.0.0", - "@babel/plugin-proposal-do-expressions": "^7.0.0", - "@babel/plugin-proposal-export-default-from": "^7.0.0", - "@babel/plugin-proposal-export-namespace-from": "^7.0.0", - "@babel/plugin-proposal-function-bind": "^7.0.0", - "@babel/plugin-proposal-function-sent": "^7.0.0", - "@babel/plugin-proposal-json-strings": "^7.0.0", - "@babel/plugin-proposal-logical-assignment-operators": "^7.0.0", - "@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0", - "@babel/plugin-proposal-numeric-separator": "^7.0.0", - "@babel/plugin-proposal-optional-chaining": "^7.0.0", - "@babel/plugin-proposal-pipeline-operator": "^7.0.0", - "@babel/plugin-proposal-throw-expressions": "^7.0.0", - "@babel/plugin-syntax-dynamic-import": "^7.0.0", - "@babel/plugin-syntax-import-meta": "^7.0.0", - "@babel/plugin-transform-destructuring": "^7.0.0", - "@babel/plugin-transform-modules-commonjs": "^7.0.0", - "@babel/plugin-transform-parameters": "^7.0.0", - "@babel/plugin-transform-runtime": "^7.1.0", - "@babel/plugin-transform-spread": "^7.0.0", - "@babel/preset-env": "^7.1.0", - "@babel/register": "^7.0.0", - "@babel/runtime": "^7.0.0", - "@types/lodash": "^4.14.116", - "@types/weixin-app": "^2.2.11", - "babel-eslint": "^10.0.1", - "babel-loader": "^8.0.0", - "babel-plugin-lodash": "^3.3.4", + "@babel/plugin-proposal-class-properties": "^7.3.0", + "@babel/plugin-proposal-decorators": "^7.3.0", + "@babel/plugin-proposal-do-expressions": "^7.2.0", + "@babel/plugin-proposal-export-default-from": "^7.2.0", + "@babel/plugin-proposal-export-namespace-from": "^7.2.0", + "@babel/plugin-proposal-function-bind": "^7.2.0", + "@babel/plugin-proposal-function-sent": "^7.2.0", + "@babel/plugin-proposal-json-strings": "^7.2.0", + "@babel/plugin-proposal-logical-assignment-operators": "^7.2.0", + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.2.0", + "@babel/plugin-proposal-numeric-separator": "^7.2.0", + "@babel/plugin-proposal-optional-chaining": "^7.2.0", + "@babel/plugin-proposal-pipeline-operator": "^7.3.2", + "@babel/plugin-proposal-throw-expressions": "^7.2.0", + "@babel/plugin-syntax-dynamic-import": "^7.2.0", + "@babel/plugin-syntax-import-meta": "^7.2.0", + "@babel/plugin-transform-async-to-generator": "^7.2.0", + "@babel/plugin-transform-destructuring": "^7.3.2", + "@babel/plugin-transform-modules-commonjs": "^7.2.0", + "@babel/plugin-transform-parameters": "^7.2.0", + "@babel/plugin-transform-runtime": "^7.2.0", + "@babel/plugin-transform-spread": "^7.2.2", + "@babel/preset-env": "^7.3.1", + "babel-loader": "^8.0.5", "babel-plugin-transform-function-bind": "^6.22.0", - "bx-wxapp-npm-plugin": "^1.0.1", - "bx-wxapp-ts-decorator": "^1.0.3bx", - "chalk": "^2.4.1", - "clean-webpack-plugin": "^0.1.19", - "copy-webpack-plugin": "^4.5.2", - "css-loader": "^1.0.1", + "babel-eslint": "^10.0.1", + "cross-env": "^5.2.0", "eslint": "^5.8.0", "eslint-config-standard": "^12.0.0", "eslint-loader": "^2.1.1", @@ -63,37 +56,13 @@ "eslint-plugin-node": "^8.0.0", "eslint-plugin-promise": "^4.0.1", "eslint-plugin-standard": "^4.0.0", - "file-loader": "^1.1.11", - "friendly-errors-webpack-plugin": "^1.7.0", - "less": "^3.8.1", - "less-loader": "^4.1.0", - "lodash-webpack-plugin": "^0.11.5", - "node-sass": "^4.9.3", - "optimize-css-assets-webpack-plugin": "^5.0.1", "postcss-load-plugins": "^2.3.0", - "postcss-loader": "^3.0.0", "postcss-plugin": "^1.0.0", "postcss-preset-env": "^6.3.0", - "precss": "^3.1.2", - "sass-loader": "^7.1.0", - "style-loader": "^0.22.1", "stylelint": "^9.7.1", "stylelint-config-standard": "^18.2.0", "stylelint-scss": "^3.3.2", - "stylelint-webpack-plugin": "^0.10.5", - "transform-runtime": "0.0.0", - "ts-loader": "^5.3.0", - "tslint": "^5.11.0", - "tslint-config-prettier": "^1.15.0", - "tslint-loader": "^3.5.4", - "typescript": "^3.1.6", - "uglifyjs-webpack-plugin": "^1.3.0", - "url-loader": "^1.1.1", - "webpack": "^4.16.5", - "webpack-cli": "^3.1.0", - "webpack-dev-middleware-hard-disk": "^1.12.1", - "webpack-merge": "^4.1.4", - "miniprogram-webpack-plugin": "^0.0.8" + "tslint": "^5.11.0" }, "engines": { "node": ">= 4.0.0", diff --git a/project.config.json b/project.config.json index e2692f9..e2d24fe 100644 --- a/project.config.json +++ b/project.config.json @@ -10,7 +10,9 @@ "miniprogramRoot": "dist/", "compileType": "miniprogram", "appid": "wxe8440a52dab9bd67", - "projectname": "webpack-wxapp", + "projectname": "quickstart-miniprogram", + "simulatorType": "wechat", + "simulatorPluginLibVersion": {}, "condition": { "search": { "current": -1, @@ -29,8 +31,20 @@ "list": [] }, "miniprogram": { - "current": -1, - "list": [] + "current": 1, + "list": [ + { + "id": -1, + "name": "index", + "pathName": "pages/index/index", + "query": "" + }, + { + "id": -1, + "name": "logs", + "pathName": "pages/logs/logs" + } + ] } } } \ No newline at end of file diff --git a/readme.md b/readme.md index db360c8..e2fa76f 100644 --- a/readme.md +++ b/readme.md @@ -4,6 +4,3 @@ 2.支持引入微信小程序NPM组件包(无需官方npm的支持) 3.完全原汁原味的小程序开发,没有引入其他的语法 - -4.扩展能力强,可以继续加入其他的webpack插件和loader - diff --git a/src/app.d.ts b/src/app.d.ts new file mode 100644 index 0000000..d36b373 --- /dev/null +++ b/src/app.d.ts @@ -0,0 +1,22 @@ +/// + +declare interface requestLock { + status: boolean; + request: Promise | null, + count: number, +} + +declare interface IApp extends App.GetApp { + logger + state + wxApi: wxApi + + request_id: number + requestLock: requestLock + + dispatch(action: string, params?: any) + commit(action: string, params?: any) + getter(action: string, params?: any) +} + +declare function getApp(): IApp; diff --git a/src/app.json b/src/app.json index dc54f12..f17141d 100755 --- a/src/app.json +++ b/src/app.json @@ -3,19 +3,10 @@ "pages/index/index", "pages/logs/logs" ], - "subpackages": [ - { - "root": "pages/article", - "pages": [ - "articleList/articleList", - "articleInfo/articleInfo" - ] - } - ], "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#fff", "navigationBarTitleText": "Wechat", "navigationBarTextStyle": "black" } -} \ No newline at end of file +} diff --git a/src/app.ts b/src/app.ts index fa7ebcb..c6dd16a 100755 --- a/src/app.ts +++ b/src/app.ts @@ -1,31 +1,30 @@ -import Conf from '@/config'; -import { createLogger, ILoggerOptions, initAppHandel } from '@/libs/log'; -import Store, { createStore } from '@/store'; -import WxApi, { promisify } from '@/utils/wxApi'; +import Conf from '@/config/index'; +import { createWxApi } from '@/libs/wx/api/index'; +import { createLogger } from '@/libs/wx/log/index'; +import { createStore } from '@/libs/wx/store/index'; +import store from '@/store/index'; -// dispatch request lock -const requestLock: { - status: boolean; - request: Promise | null, - count: number, -} = { - status: false, // lock status - request: null, // request method - count: 0, // current locking request count (resolve concurrent lock problem) -}; - -initAppHandel(); -App(Object.assign({ - requestLock, - async onLaunch(options) { - // init wx promise api mount wx.Promise - promisify.call(this); - // init store - createStore.call(this); - // init log - createLogger.call(this, { - wxAppid: Conf.APP.config.wxAppId, - version: Conf.APP.version - } as ILoggerOptions); +App({ + requestLock: { + status: false, + request: null, + count: 0 + }, + async onLaunch(options) { + try { + // mount wxApi in getApp().wxApi + createWxApi.call(this, Conf.THEME); + // mount store in getApp().$state + createStore.call(this, store); + // mount logger in getApp().logger + createLogger.call(this, { + wxAppid: Conf.APP.config.wxAppId, + version: Conf.APP.version + }); + // check network status + await this.dispatch('detectNetwork'); + } catch (error) { + console.log(error); } -}, Store, WxApi)); + } +}); diff --git a/src/config/API/account.ts b/src/config/API/account.ts new file mode 100644 index 0000000..ba41446 --- /dev/null +++ b/src/config/API/account.ts @@ -0,0 +1,8 @@ + +export default { + Login: { + url: 'account/public/miniappLogin', + method: 'post', + isAuth: false + } +} as IApi.module; diff --git a/src/config/API/api.d.ts b/src/config/API/api.d.ts new file mode 100644 index 0000000..aec288c --- /dev/null +++ b/src/config/API/api.d.ts @@ -0,0 +1,20 @@ +declare namespace IApi { + + interface api { + url: string; + method: 'get' | 'post' | 'delete' | 'put'; + isAuth?: boolean; // add session_id + isJson?: boolean; // json or formdata + isFile?: boolean; // multipart file + headers?: object; // default header + } + + interface module { + [funcName: string]: api + } + + interface modules { + [moduleName: string]: module; + } + +} \ No newline at end of file diff --git a/src/config/api.ts b/src/config/api.ts deleted file mode 100755 index 1c1b704..0000000 --- a/src/config/api.ts +++ /dev/null @@ -1,41 +0,0 @@ -interface IApiModule { - [moduleName: string]: { - [action: string]: { - url: string; - type: 'post' | 'get' | 'put' | 'delete'; - isAuth?: boolean, // check login status - hasLoading?: boolean, // loading modal - isLock?: boolean, - headers?: object // default headers - } - }; -} - -const api: IApiModule = { - Account: { - Login: { - url: 'account/public/miniappLogin', - type: 'post', - isAuth: false, - isLock: true - }, - GetUserInfo: { - url: 'account/user/{pin_uid}/miniappGetUserInfo', - type: 'post' - }, - CustomerLogin: { - url: 'spread/user/{pin_uid}/customers/login', - type: 'get' - } - } -}; - -export const file: any = { - upload: { - prefix: 'https://kolrank.cdn.pinquest.cn/', - url: 'https://app.pinquest.cn/', - key: 'file' - }, -}; - -export default api; diff --git a/src/config/app.ts b/src/config/app.ts index 85815ac..64778ea 100755 --- a/src/config/app.ts +++ b/src/config/app.ts @@ -1,23 +1,18 @@ -interface IEnvironmentMode { - ENV: string; - BASE_API: number; - APP_ID: string; -} interface IConfig { - wxAppId: string; + wxAppId: string; } -// app version -const version: string = '1.0.0'; - +// app custom config const config: IConfig = { - wxAppId: 'wx app id' + wxAppId: wx.getAccountInfoSync().miniProgram.appId }; +// app version +const version: string = 'quickstart-miniprogram-1.0.0'; + function getCurrentConfig(): IConfig & IEnvironmentMode { - // @ts-ignore - return Object.assign({}, config, process.env as IEnvironmentMode); + return Object.assign({}, config, process.env); } const currentConfig = getCurrentConfig(); @@ -26,7 +21,7 @@ console.warn('App Config', currentConfig); const isProd = currentConfig.ENV === 'production'; export default { - version, - isProd, - config: currentConfig, + version, + isProd, + config: currentConfig, }; diff --git a/src/config/route.ts b/src/config/route.ts index e058d31..6a47b12 100755 --- a/src/config/route.ts +++ b/src/config/route.ts @@ -1,39 +1,45 @@ -// app path config map -const config: IRouteModule = { - INDEX: { - url: 'index' - }, - LOG: { - url: 'log' - } -}; -interface IRouteModule { - [moduleName: string]: { - url: string; - }; +declare interface IRouteModule { + [moduleName: string]: { + url: string; + }; } +// app pages config map +const pageRoutes: IRouteModule = { + INDEX: { + url: 'index' + }, + LOGS: { + url: 'logs' + } +}; + /** * 根据 pagename 自动补全路径 * (文件命名规则为 /pages/pagename/pagename.[ts/scss/json/wxml]) */ -function prefixRouter(routesConf: IRouteModule): IRouteModule { - const res: IRouteModule = {}; +function prefixRouter(rootName: string, routesConf: IRouteModule): IRouteModule { + const res: IRouteModule = {}; - for (const route in routesConf) { - const url = routesConf[route].url; - const temp = url.split('/'); + for (const route in routesConf) { + const url = routesConf[route].url; + const temp = url.split('/').filter(v => v); - if (temp[0] === 'pages') { - res[route] = routesConf[route]; - } else { - res[route] = { - url: `/pages/${url}/${temp[temp.length - 1]}` - }; - } + if (url[0] === '/' || temp[0] === rootName) { + res[route] = routesConf[route]; + } else { + res[route] = { + url: `/${rootName}/${url}/${temp[temp.length - 1]}` + }; } - return res; + } + return res; } -export default prefixRouter(config); +const routeConf = { + ...prefixRouter('pages', pageRoutes) +}; +console.warn('Route Config ', routeConf); + +export default routeConf; diff --git a/src/config/theme.ts b/src/config/theme.ts index 89da71c..649f2d5 100755 --- a/src/config/theme.ts +++ b/src/config/theme.ts @@ -1,5 +1,6 @@ export default { - disabledColor: '#394256', - mainColor: '#2384E8', - toastDuration: 2000 + cancelColor: '#394256', + confirmColor: '#2384E8', + toastDuration: 2000, + toastMask: true }; diff --git a/src/config/typing/API.d.ts b/src/config/typing/API.d.ts new file mode 100644 index 0000000..c30b13c --- /dev/null +++ b/src/config/typing/API.d.ts @@ -0,0 +1,10 @@ +declare interface IApiModule { + [action: string]: { + url: string; + type: 'post' | 'get' | 'put' | 'delete'; + isAuth?: boolean, // check login status + hasLoading?: boolean, // loading modal + isLock?: boolean, + headers?: object // default headers + }; +} diff --git a/src/config/typing/process.d.ts b/src/config/typing/process.d.ts new file mode 100644 index 0000000..1e1f225 --- /dev/null +++ b/src/config/typing/process.d.ts @@ -0,0 +1,12 @@ +/** + * process webpack环境变量 + */ +declare interface IEnvironmentMode { + ENV: 'production' | 'development'; + BASE_API: string; + APP_ID: number; +} + +declare var process: { + env: IEnvironmentMode +}; diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 0000000..3e6bf6b --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1 @@ +/// diff --git a/src/libs/base64.d.ts b/src/libs/base64.d.ts new file mode 100644 index 0000000..63c8592 --- /dev/null +++ b/src/libs/base64.d.ts @@ -0,0 +1,4 @@ +declare class Base64 { + encode(str: string): string + decode(base64: string): string +} diff --git a/src/libs/base64.js b/src/libs/base64.js new file mode 100755 index 0000000..e2ec5ec --- /dev/null +++ b/src/libs/base64.js @@ -0,0 +1,125 @@ +export default class Base64 { + // private property + _keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' + + // method for encoding + encode(input) { + let output = ''; + let chr1, chr2, chr3, enc1, enc2, enc3, enc4; + let i = 0; + input = Base64._utf8_encode(input); + + while (i < input.length) { + + chr1 = input.charCodeAt(i++); + chr2 = input.charCodeAt(i++); + chr3 = input.charCodeAt(i++); + + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + + if (isNaN(chr2)) { + enc3 = enc4 = 64; + } else if (isNaN(chr3)) { + enc4 = 64; + } + output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); + } + + return output; + } + + // method for decoding + decode(input) { + let output = ''; + let chr1, chr2, chr3; + let enc1, enc2, enc3, enc4; + let i = 0; + + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ''); + + while (i < input.length) { + + enc1 = this._keyStr.indexOf(input.charAt(i++)); + enc2 = this._keyStr.indexOf(input.charAt(i++)); + enc3 = this._keyStr.indexOf(input.charAt(i++)); + enc4 = this._keyStr.indexOf(input.charAt(i++)); + + chr1 = (enc1 << 2) | (enc2 >> 4); + chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); + chr3 = ((enc3 & 3) << 6) | enc4; + + output = output + String.fromCharCode(chr1); + + if (enc3 !== 64) { + output = output + String.fromCharCode(chr2); + } + if (enc4 !== 64) { + output = output + String.fromCharCode(chr3); + } + + } + + output = Base64._utf8_decode(output); + + return output; + } + + // method for UTF-8 encoding + static _utf8_encode(string) { + string = string.replace(/\r\n/g, '\n'); + let utftext = ''; + + for (let n = 0; n < string.length; n++) { + + const c = string.charCodeAt(n); + + if (c < 128) { + utftext += String.fromCharCode(c); + } else if ((c > 127) && (c < 2048)) { + utftext += String.fromCharCode((c >> 6) | 192); + utftext += String.fromCharCode((c & 63) | 128); + } else { + utftext += String.fromCharCode((c >> 12) | 224); + utftext += String.fromCharCode(((c >> 6) & 63) | 128); + utftext += String.fromCharCode((c & 63) | 128); + } + + } + + return utftext; + } + + // method for UTF-8 decoding + static _utf8_decode(utftext) { + let string = ''; + let i = 0; + let c = 0; + const c1 = 0; + let c2 = 0; + + while (i < utftext.length) { + + c = utftext.charCodeAt(i); + + if (c < 128) { + string += String.fromCharCode(c); + i++; + } else if ((c > 191) && (c < 224)) { + c2 = utftext.charCodeAt(i + 1); + string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); + i += 2; + } else { + c2 = utftext.charCodeAt(i + 1); + c3 = utftext.charCodeAt(i + 2); + string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); + i += 3; + } + + } + + return string; + } +} diff --git a/src/libs/base64.ts b/src/libs/base64.ts deleted file mode 100755 index 1501cf0..0000000 --- a/src/libs/base64.ts +++ /dev/null @@ -1,89 +0,0 @@ -export function base64Encode(str: string) { // need encodeURIComponent - str = encodeURIComponent(str); - let c1: number; - let c2: number; - let c3: number; - const base64EncodeChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; - let i = 0; - const len = str.length; - let strin = ''; - while (i < len) { - c1 = str.charCodeAt(i++) & 0xff; - if (i === len) { - strin += base64EncodeChars.charAt(c1 >> 2); - strin += base64EncodeChars.charAt((c1 & 0x3) << 4); - strin += '=='; - break; - } - c2 = str.charCodeAt(i++); - if (i === len) { - strin += base64EncodeChars.charAt(c1 >> 2); - strin += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); - strin += base64EncodeChars.charAt((c2 & 0xF) << 2); - strin += '='; - break; - } - c3 = str.charCodeAt(i++); - strin += base64EncodeChars.charAt(c1 >> 2); - strin += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)); - strin += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6)); - strin += base64EncodeChars.charAt(c3 & 0x3F); - } - return strin; -} - -export function base64Decode(input: string) { // need decodeURIComponent - const base64EncodeChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; - let output = ''; - let chr1: number; - let chr2: number; - let chr3: number; - let enc1: number; - let enc2: number; - let enc3: number; - let enc4: number; - let i = 0; - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ''); - while (i < input.length) { - enc1 = base64EncodeChars.indexOf(input.charAt(i++)); - enc2 = base64EncodeChars.indexOf(input.charAt(i++)); - enc3 = base64EncodeChars.indexOf(input.charAt(i++)); - enc4 = base64EncodeChars.indexOf(input.charAt(i++)); - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - output = output + String.fromCharCode(chr1); - if (enc3 !== 64) { - output = output + String.fromCharCode(chr2); - } - if (enc4 !== 64) { - output = output + String.fromCharCode(chr3); - } - } - return decodeURIComponent(utf8Decode(output)); -} - -export function utf8Decode(utftext: string) { // utf-8解码 - let str: string = ''; - let i: number = 0; - let c: number = 0; - let c1 = 0; - let c2 = 0; - while (i < utftext.length) { - c = utftext.charCodeAt(i); - if (c < 128) { - str += String.fromCharCode(c); - i++; - } else if ((c > 191) && (c < 224)) { - c1 = utftext.charCodeAt(i + 1); - str += String.fromCharCode(((c & 31) << 6) | (c1 & 63)); - i += 2; - } else { - c1 = utftext.charCodeAt(i + 1); - c2 = utftext.charCodeAt(i + 2); - str += String.fromCharCode(((c & 15) << 12) | ((c1 & 63) << 6) | (c2 & 63)); - i += 3; - } - } - return str; -} diff --git a/src/libs/log/apiLog.ts b/src/libs/log/apiLog.ts deleted file mode 100644 index b863c2d..0000000 --- a/src/libs/log/apiLog.ts +++ /dev/null @@ -1,60 +0,0 @@ - -import { MissingError } from './util'; - -export default class ApiLog { - type: string = ''; - requestId: string = ''; - isError: boolean = false; - requestStart: number = this.getTimeStamp(); - requestEnd: number = 0; - timeCut: number = 0; - request: any; - response: any; - desc: string = ''; - url: string = ''; - - constructor({ type, requestId = '', request, url }: - { type: string, url: string, requestId?: string, request?: any }) { - - this.type = type; - this.url = url; - this.requestId = requestId; - this.request = request; - } - - logerRespSuccess(resp) { - this.requestEnd = this.getTimeStamp(); - this.response = resp; - } - - logerRespError(resp) { - this.requestEnd = this.getTimeStamp(); - this.response = resp; - this.timeCut = this.requestEnd - this.requestStart; - this.isError = true; - } - - isVaild(): boolean { - const { type, url } = this; - if (!type || !url) { - return false; - } - return true; - } - - private getTimeStamp(): number { - return new Date().valueOf(); - } -} - -// new api log -export function createApiLog({ url, type, ...other }: ApiLog): ApiLog { - if (!type || !url) { - MissingError('type', 'url'); - } - return new ApiLog({ - url, - type, - ...other - }); -} diff --git a/src/libs/log/index.ts b/src/libs/log/index.ts deleted file mode 100644 index 7145f68..0000000 --- a/src/libs/log/index.ts +++ /dev/null @@ -1,154 +0,0 @@ - -import ApiLog, { createApiLog } from './apiLog'; -import { MissingError } from './util'; - -// rid type -enum LogType { - SLOW_API = 'slow_api', - SCRIPT_ERROR = 'js_error', - PAGE_ERROR = 'page_error', - DEVICE_ERROR = 'device_error' -} - -enum ErrorType { - JS_ERROR = 'js error', - API_ERROR = 'api error', - NETWORK_ERROR = 'network_error' -} - -interface IAppInfo { - version: string; // app version - wxAppid: string; // wx app id -} - -// log module options -export interface ILoggerOptions extends IAppInfo { - getLocation: boolean; // get user loacation - statShareApp: boolean; // capture shareApp - statPullDownFresh: boolean; - statReachBottom: boolean; - statApiSpeed: boolean; - apiMaxRequestTime: number; -} - -interface IReportData extends IAppInfo { - rid: LogType; - cat: ErrorType; - data: ApiLog; - deviceInfo: WXSystemInfo; -} - -class Log { - - static options: ILoggerOptions; - static networkType: string; - static isConnected: boolean = true; - - logs: IReportData[] = []; // all log - pageLog: any[] = []; // page event log - AppLog: any[] = []; // app event log - - private requestUrl: string = 'http://dev1.pinquest.cn/api/oss/Report'; - - constructor({ wxAppid, version, ...options }: ILoggerOptions) { - if (!wxAppid || !version) { - MissingError('wxAppid', 'version'); - return; - } - Log.options = Object.assign({}, { - getLocation: false, - statPullDownFresh: true, - statReachBottom: true, - statApiSpeed: true, - apiMaxRequestTime: 500 - }, options) as ILoggerOptions; - - this.handelNetworkStatus(); - } - - // add slow api and err log - createApiLog({ isError, timeCut, ...other }: ApiLog) { - this.handelNetworkStatus(); - if (timeCut > Log.options.apiMaxRequestTime || isError) { - this.createLog(LogType.SLOW_API, ErrorType.API_ERROR, { - timeCut, - ...other - } as ApiLog); - } - } - - // add log - createLog(rid: LogType, cat: ErrorType, data: ApiLog) { - const { wxAppid, version } = Log.options; - if (!data.isVaild) { - return; - } - this.logs.push({ - rid, - cat, - data, - wxAppid, - version, - deviceInfo: wx.getSystemInfoSync() - }); - } - - // report log - handelUploadLog() { - const { logs } = this; - wx.request({ - url: this.requestUrl, - data: { logs }, - method: 'post', - success(resp) { - console.log(resp); - this.clearLog(); - }, - fail(err) { - console.log(err); - } - }); - } - - // clear upload success log - private clearLog() { - this.logs = []; - } - - // get network state - private handelNetworkStatus() { - wx.getNetworkType({ - success({ networkType }) { - Log.networkType = networkType; - }, - fail(err) { - console.log(err); - }, - }); - wx.onNetworkStatusChange(({ isConnected, networkType }) => { - Log.networkType = networkType; - Log.isConnected = isConnected; - }); - } - -} - -// mount app event -export function initAppHandel() { - App({ - onError() { }, - onPageNotFound() { } - }); -} - -// mount page event -function initPageHandel() { - Page({}); -} - -// mount logger in App -export function createLogger(options: ILoggerOptions) { - this.logger = new Log(options); - this.createApiLog = createApiLog; - this.initPageHandel = initPageHandel; -} diff --git a/src/libs/log/util.ts b/src/libs/log/util.ts deleted file mode 100644 index 96e539a..0000000 --- a/src/libs/log/util.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const MissingError = (...key) => { - console.error(`Missing parameters [${key.join(',')}]`); -}; diff --git a/src/libs/touch.ts b/src/libs/touch.ts index c3f0631..a889337 100755 --- a/src/libs/touch.ts +++ b/src/libs/touch.ts @@ -1,84 +1,82 @@ -class Touches { - dataList: any = []; - startClientX: any = null; - operationWrapperWidth: any = null; +export default class { + dataList: any = []; + startClientX: any = null; + operationWrapperWidth: any = null; - /** - * init relative data - * @param {array} dataList list data - * @param {number} operationWrapperWidth the operater width - */ - initData({ datalist, operationWrapperWidth }: any) { - this.operationWrapperWidth = operationWrapperWidth; - this.dataList = datalist instanceof Array - ? datalist.concat() - : [datalist]; - } - - /** - * touch start - * 1. reset data - * 2. get touch start x - * @return {array} reseted list data - */ - touchStart(e: any) { - this._resetData(); - this.startClientX = this._getClientX(e); - return this.dataList; - } + /** + * init relative data + * @param {array} dataList list data + * @param {number} operationWrapperWidth the operater width + */ + initData({ datalist, operationWrapperWidth }: any) { + this.operationWrapperWidth = operationWrapperWidth; + this.dataList = datalist instanceof Array + ? datalist.concat() + : [datalist]; + } - /** - * touch move - * @return {object} current item - */ - touchMove(e: any) { - const moveWidth = this._getMoveWidth(e); - if (moveWidth > 0) { return; } + /** + * touch start + * 1. reset data + * 2. get touch start x + * @return {array} reseted list data + */ + touchStart(e: any) { + this._resetData(); + this.startClientX = this._getClientX(e); + return this.dataList; + } - this.dataList[this.getItemIndex(e)].left = Math.abs(moveWidth) > this.operationWrapperWidth - ? -this.operationWrapperWidth - : moveWidth; + /** + * touch move + * @return {object} current item + */ + touchMove(e: any) { + const moveWidth = this._getMoveWidth(e); + if (moveWidth > 0) { return; } - return this.dataList[this.getItemIndex(e)]; - } + this.dataList[this.getItemIndex(e)].left = Math.abs(moveWidth) > this.operationWrapperWidth + ? -this.operationWrapperWidth + : moveWidth; - /** - * touch end - * @return {object} current item - */ - touchEnd(e: any) { - const moveWidth = this._getMoveWidth(e); - let left = 0; + return this.dataList[this.getItemIndex(e)]; + } - // 向左滑动 且 滑动的距离已大于操作块宽度的一半 - if (moveWidth < 0 && Math.abs(moveWidth) > this.operationWrapperWidth / 2) { - left = -this.operationWrapperWidth; - } + /** + * touch end + * @return {object} current item + */ + touchEnd(e: any) { + const moveWidth = this._getMoveWidth(e); + let left = 0; - this.dataList[this.getItemIndex(e)].left = left; - return this.dataList[this.getItemIndex(e)]; + // 向左滑动 且 滑动的距离已大于操作块宽度的一半 + if (moveWidth < 0 && Math.abs(moveWidth) > this.operationWrapperWidth / 2) { + left = -this.operationWrapperWidth; } - getItemIndex(e: any) { - return e.currentTarget.dataset.index; - } + this.dataList[this.getItemIndex(e)].left = left; + return this.dataList[this.getItemIndex(e)]; + } - // 获取当前滑动手势下 距离页面可显示区域的 横坐标 - _getClientX(e: any) { - const touch = e.changedTouches; - if (touch.length === 1) { return touch[0].clientX; } - } + getItemIndex(e: any) { + return e.currentTarget.dataset.index; + } - // 获取滑动过程中 滑动的宽度 - _getMoveWidth(e: any) { - return this._getClientX(e) - this.startClientX; - } + // 获取当前滑动手势下 距离页面可显示区域的 横坐标 + _getClientX(e: any) { + const touch = e.changedTouches; + if (touch.length === 1) { return touch[0].clientX; } + } - _resetData() { - this.startClientX = null; - this.dataList.forEach((v: any) => { v.left = 0; }); - } + // 获取滑动过程中 滑动的宽度 + _getMoveWidth(e: any) { + return this._getClientX(e) - this.startClientX; } -export default Touches; + _resetData() { + this.startClientX = null; + this.dataList.forEach((v: any) => { v.left = 0; }); + } +} diff --git a/src/libs/typings/es7.d.ts b/src/libs/typings/es7.d.ts deleted file mode 100755 index 8ebcd24..0000000 --- a/src/libs/typings/es7.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -interface Object { - entries(object: { [key: number]: T }): Array<[string, T]>; - entries(object: { [key: string]: T }): Array<[string, T]>; - entries(object: Object): Array<[string, any]>; - values(object: { [key: number]: T }): Array; - values(object: { [key: string]: T }): Array; - values(object: Object): Array; - includes(object: { [key: string]: T }): Boolean; -} \ No newline at end of file diff --git a/src/libs/typings/wx/index.d.ts b/src/libs/typings/wx/index.d.ts new file mode 100644 index 0000000..046fc2d --- /dev/null +++ b/src/libs/typings/wx/index.d.ts @@ -0,0 +1,63 @@ +/*! ***************************************************************************** +Copyright (c) 2018 Tencent, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +/// +/// +/// +/// +/// +/// +/// + +declare type IAnyObject = Record + +declare type KVInfer = { + [K in keyof T]: T[K] +} + +declare type Void = T | undefined | null + +type PartialOptional = Partial> & Pick> + +/** +* Make all properties in T required +*/ +type Required = { + [P in keyof T]-?: T[P]; +}; + +/** +* Exclude from T those types that are assignable to U +*/ +type Exclude = T extends U ? never : T; + +/** +* Extract from T those types that are assignable to U +*/ +type Extract = T extends U ? T : never; + +/** +* Exclude null and undefined from T +*/ +type NonNullable = T extends null | undefined ? never : T; + +/** +* Obtain the return type of a function type +*/ +type ReturnType any> = T extends (...args: any[]) => infer R ? R : any; + +/** +* Obtain the return type of a constructor function type +*/ +type InstanceType any> = T extends new (...args: any[]) => infer R ? R : any; + +type Optional = { + [K in keyof T]+?: T[K] +} diff --git a/src/libs/typings/wx/lib.wx.api.d.ts b/src/libs/typings/wx/lib.wx.api.d.ts new file mode 100644 index 0000000..a268953 --- /dev/null +++ b/src/libs/typings/wx/lib.wx.api.d.ts @@ -0,0 +1,12404 @@ +/*! ***************************************************************************** +Copyright (c) 2018 Tencent, Inc. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +***************************************************************************** */ + +declare namespace wx { + /** 账号信息 */ + interface AccountInfo { + /** 小程序账号信息 */ + miniProgram: MiniProgram; + /** 插件账号信息(仅在插件中调用时包含这一项) */ + plugin: Plugin; + } + /** 需要添加的卡券列表 */ + interface AddCardRequestInfo { + /** 卡券 ID */ + cardId: string; + /** 卡券的扩展参数。需进行 JSON 序列化为**字符串**传入 */ + cardExt: CardExt; + } + /** 卡券添加结果列表 */ + interface AddCardResponseInfo { + /** 加密 code,为用户领取到卡券的code加密后的字符串,解密请参照:[code 解码接口](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1499332673_Unm7V) */ + code: string; + /** 用户领取到卡券的 ID */ + cardId: string; + /** 卡券的扩展参数,结构请参考前文 */ + cardExt: string; + /** 是否成功 */ + isSuccess: boolean; + } + /** 动画效果 */ + interface AnimationOption { + /** 动画变化时间,单位 ms */ + duration?: number; + /** 动画变化方式 + * + * 可选值: + * - 'linear': 动画从头到尾的速度是相同的; + * - 'easeIn': 动画以低速开始; + * - 'easeOut': 动画以低速结束; + * - 'easeInOut': 动画以低速开始和结束; */ + timingFunc?: 'linear' | 'easeIn' | 'easeOut' | 'easeInOut'; + } + /** 用户授权设置信息 */ + interface AuthSetting { + /** 是否授权用户信息,对应接口 wx.getUserInfo */ + 'scope.userInfo': boolean; + /** 是否授权地理位置,对应接口 wx.getLocation wx.chooseLocation */ + 'scope.userLocation': boolean; + /** 是否授权通讯地址,对应接口 wx.chooseAddress */ + 'scope.address': boolean; + /** 是否授权发票抬头,对应接口 wx.chooseInvoiceTitle */ + 'scope.invoiceTitle': boolean; + /** 是否授权微信运动步数,对应接口 wx.getWeRunData */ + 'scope.werun': boolean; + /** 是否授权录音功能,对应接口 wx.startRecord */ + 'scope.record': boolean; + /** 是否授权保存到相册 wx.saveImageToPhotosAlbum, wx.saveVideoToPhotosAlbum */ + 'scope.writePhotosAlbum': boolean; + /** 是否授权摄像头 */ + 'scope.camera': boolean; + } + /** 设备服务列表 */ + interface BLECharacteristic { + /** 蓝牙设备特征值的 uuid */ + uuid: string; + /** 该特征值支持的操作类型 */ + properties: Properties; + } + /** 设备服务列表 */ + interface BLEService { + /** 蓝牙设备服务的 uuid */ + uuid: string; + /** 该服务是否为主服务 */ + isPrimary: boolean; + } + /** BackgroundAudioManager 实例,可通过 [wx.getBackgroundAudioManager]((wx.getBackgroundAudioManager)) 获取。 + * + * **示例代码** + * + * ```js + const backgroundAudioManager = wx.getBackgroundAudioManager() + backgroundAudioManager.title = '此时此刻' + backgroundAudioManager.epname = '此时此刻' + backgroundAudioManager.singer = '许巍' + backgroundAudioManager.coverImgUrl = 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000' + // 设置了 src 之后会自动播放 + backgroundAudioManager.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46' + ``` */ + interface BackgroundAudioManager { + /** 音频的数据源({% version('2.2.3') %} 开始支持云文件ID)。默认为空字符串,**当设置了新的 src 时,会自动开始播放**,目前支持的格式有 m4a, aac, mp3, wav。 */ + src: string; + /** 音频开始播放的位置(单位:s)。 */ + startTime: number; + /** 音频标题,用于原生音频播放器音频标题(必填)。原生音频播放器中的分享功能,分享出去的卡片标题,也将使用该值。 */ + title: string; + /** 专辑名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */ + epname: string; + /** 歌手名,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */ + singer: string; + /** 封面图 URL,用于做原生音频播放器背景图。原生音频播放器中的分享功能,分享出去的卡片配图及背景也将使用该图。 */ + coverImgUrl: string; + /** 页面链接,原生音频播放器中的分享功能,分享出去的卡片简介,也将使用该值。 */ + webUrl: string; + /** 音频协议。默认值为 'http',设置 'hls' 可以支持播放 HLS 协议的直播音频。 + * + * 最低基础库: `1.9.94` */ + protocol: string; + /** 当前音频的长度(单位:s),只有在有合法 src 时返回。(只读) */ + duration: number; + /** 当前音频的播放位置(单位:s),只有在有合法 src 时返回。(只读) */ + currentTime: number; + /** 当前是否暂停或停止。(只读) */ + paused: boolean; + /** 音频已缓冲的时间,仅保证当前播放时间点到此时间点内容已缓冲。(只读) */ + buffered: number; + } + /** 新搜索到的设备列表 */ + interface CallbackResultBlueToothDevice { + /** 蓝牙设备名称,某些设备可能没有 */ + name: string; + /** 用于区分设备的 id */ + deviceId: string; + /** 当前蓝牙设备的信号强度 */ + RSSI: number; + /** 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 */ + advertisData: ArrayBuffer; + /** 当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段 */ + advertisServiceUUIDs: Array; + /** 当前蓝牙设备的广播数据段中的 LocalName 数据段 */ + localName: string; + /** 当前蓝牙设备的广播数据段中的 ServiceData 数据段 */ + serviceData: ArrayBuffer; + } + /** uuid 对应的的已连接设备列表 */ + interface GetBluetoothDevicesSuccessCallbackResultBlueToothDevice { + /** 蓝牙设备名称,某些设备可能没有 */ + name: string; + /** 用于区分设备的 id */ + deviceId: string; + /** 当前蓝牙设备的信号强度 */ + RSSI: number; + /** 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 */ + advertisData: ArrayBuffer; + /** 当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段 */ + advertisServiceUUIDs: Array; + /** 当前蓝牙设备的广播数据段中的 LocalName 数据段 */ + localName: string; + /** 当前蓝牙设备的广播数据段中的 ServiceData 数据段 */ + serviceData: ArrayBuffer; + } + /** 搜索到的设备列表 */ + interface BluetoothDeviceInfo { + /** 蓝牙设备名称,某些设备可能没有 */ + name: string; + /** 用于区分设备的 id */ + deviceId: string; + } + /** 目标边界 */ + interface BoundingClientRectResult { + /** 左边界 */ + left: number; + /** 右边界 */ + right: number; + /** 上边界 */ + top: number; + /** 下边界 */ + bottom: number; + } + /** canvas 组件的绘图上下文 */ + interface CanvasContext { + /** 填充颜色。用法同 [CanvasContext.setFillStyle()]((CanvasContext.setFillStyle))。 + * + * 最低基础库: `1.9.90` */ + fillStyle: string; + /** 边框颜色。用法同 [CanvasContext.setFillStyle()]((CanvasContext.setStrokeStyle))。 + * + * 最低基础库: `1.9.90` */ + strokeStyle: string; + /** 阴影相对于形状在水平方向的偏移 + * + * 最低基础库: `1.9.90` */ + shadowOffsetX: number; + /** 阴影相对于形状在竖直方向的偏移 + * + * 最低基础库: `1.9.90` */ + shadowOffsetY: number; + /** 阴影的颜色 + * + * 最低基础库: `1.9.90` */ + shadowColor: number; + /** 阴影的模糊级别 + * + * 最低基础库: `1.9.90` */ + shadowBlur: number; + /** 线条的宽度。用法同 [CanvasContext.setLineWidth()]((CanvasContext.setLineWidth))。 + * + * 最低基础库: `1.9.90` */ + lineWidth: number; + /** 线条的端点样式。用法同 [CanvasContext.setLineCap()]((CanvasContext.setLineCap))。 + * + * 最低基础库: `1.9.90` */ + lineCap: number; + /** 线条的交点样式。用法同 [CanvasContext.setLineJoin()]((CanvasContext.setLineJoin))。 + * + * 最低基础库: `1.9.90` */ + lineJoin: number; + /** 最大斜接长度。用法同 [CanvasContext.setMiterLimit()]((CanvasContext.setMiterLimit))。 + * + * 最低基础库: `1.9.90` */ + miterLimit: number; + /** 虚线偏移量,初始值为0 + * + * 最低基础库: `1.9.90` */ + lineDashOffset: number; + /** 当前字体样式的属性。符合 [CSS font 语法](https://developer.mozilla.org/zh-CN/docs/Web/CSS/font) 的 DOMString 字符串,至少需要提供字体大小和字体族名。默认值为 10px sans-serif。 + * + * 最低基础库: `1.9.90` */ + font: string; + /** 全局画笔透明度。范围 0-1,0 表示完全透明,1 表示完全不透明。 */ + globalAlpha: number; + /** 在绘制新形状时应用的合成操作的类型。目前安卓版本只适用于 `fill` 填充块的合成,用于 `stroke` 线段的合成效果都是 `source-over`。 + * + * 目前支持的操作有 + * - 安卓:xor, source-over, source-atop, destination-out, lighter, overlay, darken, lighten, hard-light + * - iOS:xor, source-over, source-atop, destination-over, destination-out, lighter, multiply, overlay, darken, lighten, color-dodge, color-burn, hard-light, soft-light, difference, exclusion, saturation, luminosity + * + * 最低基础库: `1.9.90` */ + globalCompositeOperation: string; + } + /** 卡券的扩展参数。需进行 JSON 序列化为**字符串**传入 */ + interface CardExt { + /** 用户领取的 code,仅自定义 code 模式的卡券须填写,非自定义 code 模式卡券不可填写,[详情](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1451025056) */ + code?: string; + /** 指定领取者的 openid,只有该用户能领取。 bind_openid 字段为 true 的卡券必须填写,bind_openid 字段为 false 不可填写。 */ + openid?: string; + /** 时间戳,东八区时间,UTC+8,单位为秒 */ + timestamp: number; + /** 随机字符串,由开发者设置传入,加强安全性(若不填写可能被重放请求)。随机字符串,不长于 32 位。推荐使用大小写字母和数字,不同添加请求的 nonce_str 须动态生成,若重复将会导致领取失败。 */ + nonce_str?: string; + /** 卡券在第三方系统的实际领取时间,为东八区时间戳(UTC+8,精确到秒)。当卡券的有效期类为 DATE_TYPE_FIX_TERM 时专用,标识卡券的实际生效时间,用于解决商户系统内起始时间和领取微信卡券时间不同步的问题。 */ + fixed_begintimestamp?: number; + /** 领取渠道参数,用于标识本次领取的渠道值。 */ + outer_str?: string; + /** 签名,商户将接口列表中的参数按照指定方式进行签名,签名方式使用 SHA1,具体签名方案参见:[卡券签名](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1499332673_Unm7V) */ + signature: string; + } + /** 颜色。可以用以下几种方式来表示 canvas 中使用的颜色: + * - RGB 颜色: 如 `'rgb(255, 0, 0)'` + * - RGBA 颜色:如 `'rgba(255, 0, 0, 0.3)'` + * - 16 进制颜色: 如 `'#FF0000'` + * - 预定义的颜色: 如 `'red'` + * + * 其中预定义颜色有以下148个: + * + * *注意**: Color Name 大小写不敏感 + * + * | Color Name | HEX | + * + * | -------------------- | ------- | + * + * | AliceBlue | #F0F8FF | + * + * | AntiqueWhite | #FAEBD7 | + * + * | Aqua | #00FFFF | + * + * | Aquamarine | #7FFFD4 | + * + * | Azure | #F0FFFF | + * + * | Beige | #F5F5DC | + * + * | Bisque | #FFE4C4 | + * + * | Black | #000000 | + * + * | BlanchedAlmond | #FFEBCD | + * + * | Blue | #0000FF | + * + * | BlueViolet | #8A2BE2 | + * + * | Brown | #A52A2A | + * + * | BurlyWood | #DEB887 | + * + * | CadetBlue | #5F9EA0 | + * + * | Chartreuse | #7FFF00 | + * + * | Chocolate | #D2691E | + * + * | Coral | #FF7F50 | + * + * | CornflowerBlue | #6495ED | + * + * | Cornsilk | #FFF8DC | + * + * | Crimson | #DC143C | + * + * | Cyan | #00FFFF | + * + * | DarkBlue | #00008B | + * + * | DarkCyan | #008B8B | + * + * | DarkGoldenRod | #B8860B | + * + * | DarkGray | #A9A9A9 | + * + * | DarkGrey | #A9A9A9 | + * + * | DarkGreen | #006400 | + * + * | DarkKhaki | #BDB76B | + * + * | DarkMagenta | #8B008B | + * + * | DarkOliveGreen | #556B2F | + * + * | DarkOrange | #FF8C00 | + * + * | DarkOrchid | #9932CC | + * + * | DarkRed | #8B0000 | + * + * | DarkSalmon | #E9967A | + * + * | DarkSeaGreen | #8FBC8F | + * + * | DarkSlateBlue | #483D8B | + * + * | DarkSlateGray | #2F4F4F | + * + * | DarkSlateGrey | #2F4F4F | + * + * | DarkTurquoise | #00CED1 | + * + * | DarkViolet | #9400D3 | + * + * | DeepPink | #FF1493 | + * + * | DeepSkyBlue | #00BFFF | + * + * | DimGray | #696969 | + * + * | DimGrey | #696969 | + * + * | DodgerBlue | #1E90FF | + * + * | FireBrick | #B22222 | + * + * | FloralWhite | #FFFAF0 | + * + * | ForestGreen | #228B22 | + * + * | Fuchsia | #FF00FF | + * + * | Gainsboro | #DCDCDC | + * + * | GhostWhite | #F8F8FF | + * + * | Gold | #FFD700 | + * + * | GoldenRod | #DAA520 | + * + * | Gray | #808080 | + * + * | Grey | #808080 | + * + * | Green | #008000 | + * + * | GreenYellow | #ADFF2F | + * + * | HoneyDew | #F0FFF0 | + * + * | HotPink | #FF69B4 | + * + * | IndianRed | #CD5C5C | + * + * | Indigo | #4B0082 | + * + * | Ivory | #FFFFF0 | + * + * | Khaki | #F0E68C | + * + * | Lavender | #E6E6FA | + * + * | LavenderBlush | #FFF0F5 | + * + * | LawnGreen | #7CFC00 | + * + * | LemonChiffon | #FFFACD | + * + * | LightBlue | #ADD8E6 | + * + * | LightCoral | #F08080 | + * + * | LightCyan | #E0FFFF | + * + * | LightGoldenRodYellow | #FAFAD2 | + * + * | LightGray | #D3D3D3 | + * + * | LightGrey | #D3D3D3 | + * + * | LightGreen | #90EE90 | + * + * | LightPink | #FFB6C1 | + * + * | LightSalmon | #FFA07A | + * + * | LightSeaGreen | #20B2AA | + * + * | LightSkyBlue | #87CEFA | + * + * | LightSlateGray | #778899 | + * + * | LightSlateGrey | #778899 | + * + * | LightSteelBlue | #B0C4DE | + * + * | LightYellow | #FFFFE0 | + * + * | Lime | #00FF00 | + * + * | LimeGreen | #32CD32 | + * + * | Linen | #FAF0E6 | + * + * | Magenta | #FF00FF | + * + * | Maroon | #800000 | + * + * | MediumAquaMarine | #66CDAA | + * + * | MediumBlue | #0000CD | + * + * | MediumOrchid | #BA55D3 | + * + * | MediumPurple | #9370DB | + * + * | MediumSeaGreen | #3CB371 | + * + * | MediumSlateBlue | #7B68EE | + * + * | MediumSpringGreen | #00FA9A | + * + * | MediumTurquoise | #48D1CC | + * + * | MediumVioletRed | #C71585 | + * + * | MidnightBlue | #191970 | + * + * | MintCream | #F5FFFA | + * + * | MistyRose | #FFE4E1 | + * + * | Moccasin | #FFE4B5 | + * + * | NavajoWhite | #FFDEAD | + * + * | Navy | #000080 | + * + * | OldLace | #FDF5E6 | + * + * | Olive | #808000 | + * + * | OliveDrab | #6B8E23 | + * + * | Orange | #FFA500 | + * + * | OrangeRed | #FF4500 | + * + * | Orchid | #DA70D6 | + * + * | PaleGoldenRod | #EEE8AA | + * + * | PaleGreen | #98FB98 | + * + * | PaleTurquoise | #AFEEEE | + * + * | PaleVioletRed | #DB7093 | + * + * | PapayaWhip | #FFEFD5 | + * + * | PeachPuff | #FFDAB9 | + * + * | Peru | #CD853F | + * + * | Pink | #FFC0CB | + * + * | Plum | #DDA0DD | + * + * | PowderBlue | #B0E0E6 | + * + * | Purple | #800080 | + * + * | RebeccaPurple | #663399 | + * + * | Red | #FF0000 | + * + * | RosyBrown | #BC8F8F | + * + * | RoyalBlue | #4169E1 | + * + * | SaddleBrown | #8B4513 | + * + * | Salmon | #FA8072 | + * + * | SandyBrown | #F4A460 | + * + * | SeaGreen | #2E8B57 | + * + * | SeaShell | #FFF5EE | + * + * | Sienna | #A0522D | + * + * | Silver | #C0C0C0 | + * + * | SkyBlue | #87CEEB | + * + * | SlateBlue | #6A5ACD | + * + * | SlateGray | #708090 | + * + * | SlateGrey | #708090 | + * + * | Snow | #FFFAFA | + * + * | SpringGreen | #00FF7F | + * + * | SteelBlue | #4682B4 | + * + * | Tan | #D2B48C | + * + * | Teal | #008080 | + * + * | Thistle | #D8BFD8 | + * + * | Tomato | #FF6347 | + * + * | Turquoise | #40E0D0 | + * + * | Violet | #EE82EE | + * + * | Wheat | #F5DEB3 | + * + * | White | #FFFFFF | + * + * | WhiteSmoke | #F5F5F5 | + * + * | Yellow | #FFFF00 | + * + * | YellowGreen | #9ACD32 | */ + interface Color { } + /** 弹幕内容 */ + interface Danmu { + /** 弹幕文字 */ + text: string; + /** 弹幕颜色 */ + color?: string; + } + /** 上报的自定义数据。 */ + interface Data { + /** 配置中的字段名 */ + key: string; + /** 上报的数据 */ + value: any; + } + /** 可选的字体描述符 */ + interface DescOption { + /** 字体样式,可选值为 normal / italic / oblique */ + style?: string; + /** 字体粗细,可选值为 normal / bold / 100 / 200../ 900 */ + weight?: string; + /** 设置小型大写字母的字体显示文本,可选值为 normal / small-caps / inherit */ + variant?: string; + } + /** 指定 marker 移动到的目标点 */ + interface DestinationOption { + /** 经度 */ + longitude: number; + /** 纬度 */ + latitude: number; + } + interface ExtInfo { + /** 第三方平台自定义的数据 */ + extConfig: IAnyObject; + } + interface Fields { + /** 是否返回节点 id */ + id?: boolean; + /** 是否返回节点 dataset */ + dataset?: boolean; + /** 是否返回节点布局位置(`left` `right` `top` `bottom`) */ + rect?: boolean; + /** 是否返回节点尺寸(`width` `height`) */ + size?: boolean; + /** 否 是否返回节点的 `scrollLeft` `scrollTop`,节点必须是 `scroll-view` 或者 `viewport` */ + scrollOffset?: boolean; + /** 指定属性名列表,返回节点对应属性名的当前属性值(只能获得组件文档中标注的常规属性值,id class style 和事件绑定的属性值不可获取) */ + properties?: Array; + /** 指定样式名列表,返回节点对应样式名的当前值 + * + * 最低基础库: `2.1.0` */ + computedStyle?: Array; + } + /** 文件数组 */ + interface FileSystemManagerGetSavedFileListSuccessCallbackResultFileItem { + /** 本地路径 */ + filePath: string; + /** 本地文件大小,以字节为单位 */ + size: number; + /** 文件保存时的时间戳,从1970/01/01 08:00:00 到当前时间的秒数 */ + createTime: number; + } + /** 文件数组,每一项是一个 FileItem */ + interface WxGetSavedFileListSuccessCallbackResultFileItem { + /** 本地路径 */ + filePath: string; + /** 本地文件大小,以字节为单位 */ + size: number; + /** 文件保存时的时间戳,从1970/01/01 08:00:00 到当前时间的秒数 */ + createTime: number; + } + interface GetBatteryInfoSyncResult { + /** 设备电量,范围 1 - 100 */ + level: string; + /** 是否正在充电中 */ + isCharging: boolean; + } + interface GetStorageInfoSyncOption { + /** 当前 storage 中所有的 key */ + keys: Array; + /** 当前占用的空间大小, 单位 KB */ + currentSize: number; + /** 限制的空间大小,单位 KB */ + limitSize: number; + } + interface GetSystemInfoSyncResult { + /** 手机品牌 + * + * 最低基础库: `1.5.0` */ + brand: string; + /** 手机型号 */ + model: string; + /** 设备像素比 */ + pixelRatio: number; + /** 屏幕宽度 + * + * 最低基础库: `1.1.0` */ + screenWidth: number; + /** 屏幕高度 + * + * 最低基础库: `1.1.0` */ + screenHeight: number; + /** 可使用窗口宽度 */ + windowWidth: number; + /** 可使用窗口高度 */ + windowHeight: number; + /** 状态栏的高度 + * + * 最低基础库: `1.9.0` */ + statusBarHeight: number; + /** 微信设置的语言 */ + language: string; + /** 微信版本号 */ + version: string; + /** 操作系统版本 */ + system: string; + /** 客户端平台 */ + platform: string; + /** 用户字体大小设置。以“我-设置-通用-字体大小”中的设置为准,单位 px。 + * + * 最低基础库: `1.5.0` */ + fontSizeSetting: number; + /** 客户端基础库版本 + * + * 最低基础库: `1.1.0` */ + SDKVersion: string; + /** (仅Android小游戏) 性能等级,-2 或 0:该设备无法运行小游戏,-1:性能未知,>=1 设备性能值,该值越高,设备性能越好 (目前设备最高不到50) + * + * 最低基础库: `1.8.0` */ + benchmarkLevel: number; + } + interface IBeaconInfo { + /** iBeacon 设备广播的 uuid */ + uuid: string; + /** iBeacon 设备的主 id */ + major: string; + /** iBeacon 设备的次 id */ + minor: string; + /** 表示设备距离的枚举值 */ + proximity: number; + /** iBeacon 设备的距离 */ + accuracy: number; + /** 表示设备的信号强度 */ + rssi: number; + } + /** 图片的本地临时文件列表 + * + * 最低基础库: `1.2.0` */ + interface ImageFile { + /** 本地临时文件路径 */ + path: string; + /** 本地临时文件大小,单位 B */ + size: number; + } + /** InnerAudioContext 实例,可通过 [wx.createInnerAudioContext]((wx.createInnerAudioContext)) 接口获取实例。 + * + * **示例代码** + * + * ```js + const innerAudioContext = wx.createInnerAudioContext() + innerAudioContext.autoplay = true + innerAudioContext.src = 'http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E061FF02C31F716658E5C81F5594D561F2E88B854E81CAAB7806D5E4F103E55D33C16F3FAC506D1AB172DE8600B37E43FAD&fromtag=46' + innerAudioContext.onPlay(() => { + console.log('开始播放') + }) + innerAudioContext.onError((res) => { + console.log(res.errMsg) + console.log(res.errCode) + }) + ``` */ + interface InnerAudioContext { + /** 音频资源的地址,用于直接播放。{% version('2.2.3') %} 开始支持云文件ID */ + src: string; + /** 开始播放的位置(单位:s),默认为 0 */ + startTime: number; + /** 是否自动开始播放,默认为 `false` */ + autoplay: boolean; + /** 是否循环播放,默认为 `false` */ + loop: boolean; + /** 是否遵循系统静音开关,默认为 `true`。当此参数为 `false` 时,即使用户打开了静音开关,也能继续发出声音 */ + obeyMuteSwitch: boolean; + /** 音量。范围 0~1。默认为 1 + * + * 最低基础库: `1.9.90` */ + volume: number; + /** 当前音频的长度(单位 s)。只有在当前有合法的 src 时返回(只读) */ + duration: number; + /** 当前音频的播放位置(单位 s)。只有在当前有合法的 src 时返回,时间保留小数点后 6 位(只读) */ + currentTime: number; + /** 当前是是否暂停或停止状态(只读) */ + paused: boolean; + /** 音频缓冲的时间点,仅保证当前播放时间点到此时间点内容已缓冲(只读) */ + buffered: number; + } + /** 相交区域的边界 */ + interface IntersectionRectResult { + /** 左边界 */ + left: number; + /** 右边界 */ + right: number; + /** 上边界 */ + top: number; + /** 下边界 */ + bottom: number; + } + /** 用户选中的发票列表 */ + interface InvoiceInfo { + /** 所选发票卡券的 cardId */ + cardId: string; + /** 所选发票卡券的加密 code,报销方可以通过 cardId 和 encryptCode 获得报销发票的信息 */ + encryptCode: string; + /** 发票方的 appId */ + publisherAppId: string; + } + /** 要显示在可视区域内的坐标点列表 */ + interface MapPostion { + /** 经度 */ + longitude: number; + /** 纬度 */ + latitude: number; + } + /** 用来扩展(或收缩)参照节点布局区域的边界 */ + interface RelativeToMargins { + /** 节点布局区域的左边界 */ + left?: number; + /** 节点布局区域的右边界 */ + right?: number; + /** 节点布局区域的上边界 */ + top?: number; + /** 节点布局区域的下边界 */ + bottom?: number; + } + /** 用来扩展(或收缩)参照节点布局区域的边界 */ + interface RelativeToViewportMargins { + /** 节点布局区域的左边界 */ + left?: number; + /** 节点布局区域的右边界 */ + right?: number; + /** 节点布局区域的上边界 */ + top?: number; + /** 节点布局区域的下边界 */ + bottom?: number; + } + /** 小程序账号信息 */ + interface MiniProgram { + /** 小程序 appId */ + appId: string; + } + /** 需要打开的卡券列表 */ + interface OpenCardRequestInfo { + /** 卡券 ID */ + cardId: string; + /** 由 [wx.addCard]((wx.addCard)) 的返回对象中的加密 code 通过解密后得到,解密请参照:[code 解码接口](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1499332673_Unm7V) */ + code: string; + } + interface SendSocketMessageOption { + /** 需要发送的内容 */ + data: string | ArrayBuffer; + /** 接口调用成功的回调函数 */ + success?: SendSocketMessageSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SendSocketMessageFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SendSocketMessageCompleteCallback; + } + interface FaceVerifyForPayOption { + /** 场景值 */ + scene: number; + /** 支付传入的参数 */ + package: string; + /** 支付传入的参数,签名 */ + packageSign: string; + /** 别的验证方式woridng,不传就不显示入口 */ + otherVerifyTitle: string; + /** 接口调用成功的回调函数 */ + success?: FaceVerifyForPaySuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: FaceVerifyForPayFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: FaceVerifyForPayCompleteCallback; + } + interface SnapshotOption { + /** 接口调用成功的回调函数 */ + success?: SnapshotSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SnapshotFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SnapshotCompleteCallback; + } + interface GetBackgroundAudioPlayerStateOption { + /** 接口调用成功的回调函数 */ + success?: GetBackgroundAudioPlayerStateSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetBackgroundAudioPlayerStateFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBackgroundAudioPlayerStateCompleteCallback; + } + interface ShowTabBarRedDotOption { + /** tabBar 的哪一项,从左边算起 */ + index: number; + /** 接口调用成功的回调函数 */ + success?: ShowTabBarRedDotSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ShowTabBarRedDotFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowTabBarRedDotCompleteCallback; + } + interface StopWifiOption { + /** 接口调用成功的回调函数 */ + success?: StopWifiSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StopWifiFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopWifiCompleteCallback; + } + interface SwitchCameraOption { + /** 接口调用成功的回调函数 */ + success?: SwitchCameraSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SwitchCameraFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SwitchCameraCompleteCallback; + } + interface StartWifiOption { + /** 接口调用成功的回调函数 */ + success?: StartWifiSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StartWifiFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartWifiCompleteCallback; + } + interface LivePusherContextResumeOption { + /** 接口调用成功的回调函数 */ + success?: LivePusherContextResumeSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: LivePusherContextResumeFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: LivePusherContextResumeCompleteCallback; + } + interface StatOption { + /** 文件/目录路径 */ + path: string; + /** 是否递归获取目录下的每个文件的 Stats 信息 + * + * 最低基础库: `2.3.0` */ + recursive?: boolean; + /** 接口调用成功的回调函数 */ + success?: StatSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StatFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StatCompleteCallback; + } + interface LivePusherContextPauseOption { + /** 接口调用成功的回调函数 */ + success?: LivePusherContextPauseSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: LivePusherContextPauseFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: LivePusherContextPauseCompleteCallback; + } + interface SetWifiListOption { + /** 提供预设的 Wi-Fi 信息列表 */ + wifiList: WifiData; + /** 接口调用成功的回调函数 */ + success?: SetWifiListSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetWifiListFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetWifiListCompleteCallback; + } + interface NavigateBackOption { + /** 返回的页面数,如果 delta 大于现有页面数,则返回到首页。 */ + delta: number; + /** 接口调用成功的回调函数 */ + success?: NavigateBackSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: NavigateBackFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: NavigateBackCompleteCallback; + } + interface UnlinkOption { + /** 要删除的文件路径 */ + filePath: string; + /** 接口调用成功的回调函数 */ + success?: UnlinkSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: UnlinkFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: UnlinkCompleteCallback; + } + interface SwitchTabOption { + /** 需要跳转的 tabBar 页面的路径(需在 app.json 的 [tabBar]((config#tabbar)) 字段定义的页面),路径后不能带参数。 */ + url: string; + /** 接口调用成功的回调函数 */ + success?: SwitchTabSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SwitchTabFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SwitchTabCompleteCallback; + } + interface GetWifiListOption { + /** 接口调用成功的回调函数 */ + success?: GetWifiListSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetWifiListFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetWifiListCompleteCallback; + } + interface NavigateToOption { + /** 需要跳转的应用内非 tabBar 的页面的路径, 路径后可以带参数。参数与路径之间使用 `?` 分隔,参数键与参数值用 `=` 相连,不同参数用 `&` 分隔;如 'path?key=value&key2=value2' */ + url: string; + /** 接口调用成功的回调函数 */ + success?: NavigateToSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: NavigateToFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: NavigateToCompleteCallback; + } + interface UnzipOption { + /** 源文件路径,只可以是 zip 压缩文件 */ + zipFilePath: string; + /** 目标目录路径 */ + targetPath: string; + /** 接口调用成功的回调函数 */ + success?: UnzipSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: UnzipFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: UnzipCompleteCallback; + } + interface VideoContextRequestFullScreenOption { + /** 设置全屏时视频的方向,不指定则根据宽高比自动判断。 + * + * 可选值: + * - 0: 正常竖向; + * - 90: 屏幕逆时针90度; + * - -90: 屏幕顺时针90度; + * + * 最低基础库: `1.7.0` */ + direction: 0 | 90 | -90; + } + interface GetConnectedWifiOption { + /** 接口调用成功的回调函数 */ + success?: GetConnectedWifiSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetConnectedWifiFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetConnectedWifiCompleteCallback; + } + interface SetEnableDebugOption { + /** 是否打开调试 */ + enableDebug: boolean; + /** 接口调用成功的回调函数 */ + success?: SetEnableDebugSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetEnableDebugFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetEnableDebugCompleteCallback; + } + interface WriteFileOption { + /** 要写入的文件路径 */ + filePath: string; + /** 要写入的文本或二进制数据 */ + data: string | ArrayBuffer; + /** 指定写入文件的字符编码 + * + * 可选值: + * - 'ascii': ; + * - 'base64': ; + * - 'binary': ; + * - 'hex': ; + * - 'ucs2/ucs-2/utf16le/utf-16le': 以小端序读取; + * - 'utf-8/utf8': ; + * - 'latin1': ; */ + encoding?: + | 'ascii' + | 'base64' + | 'binary' + | 'hex' + | 'ucs2/ucs-2/utf16le/utf-16le' + | 'utf-8/utf8' + | 'latin1'; + /** 接口调用成功的回调函数 */ + success?: WriteFileSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: WriteFileFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: WriteFileCompleteCallback; + } + interface StopAccelerometerOption { + /** 接口调用成功的回调函数 */ + success?: StopAccelerometerSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StopAccelerometerFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopAccelerometerCompleteCallback; + } + interface ConnectWifiOption { + /** Wi-Fi 设备 SSID */ + SSID: string; + /** Wi-Fi 设备 BSSID */ + BSSID: string; + /** Wi-Fi 设备密码 */ + password?: string; + /** 接口调用成功的回调函数 */ + success?: ConnectWifiSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ConnectWifiFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ConnectWifiCompleteCallback; + } + interface RedirectToOption { + /** 需要跳转的应用内非 tabBar 的页面的路径, 路径后可以带参数。参数与路径之间使用 `?` 分隔,参数键与参数值用 `=` 相连,不同参数用 `&` 分隔;如 'path?key=value&key2=value2' */ + url: string; + /** 接口调用成功的回调函数 */ + success?: RedirectToSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: RedirectToFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RedirectToCompleteCallback; + } + interface GetLocationOption { + /** wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 */ + type?: string; + /** 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度 + * + * 最低基础库: `1.6.0` */ + altitude?: string; + /** 接口调用成功的回调函数 */ + success?: GetLocationSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetLocationFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetLocationCompleteCallback; + } + interface ExitFullScreenOption { + /** 接口调用成功的回调函数 */ + success?: ExitFullScreenSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ExitFullScreenFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ExitFullScreenCompleteCallback; + } + interface OpenLocationOption { + /** 纬度,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 */ + latitude: number; + /** 经度,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 */ + longitude: number; + /** 缩放比例,范围5~18 */ + scale?: number; + /** 位置名 */ + name?: string; + /** 地址的详细说明 */ + address?: string; + /** 接口调用成功的回调函数 */ + success?: OpenLocationSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: OpenLocationFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenLocationCompleteCallback; + } + interface GetClipboardDataOption { + /** 接口调用成功的回调函数 */ + success?: GetClipboardDataSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetClipboardDataFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetClipboardDataCompleteCallback; + } + interface SetScreenBrightnessOption { + /** 屏幕亮度值,范围 0 ~ 1。0 最暗,1 最亮 */ + value: number; + /** 接口调用成功的回调函数 */ + success?: SetScreenBrightnessSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetScreenBrightnessFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetScreenBrightnessCompleteCallback; + } + interface StartCompassOption { + /** 接口调用成功的回调函数 */ + success?: StartCompassSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StartCompassFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartCompassCompleteCallback; + } + interface ChooseLocationOption { + /** 接口调用成功的回调函数 */ + success?: ChooseLocationSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ChooseLocationFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseLocationCompleteCallback; + } + interface SetNavigationBarColorOption { + /** 前景颜色值,包括按钮、标题、状态栏的颜色,仅支持 #ffffff 和 #000000 */ + frontColor: string; + /** 背景颜色值,有效值为十六进制颜色 */ + backgroundColor: string; + /** 动画效果 */ + animation: AnimationOption; + /** 接口调用成功的回调函数 */ + success?: SetNavigationBarColorSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetNavigationBarColorFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetNavigationBarColorCompleteCallback; + } + interface StopRecordOption { + /** 接口调用成功的回调函数 */ + success?: StopRecordSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StopRecordFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopRecordCompleteCallback; + } + interface StartGyroscopeOption { + /** 监听陀螺仪数据回调函数的执行频率 + * + * 可选值: + * - 'game': 适用于更新游戏的回调频率,在 20ms/次 左右; + * - 'ui': 适用于更新 UI 的回调频率,在 60ms/次 左右; + * - 'normal': 普通的回调频率,在 200ms/次 左右; */ + interval?: 'game' | 'ui' | 'normal'; + /** 接口调用成功的回调函数 */ + success?: StartGyroscopeSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StartGyroscopeFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartGyroscopeCompleteCallback; + } + interface LoadFontFaceOption { + /** 定义的字体名称 */ + family: string; + /** 字体资源的地址。建议格式为 TTF 和 WOFF,WOFF2 在低版本的iOS上会不兼容。 */ + source: string; + /** 可选的字体描述符 */ + desc?: DescOption; + /** 接口调用成功的回调函数 */ + success?: LoadFontFaceSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: LoadFontFaceFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: LoadFontFaceCompleteCallback; + } + interface HideNavigationBarLoadingOption { + /** 接口调用成功的回调函数 */ + success?: HideNavigationBarLoadingSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: HideNavigationBarLoadingFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: HideNavigationBarLoadingCompleteCallback; + } + interface SetKeepScreenOnOption { + /** 是否保持屏幕常亮 */ + keepScreenOn: boolean; + /** 接口调用成功的回调函数 */ + success?: SetKeepScreenOnSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetKeepScreenOnFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetKeepScreenOnCompleteCallback; + } + interface StartBeaconDiscoveryOption { + /** iBeacon 设备广播的 uuid 列表 */ + uuids: Array; + /** 是否校验蓝牙开关,仅在 iOS 下有效 */ + ignoreBluetoothAvailable?: boolean; + /** 接口调用成功的回调函数 */ + success?: StartBeaconDiscoverySuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StartBeaconDiscoveryFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartBeaconDiscoveryCompleteCallback; + } + interface GetScreenBrightnessOption { + /** 接口调用成功的回调函数 */ + success?: GetScreenBrightnessSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetScreenBrightnessFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetScreenBrightnessCompleteCallback; + } + interface SetNavigationBarTitleOption { + /** 页面标题 */ + title: string; + /** 接口调用成功的回调函数 */ + success?: SetNavigationBarTitleSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetNavigationBarTitleFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetNavigationBarTitleCompleteCallback; + } + interface ChooseImageOption { + /** 最多可以选择的图片张数 */ + count?: number; + /** 所选的图片的尺寸 + * + * 可选值: + * - 'original': 原图; + * - 'compressed': 压缩图; */ + sizeType?: 'original' | 'compressed'; + /** 选择图片的来源 + * + * 可选值: + * - 'album': 从相册选图; + * - 'camera': 使用相机; */ + sourceType?: 'album' | 'camera'; + /** 接口调用成功的回调函数 */ + success?: ChooseImageSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ChooseImageFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseImageCompleteCallback; + } + interface LivePlayerContextRequestFullScreenOption { + /** 设置全屏时的方向 + * + * 可选值: + * - 0: 正常竖向; + * - 90: 屏幕逆时针90度; + * - -90: 屏幕顺时针90度; */ + direction?: 0 | 90 | -90; + /** 接口调用成功的回调函数 */ + success?: RequestFullScreenSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: RequestFullScreenFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestFullScreenCompleteCallback; + } + interface PreviewImageOption { + /** 需要预览的图片链接列表。{% version('2.2.3') %} 起支持云文件ID。 */ + urls: Array; + /** 当前显示图片的链接 */ + current?: string; + /** 接口调用成功的回调函数 */ + success?: PreviewImageSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: PreviewImageFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PreviewImageCompleteCallback; + } + interface NavigateBackMiniProgramOption { + /** 需要返回给上一个小程序的数据,上一个小程序可在 `App.onShow` 中获取到这份数据。 [详情]((小程序 App))。 */ + extraData?: IAnyObject; + /** 接口调用成功的回调函数 */ + success?: NavigateBackMiniProgramSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: NavigateBackMiniProgramFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: NavigateBackMiniProgramCompleteCallback; + } + interface GetScreenBrightnessSuccessCallbackOption { + /** 屏幕亮度值,范围 0 ~ 1,0 最暗,1 最亮 */ + value: number; + } + interface StopDeviceMotionListeningOption { + /** 接口调用成功的回调函数 */ + success?: StopDeviceMotionListeningSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StopDeviceMotionListeningFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopDeviceMotionListeningCompleteCallback; + } + interface GetImageInfoOption { + /** 图片的路径,可以是相对路径、临时文件路径、存储文件路径、网络图片路径 */ + src: string; + /** 接口调用成功的回调函数 */ + success?: GetImageInfoSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetImageInfoFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetImageInfoCompleteCallback; + } + interface CheckIsSupportSoterAuthenticationOption { + /** 接口调用成功的回调函数 */ + success?: CheckIsSupportSoterAuthenticationSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: CheckIsSupportSoterAuthenticationFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CheckIsSupportSoterAuthenticationCompleteCallback; + } + interface SaveImageToPhotosAlbumOption { + /** 图片文件路径,可以是临时文件路径或永久文件路径,不支持网络图片路径 */ + filePath: string; + /** 接口调用成功的回调函数 */ + success?: SaveImageToPhotosAlbumSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SaveImageToPhotosAlbumFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SaveImageToPhotosAlbumCompleteCallback; + } + interface CheckIsSoterEnrolledInDeviceOption { + /** 认证方式 + * + * 可选值: + * - 'fingerPrint': 指纹识别; + * - 'facial': 人脸识别(暂未支持); + * - 'speech': 声纹识别(暂未支持); */ + checkAuthMode: 'fingerPrint' | 'facial' | 'speech'; + /** 接口调用成功的回调函数 */ + success?: CheckIsSoterEnrolledInDeviceSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: CheckIsSoterEnrolledInDeviceFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CheckIsSoterEnrolledInDeviceCompleteCallback; + } + interface StopHCEOption { + /** 接口调用成功的回调函数 */ + success?: StopHCESuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StopHCEFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopHCECompleteCallback; + } + interface UpdateShareMenuOption { + /** 是否使用带 shareTicket 的转发[详情]((转发#获取更多转发信息)) */ + withShareTicket: boolean; + /** 接口调用成功的回调函数 */ + success?: UpdateShareMenuSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: UpdateShareMenuFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: UpdateShareMenuCompleteCallback; + } + interface ChooseVideoOption { + /** 视频选择的来源 + * + * 可选值: + * - 'album': 从相册选择视频; + * - 'camera': 使用相机拍摄视频; */ + sourceType?: 'album' | 'camera'; + /** 是否压缩所选择的视频文件 + * + * 最低基础库: `1.6.0` */ + compressed?: boolean; + /** 拍摄视频最长拍摄时间,单位秒 */ + maxDuration?: number; + /** 默认拉起的是前置或者后置摄像头。部分 Android 手机下由于系统 ROM 不支持无法生效 + * + * 可选值: + * - 'back': 默认拉起后置摄像头; + * - 'front': 默认拉起前置摄像头; */ + camera?: 'back' | 'front'; + /** 接口调用成功的回调函数 */ + success?: ChooseVideoSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ChooseVideoFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseVideoCompleteCallback; + } + interface ShowShareMenuOption { + /** 是否使用带 shareTicket 的转发[详情]((转发#获取更多转发信息)) */ + withShareTicket?: boolean; + /** 接口调用成功的回调函数 */ + success?: ShowShareMenuSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ShowShareMenuFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowShareMenuCompleteCallback; + } + interface SaveVideoToPhotosAlbumOption { + /** 视频文件路径,可以是临时文件路径也可以是永久文件路径 */ + filePath: string; + /** 接口调用成功的回调函数 */ + success?: SaveVideoToPhotosAlbumSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SaveVideoToPhotosAlbumFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SaveVideoToPhotosAlbumCompleteCallback; + } + interface LivePlayerContextResumeOption { + /** 接口调用成功的回调函数 */ + success?: LivePlayerContextResumeSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: LivePlayerContextResumeFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: LivePlayerContextResumeCompleteCallback; + } + interface StartHCEOption { + /** 需要注册到系统的 AID 列表 */ + aid_list: Array; + /** 接口调用成功的回调函数 */ + success?: StartHCESuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StartHCEFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartHCECompleteCallback; + } + interface VibrateLongOption { + /** 接口调用成功的回调函数 */ + success?: VibrateLongSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: VibrateLongFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: VibrateLongCompleteCallback; + } + interface DownloadFileOption { + /** 下载资源的 url */ + url: string; + /** HTTP 请求的 Header,Header 中不能设置 Referer */ + header?: IAnyObject; + /** 指定文件下载后存储的路径 + * + * 最低基础库: `1.8.0` */ + filePath?: string; + /** 接口调用成功的回调函数 */ + success?: DownloadFileSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: DownloadFileFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: DownloadFileCompleteCallback; + } + interface GetExtConfigOption { + /** 接口调用成功的回调函数 */ + success?: GetExtConfigSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetExtConfigFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetExtConfigCompleteCallback; + } + interface SendHCEMessageOption { + /** 二进制数据 */ + data: ArrayBuffer; + /** 接口调用成功的回调函数 */ + success?: SendHCEMessageSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SendHCEMessageFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SendHCEMessageCompleteCallback; + } + interface GetShareInfoOption { + /** shareTicket */ + shareTicket: string; + /** 超时时间,单位 ms + * + * 最低基础库: `1.9.90` */ + timeout?: number; + /** 接口调用成功的回调函数 */ + success?: GetShareInfoSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetShareInfoFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetShareInfoCompleteCallback; + } + interface RequestOption { + /** 开发者服务器接口地址 */ + url: string; + /** 请求的参数 */ + data?: string | IAnyObject | ArrayBuffer; + /** 设置请求的 header,header 中不能设置 Referer。 + * + * `content-type` 默认为 `application/json` */ + header?: IAnyObject; + /** HTTP 请求方法 + * + * 可选值: + * - 'OPTIONS': HTTP 请求 OPTIONS; + * - 'GET': HTTP 请求 GET; + * - 'HEAD': HTTP 请求 HEAD; + * - 'POST': HTTP 请求 POST; + * - 'PUT': HTTP 请求 PUT; + * - 'DELETE': HTTP 请求 DELETE; + * - 'TRACE': HTTP 请求 TRACE; + * - 'CONNECT': HTTP 请求 CONNECT; */ + method?: 'OPTIONS' + | 'GET' + | 'HEAD' + | 'POST' + | 'PUT' + | 'DELETE' + | 'TRACE' + | 'CONNECT' | 'string' + /** 返回的数据格式 + * + * 可选值: + * - 'json': 返回的数据为 JSON,返回后会对返回的数据进行一次 JSON.parse; + * - '其他': 不对返回的内容进行 JSON.parse; */ + dataType?: 'json' | string; + /** 响应的数据类型 + * + * 可选值: + * - 'text': 响应的数据为文本; + * - 'arraybuffer': 响应的数据为 ArrayBuffer; + * + * 最低基础库: `1.7.0` */ + responseType?: 'text' | 'arraybuffer' | string; + /** 接口调用成功的回调函数 */ + success?: RequestSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: RequestFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestCompleteCallback; + } + interface OpenSettingOption { + /** 接口调用成功的回调函数 */ + success?: OpenSettingSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: OpenSettingFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenSettingCompleteCallback; + } + interface ConnectSocketOption { + /** 开发者服务器 wss 接口地址 */ + url: string; + /** HTTP Header,Header 中不能设置 Referer */ + header?: IAnyObject; + /** 子协议数组 + * + * 最低基础库: `1.4.0` */ + protocols?: Array; + /** 接口调用成功的回调函数 */ + success?: ConnectSocketSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ConnectSocketFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ConnectSocketCompleteCallback; + } + interface GetSettingOption { + /** 接口调用成功的回调函数 */ + success?: GetSettingSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetSettingFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetSettingCompleteCallback; + } + interface CloseSocketOption { + /** 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。 */ + code?: number; + /** 一个可读的字符串,表示连接被关闭的原因。这个字符串必须是不长于 123 字节的 UTF-8 文本(不是字符)。 */ + reason?: string; + /** 接口调用成功的回调函数 */ + success?: CloseSocketSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: CloseSocketFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CloseSocketCompleteCallback; + } + interface FileSystemManagerSaveFileOption { + /** 临时存储文件路径 */ + tempFilePath: string; + /** 要存储的文件路径 */ + filePath?: string; + /** 接口调用成功的回调函数 */ + success?: FileSystemManagerSaveFileSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: FileSystemManagerSaveFileFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: FileSystemManagerSaveFileCompleteCallback; + } + interface WxSaveFileOption { + /** 需要保存的文件的临时路径 */ + tempFilePath: string; + /** 接口调用成功的回调函数 */ + success?: WxSaveFileSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: WxSaveFileFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: WxSaveFileCompleteCallback; + } + interface MuteOption { + /** 接口调用成功的回调函数 */ + success?: MuteSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: MuteFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: MuteCompleteCallback; + } + interface GetHCEStateOption { + /** 接口调用成功的回调函数 */ + success?: GetHCEStateSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetHCEStateFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetHCEStateCompleteCallback; + } + interface FileSystemManagerGetSavedFileListOption { + /** 接口调用成功的回调函数 */ + success?: FileSystemManagerGetSavedFileListSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: FileSystemManagerGetSavedFileListFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: FileSystemManagerGetSavedFileListCompleteCallback; + } + interface SendOption { + /** 需要发送的内容 */ + data: string | ArrayBuffer; + /** 接口调用成功的回调函数 */ + success?: SendSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SendFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SendCompleteCallback; + } + interface HideTabBarRedDotOption { + /** tabBar 的哪一项,从左边算起 */ + index: number; + /** 接口调用成功的回调函数 */ + success?: HideTabBarRedDotSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: HideTabBarRedDotFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: HideTabBarRedDotCompleteCallback; + } + interface LivePlayerContextStopOption { + /** 接口调用成功的回调函数 */ + success?: LivePlayerContextStopSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: LivePlayerContextStopFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: LivePlayerContextStopCompleteCallback; + } + interface WriteBLECharacteristicValueOption { + /** 蓝牙设备 id */ + deviceId: string; + /** 蓝牙特征值对应服务的 uuid */ + serviceId: string; + /** 蓝牙特征值的 uuid */ + characteristicId: string; + /** 蓝牙设备特征值对应的二进制值 */ + value: ArrayBuffer; + /** 接口调用成功的回调函数 */ + success?: WriteBLECharacteristicValueSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: WriteBLECharacteristicValueFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: WriteBLECharacteristicValueCompleteCallback; + } + interface WxGetSavedFileListOption { + /** 接口调用成功的回调函数 */ + success?: WxGetSavedFileListSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: WxGetSavedFileListFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: WxGetSavedFileListCompleteCallback; + } + interface GetSavedFileInfoOption { + /** 文件路径 */ + filePath: string; + /** 接口调用成功的回调函数 */ + success?: GetSavedFileInfoSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetSavedFileInfoFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetSavedFileInfoCompleteCallback; + } + interface StopBluetoothDevicesDiscoveryOption { + /** 接口调用成功的回调函数 */ + success?: StopBluetoothDevicesDiscoverySuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StopBluetoothDevicesDiscoveryFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopBluetoothDevicesDiscoveryCompleteCallback; + } + interface FileSystemManagerRemoveSavedFileOption { + /** 需要删除的文件路径 */ + filePath: string; + /** 接口调用成功的回调函数 */ + success?: FileSystemManagerRemoveSavedFileSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: FileSystemManagerRemoveSavedFileFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: FileSystemManagerRemoveSavedFileCompleteCallback; + } + interface UploadFileOption { + /** 开发者服务器地址 */ + url: string; + /** 要上传文件资源的路径 */ + filePath: string; + /** 文件对应的 key,开发者在服务端可以通过这个 key 获取文件的二进制内容 */ + name: string; + /** HTTP 请求 Header,Header 中不能设置 Referer */ + header?: IAnyObject; + /** HTTP 请求中其他额外的 form data */ + formData?: IAnyObject; + /** 接口调用成功的回调函数 */ + success?: UploadFileSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: UploadFileFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: UploadFileCompleteCallback; + } + interface PauseVoiceOption { + /** 接口调用成功的回调函数 */ + success?: PauseVoiceSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: PauseVoiceFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PauseVoiceCompleteCallback; + } + interface StartBluetoothDevicesDiscoveryOption { + /** 要搜索但蓝牙设备主 service 的 uuid 列表。某些蓝牙设备会广播自己的主 service 的 uuid。如果设置此参数,则只搜索广播包有对应 uuid 的主服务的蓝牙设备。建议主要通过该参数过滤掉周边不需要处理的其他蓝牙设备。 */ + services?: Array; + /** 是否允许重复上报同一设备。如果允许重复上报,则 `wx.onBlueToothDeviceFound` 方法会多次上报同一设备,但是 RSSI 值会有不同。 */ + allowDuplicatesKey?: boolean; + /** 上报设备的间隔。0 表示找到新设备立即上报,其他数值根据传入的间隔上报。 */ + interval?: number; + /** 接口调用成功的回调函数 */ + success?: StartBluetoothDevicesDiscoverySuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StartBluetoothDevicesDiscoveryFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartBluetoothDevicesDiscoveryCompleteCallback; + } + interface PlayVoiceOption { + /** 需要播放的语音文件的文件路径 */ + filePath: string; + /** 指定录音时长,到达指定的录音时长后会自动停止录音,单位:秒 + * + * 最低基础库: `1.6.0` */ + duration?: number; + /** 接口调用成功的回调函数 */ + success?: PlayVoiceSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: PlayVoiceFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PlayVoiceCompleteCallback; + } + interface LoginOption { + /** 超时时间,单位ms + * + * 最低基础库: `1.9.90` */ + timeout?: number; + /** 接口调用成功的回调函数 */ + success?: LoginSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: LoginFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: LoginCompleteCallback; + } + interface FileSystemManagerGetFileInfoOption { + /** 要读取的文件路径 */ + filePath: string; + /** 接口调用成功的回调函数 */ + success?: FileSystemManagerGetFileInfoSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: FileSystemManagerGetFileInfoFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: FileSystemManagerGetFileInfoCompleteCallback; + } + interface CheckSessionOption { + /** 接口调用成功的回调函数 */ + success?: CheckSessionSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: CheckSessionFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CheckSessionCompleteCallback; + } + interface WxGetFileInfoOption { + /** 本地文件路径 */ + filePath: string; + /** 计算文件摘要的算法 + * + * 可选值: + * - 'md5': md5 算法; + * - 'sha1': sha1 算法; */ + digestAlgorithm?: 'md5' | 'sha1'; + /** 接口调用成功的回调函数 */ + success?: WxGetFileInfoSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: WxGetFileInfoFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: WxGetFileInfoCompleteCallback; + } + interface ReadBLECharacteristicValueOption { + /** 蓝牙设备 id */ + deviceId: string; + /** 蓝牙特征值对应服务的 uuid */ + serviceId: string; + /** 蓝牙特征值的 uuid */ + characteristicId: string; + /** 接口调用成功的回调函数 */ + success?: ReadBLECharacteristicValueSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ReadBLECharacteristicValueFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ReadBLECharacteristicValueCompleteCallback; + } + interface RemoveTabBarBadgeOption { + /** tabBar 的哪一项,从左边算起 */ + index: number; + /** 接口调用成功的回调函数 */ + success?: RemoveTabBarBadgeSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: RemoveTabBarBadgeFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RemoveTabBarBadgeCompleteCallback; + } + interface ChooseAddressOption { + /** 接口调用成功的回调函数 */ + success?: ChooseAddressSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ChooseAddressFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseAddressCompleteCallback; + } + interface WxStartRecordOption { + /** 接口调用成功的回调函数 */ + success?: WxStartRecordSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: WxStartRecordFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: WxStartRecordCompleteCallback; + } + interface AuthorizeOption { + /** 需要获取权限的 scope,详见 [scope 列表]((授权#scope-列表)) */ + scope: string; + /** 接口调用成功的回调函数 */ + success?: AuthorizeSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: AuthorizeFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AuthorizeCompleteCallback; + } + interface ReaddirOption { + /** 要读取的目录路径 */ + dirPath: string; + /** 接口调用成功的回调函数 */ + success?: ReaddirSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ReaddirFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ReaddirCompleteCallback; + } + interface CameraContextStartRecordOption { + /** 超过30s或页面 `onHide` 时会结束录像 */ + timeoutCallback?: StartRecordTimeoutCallback; + /** 接口调用成功的回调函数 */ + success?: CameraContextStartRecordSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: CameraContextStartRecordFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CameraContextStartRecordCompleteCallback; + } + interface SeekBackgroundAudioOption { + /** 音乐位置,单位:秒 */ + position: number; + /** 接口调用成功的回调函数 */ + success?: SeekBackgroundAudioSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SeekBackgroundAudioFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SeekBackgroundAudioCompleteCallback; + } + interface OpenBluetoothAdapterOption { + /** 接口调用成功的回调函数 */ + success?: OpenBluetoothAdapterSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: OpenBluetoothAdapterFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenBluetoothAdapterCompleteCallback; + } + interface PauseBackgroundAudioOption { + /** 接口调用成功的回调函数 */ + success?: PauseBackgroundAudioSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: PauseBackgroundAudioFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PauseBackgroundAudioCompleteCallback; + } + interface TakePhotoOption { + /** 成像质量 + * + * 可选值: + * - 'high': 高质量; + * - 'normal': 普通质量; + * - 'low': 低质量; */ + quality?: 'high' | 'normal' | 'low'; + /** 接口调用成功的回调函数 */ + success?: TakePhotoSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: TakePhotoFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: TakePhotoCompleteCallback; + } + interface PlayBackgroundAudioOption { + /** 音乐链接,目前支持的格式有 m4a, aac, mp3, wav */ + dataUrl: string; + /** 音乐标题 */ + title?: string; + /** 封面URL */ + coverImgUrl?: string; + /** 接口调用成功的回调函数 */ + success?: PlayBackgroundAudioSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: PlayBackgroundAudioFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PlayBackgroundAudioCompleteCallback; + } + interface CanvasToTempFilePathOption { + /** 指定的画布区域的左上角横坐标 + * + * 最低基础库: `1.2.0` */ + x?: number; + /** 指定的画布区域的左上角纵坐标 + * + * 最低基础库: `1.2.0` */ + y?: number; + /** 指定的画布区域的宽度 + * + * 最低基础库: `1.2.0` */ + width?: number; + /** 指定的画布区域的高度 + * + * 最低基础库: `1.2.0` */ + height?: number; + /** 输出的图片的宽度 + * + * 最低基础库: `1.2.0` */ + destWidth?: number; + /** 输出的图片的高度 + * + * 最低基础库: `1.2.0` */ + destHeight?: number; + /** 画布标识,传入 `` 组件的 canvas-id */ + canvasId: string; + /** 目标文件的类型 + * + * 可选值: + * - 'jpg': jpg 图片; + * - 'png': png 图片; + * + * 最低基础库: `1.7.0` */ + fileType?: 'jpg' | 'png'; + /** 图片的质量,目前仅对 jpg 有效。取值范围为 (0, 1],不在范围内时当作 1.0 处理。 + * + * 最低基础库: `1.7.0` */ + quality: number; + /** 接口调用成功的回调函数 */ + success?: CanvasToTempFilePathSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: CanvasToTempFilePathFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CanvasToTempFilePathCompleteCallback; + } + interface GetCenterLocationOption { + /** 接口调用成功的回调函数 */ + success?: GetCenterLocationSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetCenterLocationFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetCenterLocationCompleteCallback; + } + interface AddCardOption { + /** 需要添加的卡券列表 */ + cardList: AddCardRequestInfo; + /** 接口调用成功的回调函数 */ + success?: AddCardSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: AddCardFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AddCardCompleteCallback; + } + interface IncludePointsOption { + /** 要显示在可视区域内的坐标点列表 */ + points: MapPostion; + /** 坐标点形成的矩形边缘到地图边缘的距离,单位像素。格式为[上,右,下,左],安卓上只能识别数组第一项,上下左右的padding一致。开发者工具暂不支持padding参数。 */ + padding?: Array; + /** 接口调用成功的回调函数 */ + success?: IncludePointsSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: IncludePointsFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: IncludePointsCompleteCallback; + } + interface NotifyBLECharacteristicValueChangeOption { + /** 蓝牙设备 id */ + deviceId: string; + /** 蓝牙特征值对应服务的 uuid */ + serviceId: string; + /** 蓝牙特征值的 uuid */ + characteristicId: string; + /** 是否启用 notify */ + state: boolean; + /** 接口调用成功的回调函数 */ + success?: NotifyBLECharacteristicValueChangeSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: NotifyBLECharacteristicValueChangeFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: NotifyBLECharacteristicValueChangeCompleteCallback; + } + interface GetScaleOption { + /** 接口调用成功的回调函数 */ + success?: GetScaleSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetScaleFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetScaleCompleteCallback; + } + interface OpenCardOption { + /** 需要打开的卡券列表 */ + cardList: OpenCardRequestInfo; + /** 接口调用成功的回调函数 */ + success?: OpenCardSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: OpenCardFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenCardCompleteCallback; + } + interface LivePusherContextStartOption { + /** 接口调用成功的回调函数 */ + success?: StartSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StartFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartCompleteCallback; + } + interface GetConnectedBluetoothDevicesOption { + /** 蓝牙设备主 service 的 uuid 列表 */ + services: Array; + /** 接口调用成功的回调函数 */ + success?: GetConnectedBluetoothDevicesSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetConnectedBluetoothDevicesFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetConnectedBluetoothDevicesCompleteCallback; + } + interface ReLaunchOption { + /** 需要跳转的应用内页面路径,路径后可以带参数。参数与路径之间使用?分隔,参数键与参数值用=相连,不同参数用&分隔;如 'path?key=value&key2=value2',如果跳转的页面路径是 tabBar 页面则不能带参数 */ + url: string; + /** 接口调用成功的回调函数 */ + success?: ReLaunchSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ReLaunchFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ReLaunchCompleteCallback; + } + interface GetBluetoothDevicesOption { + /** 接口调用成功的回调函数 */ + success?: GetBluetoothDevicesSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetBluetoothDevicesFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBluetoothDevicesCompleteCallback; + } + interface GetClipboardDataSuccessCallbackOption { + /** 剪贴板的内容 */ + data: string; + } + interface ChooseInvoiceOption { + /** 接口调用成功的回调函数 */ + success?: ChooseInvoiceSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ChooseInvoiceFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseInvoiceCompleteCallback; + } + interface StopCompassOption { + /** 接口调用成功的回调函数 */ + success?: StopCompassSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StopCompassFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopCompassCompleteCallback; + } + /** 选项 */ + interface CreateIntersectionObserverOption { + /** 一个数值数组,包含所有阈值。 */ + thresholds?: Array; + /** 初始的相交比例,如果调用时检测到的相交比例与这个值不相等且达到阈值,则会触发一次监听器的回调函数。 */ + initialRatio?: number; + /** 是否同时观测多个目标节点(而非一个),如果设为 true ,observe 的 targetSelector 将选中多个节点(注意:同时选中过多节点将影响渲染性能) + * + * 最低基础库: `2.0.0` */ + observeAll?: boolean; + } + interface StopGyroscopeOption { + /** 接口调用成功的回调函数 */ + success?: StopGyroscopeSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StopGyroscopeFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopGyroscopeCompleteCallback; + } + interface ChooseInvoiceTitleOption { + /** 接口调用成功的回调函数 */ + success?: ChooseInvoiceTitleSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ChooseInvoiceTitleFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ChooseInvoiceTitleCompleteCallback; + } + interface StopBeaconDiscoveryOption { + /** 接口调用成功的回调函数 */ + success?: StopBeaconDiscoverySuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StopBeaconDiscoveryFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopBeaconDiscoveryCompleteCallback; + } + interface GetBluetoothAdapterStateOption { + /** 接口调用成功的回调函数 */ + success?: GetBluetoothAdapterStateSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetBluetoothAdapterStateFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBluetoothAdapterStateCompleteCallback; + } + interface NavigateToMiniProgramOption { + /** 要打开的小程序 appId */ + appId: string; + /** 打开的页面路径,如果为空则打开首页 */ + path?: string; + /** 需要传递给目标小程序的数据,目标小程序可在 `App.onLaunch`,`App.onShow` 中获取到这份数据。 */ + extraData?: IAnyObject; + /** 要打开的小程序版本。仅在当前小程序为开发版或体验版时此参数有效。如果当前小程序是正式版,则打开的小程序必定是正式版。 + * + * 可选值: + * - 'develop': 开发版; + * - 'trial': 体验版; + * - 'release': 正式版; */ + envVersion?: 'develop' | 'trial' | 'release'; + /** 接口调用成功的回调函数 */ + success?: NavigateToMiniProgramSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: NavigateToMiniProgramFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: NavigateToMiniProgramCompleteCallback; + } + interface GetBLEDeviceServicesOption { + /** 蓝牙设备 id */ + deviceId: string; + /** 接口调用成功的回调函数 */ + success?: GetBLEDeviceServicesSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetBLEDeviceServicesFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBLEDeviceServicesCompleteCallback; + } + interface StartSoterAuthenticationOption { + /** 请求使用的可接受的生物认证方式 + * + * 可选值: + * - 'fingerPrint': 指纹识别; + * - 'facial': 人脸识别(暂未支持); + * - 'speech': 声纹识别(暂未支持); */ + requestAuthModes: 'fingerPrint' | 'facial' | 'speech'; + /** 挑战因子。挑战因子为调用者为此次生物鉴权准备的用于签名的字符串关键识别信息,将作为 `resultJSON` 的一部分,供调用者识别本次请求。例如:如果场景为请求用户对某订单进行授权确认,则可以将订单号填入此参数。 */ + challenge: string; + /** 验证描述,即识别过程中显示在界面上的对话框提示内容 */ + authContent?: string; + /** 接口调用成功的回调函数 */ + success?: StartSoterAuthenticationSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StartSoterAuthenticationFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartSoterAuthenticationCompleteCallback; + } + interface ToggleTorchOption { + /** 接口调用成功的回调函数 */ + success?: ToggleTorchSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ToggleTorchFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ToggleTorchCompleteCallback; + } + interface MakePhoneCallOption { + /** 需要拨打的电话号码 */ + phoneNumber: string; + /** 接口调用成功的回调函数 */ + success?: MakePhoneCallSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: MakePhoneCallFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: MakePhoneCallCompleteCallback; + } + interface SetTabBarBadgeOption { + /** tabBar 的哪一项,从左边算起 */ + index: number; + /** 显示的文本,超过 4 个字符则显示成 ... */ + text: string; + /** 接口调用成功的回调函数 */ + success?: SetTabBarBadgeSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetTabBarBadgeFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetTabBarBadgeCompleteCallback; + } + interface GetSystemInfoOption { + /** 接口调用成功的回调函数 */ + success?: GetSystemInfoSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetSystemInfoFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetSystemInfoCompleteCallback; + } + interface GetUserInfoOption { + /** 是否带上登录态信息。当 withCredentials 为 true 时,要求此前有调用过 wx.login 且登录态尚未过期,此时返回的数据会包含 encryptedData, iv 等敏感信息;当 withCredentials 为 false 时,不要求有登录态,返回的数据不包含 encryptedData, iv 等敏感信息。 */ + withCredentials?: boolean; + /** 显示用户信息的语言 + * + * 可选值: + * - 'en': 英文; + * - 'zh_CN': 简体中文; + * - 'zh_TW': 繁体中文; */ + lang?: 'en' | 'zh_CN' | 'zh_TW'; + /** 接口调用成功的回调函数 */ + success?: GetUserInfoSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetUserInfoFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetUserInfoCompleteCallback; + } + interface HideShareMenuOption { + /** 接口调用成功的回调函数 */ + success?: HideShareMenuSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: HideShareMenuFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: HideShareMenuCompleteCallback; + } + interface GetBLEDeviceCharacteristicsOption { + /** 蓝牙设备 id */ + deviceId: string; + /** 蓝牙服务 uuid,需要使用 `getBLEDeviceServices` 获取 */ + serviceId: string; + /** 接口调用成功的回调函数 */ + success?: GetBLEDeviceCharacteristicsSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetBLEDeviceCharacteristicsFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBLEDeviceCharacteristicsCompleteCallback; + } + interface AccessOption { + /** 要判断是否存在的文件/目录路径 */ + path: string; + /** 接口调用成功的回调函数 */ + success?: AccessSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: AccessFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AccessCompleteCallback; + } + interface RequestPaymentOption { + /** 时间戳,从 1970 年 1 月 1 日 00:00:00 至今的秒数,即当前的时间 */ + timeStamp: string; + /** 随机字符串,长度为32个字符以下 */ + nonceStr: string; + /** 统一下单接口返回的 prepay_id 参数值,提交格式如:prepay_id=*** */ + package: string; + /** 签名算法 + * + * 可选值: + * - 'MD5': MD5; + * - 'HMAC-SHA256': HMAC-SHA256; */ + signType?: 'MD5' | 'HMAC-SHA256'; + /** 签名,具体签名方案参见 [小程序支付接口文档](https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_7&index=3) */ + paySign: string; + /** 接口调用成功的回调函数 */ + success?: RequestPaymentSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: RequestPaymentFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RequestPaymentCompleteCallback; + } + interface CanvasGetImageDataOption { + /** 画布标识,传入 `` 组件的 `canvas-id` 属性。 */ + canvasId: string; + /** 将要被提取的图像数据矩形区域的左上角横坐标 */ + x: number; + /** 将要被提取的图像数据矩形区域的左上角纵坐标 */ + y: number; + /** 将要被提取的图像数据矩形区域的宽度 */ + width: number; + /** 将要被提取的图像数据矩形区域的高度 */ + height: number; + /** 接口调用成功的回调函数 */ + success?: CanvasGetImageDataSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: CanvasGetImageDataFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CanvasGetImageDataCompleteCallback; + } + interface SetBackgroundTextStyleOption { + /** 下拉背景字体、loading 图的样式。 + * + * 可选值: + * - 'dark': dark 样式; + * - 'light': light 样式; */ + textStyle: 'dark' | 'light'; + /** 接口调用成功的回调函数 */ + success?: SetBackgroundTextStyleSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetBackgroundTextStyleFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetBackgroundTextStyleCompleteCallback; + } + interface OpenDocumentOption { + /** 文件路径,可通过 downloadFile 获得 */ + filePath: string; + /** 文件类型,指定文件类型打开文件 + * + * 可选值: + * - 'doc': doc 格式; + * - 'docx': docx 格式; + * - 'xls': xls 格式; + * - 'xlsx': xlsx 格式; + * - 'ppt': ppt 格式; + * - 'pptx': pptx 格式; + * - 'pdf': pdf 格式; + * + * 最低基础库: `1.4.0` */ + fileType?: 'doc' | 'docx' | 'xls' | 'xlsx' | 'ppt' | 'pptx' | 'pdf'; + /** 接口调用成功的回调函数 */ + success?: OpenDocumentSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: OpenDocumentFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: OpenDocumentCompleteCallback; + } + interface GetWeRunDataOption { + /** 接口调用成功的回调函数 */ + success?: GetWeRunDataSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetWeRunDataFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetWeRunDataCompleteCallback; + } + interface StopVoiceOption { + /** 接口调用成功的回调函数 */ + success?: StopVoiceSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StopVoiceFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopVoiceCompleteCallback; + } + interface CreateBLEConnectionOption { + /** 用于区分设备的 id */ + deviceId: string; + /** 超时时间,单位ms,不填表示不会超时 */ + timeout?: number; + /** 接口调用成功的回调函数 */ + success?: CreateBLEConnectionSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: CreateBLEConnectionFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CreateBLEConnectionCompleteCallback; + } + interface CopyFileOption { + /** 源文件路径,只可以是普通文件 */ + srcPath: string; + /** 目标文件路径 */ + destPath: string; + /** 接口调用成功的回调函数 */ + success?: CopyFileSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: CopyFileFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CopyFileCompleteCallback; + } + interface CloseBluetoothAdapterOption { + /** 接口调用成功的回调函数 */ + success?: CloseBluetoothAdapterSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: CloseBluetoothAdapterFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CloseBluetoothAdapterCompleteCallback; + } + interface RecorderManagerStartOption { + /** 录音的时长,单位 ms,最大值 600000(10 分钟) */ + duration?: number; + /** 采样率 + * + * 可选值: + * - 8000: 8000 采样率; + * - 11025: 11025 采样率; + * - 12000: 12000 采样率; + * - 16000: 16000 采样率; + * - 22050: 22050 采样率; + * - 24000: 24000 采样率; + * - 32000: 32000 采样率; + * - 44100: 44100 采样率; + * - 48000: 48000 采样率; */ + sampleRate?: + | 8000 + | 11025 + | 12000 + | 16000 + | 22050 + | 24000 + | 32000 + | 44100 + | 48000; + /** 录音通道数 + * + * 可选值: + * - 1: 1 个通道; + * - 2: 2 个通道; */ + numberOfChannels?: 1 | 2; + /** 编码码率,有效值见下表格 */ + encodeBitRate?: number; + /** 音频格式 + * + * 可选值: + * - 'mp3': mp3 格式; + * - 'aac': aac 格式; */ + format?: 'mp3' | 'aac'; + /** 指定帧大小,单位 KB。传入 frameSize 后,每录制指定帧大小的内容后,会回调录制的文件内容,不指定则不会回调。暂仅支持 mp3 格式。 */ + frameSize?: number; + /** 指定录音的音频输入源,可通过 [wx.getAvailableAudioSources()]((wx.getAvailableAudioSources)) 获取当前可用的音频源 + * + * 可选值: + * - 'auto': 自动设置,默认使用手机麦克风,插上耳麦后自动切换使用耳机麦克风,所有平台适用; + * - 'buildInMic': 手机麦克风,仅限 iOS; + * - 'headsetMic': 耳机麦克风,仅限 iOS; + * - 'mic': 麦克风(没插耳麦时是手机麦克风,插耳麦时是耳机麦克风),仅限 Android; + * - 'camcorder': 同 mic,适用于录制音视频内容,仅限 Android; + * - 'voice_communication': 同 mic,适用于实时沟通,仅限 Android; + * - 'voice_recognition': 同 mic,适用于语音识别,仅限 Android; + * + * 最低基础库: `2.1.0` */ + audioSource?: + | 'auto' + | 'buildInMic' + | 'headsetMic' + | 'mic' + | 'camcorder' + | 'voice_communication' + | 'voice_recognition'; + } + interface CloseBLEConnectionOption { + /** 用于区分设备的 id */ + deviceId: string; + /** 接口调用成功的回调函数 */ + success?: CloseBLEConnectionSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: CloseBLEConnectionFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CloseBLEConnectionCompleteCallback; + } + interface MkdirOption { + /** 创建的目录路径 */ + dirPath: string; + /** 是否在递归创建该目录的上级目录后再创建该目录。如果对应的上级目录已经存在,则不创建该上级目录。如 dirPath 为 a/b/c/d 且 recursive 为 true,将创建 a 目录,再在 a 目录下创建 b 目录,以此类推直至创建 a/b/c 目录下的 d 目录。 + * + * 最低基础库: `2.3.0` */ + recursive?: boolean; + /** 接口调用成功的回调函数 */ + success?: MkdirSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: MkdirFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: MkdirCompleteCallback; + } + interface GetStorageOption { + /** 本地缓存中指定的 key */ + key: string; + /** 接口调用成功的回调函数 */ + success?: GetStorageSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetStorageFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetStorageCompleteCallback; + } + interface StopBackgroundAudioOption { + /** 接口调用成功的回调函数 */ + success?: StopBackgroundAudioSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StopBackgroundAudioFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopBackgroundAudioCompleteCallback; + } + interface SetStorageOption { + /** 本地缓存中指定的 key */ + key: string; + /** 需要存储的内容 */ + data: IAnyObject | string; + /** 接口调用成功的回调函数 */ + success?: SetStorageSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetStorageFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetStorageCompleteCallback; + } + interface RenameOption { + /** 源文件路径,可以是普通文件或目录 */ + oldPath: string; + /** 新文件路径 */ + newPath: string; + /** 接口调用成功的回调函数 */ + success?: RenameSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: RenameFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RenameCompleteCallback; + } + interface RemoveStorageOption { + /** 本地缓存中指定的 key */ + key: string; + /** 接口调用成功的回调函数 */ + success?: RemoveStorageSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: RemoveStorageFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RemoveStorageCompleteCallback; + } + interface TranslateMarkerOption { + /** 指定 marker */ + markerId: number; + /** 指定 marker 移动到的目标点 */ + destination: DestinationOption; + /** 移动过程中是否自动旋转 marker */ + autoRotate: boolean; + /** marker 的旋转角度 */ + rotate: number; + /** 动画持续时长,平移与旋转分别计算 */ + duration?: number; + /** 动画结束回调函数 */ + animationEnd?: Function; + /** 接口调用成功的回调函数 */ + success?: TranslateMarkerSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: TranslateMarkerFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: TranslateMarkerCompleteCallback; + } + interface ClearStorageOption { + /** 接口调用成功的回调函数 */ + success?: ClearStorageSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ClearStorageFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ClearStorageCompleteCallback; + } + interface LivePusherContextStopOption { + /** 接口调用成功的回调函数 */ + success?: LivePusherContextStopSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: LivePusherContextStopFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: LivePusherContextStopCompleteCallback; + } + interface GetStorageInfoSuccessCallbackOption { + /** 当前 storage 中所有的 key */ + keys: Array; + /** 当前占用的空间大小, 单位 KB */ + currentSize: number; + /** 限制的空间大小,单位 KB */ + limitSize: number; + } + interface GetBatteryInfoOption { + /** 接口调用成功的回调函数 */ + success?: GetBatteryInfoSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetBatteryInfoFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBatteryInfoCompleteCallback; + } + interface GetStorageInfoOption { + /** 接口调用成功的回调函数 */ + success?: GetStorageInfoSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetStorageInfoFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetStorageInfoCompleteCallback; + } + interface AddPhoneContactOption { + /** 名字 */ + firstName: string; + /** 头像本地文件路径 */ + photoFilePath?: string; + /** 昵称 */ + nickName?: string; + /** 姓氏 */ + lastName?: string; + /** 中间名 */ + middleName?: string; + /** 备注 */ + remark?: string; + /** 手机号 */ + mobilePhoneNumber?: string; + /** 微信号 */ + weChatNumber?: string; + /** 联系地址国家 */ + addressCountry?: string; + /** 联系地址省份 */ + addressState?: string; + /** 联系地址城市 */ + addressCity?: string; + /** 联系地址街道 */ + addressStreet?: string; + /** 联系地址邮政编码 */ + addressPostalCode?: string; + /** 公司 */ + organization?: string; + /** 职位 */ + title?: string; + /** 工作传真 */ + workFaxNumber?: string; + /** 工作电话 */ + workPhoneNumber?: string; + /** 公司电话 */ + hostNumber?: string; + /** 电子邮件 */ + email?: string; + /** 网站 */ + url?: string; + /** 工作地址国家 */ + workAddressCountry?: string; + /** 工作地址省份 */ + workAddressState?: string; + /** 工作地址城市 */ + workAddressCity?: string; + /** 工作地址街道 */ + workAddressStreet?: string; + /** 工作地址邮政编码 */ + workAddressPostalCode?: string; + /** 住宅传真 */ + homeFaxNumber?: string; + /** 住宅电话 */ + homePhoneNumber?: string; + /** 住宅地址国家 */ + homeAddressCountry?: string; + /** 住宅地址省份 */ + homeAddressState?: string; + /** 住宅地址城市 */ + homeAddressCity?: string; + /** 住宅地址街道 */ + homeAddressStreet?: string; + /** 住宅地址邮政编码 */ + homeAddressPostalCode?: string; + /** 接口调用成功的回调函数 */ + success?: AddPhoneContactSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: AddPhoneContactFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AddPhoneContactCompleteCallback; + } + interface SetTopBarTextOption { + /** 置顶栏文字 */ + text: string; + /** 接口调用成功的回调函数 */ + success?: SetTopBarTextSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetTopBarTextFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetTopBarTextCompleteCallback; + } + interface GetBeaconsOption { + /** 接口调用成功的回调函数 */ + success?: GetBeaconsSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetBeaconsFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetBeaconsCompleteCallback; + } + interface SetTabBarItemOption { + /** tabBar 的哪一项,从左边算起 */ + index: number; + /** tab 上的按钮文字 */ + text?: string; + /** 图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效,不支持网络图片 */ + iconPath?: string; + /** 选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效 */ + selectedIconPath?: string; + /** 接口调用成功的回调函数 */ + success?: SetTabBarItemSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetTabBarItemFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetTabBarItemCompleteCallback; + } + interface GetNetworkTypeOption { + /** 接口调用成功的回调函数 */ + success?: GetNetworkTypeSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetNetworkTypeFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetNetworkTypeCompleteCallback; + } + interface StepOption { + /** 动画持续时间,单位 ms */ + duration?: number; + /** 动画的效果 + * + * 可选值: + * - 'linear': 动画从头到尾的速度是相同的; + * - 'ease': 动画以低速开始,然后加快,在结束前变慢; + * - 'ease-in': 动画以低速开始; + * - 'ease-in-out': 动画以低速开始和结束; + * - 'ease-out': 动画以低速结束; + * - 'step-start': 动画第一帧就跳至结束状态直到结束; + * - 'step-end': 动画一直保持开始状态,最后一帧跳到结束状态; */ + timingFunction?: + | 'linear' + | 'ease' + | 'ease-in' + | 'ease-in-out' + | 'ease-out' + | 'step-start' + | 'step-end'; + /** 动画延迟时间,单位 ms */ + delay?: number; + transformOrigin?: string; + } + interface VibrateShortOption { + /** 接口调用成功的回调函数 */ + success?: VibrateShortSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: VibrateShortFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: VibrateShortCompleteCallback; + } + interface CreateAnimationOption { + /** 动画持续时间,单位 ms */ + duration?: number; + /** 动画的效果 + * + * 可选值: + * - 'linear': 动画从头到尾的速度是相同的; + * - 'ease': 动画以低速开始,然后加快,在结束前变慢; + * - 'ease-in': 动画以低速开始; + * - 'ease-in-out': 动画以低速开始和结束; + * - 'ease-out': 动画以低速结束; + * - 'step-start': 动画第一帧就跳至结束状态直到结束; + * - 'step-end': 动画一直保持开始状态,最后一帧跳到结束状态; */ + timingFunction?: + | 'linear' + | 'ease' + | 'ease-in' + | 'ease-in-out' + | 'ease-out' + | 'step-start' + | 'step-end'; + /** 动画延迟时间,单位 ms */ + delay?: number; + transformOrigin?: string; + } + interface AppendFileOption { + /** 要追加内容的文件路径 */ + filePath: string; + /** 要追加的文本或二进制数据 */ + data: string | ArrayBuffer; + /** 指定写入文件的字符编码 + * + * 可选值: + * - 'ascii': ; + * - 'base64': ; + * - 'binary': ; + * - 'hex': ; + * - 'ucs2/ucs-2/utf16le/utf-16le': 以小端序读取; + * - 'utf-8/utf8': ; + * - 'latin1': ; */ + encoding?: + | 'ascii' + | 'base64' + | 'binary' + | 'hex' + | 'ucs2/ucs-2/utf16le/utf-16le' + | 'utf-8/utf8' + | 'latin1'; + /** 接口调用成功的回调函数 */ + success?: AppendFileSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: AppendFileFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: AppendFileCompleteCallback; + } + interface SetBackgroundColorOption { + /** 窗口的背景色,必须为十六进制颜色值 */ + backgroundColor?: string; + /** 顶部窗口的背景色,必须为十六进制颜色值,仅 iOS 支持 */ + backgroundColorTop?: string; + /** 底部窗口的背景色,必须为十六进制颜色值,仅 iOS 支持 */ + backgroundColorBottom?: string; + /** 接口调用成功的回调函数 */ + success?: SetBackgroundColorSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetBackgroundColorFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetBackgroundColorCompleteCallback; + } + interface CanvasPutImageDataOption { + /** 画布标识,传入 `` 组件的 canvas-id 属性。 */ + canvasId: string; + /** 图像像素点数据,一维数组,每四项表示一个像素点的 rgba */ + data: Uint8ClampedArray; + /** 源图像数据在目标画布中的位置偏移量(x 轴方向的偏移量) */ + x: number; + /** 源图像数据在目标画布中的位置偏移量(y 轴方向的偏移量) */ + y: number; + /** 源图像数据矩形区域的宽度 */ + width: number; + /** 源图像数据矩形区域的高度 */ + height: number; + /** 接口调用成功的回调函数 */ + success?: CanvasPutImageDataSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: CanvasPutImageDataFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CanvasPutImageDataCompleteCallback; + } + interface SetTabBarStyleOption { + /** tab 上的文字默认颜色,HexColor */ + color: string; + /** tab 上的文字选中时的颜色,HexColor */ + selectedColor: string; + /** tab 的背景色,HexColor */ + backgroundColor: string; + /** tabBar上边框的颜色, 仅支持 black/white */ + borderStyle: string; + /** 接口调用成功的回调函数 */ + success?: SetTabBarStyleSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetTabBarStyleFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetTabBarStyleCompleteCallback; + } + interface SetInnerAudioOption { + /** 是否与其他音频混播,设置为 true 之后,不会终止其他应用或微信内的音乐 */ + mixWithOther?: boolean; + /** (仅在 iOS 生效)是否遵循静音开关,设置为 false 之后,即使是在静音模式下,也能播放声音 */ + obeyMuteSwitch?: boolean; + /** 接口调用成功的回调函数 */ + success?: SetInnerAudioOptionSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetInnerAudioOptionFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetInnerAudioOptionCompleteCallback; + } + interface ShowModalOption { + /** 提示的标题 */ + title: string; + /** 提示的内容 */ + content: string; + /** 是否显示取消按钮 */ + showCancel?: boolean; + /** 取消按钮的文字,最多 4 个字符 */ + cancelText?: string; + /** 取消按钮的文字颜色,必须是 16 进制格式的颜色字符串 */ + cancelColor?: string; + /** 确认按钮的文字,最多 4 个字符 */ + confirmText?: string; + /** 确认按钮的文字颜色,必须是 16 进制格式的颜色字符串 */ + confirmColor?: string; + /** 接口调用成功的回调函数 */ + success?: ShowModalSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ShowModalFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowModalCompleteCallback; + } + interface GetAvailableAudioSourcesOption { + /** 接口调用成功的回调函数 */ + success?: GetAvailableAudioSourcesSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetAvailableAudioSourcesFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetAvailableAudioSourcesCompleteCallback; + } + interface ShowToastOption { + /** 提示的内容 */ + title: string; + /** 图标 + * + * 可选值: + * - 'success': 显示成功图标,此时 title 文本最多显示 7 个汉字长度; + * - 'loading': 显示加载图标,此时 title 文本最多显示 7 个汉字长度; + * - 'none': 不显示图标,此时 title 文本最多可显示两行,{% version('1.9.0') %}及以上版本支持; */ + icon?: 'success' | 'loading' | 'none'; + /** 自定义图标的本地路径,image 的优先级高于 icon + * + * 最低基础库: `1.1.0` */ + image?: string; + /** 提示的延迟时间 */ + duration?: number; + /** 是否显示透明蒙层,防止触摸穿透 */ + mask?: boolean; + /** 接口调用成功的回调函数 */ + success?: ShowToastSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ShowToastFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowToastCompleteCallback; + } + interface RmdirOption { + /** 要删除的目录路径 */ + dirPath: string; + /** 是否递归删除目录。如果为 true,则删除该目录和该目录下的所有子目录以及文件。 + * + * 最低基础库: `2.3.0` */ + recursive?: boolean; + /** 接口调用成功的回调函数 */ + success?: RmdirSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: RmdirFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: RmdirCompleteCallback; + } + interface HideToastOption { + /** 接口调用成功的回调函数 */ + success?: HideToastSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: HideToastFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: HideToastCompleteCallback; + } + interface StartAccelerometerOption { + /** 监听加速度数据回调函数的执行频率 + * + * 可选值: + * - 'game': 适用于更新游戏的回调频率,在 20ms/次 左右; + * - 'ui': 适用于更新 UI 的回调频率,在 60ms/次 左右; + * - 'normal': 普通的回调频率,在 200ms/次 左右; + * + * 最低基础库: `2.1.0` */ + interval?: 'game' | 'ui' | 'normal'; + /** 接口调用成功的回调函数 */ + success?: StartAccelerometerSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StartAccelerometerFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartAccelerometerCompleteCallback; + } + interface ShowLoadingOption { + /** 提示的内容 */ + title: string; + /** 是否显示透明蒙层,防止触摸穿透 */ + mask?: boolean; + /** 接口调用成功的回调函数 */ + success?: ShowLoadingSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ShowLoadingFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowLoadingCompleteCallback; + } + interface ShowNavigationBarLoadingOption { + /** 接口调用成功的回调函数 */ + success?: ShowNavigationBarLoadingSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ShowNavigationBarLoadingFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowNavigationBarLoadingCompleteCallback; + } + interface HideLoadingOption { + /** 接口调用成功的回调函数 */ + success?: HideLoadingSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: HideLoadingFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: HideLoadingCompleteCallback; + } + interface ScanCodeOption { + /** 是否只能从相机扫码,不允许从相册选择图片 + * + * 最低基础库: `1.2.0` */ + onlyFromCamera?: boolean; + /** 扫码类型 + * + * 可选值: + * - 'barCode': 一维码; + * - 'qrCode': 二维码; + * - 'datamatrix': Data Matrix 码; + * - 'pdf417': PDF417 条码; + * + * 最低基础库: `1.7.0` */ + scanType?: 'barCode' | 'qrCode' | 'datamatrix' | 'pdf417'; + /** 接口调用成功的回调函数 */ + success?: ScanCodeSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ScanCodeFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ScanCodeCompleteCallback; + } + interface HideTabBarOption { + /** 是否需要动画效果 */ + animation?: boolean; + /** 接口调用成功的回调函数 */ + success?: HideTabBarSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: HideTabBarFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: HideTabBarCompleteCallback; + } + interface CloseOption { + /** 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。 */ + code?: number; + /** 一个可读的字符串,表示连接被关闭的原因。这个字符串必须是不长于 123 字节的 UTF-8 文本(不是字符)。 */ + reason?: string; + /** 接口调用成功的回调函数 */ + success?: CloseSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: CloseFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: CloseCompleteCallback; + } + interface ShowActionSheetOption { + /** 按钮的文字数组,数组长度最大为 6 */ + itemList: Array; + /** 按钮的文字颜色 */ + itemColor?: string; + /** 接口调用成功的回调函数 */ + success?: ShowActionSheetSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ShowActionSheetFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowActionSheetCompleteCallback; + } + interface PlayOption { + /** 接口调用成功的回调函数 */ + success?: PlaySuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: PlayFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PlayCompleteCallback; + } + interface GetRegionOption { + /** 接口调用成功的回调函数 */ + success?: GetRegionSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: GetRegionFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: GetRegionCompleteCallback; + } + interface ShowTabBarOption { + /** 是否需要动画效果 */ + animation?: boolean; + /** 接口调用成功的回调函数 */ + success?: ShowTabBarSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ShowTabBarFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ShowTabBarCompleteCallback; + } + interface StopPullDownRefreshOption { + /** 接口调用成功的回调函数 */ + success?: StopPullDownRefreshSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StopPullDownRefreshFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StopPullDownRefreshCompleteCallback; + } + interface StartPullDownRefreshOption { + /** 接口调用成功的回调函数 */ + success?: StartPullDownRefreshSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StartPullDownRefreshFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartPullDownRefreshCompleteCallback; + } + interface PageScrollToOption { + /** 滚动到页面的目标位置,单位 px */ + scrollTop: number; + /** 滚动动画的时长,单位 ms */ + duration?: number; + /** 接口调用成功的回调函数 */ + success?: PageScrollToSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: PageScrollToFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: PageScrollToCompleteCallback; + } + interface SetClipboardDataOption { + /** 剪贴板的内容 */ + data: string; + /** 接口调用成功的回调函数 */ + success?: SetClipboardDataSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: SetClipboardDataFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: SetClipboardDataCompleteCallback; + } + interface ReadFileOption { + /** 要读取的文件的路径 */ + filePath: string; + /** 指定读取文件的字符编码,如果不传 encoding,则以 ArrayBuffer 格式读取文件的二进制内容 + * + * 可选值: + * - 'ascii': ; + * - 'base64': ; + * - 'binary': ; + * - 'hex': ; + * - 'ucs2/ucs-2/utf16le/utf-16le': 以小端序读取; + * - 'utf-8/utf8': ; + * - 'latin1': ; */ + encoding?: 'ascii' + | 'base64' + | 'binary' + | 'hex' + | 'ucs2' | 'ucs-2' | 'utf16le' | 'utf-16le' + | 'utf-8' | 'utf8' + | 'latin1' | string + /** 接口调用成功的回调函数 */ + success?: ReadFileSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: ReadFileFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: ReadFileCompleteCallback; + } + interface WxRemoveSavedFileOption { + /** 需要删除的文件路径 */ + filePath: string; + /** 接口调用成功的回调函数 */ + success?: WxRemoveSavedFileSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: WxRemoveSavedFileFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: WxRemoveSavedFileCompleteCallback; + } + interface LivePlayerContextPauseOption { + /** 接口调用成功的回调函数 */ + success?: LivePlayerContextPauseSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: LivePlayerContextPauseFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: LivePlayerContextPauseCompleteCallback; + } + interface StartDeviceMotionListeningOption { + /** 监听设备方向的变化回调函数的执行频率 + * + * 可选值: + * - 'game': 适用于更新游戏的回调频率,在 20ms/次 左右; + * - 'ui': 适用于更新 UI 的回调频率,在 60ms/次 左右; + * - 'normal': 普通的回调频率,在 200ms/次 左右; */ + interval?: 'game' | 'ui' | 'normal'; + /** 接口调用成功的回调函数 */ + success?: StartDeviceMotionListeningSuccessCallback; + /** 接口调用失败的回调函数 */ + fail?: StartDeviceMotionListeningFailCallback; + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: StartDeviceMotionListeningCompleteCallback; + } + /** 插件账号信息(仅在插件中调用时包含这一项) */ + interface Plugin { + /** 插件 appId */ + appId: string; + /** 插件版本号 */ + version: string; + } + /** 该特征值支持的操作类型 */ + interface Properties { + /** 该特征值是否支持 read 操作 */ + read: boolean; + /** 该特征值是否支持 write 操作 */ + write: boolean; + /** 该特征值是否支持 notify 操作 */ + notify: boolean; + /** 该特征值是否支持 indicate 操作 */ + indicate: boolean; + } + /** 菜单按钮的布局位置信息 */ + interface Rect { + /** 宽度 */ + width: number; + /** 高度 */ + height: number; + /** 上边界坐标 */ + top: number; + /** 右边界坐标 */ + right: number; + /** 下边界坐标 */ + bottom: number; + /** 左边界坐标 */ + left: number; + } + /** 参照区域的边界 */ + interface RelativeRectResult { + /** 左边界 */ + left: number; + /** 右边界 */ + right: number; + /** 上边界 */ + top: number; + /** 下边界 */ + bottom: number; + } + interface GetUserInfoSuccessCallbackResult { + /** [UserInfo]((UserInfo)) + * + * 用户信息对象,不包含 openid 等敏感信息 */ + userInfo: UserInfo; + /** 不包括敏感信息的原始数据字符串,用于计算签名 */ + rawData: string; + /** 使用 sha1( rawData + sessionkey ) 得到字符串,用于校验用户信息,详见 [用户数据的签名验证和加解密]((signature)) */ + signature: string; + /** 包括敏感数据在内的完整用户信息的加密数据,详见 [用户数据的签名验证和加解密]((signature#加密数据解密算法)) */ + encryptedData: string; + /** 加密算法的初始向量,详见 [用户数据的签名验证和加解密]((signature#加密数据解密算法)) */ + iv: string; + } + interface GetBackgroundAudioPlayerStateSuccessCallbackResult { + /** 选定音频的长度(单位:s),只有在音乐播放中时返回 */ + duration: number; + /** 选定音频的播放位置(单位:s),只有在音乐播放中时返回 */ + currentPosition: number; + /** 播放状态 + * + * 可选值: + * - 0: 暂停中; + * - 1: 播放中; + * - 2: 没有音乐播放; */ + status: 0 | 1 | 2; + /** 音频的下载进度百分比,只有在音乐播放中时返回 */ + downloadPercent: number; + /** 歌曲数据链接,只有在音乐播放中时返回 */ + dataUrl: string; + } + interface OnWindowResizeCallbackResult { + size: Size; + } + interface UnlinkFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail permission denied, open ${path}': 指定的 path 路径没有读权限; + * - 'fail no such file or directory ${path}': 文件不存在; + * - 'fail operation not permitted, unlink ${filePath}': 传入的 filePath 是一个目录; */ + errMsg: string; + } + interface OnGyroscopeChangeCallbackResult { + res: Result; + } + interface StatFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail permission denied, open ${path}': 指定的 path 路径没有读权限; + * - 'fail no such file or directory ${path}': 文件不存在; */ + errMsg: string; + } + interface ShowActionSheetSuccessCallbackResult { + /** 用户点击的按钮序号,从上到下的顺序,从0开始 */ + tapIndex: number; + } + interface StatSuccessCallbackResult { + /** [Stats]((Stats))|Object + * + * 当 recursive 为 false 时,res.stats 是一个 Stats 对象。当 recursive 为 true 且 path 是一个目录的路径时,res.stats 是一个 Object,key 以 path 为根路径的相对路径,value 是该路径对应的 Stats 对象。 */ + stats: Stats | IAnyObject; + } + interface ScrollOffsetCallbackResult { + /** 节点的 ID */ + id: string; + /** 节点的 dataset */ + dataset: IAnyObject; + /** 节点的水平滚动位置 */ + scrollLeft: number; + /** 节点的竖直滚动位置 */ + scrollTop: number; + } + interface OnCheckForUpdateCallbackResult { + /** 是否有新版本 */ + hasUpdate: boolean; + } + interface WorkerOnMessageCallbackResult { + /** 主线程/Worker 线程向当前线程发送的消息 */ + message: any; + } + interface OnMemoryWarningCallbackResult { + /** 内存告警等级,只有 Android 才有,对应系统宏定义 + * + * 可选值: + * - 5: TRIM_MEMORY_RUNNING_MODERATE; + * - 10: TRIM_MEMORY_RUNNING_LOW; + * - 15: TRIM_MEMORY_RUNNING_CRITICAL; */ + level: 5 | 10 | 15; + } + interface OnBeaconUpdateCallbackResult { + /** 当前搜寻到的所有 iBeacon 设备列表 */ + beacons: Array; + } + interface RmdirFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail no such file or directory ${dirPath}': 目录不存在; + * - 'fail directory not empty': 目录不为空; + * - 'fail permission denied, open ${dirPath}': 指定的 dirPath 路径没有写权限; */ + errMsg: string; + } + interface ShowModalSuccessCallbackResult { + /** 为 true 时,表示用户点击了确定按钮 */ + confirm: boolean; + /** 为 true 时,表示用户点击了取消(用于 Android 系统区分点击蒙层关闭还是点击取消按钮关闭) + * + * 最低基础库: `1.1.0` */ + cancel: boolean; + } + interface RenameFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail permission denied, rename ${oldPath} -> ${newPath}': 指定源文件或目标文件没有写权限; + * - 'fail no such file or directory, rename ${oldPath} -> ${newPath}': 源文件不存在,或目标文件路径的上层目录不存在; */ + errMsg: string; + } + interface ObserveCallbackResult { + /** 相交比例 */ + intersectionRatio: number; + /** 相交区域的边界 */ + intersectionRect: IntersectionRectResult; + /** 目标边界 */ + boundingClientRect: BoundingClientRectResult; + /** 参照区域的边界 */ + relativeRect: RelativeRectResult; + /** 相交检测时的时间戳 */ + time: number; + } + interface ReadFileFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail no such file or directory, open ${filePath}': 指定的 filePath 所在目录不存在; + * - 'fail permission denied, open ${dirPath}': 指定的 filePath 路径没有读权限; */ + errMsg: string; + } + interface OnAccelerometerChangeCallbackResult { + /** X 轴 */ + x: number; + /** Y 轴 */ + y: number; + /** Z 轴 */ + z: number; + } + interface ReadFileSuccessCallbackResult { + /** 文件内容 */ + data: string | ArrayBuffer; + } + interface GetBLEDeviceServicesSuccessCallbackResult { + /** 设备服务列表 */ + services: BLEService; + } + interface CanvasToTempFilePathSuccessCallbackResult { + /** 生成文件的临时路径 */ + tempFilePath: string; + } + interface GetBluetoothAdapterStateSuccessCallbackResult { + /** 是否正在搜索设备 */ + discovering: boolean; + /** 蓝牙适配器是否可用 */ + available: boolean; + } + interface GetAvailableAudioSourcesSuccessCallbackResult { + /** 支持的音频输入源列表,可在 [RecorderManager.start()]((RecorderManager.start)) 接口中使用。返回值定义参考 https://developer.android.com/reference/kotlin/android/media/MediaRecorder.AudioSource + * + * 可选值: + * - 'auto': 自动设置,默认使用手机麦克风,插上耳麦后自动切换使用耳机麦克风,所有平台适用; + * - 'buildInMic': 手机麦克风,仅限 iOS; + * - 'headsetMic': 耳机麦克风,仅限 iOS; + * - 'mic': 麦克风(没插耳麦时是手机麦克风,插耳麦时是耳机麦克风),仅限 Android; + * - 'camcorder': 同 mic,适用于录制音视频内容,仅限 Android; + * - 'voice_communication': 同 mic,适用于实时沟通,仅限 Android; + * - 'voice_recognition': 同 mic,适用于语音识别,仅限 Android; */ + audioSources: + | 'auto' + | 'buildInMic' + | 'headsetMic' + | 'mic' + | 'camcorder' + | 'voice_communication' + | 'voice_recognition'; + } + interface ChooseInvoiceTitleSuccessCallbackResult { + /** 抬头类型 + * + * 可选值: + * - 0: 单位; + * - 1: 个人; */ + type: 0 | 1; + /** 抬头名称 */ + title: string; + /** 抬头税号 */ + taxNumber: string; + /** 单位地址 */ + companyAddress: string; + /** 手机号码 */ + telephone: string; + /** 银行名称 */ + bankName: string; + /** 银行账号 */ + bankAccount: string; + /** 错误信息 */ + errMsg: string; + } + interface ReaddirFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail no such file or directory ${dirPath}': 目录不存在; + * - 'fail not a directory ${dirPath}': dirPath 不是目录; + * - 'fail permission denied, open ${dirPath}': 指定的 filePath 路径没有读权限; */ + errMsg: string; + } + interface ChooseInvoiceSuccessCallbackResult { + /** 用户选中的发票列表 */ + invoiceInfo: InvoiceInfo; + } + interface StartRecordSuccessCallbackResult { + /** 录音文件的临时路径 */ + tempFilePath: string; + } + interface GetConnectedBluetoothDevicesSuccessCallbackResult { + /** 搜索到的设备列表 */ + devices: BluetoothDeviceInfo; + } + interface ReaddirSuccessCallbackResult { + /** 指定目录下的文件名数组。 */ + files: Array; + } + interface TakePhotoSuccessCallbackResult { + /** 照片文件的临时路径 */ + tempImagePath: string; + } + interface MkdirFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail no such file or directory ${dirPath}': 上级目录不存在; + * - 'fail permission denied, open ${dirPath}': 指定的 filePath 路径没有写权限; + * - 'fail file already exists ${dirPath}': 有同名文件或目录; */ + errMsg: string; + } + interface OnBLEConnectionStateChangeCallbackResult { + /** 蓝牙设备ID */ + deviceId: string; + /** 是否处于已连接状态 */ + connected: boolean; + } + interface WxGetFileInfoSuccessCallbackResult { + /** 文件大小,以字节为单位 */ + size: number; + /** 按照传入的 digestAlgorithm 计算得出的的文件摘要 */ + digest: string; + } + interface AddCardSuccessCallbackResult { + /** 卡券添加结果列表 */ + cardList: AddCardResponseInfo; + } + interface OnStopCallbackResult { + /** 录音文件的临时路径 */ + tempFilePath: string; + } + interface StartRecordTimeoutCallbackResult { + /** 封面图片文件的临时路径 */ + tempThumbPath: string; + /** 视频的文件的临时路径 */ + tempVideoPath: string; + } + interface OnFrameRecordedCallbackResult { + /** 录音分片数据 */ + frameBuffer: ArrayBuffer; + /** 当前帧是否正常录音结束前的最后一帧 */ + isLastFrame: boolean; + } + interface LoginSuccessCallbackResult { + /** 用户登录凭证(有效期五分钟)。开发者需要在开发者服务器后台调用 [code2Session]((code2Session)),使用 code 换取 openid 和 session_key 等信息 */ + code: string; + } + interface RecorderManagerOnErrorCallbackResult { + /** 错误信息 */ + errMsg: string; + } + interface OnSocketMessageCallbackResult { + /** 服务器返回的消息 */ + data: string | ArrayBuffer; + } + interface GetFileInfoFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail file not exist': 指定的 filePath 找不到文件; */ + errMsg: string; + } + interface OnHCEMessageCallbackResult { + /** 消息类型 + * + * 可选值: + * - 1: HCE APDU Command类型,小程序需对此指令进行处理,并调用 sendHCEMessage 接口返回处理指令; + * - 2: 设备离场事件类型; */ + messageType: 1 | 2; + /** `messageType=1` 时 ,客户端接收到 NFC 设备的指令 */ + data: ArrayBuffer; + /** `messageType=2` 时,原因 */ + reason: number; + } + interface FileSystemManagerGetFileInfoSuccessCallbackResult { + /** 文件大小,以字节为单位 */ + size: number; + } + interface DownloadFileSuccessCallbackResult { + /** 临时文件路径。如果没传入 filePath 指定文件存储路径,则下载后的文件会存储到一个临时文件 */ + tempFilePath: string; + /** 开发者服务器返回的 HTTP 状态码 */ + statusCode: number; + } + interface CopyFileFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail permission denied, copyFile ${srcPath} -> ${destPath}': 指定目标文件路径没有写权限; + * - 'fail no such file or directory, copyFile ${srcPath} -> ${destPath}': 源文件不存在,或目标文件路径的上层目录不存在; */ + errMsg: string; + } + interface GetImageInfoSuccessCallbackResult { + /** 图片原始宽度,单位px。不考虑旋转。 */ + width: number; + /** 图片原始高度,单位px。不考虑旋转。 */ + height: number; + /** 图片的本地路径 */ + path: string; + /** [拍照时设备方向](http://sylvana.net/jpegcrop/exif_orientation.html) + * + * 可选值: + * - 'up': 默认方向(手机横持拍照),对应 Exif 中的 1。或无 orientation 信息。; + * - 'up-mirrored': 同 up,但镜像翻转,对应 Exif 中的 2; + * - 'down': 旋转180度,对应 Exif 中的 3; + * - 'down-mirrored': 同 down,但镜像翻转,对应 Exif 中的 4; + * - 'left-mirrored': 同 left,但镜像翻转,对应 Exif 中的 5; + * - 'right': 顺时针旋转90度,对应 Exif 中的 6; + * - 'right-mirrored': 同 right,但镜像翻转,对应 Exif 中的 7; + * - 'left': 逆时针旋转90度,对应 Exif 中的 8; + * + * 最低基础库: `1.9.90` */ + orientation: + | 'up' + | 'up-mirrored' + | 'down' + | 'down-mirrored' + | 'left-mirrored' + | 'right' + | 'right-mirrored' + | 'left'; + /** 图片格式 + * + * 最低基础库: `1.9.90` */ + type: string; + } + interface RemoveSavedFileFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail file not exist': 指定的 tempFilePath 找不到文件; */ + errMsg: string; + } + interface StopRecordSuccessCallbackResult { + /** 封面图片文件的临时路径 */ + tempThumbPath: string; + /** 视频的文件的临时路径 */ + tempVideoPath: string; + } + interface GetSavedFileInfoSuccessCallbackResult { + /** 文件大小,单位 B */ + size: number; + /** 文件保存时的时间戳,从1970/01/01 08:00:00 到该时刻的秒数 */ + createTime: number; + } + interface GetLocationSuccessCallbackResult { + /** 纬度,范围为 -90~90,负数表示南纬 */ + latitude: number; + /** 经度,范围为 -180~180,负数表示西经 */ + longitude: number; + /** 速度,单位 m/s */ + speed: number; + /** 位置的精确度 */ + accuracy: number; + /** 高度,单位 m + * + * 最低基础库: `1.2.0` */ + altitude: number; + /** 垂直精度,单位 m(Android 无法获取,返回 0) + * + * 最低基础库: `1.2.0` */ + verticalAccuracy: number; + /** 水平精度,单位 m + * + * 最低基础库: `1.2.0` */ + horizontalAccuracy: number; + } + interface DownloadTaskOnProgressUpdateCallbackResult { + /** 下载进度百分比 */ + progress: number; + /** 已经下载的数据长度,单位 Bytes */ + totalBytesWritten: number; + /** 预期需要下载的数据总长度,单位 Bytes */ + totalBytesExpectedToWrite: number; + } + interface WriteFileFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail no such file or directory, open ${filePath}': 指定的 filePath 所在目录不存在; + * - 'fail permission denied, open ${dirPath}': 指定的 filePath 路径没有写权限; */ + errMsg: string; + } + interface WxGetSavedFileListSuccessCallbackResult { + /** 文件数组,每一项是一个 FileItem */ + fileList: WxGetSavedFileListSuccessCallbackResultFileItem; + } + interface OnGetWifiListCallbackResult { + /** Wi-Fi 列表数据 */ + wifiList: Array; + } + interface GetBeaconsSuccessCallbackResult { + /** iBeacon 设备列表 */ + beacons: Array; + } + interface OnWifiConnectedCallbackResult { + /** [WifiInfo]((WifiInfo)) + * + * Wi-Fi 信息 */ + wifi: WifiInfo; + } + interface FileSystemManagerGetSavedFileListSuccessCallbackResult { + /** 文件数组 */ + fileList: FileSystemManagerGetSavedFileListSuccessCallbackResultFileItem; + } + interface BoundingClientRectCallbackResult { + /** 节点的 ID */ + id: string; + /** 节点的 dataset */ + dataset: IAnyObject; + /** 节点的左边界坐标 */ + left: number; + /** 节点的右边界坐标 */ + right: number; + /** 节点的上边界坐标 */ + top: number; + /** 节点的下边界坐标 */ + bottom: number; + /** 节点的宽度 */ + width: number; + /** 节点的高度 */ + height: number; + } + interface WxSaveFileSuccessCallbackResult { + /** 存储后的文件路径 */ + savedFilePath: number; + } + interface GetScaleSuccessCallbackResult { + /** 缩放值 */ + scale: number; + } + interface OnOpenCallbackResult { + /** 连接成功的 HTTP 响应 Header + * + * 最低基础库: `2.0.0` */ + header: IAnyObject; + } + interface GetWeRunDataSuccessCallbackResult { + /** 包括敏感数据在内的完整用户信息的加密数据,详细见[加密数据解密算法]((signature))。解密后得到的数据结构见后文 */ + encryptedData: string; + /** 加密算法的初始向量,详细见[加密数据解密算法]((signature)) */ + iv: string; + } + interface SocketTaskOnErrorCallbackResult { + /** 错误信息 */ + errMsg: string; + } + interface GetCenterLocationSuccessCallbackResult { + /** 经度 */ + longitude: number; + /** 纬度 */ + latitude: number; + } + interface SocketTaskOnMessageCallbackResult { + /** 服务器返回的消息 */ + data: string | ArrayBuffer; + } + interface FaceVerifyForPaySuccessCallbackResult { + /** 本次认证结果凭据 */ + token: string; + /** 用户是否点了别的验证方式 */ + clickOtherVerifyBtn: boolean; + } + interface Result { + /** x 轴的角速度 */ + x: number; + /** y 轴的角速度 */ + y: number; + /** z 轴的角速度 */ + z: number; + } + interface GetBatteryInfoSuccessCallbackResult { + /** 设备电量,范围 1 - 100 */ + level: string; + /** 是否正在充电中 */ + isCharging: boolean; + } + interface UploadTaskOnProgressUpdateCallbackResult { + /** 上传进度百分比 */ + progress: number; + /** 已经上传的数据长度,单位 Bytes */ + totalBytesSent: number; + /** 预期需要上传的数据总长度,单位 Bytes */ + totalBytesExpectedToSend: number; + } + interface OnBLECharacteristicValueChangeCallbackResult { + /** 蓝牙设备 id */ + deviceId: string; + /** 蓝牙特征值对应服务的 uuid */ + serviceId: string; + /** 蓝牙特征值的 uuid */ + characteristicId: string; + /** 特征值最新的值 */ + value: ArrayBuffer; + } + interface SaveFileFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail tempFilePath file not exist': 指定的 tempFilePath 找不到文件; + * - 'fail permission denied, open "${filePath}"': 指定的 filePath 路径没有写权限; + * - 'fail no such file or directory "${dirPath}"': 上级目录不存在; */ + errMsg: string; + } + interface OnBluetoothDeviceFoundCallbackResult { + /** 新搜索到的设备列表 */ + devices: CallbackResultBlueToothDevice; + } + interface GetSettingSuccessCallbackResult { + /** [AuthSetting]((AuthSetting)) + * + * 用户授权结果 */ + authSetting: AuthSetting; + } + interface UploadFileSuccessCallbackResult { + /** 开发者服务器返回的数据 */ + data: string; + /** 开发者服务器返回的 HTTP 状态码 */ + statusCode: number; + } + interface FileSystemManagerSaveFileSuccessCallbackResult { + /** 存储后的文件路径 */ + savedFilePath: number; + } + interface RequestSuccessCallbackResult { + /** 开发者服务器返回的数据 */ + data: string | IAnyObject | ArrayBuffer; + /** 开发者服务器返回的 HTTP 状态码 */ + statusCode: number; + /** 开发者服务器返回的 HTTP Response Header + * + * 最低基础库: `1.2.0` */ + header: IAnyObject; + } + interface OpenSettingSuccessCallbackResult { + /** [AuthSetting]((AuthSetting)) + * + * 用户授权结果 */ + authSetting: AuthSetting; + } + interface ChooseImageSuccessCallbackResult { + /** 图片的本地临时文件路径列表 */ + tempFilePaths: Array; + /** 图片的本地临时文件列表 + * + * 最低基础库: `1.2.0` + * + * 最低基础库: `1.2.0` */ + tempFiles: ImageFile; + } + interface AppendFileFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail no such file or directory, open ${filePath}': 指定的 filePath 文件不存在; + * - 'fail illegal operation on a directory, open "${filePath}" ': 指定的 filePath 是一个已经存在的目录; + * - 'fail permission denied, open ${dirPath}': 指定的 filePath 路径没有写权限; + * - 'fail sdcard not mounted ': 指定的 filePath 是一个已经存在的目录; */ + errMsg: string; + } + interface GetConnectedWifiSuccessCallbackResult { + /** [WifiInfo]((WifiInfo)) + * + * Wi-Fi 信息 */ + wifi: WifiInfo; + } + interface GetShareInfoSuccessCallbackResult { + /** 错误信息 */ + errMsg: string; + /** 包括敏感数据在内的完整转发信息的加密数据,详细见[加密数据解密算法]((开放数据校验与解密)) */ + encryptedData: string; + /** 加密算法的初始向量,详细见[加密数据解密算法]((开放数据校验与解密)) */ + iv: string; + } + interface OnCompassChangeCallbackResult { + /** 面对的方向度数 */ + direction: number; + } + interface AccessFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail no such file or directory ${path}': 文件/目录不存在; */ + errMsg: string; + } + interface GetRegionSuccessCallbackResult { + /** 西南角经纬度 */ + southwest: number; + /** 东北角经纬度 */ + northeast: number; + } + interface GetExtConfigSuccessCallbackResult { + /** 第三方平台自定义的数据 */ + extConfig: IAnyObject; + } + interface GetBLEDeviceCharacteristicsSuccessCallbackResult { + /** 设备服务列表 */ + characteristics: BLECharacteristic; + } + interface GetSystemInfoSuccessCallbackResult { + /** 手机品牌 + * + * 最低基础库: `1.5.0` */ + brand: string; + /** 手机型号 */ + model: string; + /** 设备像素比 */ + pixelRatio: number; + /** 屏幕宽度 + * + * 最低基础库: `1.1.0` */ + screenWidth: number; + /** 屏幕高度 + * + * 最低基础库: `1.1.0` */ + screenHeight: number; + /** 可使用窗口宽度 */ + windowWidth: number; + /** 可使用窗口高度 */ + windowHeight: number; + /** 状态栏的高度 + * + * 最低基础库: `1.9.0` */ + statusBarHeight: number; + /** 微信设置的语言 */ + language: string; + /** 微信版本号 */ + version: string; + /** 操作系统版本 */ + system: string; + /** 客户端平台 */ + platform: string; + /** 用户字体大小设置。以“我-设置-通用-字体大小”中的设置为准,单位 px。 + * + * 最低基础库: `1.5.0` */ + fontSizeSetting: number; + /** 客户端基础库版本 + * + * 最低基础库: `1.1.0` */ + SDKVersion: string; + /** (仅Android小游戏) 性能等级,-2 或 0:该设备无法运行小游戏,-1:性能未知,>=1 设备性能值,该值越高,设备性能越好 (目前设备最高不到50) + * + * 最低基础库: `1.8.0` */ + benchmarkLevel: number; + } + interface GetBluetoothDevicesSuccessCallbackResult { + /** uuid 对应的的已连接设备列表 */ + devices: GetBluetoothDevicesSuccessCallbackResultBlueToothDevice; + } + interface ScanCodeSuccessCallbackResult { + /** 所扫码的内容 */ + result: string; + /** 所扫码的类型 + * + * 可选值: + * - 'QR_CODE': 二维码; + * - 'AZTEC': 一维码; + * - 'CODABAR': 一维码; + * - 'CODE_39': 一维码; + * - 'CODE_93': 一维码; + * - 'CODE_128': 一维码; + * - 'DATA_MATRIX': 二维码; + * - 'EAN_8': 一维码; + * - 'EAN_13': 一维码; + * - 'ITF': 一维码; + * - 'MAXICODE': 一维码; + * - 'PDF_417': 二维码; + * - 'RSS_14': 一维码; + * - 'RSS_EXPANDED': 一维码; + * - 'UPC_A': 一维码; + * - 'UPC_E': 一维码; + * - 'UPC_EAN_EXTENSION': 一维码; + * - 'WX_CODE': 二维码; + * - 'CODE_25': 一维码; */ + scanType: + | 'QR_CODE' + | 'AZTEC' + | 'CODABAR' + | 'CODE_39' + | 'CODE_93' + | 'CODE_128' + | 'DATA_MATRIX' + | 'EAN_8' + | 'EAN_13' + | 'ITF' + | 'MAXICODE' + | 'PDF_417' + | 'RSS_14' + | 'RSS_EXPANDED' + | 'UPC_A' + | 'UPC_E' + | 'UPC_EAN_EXTENSION' + | 'WX_CODE' + | 'CODE_25'; + /** 所扫码的字符集 */ + charSet: string; + /** 当所扫的码为当前小程序的合法二维码时,会返回此字段,内容为二维码携带的 path */ + path: string; + /** 原始数据,base64编码 */ + rawData: string; + } + interface OnBluetoothAdapterStateChangeCallbackResult { + /** 蓝牙适配器是否可用 */ + available: boolean; + /** 蓝牙适配器是否处于搜索状态 */ + discovering: boolean; + } + interface CheckIsSoterEnrolledInDeviceSuccessCallbackResult { + /** 是否已录入信息 */ + isEnrolled: boolean; + /** 错误信息 */ + errMs: string; + } + interface OnSocketOpenCallbackResult { + /** 连接成功的 HTTP 响应 Header + * + * 最低基础库: `2.0.0` */ + header: IAnyObject; + } + interface OnNetworkStatusChangeCallbackResult { + /** 当前是否有网络链接 */ + isConnected: boolean; + /** 网络类型 + * + * 可选值: + * - 'wifi': wifi 网络; + * - '2g': 2g 网络; + * - '3g': 3g 网络; + * - '4g': 4g 网络; + * - 'unknown': Android 下不常见的网络类型; + * - 'none': 无网络; */ + networkType: 'wifi' | '2g' | '3g' | '4g' | 'unknown' | 'none'; + } + interface ChooseLocationSuccessCallbackResult { + /** 位置名称 */ + name: string; + /** 详细地址 */ + address: string; + /** 纬度,浮点数,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 */ + latitude: string; + /** 经度,浮点数,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 */ + longitude: string; + } + interface CheckIsSupportSoterAuthenticationSuccessCallbackResult { + /** 该设备支持的可被SOTER识别的生物识别方式 + * + * 可选值: + * - 'fingerPrint': 指纹识别; + * - 'facial': 人脸识别(暂未支持); + * - 'speech': 声纹识别(暂未支持); */ + supportMode: 'fingerPrint' | 'facial' | 'speech'; + } + interface CanvasGetImageDataSuccessCallbackResult { + /** 图像数据矩形的宽度 */ + width: number; + /** 图像数据矩形的高度 */ + height: number; + } + interface FaceVerifyForPayFailCallbackResult { + /** 错误信息 */ + errMsg: string; + /** 错误码 */ + number: number; + } + interface OnBeaconServiceChangeCallbackResult { + /** 服务目前是否可用 */ + available: boolean; + /** 目前是否处于搜索状态 */ + discovering: boolean; + } + interface OnDeviceMotionChangeCallbackResult { + /** 当 手机坐标 X/Y 和 地球 X/Y 重合时,绕着 Z 轴转动的夹角为 alpha,范围值为 [0, 2*PI)。逆时针转动为正。 */ + alpha: number; + /** 当手机坐标 Y/Z 和地球 Y/Z 重合时,绕着 X 轴转动的夹角为 beta。范围值为 [-1*PI, PI) 。顶部朝着地球表面转动为正。也有可能朝着用户为正。 */ + beta: number; + /** 当手机 X/Z 和地球 X/Z 重合时,绕着 Y 轴转动的夹角为 gamma。范围值为 [-1*PI/2, PI/2)。右边朝着地球表面转动为正。 */ + gamma: number; + } + interface StartSoterAuthenticationSuccessCallbackResult { + /** 生物认证方式 */ + authMode: string; + /** 在设备安全区域(TEE)内获得的本机安全信息(如TEE名称版本号等以及防重放参数)以及本次认证信息(仅Android支持,本次认证的指纹ID)。具体说明见下文 */ + resultJSON: string; + /** 用SOTER安全密钥对 `resultJSON` 的签名(SHA256 with RSA/PSS, saltlen=20) */ + resultJSONSignature: string; + /** 错误码 */ + errCode: number; + /** 错误信息 */ + errMsg: string; + } + interface GetNetworkTypeSuccessCallbackResult { + /** 网络类型 + * + * 可选值: + * - 'wifi': wifi 网络; + * - '2g': 2g 网络; + * - '3g': 3g 网络; + * - '4g': 4g 网络; + * - 'unknown': Android 下不常见的网络类型; + * - 'none': 无网络; */ + networkType: 'wifi' | '2g' | '3g' | '4g' | 'unknown' | 'none'; + } + interface InnerAudioContextOnErrorCallbackResult { + /** 可选值: + * - 10001: 系统错误; + * - 10002: 网络错误; + * - 10003: 文件错误; + * - 10004: 格式错误; + * - -1: 未知错误; */ + errCode: 10001 | 10002 | 10003 | 10004 | -1; + } + interface GetStorageSuccessCallbackResult { + /** key对应的内容 */ + data: IAnyObject | string; + } + interface UnzipFailCallbackResult { + /** 错误信息 + * + * 可选值: + * - 'fail permission denied, unzip ${zipFilePath} -> ${destPath}': 指定目标文件路径没有写权限; + * - 'fail no such file or directory, unzip ${zipFilePath} -> "${destPath}': 源文件不存在,或目标文件路径的上层目录不存在; */ + errMsg: string; + } + interface ChooseVideoSuccessCallbackResult { + /** 选定视频的临时文件路径 */ + tempFilePath: string; + /** 选定视频的时间长度 */ + duration: number; + /** 选定视频的数据量大小 */ + size: number; + /** 返回选定视频的高度 */ + height: number; + /** 返回选定视频的宽度 */ + width: number; + } + interface ChooseAddressSuccessCallbackResult { + /** 收货人姓名 */ + userName: string; + /** 邮编 */ + postalCode: string; + /** 国标收货地址第一级地址 */ + provinceName: string; + /** 国标收货地址第一级地址 */ + cityName: string; + /** 国标收货地址第一级地址 */ + countyName: string; + /** 详细收货地址信息 */ + detailInfo: string; + /** 收货地址国家码 */ + nationalCode: string; + /** 收货人手机号码 */ + telNumber: string; + /** 错误信息 */ + errMsg: string; + } + interface Size { + /** 变化后的窗口宽度,单位 px */ + windowWidth: number; + /** 变化后的窗口高度,单位 px */ + windowHeight: number; + } + /** 描述文件状态的对象 */ + interface Stats { + /** 文件的类型和存取的权限,对应 POSIX stat.st_mode */ + mode: string; + /** 文件大小,单位:B,对应 POSIX stat.st_size */ + size: number; + /** 文件最近一次被存取或被执行的时间,UNIX 时间戳,对应 POSIX stat.st_atime */ + lastAccessedTime: number; + /** 文件最后一次被修改的时间,UNIX 时间戳,对应 POSIX stat.st_mtime */ + lastModifiedTime: number; + } + interface TextMetrics { + /** 文本的宽度 */ + width: number; + } + /** 用户信息 */ + interface UserInfo { + /** 用户昵称 */ + nickName: string; + /** 用户头像图片的 URL。URL 最后一个数值代表正方形头像大小(有 0、46、64、96、132 数值可选,0 代表 640x640 的正方形头像,46 表示 46x46 的正方形头像,剩余数值以此类推。默认132),用户没有头像时该项为空。若用户更换头像,原有头像 URL 将失效。 */ + avatarUrl: string; + /** 用户性别 + * + * 可选值: + * - 0: 未知; + * - 1: 男性; + * - 2: 女性; */ + gender: 0 | 1 | 2; + /** 用户所在国家 */ + country: string; + /** 用户所在省份 */ + province: string; + /** 用户所在城市 */ + city: string; + /** 显示 country,province,city 所用的语言 + * + * 可选值: + * - 'en': 英文; + * - 'zh_CN': 简体中文; + * - 'zh_TW': 繁体中文; */ + language: 'en' | 'zh_CN' | 'zh_TW'; + } + /** 提供预设的 Wi-Fi 信息列表 */ + interface WifiData { + /** Wi-Fi 的 SSID */ + SSID?: string; + /** Wi-Fi 的 BSSID */ + BSSID?: string; + /** Wi-Fi 设备密码 */ + password?: string; + } + /** Wifi 信息 */ + interface WifiInfo { + /** Wi-Fi 的 SSID */ + SSID: string; + /** Wi-Fi 的 BSSID */ + BSSID: string; + /** Wi-Fi 是否安全 */ + secure: boolean; + /** Wi-Fi 信号强度 */ + signalStrength: number; + } + interface WxComponent { + /** [wx.canvasGetImageData(Object object, Object this)](wx.canvasGetImageData.md) + * + * 获取 canvas 区域隐含的像素数据。 + * + * **示例代码** + * + * {% minicode('GlCRTlmS7n27') %} + * + * ```js + wx.canvasGetImageData({ + canvasId: 'myCanvas', + x: 0, + y: 0, + width: 100, + height: 100, + success(res) { + console.log(res.width) // 100 + console.log(res.height) // 100 + console.log(res.data instanceof Uint8ClampedArray) // true + console.log(res.data.length) // 100 100 4 + } + }) + ``` + * + * 最低基础库: `1.9.0` */ + canvasGetImageData(option: CanvasGetImageDataOption): void; + /** [wx.canvasPutImageData(Object object, Object this)](wx.canvasPutImageData.md) + * + * 将像素数据绘制到画布。在自定义组件下,第二个参数传入自定义组件实例 this,以操作组件内 组件 + * + * 最低基础库: `1.9.0` */ + canvasPutImageData(option: CanvasPutImageDataOption): void; + /** [wx.canvasToTempFilePath(Object object, Object this)](wx.canvasToTempFilePath.md) + * + * 把当前画布指定区域的内容导出生成指定大小的图片。在 `draw()` 回调里调用该方法才能保证图片导出成功。 */ + canvasToTempFilePath(option: CanvasToTempFilePathOption): void; + /** [[CanvasContext]((CanvasContext)) wx.createCanvasContext(string canvasId, Object this)](wx.createCanvasContext.md) + * + * 创建 canvas 的绘图上下文 `CanvasContext` 对象 */ + createCanvasContext( + /** 要获取上下文的 `` 组件 canvas-id 属性 */ + canvasId: string, + ): CanvasContext; + /** [[IntersectionObserver]((IntersectionObserver)) wx.createIntersectionObserver(Object this, Object options)](wx.createIntersectionObserver.md) + * + * 创建并返回一个 IntersectionObserver 对象实例。在自定义组件中,可以使用 `this.createIntersectionObserver([options])` 来代替。 + * + * **示例代码** + * + * {% minicode('LAbMxkmI7F2A') %} + * + * 最低基础库: `1.9.3` */ + createIntersectionObserver( + /** 选项 */ + options: CreateIntersectionObserverOption, + ): IntersectionObserver; + /** [[AudioContext]((AudioContext)) wx.createAudioContext(string id, Object this)](wx.createAudioContext.md) + * + * 创建 `audio` 上下文 `AudioContext` 对象。 */ + createAudioContext( + /** `