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;
+ /** 画布标识,传入 `