diff --git a/.gitignore b/.gitignore
index 8ff30f3a..221095f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,5 @@ unpackage/
.DS_Store
wxcomponents/**/*.vue
wxcomponents/**/*.css
-.hbuilderx/
\ No newline at end of file
+.hbuilderx/
+__image_snapshots__
\ No newline at end of file
diff --git a/App.vue b/App.vue
index 9ead80fe..ce99d18d 100644
--- a/App.vue
+++ b/App.vue
@@ -5,7 +5,9 @@
import {
version
} from './package.json'
+ // #ifdef APP
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
+ // #endif
export default {
onLaunch: function() {
@@ -17,7 +19,7 @@
)
// #endif
// 线上示例使用
- // console.log('%c uni-app官方团队诚邀优秀前端工程师加盟,一起打造更卓越的uni-app & uniCloud,欢迎投递简历到 hr2013@dcloud.io', 'color: red');
+ // console.log('%c uni-app官方团队诚邀优秀前 端工程师加盟,一起打造更卓越的uni-app & uniCloud,欢迎投递简历到 hr2013@dcloud.io', 'color: red');
console.log('App Launch');
// #ifdef APP-PLUS
// App平台检测升级,服务端代码是通过uniCloud的云函数实现的,详情可参考:https://ext.dcloud.net.cn/plugin?id=4542
diff --git a/README.md b/README.md
index 36c44dff..17bb22bc 100644
--- a/README.md
+++ b/README.md
@@ -73,7 +73,7 @@ npm run dev:h5
-

+
H5版
diff --git a/changelog.md b/changelog.md
index 4f33931d..92cd6813 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,3 +1,12 @@
+## 3.4.8(2025-04-10)
+- 调整 renderjs示例的平台兼容性
+## 3.4.7(2025-01-08)
+- 新增 uni-calendar显示
+- 更新 uniui 组件
+- 更新uni-id至3.3.33版本
+- 替换示例中失效图片资源地址
+## 3.4.6(2023-06-30)
+- 更新 video组件引用的视频链接
## 3.4.4(2022-07-25)
- 新增 同步 uni-ui@1.4.20
- uni-forms 【重要】组件逻辑重构,部分用法旧版本不兼容,请注意兼容问题
diff --git a/components/api-set-tabbar.nvue b/components/api-set-tabbar.nvue
index c9c91872..19529af1 100644
--- a/components/api-set-tabbar.nvue
+++ b/components/api-set-tabbar.nvue
@@ -2,9 +2,11 @@
+
+
diff --git a/env.js b/env.js
new file mode 100644
index 00000000..2cc35e5e
--- /dev/null
+++ b/env.js
@@ -0,0 +1,31 @@
+module.exports = {
+ "is-custom-runtime": false,
+ "compile": true,
+ "h5": {
+ "options": {
+ "headless": true
+ },
+ "executablePath": ""
+ },
+ "mp-weixin": {
+ "port": 9420,
+ "account": "",
+ "args": "",
+ "cwd": "",
+ "launch": true,
+ "teardown": "disconnect",
+ "remote": false,
+ "executablePath": ""
+ },
+ "app-plus": {
+ "android": {
+ "id": "emulator-5554",
+ "executablePath": "/Applications/HBuilderX-Dev.app/Contents/HBuilderX/plugins/launcher/base/android_base.apk"
+ },
+ "version": "/Applications/HBuilderX-Dev.app/Contents/HBuilderX/plugins/launcher/base/version.txt",
+ "ios": {
+ "id": "88E23FD4-D59B-46C8-BF89-C15586FE1507",
+ "executablePath": "/Applications/HBuilderX-Dev.app/Contents/HBuilderX/plugins/launcher/base/Pandora_simulator.app"
+ }
+ }
+}
diff --git a/hybrid/html/issue-17581.html b/hybrid/html/issue-17581.html
new file mode 100644
index 00000000..b235ffc4
--- /dev/null
+++ b/hybrid/html/issue-17581.html
@@ -0,0 +1,55 @@
+
+
+
+
+
+ Codestin Search App
+
+
+
+
+
+
+
+
diff --git a/index.html b/index.html
index c1ee9124..2a448cb1 100644
--- a/index.html
+++ b/index.html
@@ -10,8 +10,8 @@
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
Codestin Search App
-
-
+
+
diff --git a/jest-setup.js b/jest-setup.js
new file mode 100644
index 00000000..32595829
--- /dev/null
+++ b/jest-setup.js
@@ -0,0 +1,191 @@
+const path = require("path");
+const fs = require("fs");
+const {
+ configureToMatchImageSnapshot
+} = require('jest-image-snapshot');
+let saveImageSnapshotDir = process.env.saveImageSnapshotDir || path.join(__dirname, '__snapshot__');
+
+expect.extend({
+ toMatchImageSnapshot: configureToMatchImageSnapshot({
+ customSnapshotIdentifier(args) {
+ return args.currentTestName.replace(/\//g, "-").replace(" ", "-");
+ },
+ customSnapshotsDir: process.env.saveImageSnapshotDir,
+ customDiffDir: path.join(saveImageSnapshotDir, "diff"),
+ }),
+ toSaveSnapshot,
+ toSaveImageSnapshot,
+});
+
+const testCaseToSnapshotFilePath =
+ process.env.testCaseToSnapshotFilePath || "./testCaseToSnapshotFilePath.json";
+
+if (!fs.existsSync(testCaseToSnapshotFilePath)) {
+ fs.writeFileSync(testCaseToSnapshotFilePath, "{}");
+}
+
+function writeTestCaseToSnapshotFile(testCaseName, snapshotFilePath) {
+ const data = JSON.parse(fs.readFileSync(testCaseToSnapshotFilePath));
+
+ if (testCaseName.includes(__dirname)) {
+ testCaseName = testCaseName.substring(`${__dirname}`.length);
+ if (testCaseName[0] == '/' || testCaseName[0] == '\\') {
+ testCaseName = testCaseName.substring(1);
+ };
+ };
+
+ if (!data[testCaseName]) {
+ data[testCaseName] = [snapshotFilePath];
+ } else {
+ data[testCaseName].push(snapshotFilePath);
+ }
+ fs.writeFileSync(testCaseToSnapshotFilePath, JSON.stringify(data, null, 2));
+}
+
+function toSaveSnapshot(received, {
+ customSnapshotsDir,
+ fileName
+} = {}) {
+ const {
+ snapshotState: {
+ _rootDir
+ },
+ testPath,
+ currentTestName,
+ } = this;
+ const SNAPSHOTS_DIR = "__file_snapshots__";
+ const snapshotDir =
+ process.env.saveSnapshotDir ||
+ createSnapshotDir({
+ customSnapshotsDir,
+ testPath,
+ SNAPSHOTS_DIR,
+ });
+ const _fileName = createFileName({
+ fileName,
+ testPath,
+ currentTestName,
+ });
+ const filePath = path.join(snapshotDir, _fileName);
+ let message = () => `${currentTestName} toSaveSnapshot success`;
+ let pass = true;
+
+ try {
+ checkSnapshotDir(path.dirname(filePath));
+ fs.writeFileSync(filePath, received);
+ writeTestCaseToSnapshotFile(testPath.replace(`${_rootDir}/`, ""), filePath);
+ } catch (e) {
+ console.log("toSaveSnapshot fail", e);
+ message = () => e.message;
+ pass = false;
+ }
+
+ return {
+ message,
+ pass,
+ };
+}
+
+function toSaveImageSnapshot(
+ received, {
+ customSnapshotsDir,
+ customSnapshotIdentifier
+ } = {}
+) {
+ const {
+ snapshotState: {
+ _rootDir
+ },
+ testPath,
+ currentTestName,
+ } = this;
+ const SNAPSHOTS_DIR = "__image_snapshots__";
+ const snapshotDir =
+ process.env.saveImageSnapshotDir ||
+ createSnapshotDir({
+ customSnapshotsDir,
+ testPath,
+ SNAPSHOTS_DIR,
+ });
+ const _fileName = createFileName({
+ fileName: customSnapshotIdentifier ? `${customSnapshotIdentifier()}.png` : "",
+ testPath,
+ currentTestName,
+ fileType: "png",
+ });
+ const filePath = path.join(snapshotDir, _fileName);
+ let message = () => `${currentTestName} toSaveImageSnapshot success`;
+ let pass = true;
+
+ try {
+ checkSnapshotDir(path.dirname(filePath));
+ fs.writeFileSync(filePath, Buffer.from(received, "base64"));
+ writeTestCaseToSnapshotFile(testPath.replace(`${_rootDir}/`, ""), filePath);
+ } catch (e) {
+ console.log("toSaveImageSnapshot fail", e);
+ message = () => e.message;
+ pass = false;
+ }
+
+ return {
+ message,
+ pass,
+ };
+}
+
+function createSnapshotDir({
+ customSnapshotsDir,
+ testPath,
+ SNAPSHOTS_DIR
+}) {
+ return customSnapshotsDir || path.join(path.dirname(testPath), SNAPSHOTS_DIR);
+}
+
+function createFileName({
+ fileName,
+ testPath,
+ currentTestName,
+ fileType
+}) {
+ return (
+ fileName ||
+ createSnapshotIdentifier({
+ testPath,
+ currentTestName,
+ fileType,
+ })
+ );
+}
+
+function createSnapshotIdentifier({
+ testPath,
+ currentTestName,
+ fileType = "txt",
+}) {
+ const snapshotIdentifier = kebabCase(
+ `${path.basename(testPath)}-${currentTestName}`
+ );
+ const counter = timesCalled.get(`${snapshotIdentifier}-${fileType}`) || 1;
+ timesCalled.set(`${snapshotIdentifier}-${fileType}`, counter + 1);
+ return `${snapshotIdentifier}-${counter}.${fileType}`;
+}
+
+function kebabCase(str) {
+ return str
+ .replaceAll(/([a-z])([A-Z])/g, "$1-$2")
+ .replaceAll(/\s+/g, "-")
+ .replaceAll(/_+/g, "-")
+ .replaceAll(/\/+/g, "-")
+ .replaceAll(/\.+/g, "-")
+ .toLowerCase();
+}
+
+function checkSnapshotDir(snapshotDir) {
+ if (!fs.existsSync(snapshotDir)) {
+ fs.mkdirSync(snapshotDir, {
+ recursive: true,
+ });
+ }
+}
+
+const timesCalled = new Map();
diff --git a/jest.config.js b/jest.config.js
index 96c1fcee..954fc12a 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -1,11 +1,12 @@
module.exports = {
- testTimeout: 20000,
- reporters: [
- 'default'
- ],
- watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
- moduleFileExtensions: ['js', 'json'],
- rootDir: __dirname,
- testMatch: ["/pages/**/*test.[jt]s?(x)"],
- testPathIgnorePatterns: ['/node_modules/']
-}
+ testTimeout: 20000,
+ reporters: [
+ 'default'
+ ],
+ watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
+ moduleFileExtensions: ['js', 'json'],
+ rootDir: __dirname,
+ testMatch: ["/pages/**/*test.[jt]s?(x)"],
+ testPathIgnorePatterns: ['/node_modules/'],
+ setupFilesAfterEnv: ['/jest-setup.js'],
+}
diff --git a/main.js b/main.js
index a72be26e..ff49fdee 100644
--- a/main.js
+++ b/main.js
@@ -22,10 +22,13 @@ app.$mount()
// #ifdef VUE3
import {
createSSRApp
-} from 'vue'
+} from 'vue'
+import * as Pinia from 'pinia';
+import Vuex from "vuex";
export function createApp() {
const app = createSSRApp(App)
- app.use(store)
+ app.use(store)
+ app.use(Pinia.createPinia());
app.config.globalProperties.$adpid = "1111111111"
app.config.globalProperties.$backgroundAudioData = {
playing: false,
@@ -33,7 +36,9 @@ export function createApp() {
formatedPlayTime: '00:00:00'
}
return {
- app
+ app,
+ Vuex, // 如果 nvue 使用 vuex 的各种map工具方法时,必须 return Vuex
+ Pinia // 此处必须将 Pinia 返回
}
}
// #endif
diff --git a/manifest.json b/manifest.json
index 79189a62..ee4b3918 100644
--- a/manifest.json
+++ b/manifest.json
@@ -114,7 +114,8 @@
},
"uniStatistics" : {
"enable" : true
- }
+ },
+ "libVersion" : "latest"
},
"mp-alipay" : {
"usingComponents" : true,
diff --git a/package.json b/package.json
index 7294780c..5f1b1269 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"id": "hello-uniapp",
"name": "hello-uniapp",
"displayName": "hello-uniapp 示例工程",
- "version": "3.4.4",
+ "version": "3.4.8",
"description": "uni-app 框架示例,一套代码,同时发行到iOS、Android、H5、小程序等多个平台,请使用手机扫码快速体验 uni-app 的强大功能",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
@@ -21,12 +21,8 @@
},
"homepage": "https://github.com/dcloudio/hello-uniapp#readme",
"dependencies": {},
- "dcloudext": {
- "category": [
- "前端页面模板",
- "uni-app前端项目模板"
- ],
- "sale": {
+ "dcloudext": {
+ "sale": {
"regular": {
"price": "0.00"
},
@@ -42,7 +38,8 @@
"data": "无",
"permissions": "无"
},
- "npmurl": ""
+ "npmurl": "",
+ "type": "uniapp-template-project"
},
"uni_modules": {
"dependencies": [],
@@ -50,13 +47,16 @@
"platforms": {
"cloud": {
"tcb": "y",
- "aliyun": "y"
+ "aliyun": "y",
+ "alipay": "n"
},
"client": {
"App": {
- "app-vue": "y",
- "app-nvue": "y"
- },
+ "app-vue": "y",
+ "app-nvue": "y",
+ "app-harmony": "u",
+ "app-uvue": "u"
+ },
"H5-mobile": {
"Safari": "y",
"Android Browser": "y",
diff --git a/pages.json b/pages.json
index 93f12a93..d1db59e9 100644
--- a/pages.json
+++ b/pages.json
@@ -279,11 +279,17 @@
}
},
// #endif
- // #ifdef APP-PLUS || H5
+ // #ifdef APP || H5
{
"path": "pages/component/web-view-local/web-view-local",
"style": {}
},
+ {
+ "path": "pages/component/web-view-local/issue-17581",
+ "style": {
+ "navigationBarTitleText": "issue-17581"
+ }
+ },
// #endif
{
"path": "platforms/app-plus/speech/speech",
@@ -1321,11 +1327,54 @@
},
// #endif
// #endif
+ // #ifdef APP || H5
+ {
+ "path" : "renderjs/renderjs",
+ "style" :
+ {
+ "navigationBarTitleText" : "renderjs"
+ }
+ },
+ // #endif
{
"path": "global/global",
"style": {
"navigationBarTitleText": "GlobalData和vuex"
}
+ },
+ // #ifdef VUE3
+ {
+ "path" : "pinia/pinia",
+ "style" :
+ {
+ "navigationBarTitleText" : "pinia"
+ }
+ },
+ // #endif
+ // #ifdef APP
+ {
+ "path" : "vuex-nvue/vuex-nvue",
+ "style" :
+ {
+ "navigationBarTitleText" : "vuex-nvue"
+ }
+ },
+ // #endif
+ // #ifdef MP-WEIXIN
+ {
+ "path" : "issue-15216/issue-15216",
+ "style" :
+ {
+ "navigationBarTitleText" : "issue-15216"
+ }
+ },
+ // #endif
+ {
+ "path" : "vuex-vue/vuex-vue",
+ "style" :
+ {
+ "navigationBarTitleText" : "vuex-vue"
+ }
}
]
}
diff --git a/pages/API/download-file/download-file.test.js b/pages/API/download-file/download-file.test.js
index 1947f1af..f2a80d73 100644
--- a/pages/API/download-file/download-file.test.js
+++ b/pages/API/download-file/download-file.test.js
@@ -1,10 +1,17 @@
-// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
+const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
describe('pages/API/download-file/download-file.vue', () => {
let page;
+ const versions = ['12.4', '13.7', '15.5', '17.4', '17.5_深色主题', '18.1'];
+ const [platform, version] = platformInfo.split(' ');
+ if (platform === 'ios_simulator' && versions.includes(version)) {
+ it('skip', async () => {
+ expect(1).toBe(1);
+ });
+ return;
+ }
beforeAll(async () => {
page = await program.reLaunch('/pages/API/download-file/download-file')
await page.waitFor('view')
-
});
it('check download url', async () => {
expect.assertions(2);
@@ -14,7 +21,6 @@ describe('pages/API/download-file/download-file.vue', () => {
await page.waitFor(async () => {
return await page.data('jest_result') === true || (Date.now() - start > waitTime)
})
- console.log("data",await page.data(),Date.now() - start > waitTime)
expect(await page.data('jest_result')).toBeTruthy();
expect(await page.data('imageSrc')).toBeTruthy();
});
diff --git a/pages/API/download-file/download-file.vue b/pages/API/download-file/download-file.vue
index 7e3b8989..b6bc215b 100644
--- a/pages/API/download-file/download-file.vue
+++ b/pages/API/download-file/download-file.vue
@@ -21,8 +21,8 @@
data() {
return {
title: 'downloadFile',
- imageSrc: '',
- //自动化测试例专用
+ imageSrc: '',
+ //自动化测试例专用
jest_result: false
}
},
@@ -37,14 +37,14 @@
var self = this
uni.downloadFile({
url: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png",
- success: (res) => {
+ success: (res) => {
this.jest_result = true
console.log('downloadFile success, res is', res)
self.imageSrc = res.tempFilePath;
- uni.hideLoading();
+ uni.hideLoading();
},
fail: (err) => {
- console.log('downloadFile fail, err is:', err)
+ console.log('downloadFile fail, err is:', err)
this.jest_result = false
}
})
diff --git a/pages/API/get-location/get-location.vue b/pages/API/get-location/get-location.vue
index 82b508d6..a1527707 100644
--- a/pages/API/get-location/get-location.vue
+++ b/pages/API/get-location/get-location.vue
@@ -70,8 +70,22 @@
return;
}
// #endif
-
- this.doGetLocation();
+ // #ifdef MP-HARMONY
+ uni.authorize({
+ scope: "scope.userLocation",
+ success: () => {
+ this.doGetLocation();
+ },
+ fail: () => {
+ uni.showToast({
+ title: "未授权获取地理位置权限"
+ })
+ }
+ })
+ // #endif
+ // #ifndef MP-HARMONY
+ this.doGetLocation();
+ // #endif
},
doGetLocation() {
uni.getLocation({
diff --git a/pages/API/get-network-type/get-network-type.vue b/pages/API/get-network-type/get-network-type.vue
index 3e9cf725..ae3c1f42 100644
--- a/pages/API/get-network-type/get-network-type.vue
+++ b/pages/API/get-network-type/get-network-type.vue
@@ -10,13 +10,15 @@
{{networkType}}
-
+
+
-
+
+
-
+
diff --git a/pages/API/get-node-info/get-node-info.test.js b/pages/API/get-node-info/get-node-info.test.js
new file mode 100644
index 00000000..509dff06
--- /dev/null
+++ b/pages/API/get-node-info/get-node-info.test.js
@@ -0,0 +1,32 @@
+describe('测试 css 变量', () => {
+ let page
+ const isApp = process.env.UNI_PLATFORM.includes('app');
+ beforeAll(async () => {
+ // 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
+ page = await program.reLaunch('/pages/API/get-node-info/get-node-info')
+ await page.waitFor(1000)
+ })
+
+ it('css var', async () => {
+
+ if (isApp) {
+ const element1 = await page.$('.box1')
+ const size = await element1.size()
+ expect(size.height > 0).toBe(true)
+
+ const element2 = await page.$('.box2')
+ const size2 = await element2.size()
+ expect(size2.height === 0).toBe(true)
+
+ const element3 = await page.$('.box3')
+ const size3 = await element3.size()
+ expect(size3.height === 0).toBe(true)
+
+ const element4 = await page.$('.box4')
+ const size4 = await element4.size()
+ expect(size4.height > size.height).toBe(true)
+ } else {
+ expect(1).toBe(1)
+ }
+ })
+});
diff --git a/pages/API/get-node-info/get-node-info.vue b/pages/API/get-node-info/get-node-info.vue
index 870ab167..0b41e305 100644
--- a/pages/API/get-node-info/get-node-info.vue
+++ b/pages/API/get-node-info/get-node-info.vue
@@ -20,6 +20,14 @@
+
+
+
+
+
+
+
+
@@ -114,4 +122,20 @@
width: 100rpx;
display: inline-block;
}
+
+ .box {
+ width: 50px;
+ }
+ .box1 {
+ height: var(--status-bar-height);
+ }
+ .box2 {
+ height: var(--window-bottom);
+ }
+ .box3 {
+ height: var(--window-top);
+ }
+ .box4 {
+ height: calc(var(--status-bar-height) + 2px);
+ }
diff --git a/pages/API/login/login.vue b/pages/API/login/login.vue
index 5cd7d0bf..e6361475 100644
--- a/pages/API/login/login.vue
+++ b/pages/API/login/login.vue
@@ -91,6 +91,9 @@
break;
case 'univerify':
providerName = '一键登录'
+ break;
+ case 'huawei':
+ providerName = '华为登录'
break;
}
return {
@@ -259,7 +262,7 @@
provider
});
// #endif
-
+
// #ifdef VUE3
try {
result = await uni.getUserInfo({
@@ -269,7 +272,7 @@
getUserInfoErr = e
}
// #endif
-
+
if (getUserInfoErr) {
let content = getUserInfoErr.errMsg;
if (~content.indexOf('uni.login')) {
diff --git a/pages/API/request-payment/request-payment.vue b/pages/API/request-payment/request-payment.vue
index 395295b8..41e2d8a7 100644
--- a/pages/API/request-payment/request-payment.vue
+++ b/pages/API/request-payment/request-payment.vue
@@ -54,6 +54,13 @@
id: value,
loading: false
});
+ break;
+ case 'huawei':
+ providerList.push({
+ name: '华为',
+ id: value,
+ loading: false
+ });
break;
default:
break;
diff --git a/pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js b/pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js
index 249cff6d..93b017c9 100644
--- a/pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js
+++ b/pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js
@@ -1,14 +1,10 @@
-
describe('pages/API/set-navigation-bar-title/set-navigation-bar-title.vue', () => {
let page
beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/API/set-navigation-bar-title/set-navigation-bar-title')
- if (process.env.UNI_PLATFORM === "mp-weixin") {
- await page.waitFor(10000)
- } else {
- await page.waitFor(5000)
- }
+ const waitTime = process.env.UNI_PLATFORM === "mp-weixin" ? 10000 : 5000
+ await page.waitFor(waitTime)
page = await program.currentPage()
})
it('set-navigation-bar-title 组件标题', async () => {
diff --git a/pages/API/share/share.vue b/pages/API/share/share.vue
index 1f484198..90e8701a 100644
--- a/pages/API/share/share.vue
+++ b/pages/API/share/share.vue
@@ -135,7 +135,7 @@
methods: {
async share(e) {
console.log('分享通道:'+ e.id +'; 分享类型:' + this.shareType);
-
+
if(!this.shareText && (this.shareType === 1 || this.shareType === 0)){
uni.showModal({
content:'分享内容不能为空',
@@ -143,7 +143,7 @@
})
return;
}
-
+
if(!this.image && (this.shareType === 2 || this.shareType === 0)){
uni.showModal({
content:'分享图片不能为空',
@@ -151,10 +151,10 @@
})
return;
}
-
+
let shareOPtions = {
provider: e.id,
- scene: e.type && e.type === 'WXSceneTimeline' ? 'WXSceneTimeline' : 'WXSceneSession', //WXSceneSession”分享到聊天界面,“WXSceneTimeline”分享到朋友圈,“WXSceneFavorite”分享到微信收藏
+ scene: e.type && e.type === 'WXSceneTimeline' ? 'WXSceneTimeline' : 'WXSceneSession', //WXSceneSession”分享到聊天界面,“WXSceneTimeline”分享到朋友圈,“WXSceneFavorite”分享到微信收藏
type: this.shareType,
success: (e) => {
console.log('success', e);
@@ -174,7 +174,7 @@
console.log('分享操作结束!')
}
}
-
+
switch (this.shareType){
case 0:
shareOPtions.summary = this.shareText;
@@ -189,7 +189,7 @@
shareOPtions.imageUrl = this.image;
break;
case 5:
- shareOPtions.imageUrl = this.image ? this.image : 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b6304f00-5168-11eb-bd01-97bc1429a9ff.png'
+ shareOPtions.imageUrl = this.image ? this.image : 'https://web-ext-storage.dcloud.net.cn/hello-uni-app/share.png'
shareOPtions.title = '欢迎体验uniapp';
shareOPtions.miniProgram = {
id:'gh_33446d7f7a26',
@@ -201,8 +201,8 @@
default:
break;
}
-
- if(shareOPtions.type === 0 && plus.os.name === 'iOS'){//如果是图文分享,且是ios平台,则压缩图片
+
+ if(shareOPtions.type === 0 && plus.os.name === 'iOS'){//如果是图文分享,且是ios平台,则压缩图片
shareOPtions.imageUrl = await this.compress();
}
if(shareOPtions.type === 1 && shareOPtions.provider === 'qq'){//如果是分享文字到qq,则必须加上href和title
@@ -253,7 +253,7 @@
console.log('after' + localPath);
// 压缩size
plus.io.resolveLocalFileSystemURL(localPath, (entry) => {
- entry.file((file) => {// 可通过entry对象操作图片
+ entry.file((file) => {// 可通过entry对象操作图片
console.log('getFile:' + JSON.stringify(file));
if(file.size > 20480) {// 压缩后size 大于20Kb
plus.zip.compressImage({
diff --git a/pages/API/toast/toast.vue b/pages/API/toast/toast.vue
index e290bab1..2fd0ccd0 100644
--- a/pages/API/toast/toast.vue
+++ b/pages/API/toast/toast.vue
@@ -5,14 +5,19 @@
+
-
+
+
+
-
-
+
+
+
+
@@ -30,18 +35,18 @@
},
// #endif
methods: {
- toast1Tap: function () {
+ toast1Tap: function() {
uni.showToast({
title: "默认"
})
},
- toast2Tap: function () {
+ toast2Tap: function() {
uni.showToast({
title: "duration 3000",
duration: 3000
})
},
- toast3Tap: function () {
+ toast3Tap: function() {
uni.showToast({
title: "loading",
icon: "loading",
@@ -57,23 +62,23 @@
// #endif
},
- toast4Tap: function () {
+ toast4Tap: function() {
uni.showToast({
title: "logo",
image: "../../../static/uni.png"
})
},
// #ifdef APP-PLUS
- toast5Tap: function () {
+ toast5Tap: function() {
uni.showToast({
title: "显示一段轻提示",
- position:'bottom'
+ position: 'bottom'
})
},
// #endif
- hideToast: function () {
+ hideToast: function() {
uni.hideToast()
}
}
}
-
+
diff --git a/pages/API/vibrate/vibrate.vue b/pages/API/vibrate/vibrate.vue
index 4dedb00b..41a413a3 100644
--- a/pages/API/vibrate/vibrate.vue
+++ b/pages/API/vibrate/vibrate.vue
@@ -30,7 +30,10 @@ export default {
});
},
shortshock() {
- uni.vibrateShort({
+ uni.vibrateShort({
+ // #ifdef MP-HARMONY
+ type:"medium",
+ // #endif
success: function() {
console.log('success');
}
diff --git a/pages/component/web-view-local/issue-17581.test.js b/pages/component/web-view-local/issue-17581.test.js
new file mode 100644
index 00000000..e9c46d4d
--- /dev/null
+++ b/pages/component/web-view-local/issue-17581.test.js
@@ -0,0 +1,29 @@
+const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
+const isHarmony = platformInfo.startsWith('harmony')
+
+describe('pages/component/web-view-local/issue-17581.vue', () => {
+ if (!isHarmony) {
+ it('skip', async () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
+ let page
+ beforeAll(async () => {
+ page = await program.reLaunch('/pages/component/web-view-local/issue-17581')
+ await page.waitFor(1000)
+ })
+
+ it('click position', async () => {
+ await program.tap({
+ x: 100,
+ y: 400
+ })
+ await page.waitFor(200)
+ const {
+ clickClientY
+ } = await page.data()
+ expect(clickClientY).toBeLessThan(200)
+ expect(clickClientY).toBeGreaterThan(0)
+ })
+})
diff --git a/pages/component/web-view-local/issue-17581.vue b/pages/component/web-view-local/issue-17581.vue
new file mode 100644
index 00000000..c347105e
--- /dev/null
+++ b/pages/component/web-view-local/issue-17581.vue
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
diff --git a/pages/component/web-view/web-view.vue b/pages/component/web-view/web-view.vue
index dce6413e..ebc19e19 100644
--- a/pages/component/web-view/web-view.vue
+++ b/pages/component/web-view/web-view.vue
@@ -8,7 +8,7 @@
export default {
data() {
return {
- url: 'https://uniapp.dcloud.io/static/web-view.html'
+ url: 'https://hellouniapp.dcloud.net.cn/html/web-view.html'
}
},
onLoad(options) {
diff --git a/pages/extUI/collapse/collapse.vue b/pages/extUI/collapse/collapse.vue
index 4abc8a1b..fda3e02c 100644
--- a/pages/extUI/collapse/collapse.vue
+++ b/pages/extUI/collapse/collapse.vue
@@ -62,13 +62,13 @@
+ thumb="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png">
折叠内容主体,可自定义内容及样式
+ thumb="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png">
折叠内容主体,可自定义内容及样式
@@ -96,7 +96,7 @@
diff --git a/pages/extUI/file-picker/file-picker.vue b/pages/extUI/file-picker/file-picker.vue
index c0a2d076..1a1e705a 100644
--- a/pages/extUI/file-picker/file-picker.vue
+++ b/pages/extUI/file-picker/file-picker.vue
@@ -79,11 +79,11 @@
extname: 'png',
name: 'shuijiao.png'
}, {
- url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b7c7f970-517d-11eb-97b7-0dc4655d6e68.jpg',
+ url: 'https://web-assets.dcloud.net.cn/unidoc/zh/shuijiao-small.jpg',
extname: 'png',
name: 'uniapp-logo.png'
}, {
- url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b7c7f970-517d-11eb-97b7-0dc4655d6e68.jpg',
+ url: 'https://web-assets.dcloud.net.cn/unidoc/zh/shuijiao-small.jpg',
extname: 'png',
name: 'shuijiao.png'
}]
diff --git a/pages/extUI/list/list.nvue b/pages/extUI/list/list.nvue
index 4f734782..8c812910 100644
--- a/pages/extUI/list/list.nvue
+++ b/pages/extUI/list/list.nvue
@@ -69,7 +69,7 @@
thumb="https://web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png"
thumb-size="base" rightText="默认" />
@@ -112,7 +112,7 @@
data() {
return {
cover: 'https://web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg',
- avatar: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png',
+ avatar: 'https://web-assets.dcloud.net.cn/unidoc/zh/unicloudlogo.png',
extraIcon: {
color: '#4cd964',
size: '22',
diff --git a/pages/extUI/swiper-dot/swiper-dot.nvue b/pages/extUI/swiper-dot/swiper-dot.nvue
index eccf59b1..7e8d34f7 100644
--- a/pages/extUI/swiper-dot/swiper-dot.nvue
+++ b/pages/extUI/swiper-dot/swiper-dot.nvue
@@ -63,12 +63,12 @@
},
{
colorClass: 'uni-bg-green',
- url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
+ url: 'https://web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg',
content: '内容 B'
},
{
colorClass: 'uni-bg-blue',
- url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg',
+ url: 'https://web-assets.dcloud.net.cn/unidoc/zh/shuijiao.jpg',
content: '内容 C'
}
],
@@ -155,21 +155,6 @@
background-color: #cee1fd;
}
- .image {
- width: 750rpx;
- }
-
- /* #ifndef APP-NVUE */
- ::v-deep .image img {
- -webkit-user-drag: none;
- -khtml-user-drag: none;
- -moz-user-drag: none;
- -o-user-drag: none;
- user-drag: none;
- }
-
- /* #endif */
-
@media screen and (min-width: 500px) {
.uni-swiper-dot-box {
width: 400px;
diff --git a/pages/pages.test.js b/pages/pages.test.js
new file mode 100644
index 00000000..a86af698
--- /dev/null
+++ b/pages/pages.test.js
@@ -0,0 +1,244 @@
+jest.setTimeout(10000000);
+let pageIndex = 0
+const pages = [
+ "/pages/component/view/view",
+ "/pages/component/scroll-view/scroll-view",
+ "/pages/component/movable-view/movable-view",
+ "/pages/component/text/text",
+ "/pages/component/progress/progress",
+ "/pages/component/checkbox/checkbox",
+ "/pages/component/form/form",
+ "/pages/component/label/label",
+ "/pages/component/radio/radio",
+ "/pages/component/slider/slider",
+ "/pages/component/switch/switch",
+ "/pages/component/textarea/textarea",
+ "/pages/component/editor/editor",
+ "/pages/component/navigator/navigator",
+ "/pages/component/navigator/navigate/navigate",
+ "/pages/component/navigator/redirect/redirect",
+ "/pages/component/image/image",
+ "/pages/component/web-view/web-view",
+ "/pages/API/login/login",
+ "/pages/API/get-user-info/get-user-info",
+ "/pages/API/request-payment/request-payment",
+ "/pages/API/share/share",
+ "/pages/API/set-navigation-bar-title/set-navigation-bar-title",
+ "/pages/API/show-loading/show-loading",
+ "/pages/API/navigator/navigator",
+ "/pages/API/navigator/new-page/new-vue-page-1",
+ "/pages/API/navigator/new-page/new-vue-page-2",
+ "/pages/API/pull-down-refresh/pull-down-refresh",
+ "/pages/API/animation/animation",
+ "/pages/API/get-node-info/get-node-info",
+ "/pages/API/intersection-observer/intersection-observer",
+ "/pages/API/canvas/canvas",
+ "/pages/API/action-sheet/action-sheet",
+ "/pages/API/modal/modal",
+ "/pages/API/toast/toast",
+ "/pages/API/get-network-type/get-network-type",
+ "/pages/API/get-system-info/get-system-info",
+ "/pages/API/add-phone-contact/add-phone-contact",
+ "/pages/API/on-accelerometer-change/on-accelerometer-change",
+ "/pages/API/on-compass-change/on-compass-change",
+ "/pages/API/make-phone-call/make-phone-call",
+ "/pages/API/scan-code/scan-code",
+ "/pages/API/clipboard/clipboard",
+ "/pages/API/request/request",
+ "/pages/API/upload-file/upload-file",
+ "/pages/API/download-file/download-file",
+ "/pages/API/image/image",
+ "/pages/API/voice/voice",
+ "/pages/API/background-audio/background-audio",
+ "/pages/API/video/video",
+ "/pages/API/file/file",
+ "/pages/extUI/popup/popup",
+ "/pages/extUI/segmented-control/segmented-control",
+ "/pages/extUI/collapse/collapse",
+ "/pages/extUI/pagination/pagination",
+ "/pages/extUI/steps/steps",
+ "/pages/extUI/swipe-action/swipe-action",
+ "/pages/extUI/search-bar/search-bar",
+ "/pages/extUI/fab/fab",
+ "/pages/extUI/fav/fav",
+ "/pages/extUI/section/section",
+ "/pages/extUI/transition/transition",
+ "/pages/extUI/title/title",
+ "/pages/extUI/tooltip/tooltip",
+ "/pages/extUI/link/link",
+ "/pages/extUI/combox/combox",
+ "/pages/extUI/table/table",
+ "/pages/extUI/data-checkbox/data-checkbox",
+ "/pages/extUI/easyinput/easyinput",
+ "/pages/extUI/data-select/data-select",
+ "/pages/extUI/row/row",
+ "/pages/extUI/file-picker/file-picker",
+ "/pages/extUI/button/button",
+ "/pages/template/nav-default/nav-default",
+ "/pages/template/component-communication/component-communication",
+ "/pages/template/list2detail-detail/list2detail-detail",
+ "/pages/template/tabbar/detail/detail",
+ "/pages/template/scheme/scheme",
+ "/pages/template/global/global",
+ "/pages/component/rich-text/rich-text",
+ "/pages/API/get-location/get-location",
+ "/pages/API/open-location/open-location",
+ "/pages/API/choose-location/choose-location",
+ "/pages/API/storage/storage",
+ "/pages/API/sqlite/sqlite",
+ "/pages/API/vibrate/vibrate",
+ "/pages/API/websocket-socketTask/websocket-socketTask",
+ "/pages/extUI/forms/forms",
+ "/pages/extUI/group/group",
+ "/pages/extUI/breadcrumb/breadcrumb",
+ "/pages/extUI/drawer/drawer",
+
+ ...(isMatch('web') ? [
+ // 只有h5支持
+ "/pages/error/404",
+ ] : [
+ // 只有h5不支持
+ "/pages/API/brightness/brightness",
+ "/pages/API/save-media/save-media",
+ "/pages/API/soter/soter",
+ "/pages/API/bluetooth/bluetooth",
+ ]),
+
+ ...(isMatch('android') ? [
+ // 只有app支持
+ "/pages/API/subnvue/subnvue",
+ "/pages/API/full-screen-video-ad/full-screen-video-ad",
+ "/platforms/app-plus/feedback/feedback",
+ "/platforms/app-plus/speech/speech",
+ "/platforms/app-plus/orientation/orientation",
+ "/platforms/app-plus/proximity/proximity",
+ "/platforms/app-plus/push/push",
+ "/platforms/app-plus/shake/shake",
+ ] : []),
+
+ ...((isMatch('android') || isMatch('mp-weixin')) ? [
+ // 只有app和微信小程序支持
+ "/pages/API/ibeacon/ibeacon",
+ ] : []),
+
+ ...(isMatch('mp-weixin') ? [] : [
+ // 微信小程序不支持
+ "/pages/component/web-view-local/web-view-local",
+ "/pages/template/nav-transparent/nav-transparent",
+ "/pages/template/nav-image/nav-image",
+ "/pages/template/nav-city-dropdown/nav-city-dropdown",
+ "/pages/template/nav-dot/nav-dot",
+ "/pages/template/nav-search-input/detail/detail",
+ "/pages/template/nav-button/nav-button",
+ "/pages/template/nav-search-input/nav-search-input",
+ "/pages/about/about",
+ ]),
+
+ ...(isMatch('safari') ? [] : [
+ // safari 在此页面会莫名卡住
+ "/pages/API/inner-audio/inner-audio",
+ ]),
+
+ // 只有vue3支持
+ // "/pages/API/navigator/new-page/new-nvue-page-1",
+ // "/pages/API/navigator/new-page/new-nvue-page-2",
+
+ // 只有vue2支持
+ // "/pages/template/ucharts/ucharts",
+ // "/pages/template/vant-button/vant-button",
+
+ // 动态内容
+ // "/pages/component/ad/ad",
+ // "/pages/component/swiper/swiper",
+ // "/pages/component/canvas/canvas",
+ // "/pages/extUI/dateformat/dateformat",
+ // "/pages/extUI/datetime-picker/datetime-picker",
+ // "/pages/extUI/list/chat",
+ // "/pages/extUI/notice-bar/notice-bar",
+ // "/pages/template/list2detail-list/list2detail-list",
+ // "/pages/API/rewarded-video-ad/rewarded-video-ad",
+ // "/pages/extUI/badge/badge",
+ // "/pages/component/picker/picker",
+ // "/pages/component/picker-view/picker-view",
+ // "/pages/extUI/calendar/calendar",
+ // "/pages/component/button/button",
+
+ // nvue页面截图白屏
+ // "/pages/tabBar/component/component",
+ // "/pages/tabBar/API/API",
+ // "/pages/tabBar/template/template",
+ // "/pages/tabBar/extUI/extUI",
+ // "/pages/component/cover-view/cover-view",
+ // "/pages/component/input/input",
+ // "/pages/component/video/video",
+ // "/pages/API/map/map",
+ // "/pages/extUI/icons/icons",
+ // "/pages/extUI/load-more/load-more",
+ // "/pages/extUI/nav-bar/nav-bar",
+ // "/pages/extUI/number-box/number-box",
+ // "/pages/extUI/tag/tag",
+ // "/pages/extUI/list/list",
+ // "/pages/extUI/card/card",
+ // "/pages/extUI/swiper-dot/swiper-dot",
+ // "/pages/extUI/grid/grid",
+ // "/pages/extUI/rate/rate",
+ // "/pages/extUI/indexed-list/indexed-list",
+ // "/pages/extUI/goods-nav/goods-nav",
+ // "/pages/extUI/data-picker/data-picker",
+ // "/pages/extUI/space/space",
+ // "/pages/extUI/font/font",
+ // "/pages/extUI/color/color",
+ // "/pages/extUI/radius/radius",
+ // "/pages/template/tabbar/tabbar",
+ // "/pages/template/swiper-vertical/swiper-vertical",
+ // "/pages/template/swiper-list/swiper-list",
+ // "/pages/extUI/countdown/countdown",
+ // "/pages/template/swiper-list-nvue/swiper-list-nvue",
+ // "/pages/API/map-search/map-search",
+
+ // "/pages/API/websocket-global/websocket-global",
+ // "/pages/component/map/map",
+]
+
+function isMatch(platform) {
+ return process.env.uniTestPlatformInfo.toLocaleLowerCase().includes(platform)
+}
+
+// 设置position: fixed的页面不能截取完整内容
+const notFullPages = []
+
+let page;
+describe("page screenshot test", () => {
+ if (isMatch('ios')) {
+ it("ios platform not support", async () => {
+ expect(1).toBe(1);
+ });
+ return
+ }
+ beforeAll(async () => {
+ console.log("page screenshot test start");
+ });
+ beforeEach(async () => {
+ page = await program.reLaunch(pages[pageIndex]);
+ await page.waitFor(2000);
+ });
+ afterEach(() => {
+ pageIndex++;
+ });
+ afterAll(() => {
+ console.log("page screenshot test finish");
+ });
+ test.each(pages)("%s", async () => {
+ console.log("Taking screenshot: ", pageIndex, pages[pageIndex],
+ `${(((pageIndex + 1) / pages.length) * 100).toFixed(1)}%`);
+ let fullPage = true;
+ if (notFullPages.includes(pages[pageIndex])) {
+ fullPage = false;
+ }
+ const image = await program.screenshot({
+ fullPage: fullPage
+ });
+ expect(image).toSaveImageSnapshot();
+ await page.waitFor(500);
+ });
+});
diff --git a/pages/tabBar/API/API.nvue b/pages/tabBar/API/API.nvue
index 37bc1992..b363cbdf 100644
--- a/pages/tabBar/API/API.nvue
+++ b/pages/tabBar/API/API.nvue
@@ -47,13 +47,13 @@
name: '图片',
url: 'image'
},
- // #ifndef MP-LARK
+ // #ifndef MP-LARK || MP-HARMONY
{
name: '音频',
url: 'inner-audio'
},
// #endif
- // #ifdef APP-PLUS || MP-WEIXIN || MP-BAIDU || MP-QQ|| MP-JD
+ // #ifdef APP-PLUS || MP-WEIXIN || MP-BAIDU || MP-QQ|| MP-JD || MP-HARMONY
{
name: '录音',
url: 'voice'
@@ -111,10 +111,12 @@
name: '下拉刷新',
url: 'pull-down-refresh'
},
+ // #ifndef MP-HARMONY
{
name: '创建动画',
url: 'animation'
},
+ // #endif
// #ifndef QUICKAPP-WEBVIEW-UNION
{
name: '创建绘画',
@@ -127,10 +129,12 @@
url: 'get-node-info'
},
// #endif
+ // #ifndef MP-HARMONY
{
name: '节点布局交互状态',
url: 'intersection-observer'
},
+ // #endif
{
name: '显示操作菜单',
url: 'action-sheet'
@@ -189,7 +193,7 @@
url: 'brightness'
},
// #endif
- // #ifdef APP-PLUS || MP-WEIXIN || MP-QQ || MP-JD
+ // #ifdef APP-PLUS || MP-WEIXIN || MP-QQ || MP-JD || MP-HARMONY
{
name: '蓝牙',
url: 'bluetooth'
@@ -207,13 +211,13 @@
url: 'ibeacon'
},
// #endif
- // #ifdef APP || MP-WEIXIN
+ // #ifdef APP || MP-WEIXIN || MP-HARMONY
{
name: '监听加速度传感器',
url: 'on-accelerometer-change'
},
// #endif
- // #ifdef APP || H5 ||MP-WEIXIN
+ // #ifdef APP || H5 ||MP-WEIXIN || MP-HARMONY
{
name: '监听罗盘数据',
url: 'on-compass-change'
@@ -347,14 +351,16 @@
name: '登录',
url: 'login'
},
+ // #ifndef MP-HARMONY
{
name: '获取用户信息',
url: 'get-user-info'
}
+ // #endif
]
},
// #endif
- // #ifndef H5 || QUICKAPP-WEBVIEW-UNION
+ // #ifndef H5 || QUICKAPP-WEBVIEW-UNION || MP-HARMONY
{
id: 'share',
name: '分享',
diff --git a/pages/tabBar/component/component.nvue b/pages/tabBar/component/component.nvue
index c7b0f181..61260783 100644
--- a/pages/tabBar/component/component.nvue
+++ b/pages/tabBar/component/component.nvue
@@ -53,9 +53,11 @@
'swiper'
// #ifndef MP-TOUTIAO || MP-LARK
,
- 'movable-view',
+ 'movable-view',
+ // #ifndef MP-HARMONY
'cover-view'
// #endif
+ // #endif
]
}, {
id: 'content',
@@ -118,7 +120,7 @@
}]
},
// #endif
- // #ifndef APP-PLUS || H5 || MP-LARK || MP-JD
+ // #ifndef APP-PLUS || H5 || MP-LARK || MP-JD || MP-HARMONY
{
id: 'web-view',
name: '网页',
@@ -126,7 +128,7 @@
pages: ['web-view']
},
// #endif
- // #ifndef H5 || MP-BAIDU || QUICKAPP-WEBVIEW || MP-LARK || MP-JD
+ // #ifndef H5 || MP-BAIDU || QUICKAPP-WEBVIEW || MP-LARK || MP-JD || MP-HARMONY
{
id: 'ad',
url: 'ad',
diff --git a/pages/tabBar/component/component.test.js b/pages/tabBar/component/component.test.js
index 3640f673..624f534b 100644
--- a/pages/tabBar/component/component.test.js
+++ b/pages/tabBar/component/component.test.js
@@ -1,5 +1,13 @@
describe('pages/tabBar/component/component.nvue', () => {
- let page
+ let page, containsVite, isApp;
+ containsVite = process.env.UNI_CLI_PATH.includes('uniapp-cli-vite')
+ isApp = process.env.UNI_PLATFORM.includes('app')
+ if (containsVite && isApp) {
+ it('vue3', async () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/tabBar/component/component')
@@ -29,7 +37,7 @@ describe('pages/tabBar/component/component.nvue', () => {
const lists = await page.$$('.uni-panel')
if(process.env.UNI_PLATFORM == 'app-plus' || process.env.UNI_PLATFORM == 'mp-weixin'){
expect(lists.length).toBe(9)
- }else if(process.env.UNI_PLATFORM == 'h5'){
+ }else if(process.env.UNI_PLATFORM == 'h5' && !containsVite){
expect(lists.length).toBe(8)
}
})
diff --git a/pages/tabBar/extUI/extUI.test.js b/pages/tabBar/extUI/extUI.test.js
index b7b89ee5..8699152a 100644
--- a/pages/tabBar/extUI/extUI.test.js
+++ b/pages/tabBar/extUI/extUI.test.js
@@ -1,5 +1,13 @@
describe('pages/tabBar/extUI/extUI.nvue', () => {
- let page
+ let page, containsVite, isApp;
+ containsVite = process.env.UNI_CLI_PATH.includes('uniapp-cli-vite')
+ isApp = process.env.UNI_PLATFORM.includes('app')
+ if (containsVite && isApp) {
+ it('vue3', async () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
beforeAll(async () => {
// 重新reLaunch至首页,并获取首页page对象(其中 program 是uni-automator自动注入的全局对象)
page = await program.reLaunch('/pages/tabBar/extUI/extUI')
@@ -32,8 +40,6 @@ describe('pages/tabBar/extUI/extUI.nvue', () => {
const extUIEl = await page.$('.extUI')
lists = await extUIEl.$$('.uni-panel')
}
- console.log('lists.length:',lists.length,(await page.data('lists')).length)
- console.log('uniTestPlatformInfo:',process.env.uniTestPlatformInfo)
if(process.env.UNI_PLATFORM == 'app-plus'){
expect(lists.length).toBe(41)
}else if(process.env.UNI_PLATFORM == 'h5' || process.env.UNI_PLATFORM == 'mp-weixin'){
@@ -51,7 +57,8 @@ describe('pages/tabBar/extUI/extUI.nvue', () => {
expect(await listHead.attribute('class')).toContain('uni-panel-h')
// 点击第一个 item,验证打开的新页面是否正确
await listHead.tap()
- await page.waitFor(2000)
+ const waitTime = process.env.UNI_PLATFORM == 'mp-weixin'? 5000 : 2000
+ await page.waitFor(waitTime)
expect((await program.currentPage()).path).toBe('pages/extUI/badge/badge')
await page.waitFor(500)
// 执行 navigateBack 验证是否返回
diff --git a/pages/tabBar/template/template.nvue b/pages/tabBar/template/template.nvue
index 7a92387d..3945223c 100644
--- a/pages/tabBar/template/template.nvue
+++ b/pages/tabBar/template/template.nvue
@@ -116,12 +116,34 @@
{
name: 'swiper-list',
url: 'swiper-list-nvue'
- },
+ },
+ // #endif
+ {
+ name: 'GlobalData和vuex',
+ url: 'global'
+ },
+ // #ifdef APP-NVUE
+ {
+ name: 'vuex-nvue',
+ url: 'vuex-nvue'
+ },
+ // #endif
+ {
+ name: 'vuex-vue',
+ url: 'vuex-vue'
+ },
+ // #ifdef VUE3
+ {
+ name: 'pinia',
+ url: 'pinia'
+ },
+ // #endif
+ // #ifdef APP || H5
+ {
+ name: 'renderjs',
+ url: 'renderjs'
+ },
// #endif
- {
- name: 'GlobalData和vuex',
- url: 'global'
- },
// #ifdef APP-PLUS
{
name: '问题反馈',
@@ -189,7 +211,7 @@
},
goDetailPage(e) {
let path = e.url ? e.url : e;
- let url = ~path.indexOf('platform') ? path : '/pages/template/' + path + '/' + path;
+ let url = ~path.indexOf('platform') ? path : '/pages/template/' + path + '/' + path;
if (this.hasLeftWin) {
uni.reLaunch({
url: url
diff --git a/pages/template/issue-15216/issue-15216.test.js b/pages/template/issue-15216/issue-15216.test.js
new file mode 100644
index 00000000..0f4b3976
--- /dev/null
+++ b/pages/template/issue-15216/issue-15216.test.js
@@ -0,0 +1,18 @@
+describe('renderjs', () => {
+ let page;
+ if (process.env.UNI_PLATFORM !== "mp-weixin") {
+ // renderjs仅支持App和H5
+ it('not mp-weixin', async () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
+ beforeAll(async () => {
+ page = await program.reLaunch('/pages/template/issue-15216/issue-15216')
+ await page.waitFor('view');
+ });
+ it('check page data', async () => {
+ const uniXxx = await page.data('uniXxx');
+ expect(uniXxx).toEqual('abc');
+ });
+});
diff --git a/pages/template/issue-15216/issue-15216.vue b/pages/template/issue-15216/issue-15216.vue
new file mode 100644
index 00000000..1fbcec0a
--- /dev/null
+++ b/pages/template/issue-15216/issue-15216.vue
@@ -0,0 +1,29 @@
+
+
+ test
+
+
+
+
+
+
diff --git a/pages/template/list2detail-detail/list2detail-detail.vue b/pages/template/list2detail-detail/list2detail-detail.vue
index 078d60dd..73e04455 100644
--- a/pages/template/list2detail-detail/list2detail-detail.vue
+++ b/pages/template/list2detail-detail/list2detail-detail.vue
@@ -10,7 +10,7 @@
{{banner.published_at}}
-
+
@@ -54,7 +54,9 @@
return {
title: '',
banner: {},
- htmlNodes: []
+ htmlNodes: [],
+ visible: true,
+
}
},
onLoad(event) {
@@ -125,7 +127,13 @@
success: (data) => {
if (data.statusCode == 200) {
var htmlString = data.data.content.replace(/\\/g, "").replace(/
{
+ this.visible = true
+ })
+ // #endif
}
},
fail: () => {
diff --git a/pages/template/pinia/pinia.test.js b/pages/template/pinia/pinia.test.js
new file mode 100644
index 00000000..462d7256
--- /dev/null
+++ b/pages/template/pinia/pinia.test.js
@@ -0,0 +1,50 @@
+describe('test pinia', () => {
+ let page,containsVite;
+ containsVite = process.env.UNI_CLI_PATH.includes('uniapp-cli-vite')
+ if (!containsVite) {
+ // Vue 2 项目暂不支持 Pinia
+ it('is vue2', async () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
+ beforeAll(async () => {
+ page = await program.reLaunch('/pages/template/pinia/pinia')
+ await page.waitFor('view');
+ });
+ it('check page data', async () => {
+ const count = await page.$('.count');
+ expect(await count.text()).toEqual('当前计数:0');
+ const doubleCount = await page.$('.doubleCount');
+ expect(await doubleCount.text()).toEqual('计数翻倍:0');
+ });
+ it('store incrementCounter', async () => {
+ await page.callMethod('incrementCounter')
+ const count = await page.$('.count');
+ expect(await count.text()).toEqual('当前计数:1');
+ const doubleCount = await page.$('.doubleCount');
+ expect(await doubleCount.text()).toEqual('计数翻倍:2');
+ });
+ it('store incrementPatchCounter', async () => {
+ await page.callMethod('incrementPatchCounter')
+ const count = await page.$('.count');
+ expect(await count.text()).toEqual('当前计数:2');
+ const doubleCount = await page.$('.doubleCount');
+ expect(await doubleCount.text()).toEqual('计数翻倍:4');
+ });
+ it('store actions', async () => {
+ const increment = await page.$('.increment');
+ await increment.tap()
+ const countIn = await page.$('.count');
+ expect(await countIn.text()).toEqual('当前计数:3');
+ const doubleCountIn = await page.$('.doubleCount');
+ expect(await doubleCountIn.text()).toEqual('计数翻倍:6');
+
+ const decrement = await page.$('.decrement');
+ await decrement.tap()
+ const countDe = await page.$('.count');
+ expect(await countDe.text()).toEqual('当前计数:2');
+ const doubleCountDe = await page.$('.doubleCount');
+ expect(await doubleCountDe.text()).toEqual('计数翻倍:4');
+ });
+});
diff --git a/pages/template/pinia/pinia.vue b/pages/template/pinia/pinia.vue
new file mode 100644
index 00000000..7e9a1b0b
--- /dev/null
+++ b/pages/template/pinia/pinia.vue
@@ -0,0 +1,32 @@
+
+
+
+ 当前计数:{{ counter.count }}
+ 计数翻倍:{{ counter.doubleCount }}
+
+
+
+
+
+
+
+
diff --git a/pages/template/renderjs/renderjs.test.js b/pages/template/renderjs/renderjs.test.js
new file mode 100644
index 00000000..ad6a3358
--- /dev/null
+++ b/pages/template/renderjs/renderjs.test.js
@@ -0,0 +1,38 @@
+describe('renderjs', () => {
+ let page, btns;
+ if (process.env.UNI_PLATFORM === "mp-weixin") {
+ // renderjs仅支持App和H5
+ it('is mp-weixin', async () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
+ beforeAll(async () => {
+ page = await program.reLaunch('/pages/template/renderjs/renderjs')
+ await page.waitFor('view');
+ btns = await page.$$('button');
+ });
+ it('check page data', async () => {
+ const data1 = await page.$('.renderjs');
+ expect(await data1.text()).toEqual('serviceData');
+ });
+ it('callMethod renderjs', async () => {
+ await btns[0].tap();
+ await page.waitFor(300);
+ const data2 = await page.$('.renderjs');
+ expect(await data2.text()).toEqual('renderjsData');
+ });
+ it('callMethod service', async () => {
+ await btns[1].tap();
+ await page.waitFor(300);
+ const data3 = await page.$('.renderjs');
+ expect(await data3.text()).toEqual('serviceData改变了');
+ });
+ if (process.env.UNI_PLATFORM === "h5") {
+ it('trigger getServiceData', async () => {
+ expect(await page.data('newValue')).toEqual('serviceData改变了');
+ expect(await page.data('oldValue')).toEqual('renderjsData');
+ });
+ }
+
+});
diff --git a/pages/template/renderjs/renderjs.vue b/pages/template/renderjs/renderjs.vue
new file mode 100644
index 00000000..498e0cbf
--- /dev/null
+++ b/pages/template/renderjs/renderjs.vue
@@ -0,0 +1,60 @@
+
+
+
+
+ {{data}}
+
+
+
+
+
+
+
+
+
diff --git a/pages/template/tabbar/tabbar.nvue b/pages/template/tabbar/tabbar.nvue
index 17b812d1..abfa65a0 100644
--- a/pages/template/tabbar/tabbar.nvue
+++ b/pages/template/tabbar/tabbar.nvue
@@ -78,11 +78,11 @@
"width": 563,
"height": 316
}, {
- "url": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b4cd3000-517d-11eb-a16f-5b3e54966275.jpg",
+ "url": "https://web-ext-storage.dcloud.net.cn/hello-uni-app/template-tabbar-2.jpg",
"width": 641,
"height": 360
}, {
- "url": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b7c7f970-517d-11eb-97b7-0dc4655d6e68.jpg",
+ "url": "https://web-assets.dcloud.net.cn/unidoc/zh/shuijiao-small.jpg",
"width": 640,
"height": 360
}],
@@ -95,7 +95,7 @@
"datetime": "2小时前",
"article_type": 4,
"title": "uni-app 支持原生小程序自定义组件,更开放、更自由",
- "image_url": "https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b2e201d0-517d-11eb-8a36-ebb87efcf8c0.jpg",
+ "image_url": "https://web-ext-storage.dcloud.net.cn/hello-uni-app/template-tabbar-1.jpg",
"source": "DCloud",
"comment_count": 69
}
diff --git a/pages/template/vuex-nvue/vuex-nvue.nvue b/pages/template/vuex-nvue/vuex-nvue.nvue
new file mode 100644
index 00000000..588910af
--- /dev/null
+++ b/pages/template/vuex-nvue/vuex-nvue.nvue
@@ -0,0 +1,56 @@
+
+
+
+ 用户名:{{username}}
+ 性别:{{sex}}
+ 年龄:{{age}}
+ 年龄翻倍:{{doubleAge}}
+
+
+
+
+
+
+
diff --git a/pages/template/vuex-vue/vuex-vue.vue b/pages/template/vuex-vue/vuex-vue.vue
new file mode 100644
index 00000000..90597403
--- /dev/null
+++ b/pages/template/vuex-vue/vuex-vue.vue
@@ -0,0 +1,53 @@
+
+
+
+ 用户名:{{username}}
+ 性别:{{sex}}
+ 年龄:{{age}}
+ 年龄翻倍:{{doubleAge}}
+
+
+
+
+
+
+
diff --git a/pages/template/vuex-vue/vuex.test.js b/pages/template/vuex-vue/vuex.test.js
new file mode 100644
index 00000000..25bbbaca
--- /dev/null
+++ b/pages/template/vuex-vue/vuex.test.js
@@ -0,0 +1,90 @@
+let page;
+const containsVite = process.env.UNI_CLI_PATH.includes('uniapp-cli-vite');
+const isApp = process.env.UNI_PLATFORM.includes('app');
+const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase();
+
+function createTests(pagePath, type) {
+ return describe(`测试页面路径: ${pagePath}`, () => {
+ async function toScreenshot(imgName) {
+ await page.waitFor(300)
+ const image = await program.screenshot({
+ deviceShot: true
+ });
+ expect(image).toSaveImageSnapshot({
+ customSnapshotIdentifier() {
+ return imgName
+ }
+ })
+ await page.waitFor(500);
+ }
+ if (platformInfo === 'ios_simulator 13.7') {
+ it('skip', async () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
+ beforeAll(async () => {
+ page = await program.reLaunch(pagePath)
+ await page.waitFor('view');
+ await toScreenshot(type)
+ });
+ afterAll(async () => {
+ await page.callMethod('resetAge')
+ });
+ it('check page data', async () => {
+ const username = await page.$('.username');
+ expect(await username.text()).toEqual('用户名:foo');
+ const sex = await page.$('.sex');
+ expect(await sex.text()).toEqual('性别:男');
+ const age = await page.$('.age');
+ expect(await age.text()).toEqual('年龄:10');
+ const doubleAge = await page.$('.doubleAge');
+ expect(await doubleAge.text()).toEqual('年龄翻倍:20');
+ });
+ it('store mutations', async () => {
+ await page.callMethod('addAge')
+ const age = await page.$('.age');
+ expect(await age.text()).toEqual('年龄:11');
+ const doubleAge = await page.$('.doubleAge');
+ expect(await doubleAge.text()).toEqual('年龄翻倍:22');
+ });
+ it('store getters', async () => {
+ await page.callMethod('addAgeTen')
+ const age = await page.$('.age');
+ expect(await age.text()).toEqual('年龄:21');
+ const doubleAge = await page.$('.doubleAge');
+ expect(await doubleAge.text()).toEqual('年龄翻倍:42');
+ });
+ it('store actions', async () => {
+ await page.callMethod('addAgeAction')
+ const age = await page.$('.age');
+ expect(await age.text()).toEqual('年龄:41');
+ const doubleAge = await page.$('.doubleAge');
+ expect(await doubleAge.text()).toEqual('年龄翻倍:82');
+ });
+ })
+}
+
+// vue3-nvue不支持自动化测试
+const nvuePath = '/pages/template/vuex-nvue/vuex-nvue'
+const vuepath = '/pages/template/vuex-vue/vuex-vue'
+if (containsVite) {
+ // vue3
+ if (isApp) {
+ createTests(vuepath, 'vue3-App-vue');
+ } else if (process.env.UNI_PLATFORM == 'h5') {
+ createTests(vuepath, 'vue3-H5-vue');
+ } else {
+ createTests(vuepath, 'vue3-Mp-vue');
+ }
+} else {
+ // vue2
+ if (isApp) {
+ createTests(nvuePath, 'vue2-App-nvue');
+ createTests(vuepath, 'vue2-App-vue');
+ } else if (process.env.UNI_PLATFORM == 'h5') {
+ createTests(vuepath, 'vue2-H5-vue');
+ } else {
+ createTests(vuepath, 'vue2-Mp-vue');
+ }
+}
diff --git a/platforms/app-plus/shake/shake.vue b/platforms/app-plus/shake/shake.vue
index 01ce86be..eb13a6c4 100644
--- a/platforms/app-plus/shake/shake.vue
+++ b/platforms/app-plus/shake/shake.vue
@@ -21,15 +21,15 @@
computed:{
pageIndex() {
if (this.index === 1) {
- return 'aff47ed0-517d-11eb-8ff1-d5dcf8779628'
+ return 'shake-1'
} else if (this.index === 2) {
- return '1fc36f80-5199-11eb-a16f-5b3e54966275'
+ return 'shake-2'
} else if (this.index === 3) {
- return '20a3bd60-5199-11eb-97b7-0dc4655d6e68'
+ return 'shake-3'
} else if (this.index === 4) {
- return '8b872410-51a7-11eb-8a36-ebb87efcf8c0'
+ return 'shake-4'
} else {
- return 'aff47ed0-517d-11eb-8ff1-d5dcf8779628'
+ return 'shake-1'
}
}
},
@@ -46,7 +46,7 @@
if (this.index > 4) {
this.index = 1
}
- this.img = 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/' + this.pageIndex + '.jpg';
+ this.img = 'https://web-ext-storage.dcloud.net.cn/hello-uni-app/' + this.pageIndex + '.jpg';
}, 2000);
this.show = true;
if (t) {
diff --git a/static/image-resize-3.0.1.min.js b/static/web/image-resize-3.0.1.min.js
similarity index 100%
rename from static/image-resize-3.0.1.min.js
rename to static/web/image-resize-3.0.1.min.js
diff --git a/static/quill-1.3.7.min.js b/static/web/quill-1.3.7.min.js
similarity index 100%
rename from static/quill-1.3.7.min.js
rename to static/web/quill-1.3.7.min.js
diff --git a/store/counter.js b/store/counter.js
new file mode 100644
index 00000000..1e2adf77
--- /dev/null
+++ b/store/counter.js
@@ -0,0 +1,17 @@
+import { defineStore } from 'pinia'
+export const useCounterStore = defineStore('counter', {
+ state: () => ({
+ count: 0
+ }),
+ getters: {
+ doubleCount: (state) => state.count * 2
+ },
+ actions: {
+ increment() {
+ this.count++
+ },
+ decrement() {
+ this.count--
+ }
+ }
+})
diff --git a/store/index.js b/store/index.js
index 9da3f760..2d0a3275 100644
--- a/store/index.js
+++ b/store/index.js
@@ -22,7 +22,11 @@ const store = createStore({
leftWinActive: '/pages/component/view/view',
activeOpen: '',
menu: [],
- univerifyErrorMsg: ''
+ univerifyErrorMsg: '',
+ // vuex测试例使用
+ username: "foo",
+ sex: "男",
+ age: 10
},
mutations: {
login(state, provider) {
@@ -66,14 +70,32 @@ const store = createStore({
},
setUniverifyErrorMsg(state,payload = ''){
state.univerifyErrorMsg = payload
+ },
+ // vuex测试例使用
+ increment(state) {
+ state.age++;
+ },
+ incrementTen(state, payload) {
+ state.age += payload.amount
+ },
+ resetAge(state){
+ state.age = 10
}
},
getters: {
currentColor(state) {
return state.colorList[state.colorIndex]
+ },
+ // vuex测试例使用
+ doubleAge(state) {
+ return state.age * 2;
}
},
- actions: {
+ actions: {
+ // vuex测试例使用
+ incrementAsync(context , payload) {
+ context.commit('incrementTen',payload)
+ },
// lazy loading openid
getUserOpenId: async function({
commit,
diff --git a/template.h5.html b/template.h5.html
index 1dbec302..b84b7af2 100644
--- a/template.h5.html
+++ b/template.h5.html
@@ -41,8 +41,8 @@
// document.documentElement.style.fontSize = document.documentElement.clientWidth / 20 + 'px'
// })
-
-
+
+
diff --git a/uni_modules/uni-calendar/changelog.md b/uni_modules/uni-calendar/changelog.md
index a728bb80..30ca0df7 100644
--- a/uni_modules/uni-calendar/changelog.md
+++ b/uni_modules/uni-calendar/changelog.md
@@ -1,3 +1,5 @@
+## 1.4.12(2024-09-21)
+- 修复 calendar在选择日期范围后重新选择日期需要点两次的Bug
## 1.4.11(2024-01-10)
- 修复 回到今天时,月份显示不一致问题
## 1.4.10(2023-04-10)
diff --git a/uni_modules/uni-calendar/components/uni-calendar/calendar.js b/uni_modules/uni-calendar/components/uni-calendar/calendar.js
index b8d7d6fc..55eed81d 100644
--- a/uni_modules/uni-calendar/components/uni-calendar/calendar.js
+++ b/uni_modules/uni-calendar/components/uni-calendar/calendar.js
@@ -351,10 +351,8 @@ var calendar = {
s = '\u521d\u5341'; break
case 20:
s = '\u4e8c\u5341'; break
- break
case 30:
s = '\u4e09\u5341'; break
- break
default :
s = this.nStr2[Math.floor(d / 10)]
s += this.nStr1[d % 10]
diff --git a/uni_modules/uni-calendar/components/uni-calendar/util.js b/uni_modules/uni-calendar/components/uni-calendar/util.js
index 671f61e0..6e949d73 100644
--- a/uni_modules/uni-calendar/components/uni-calendar/util.js
+++ b/uni_modules/uni-calendar/components/uni-calendar/util.js
@@ -296,7 +296,7 @@ class Calendar {
if (!this.range) return
if (before && after) {
- this.multipleStatus.before = ''
+ this.multipleStatus.before = fullDate
this.multipleStatus.after = ''
this.multipleStatus.data = []
} else {
diff --git a/uni_modules/uni-calendar/package.json b/uni_modules/uni-calendar/package.json
index bceaed37..ec924e91 100644
--- a/uni_modules/uni-calendar/package.json
+++ b/uni_modules/uni-calendar/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-calendar",
"displayName": "uni-calendar 日历",
- "version": "1.4.11",
+ "version": "1.4.12",
"description": "日历组件",
"keywords": [
"uni-ui",
@@ -44,7 +44,8 @@
"platforms": {
"cloud": {
"tcb": "y",
- "aliyun": "y"
+ "aliyun": "y",
+ "alipay": "n"
},
"client": {
"App": {
@@ -82,4 +83,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/uni_modules/uni-combox/changelog.md b/uni_modules/uni-combox/changelog.md
index 15256a2e..64972dbc 100644
--- a/uni_modules/uni-combox/changelog.md
+++ b/uni_modules/uni-combox/changelog.md
@@ -1,3 +1,5 @@
+## 1.0.2(2024-09-21)
+- 新增 clearAble属性
## 1.0.1(2021-11-23)
- 优化 label、label-width 属性
## 1.0.0(2021-11-19)
diff --git a/uni_modules/uni-combox/components/uni-combox/uni-combox.vue b/uni_modules/uni-combox/components/uni-combox/uni-combox.vue
index 98bf152e..ed1f7cd4 100644
--- a/uni_modules/uni-combox/components/uni-combox/uni-combox.vue
+++ b/uni_modules/uni-combox/components/uni-combox/uni-combox.vue
@@ -4,10 +4,11 @@
{{label}}
-
-
+
+
+
+
@@ -16,8 +17,8 @@
{{emptyTips}}
-
+
{{item}}
@@ -41,6 +42,10 @@
name: 'uniCombox',
emits: ['input', 'update:modelValue'],
props: {
+ clearAble: {
+ type: Boolean,
+ default: false
+ },
border: {
type: Boolean,
default: true
@@ -143,6 +148,10 @@
this.$emit('input', this.inputVal)
this.$emit('update:modelValue', this.inputVal)
})
+ },
+ clean() {
+ this.inputVal = ''
+ this.onInput()
}
}
}
@@ -272,4 +281,4 @@
.uni-combox__no-border {
border: none;
}
-
+
diff --git a/uni_modules/uni-combox/package.json b/uni_modules/uni-combox/package.json
index 3fed6140..779716d7 100644
--- a/uni_modules/uni-combox/package.json
+++ b/uni_modules/uni-combox/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-combox",
"displayName": "uni-combox 组合框",
- "version": "1.0.1",
+ "version": "1.0.2",
"description": "可以选择也可以输入的表单项 ",
"keywords": [
"uni-ui",
@@ -17,11 +17,7 @@
"directories": {
"example": "../../temps/example_temps"
},
- "dcloudext": {
- "category": [
- "前端组件",
- "通用组件"
- ],
+"dcloudext": {
"sale": {
"regular": {
"price": "0.00"
@@ -38,7 +34,8 @@
"data": "无",
"permissions": "无"
},
- "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
+ "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
+ "type": "component-vue"
},
"uni_modules": {
"dependencies": [
@@ -49,7 +46,8 @@
"platforms": {
"cloud": {
"tcb": "y",
- "aliyun": "y"
+ "aliyun": "y",
+ "alipay": "n"
},
"client": {
"App": {
@@ -87,4 +85,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/package.json b/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/package.json
index 35d1d3ad..3b735925 100644
--- a/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/package.json
+++ b/uni_modules/uni-config-center/uniCloud/cloudfunctions/common/uni-config-center/package.json
@@ -1,9 +1,13 @@
{
- "name": "uni-config-center",
- "version": "0.0.3",
- "description": "配置中心",
- "main": "index.js",
- "keywords": [],
- "author": "DCloud",
- "license": "Apache-2.0"
+ "name": "uni-config-center",
+ "version": "0.0.3",
+ "description": "配置中心",
+ "main": "index.js",
+ "keywords": [],
+ "author": "DCloud",
+ "license": "Apache-2.0",
+ "origin-plugin-dev-name": "uni-config-center",
+ "origin-plugin-version": "0.0.3",
+ "plugin-dev-name": "uni-config-center",
+ "plugin-version": "0.0.3"
}
\ No newline at end of file
diff --git a/uni_modules/uni-countdown/changelog.md b/uni_modules/uni-countdown/changelog.md
index 16fc324b..13374184 100644
--- a/uni_modules/uni-countdown/changelog.md
+++ b/uni_modules/uni-countdown/changelog.md
@@ -1,3 +1,5 @@
+## 1.2.4(2024-09-21)
+- 新增 支持控制显示位数 默认显示2位
## 1.2.3(2024-02-20)
- 新增 支持控制小时,分钟的显隐:showHour showMinute
## 1.2.2(2022-01-19)
diff --git a/uni_modules/uni-countdown/components/uni-countdown/uni-countdown.vue b/uni_modules/uni-countdown/components/uni-countdown/uni-countdown.vue
index 820209b8..7c965465 100644
--- a/uni_modules/uni-countdown/components/uni-countdown/uni-countdown.vue
+++ b/uni_modules/uni-countdown/components/uni-countdown/uni-countdown.vue
@@ -96,6 +96,10 @@
timestamp: {
type: Number,
default: 0
+ },
+ filterShow : {
+ type:Object,
+ default:{}
}
},
data() {
@@ -208,23 +212,14 @@
second = Math.floor(seconds) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60)
} else {
this.timeUp()
- }
- if (day < 10) {
- day = '0' + day
- }
- if (hour < 10) {
- hour = '0' + hour
- }
- if (minute < 10) {
- minute = '0' + minute
- }
- if (second < 10) {
- second = '0' + second
- }
- this.d = day
- this.h = hour
- this.i = minute
- this.s = second
+ }
+ this.d = String(day).padStart(this.validFilterShow(this.filterShow.d), '0')
+ this.h = String(hour).padStart(this.validFilterShow(this.filterShow.h), '0')
+ this.i = String(minute).padStart(this.validFilterShow(this.filterShow.m), '0')
+ this.s = String(second).padStart(this.validFilterShow(this.filterShow.s), '0')
+ },
+ validFilterShow(filter){
+ return (filter && filter > 0) ? filter : 2;
},
startData() {
this.seconds = this.toSeconds(this.timestamp, this.day, this.hour, this.minute, this.second)
diff --git a/uni_modules/uni-countdown/package.json b/uni_modules/uni-countdown/package.json
index 66220744..9ec970b6 100644
--- a/uni_modules/uni-countdown/package.json
+++ b/uni_modules/uni-countdown/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-countdown",
"displayName": "uni-countdown 倒计时",
- "version": "1.2.3",
+ "version": "1.2.4",
"description": "CountDown 倒计时组件",
"keywords": [
"uni-ui",
@@ -42,7 +42,8 @@
"platforms": {
"cloud": {
"tcb": "y",
- "aliyun": "y"
+ "aliyun": "y",
+ "alipay": "n"
},
"client": {
"App": {
@@ -80,4 +81,4 @@
}
}
}
-}
\ No newline at end of file
+}
diff --git a/uni_modules/uni-data-checkbox/changelog.md b/uni_modules/uni-data-checkbox/changelog.md
index b475fcbb..7c99f6ce 100644
--- a/uni_modules/uni-data-checkbox/changelog.md
+++ b/uni_modules/uni-data-checkbox/changelog.md
@@ -1,3 +1,5 @@
+## 1.0.6(2024-10-22)
+- 新增 当 multiple 为 false 且传递的 value 为 数组时,使用数组第一项用作反显
## 1.0.5(2024-03-20)
- 修复 单选模式下选中样式不生效的bug
## 1.0.4(2024-01-27)
diff --git a/uni_modules/uni-data-checkbox/components/uni-data-checkbox/clientdb.js b/uni_modules/uni-data-checkbox/components/uni-data-checkbox/clientdb.js
new file mode 100644
index 00000000..789572b5
--- /dev/null
+++ b/uni_modules/uni-data-checkbox/components/uni-data-checkbox/clientdb.js
@@ -0,0 +1,316 @@
+
+const events = {
+ load: 'load',
+ error: 'error'
+}
+const pageMode = {
+ add: 'add',
+ replace: 'replace'
+}
+
+const attrs = [
+ 'pageCurrent',
+ 'pageSize',
+ 'collection',
+ 'action',
+ 'field',
+ 'getcount',
+ 'orderby',
+ 'where'
+]
+
+export default {
+ data() {
+ return {
+ loading: false,
+ listData: this.getone ? {} : [],
+ paginationInternal: {
+ current: this.pageCurrent,
+ size: this.pageSize,
+ count: 0
+ },
+ errorMessage: ''
+ }
+ },
+ created() {
+ let db = null;
+ let dbCmd = null;
+
+ if(this.collection){
+ this.db = uniCloud.database();
+ this.dbCmd = this.db.command;
+ }
+
+ this._isEnded = false
+
+ this.$watch(() => {
+ let al = []
+ attrs.forEach(key => {
+ al.push(this[key])
+ })
+ return al
+ }, (newValue, oldValue) => {
+ this.paginationInternal.pageSize = this.pageSize
+
+ let needReset = false
+ for (let i = 2; i < newValue.length; i++) {
+ if (newValue[i] != oldValue[i]) {
+ needReset = true
+ break
+ }
+ }
+ if (needReset) {
+ this.clear()
+ this.reset()
+ }
+ if (newValue[0] != oldValue[0]) {
+ this.paginationInternal.current = this.pageCurrent
+ }
+
+ this._execLoadData()
+ })
+
+ // #ifdef H5
+ if (process.env.NODE_ENV === 'development') {
+ this._debugDataList = []
+ if (!window.unidev) {
+ window.unidev = {
+ clientDB: {
+ data: []
+ }
+ }
+ }
+ unidev.clientDB.data.push(this._debugDataList)
+ }
+ // #endif
+
+ // #ifdef MP-TOUTIAO
+ let changeName
+ let events = this.$scope.dataset.eventOpts
+ for (let i = 0; i < events.length; i++) {
+ let event = events[i]
+ if (event[0].includes('^load')) {
+ changeName = event[1][0][0]
+ }
+ }
+ if (changeName) {
+ let parent = this.$parent
+ let maxDepth = 16
+ this._changeDataFunction = null
+ while (parent && maxDepth > 0) {
+ let fun = parent[changeName]
+ if (fun && typeof fun === 'function') {
+ this._changeDataFunction = fun
+ maxDepth = 0
+ break
+ }
+ parent = parent.$parent
+ maxDepth--;
+ }
+ }
+ // #endif
+
+ // if (!this.manual) {
+ // this.loadData()
+ // }
+ },
+ // #ifdef H5
+ beforeDestroy() {
+ if (process.env.NODE_ENV === 'development' && window.unidev) {
+ let cd = this._debugDataList
+ let dl = unidev.clientDB.data
+ for (let i = dl.length - 1; i >= 0; i--) {
+ if (dl[i] === cd) {
+ dl.splice(i, 1)
+ break
+ }
+ }
+ }
+ },
+ // #endif
+ methods: {
+ loadData(args1, args2) {
+ let callback = null
+ if (typeof args1 === 'object') {
+ if (args1.clear) {
+ this.clear()
+ this.reset()
+ }
+ if (args1.current !== undefined) {
+ this.paginationInternal.current = args1.current
+ }
+ if (typeof args2 === 'function') {
+ callback = args2
+ }
+ } else if (typeof args1 === 'function') {
+ callback = args1
+ }
+
+ this._execLoadData(callback)
+ },
+ loadMore() {
+ if (this._isEnded) {
+ return
+ }
+ this._execLoadData()
+ },
+ refresh() {
+ this.clear()
+ this._execLoadData()
+ },
+ clear() {
+ this._isEnded = false
+ this.listData = []
+ },
+ reset() {
+ this.paginationInternal.current = 1
+ },
+ remove(id, {
+ action,
+ callback,
+ confirmTitle,
+ confirmContent
+ } = {}) {
+ if (!id || !id.length) {
+ return
+ }
+ uni.showModal({
+ title: confirmTitle || '提示',
+ content: confirmContent || '是否删除该数据',
+ showCancel: true,
+ success: (res) => {
+ if (!res.confirm) {
+ return
+ }
+ this._execRemove(id, action, callback)
+ }
+ })
+ },
+ _execLoadData(callback) {
+ if (this.loading) {
+ return
+ }
+ this.loading = true
+ this.errorMessage = ''
+
+ this._getExec().then((res) => {
+ this.loading = false
+ const {
+ data,
+ count
+ } = res.result
+ this._isEnded = data.length < this.pageSize
+
+ callback && callback(data, this._isEnded)
+ this._dispatchEvent(events.load, data)
+
+ if (this.getone) {
+ this.listData = data.length ? data[0] : undefined
+ } else if (this.pageData === pageMode.add) {
+ this.listData.push(...data)
+ if (this.listData.length) {
+ this.paginationInternal.current++
+ }
+ } else if (this.pageData === pageMode.replace) {
+ this.listData = data
+ this.paginationInternal.count = count
+ }
+
+ // #ifdef H5
+ if (process.env.NODE_ENV === 'development') {
+ this._debugDataList.length = 0
+ this._debugDataList.push(...JSON.parse(JSON.stringify(this.listData)))
+ }
+ // #endif
+ }).catch((err) => {
+ this.loading = false
+ this.errorMessage = err
+ callback && callback()
+ this.$emit(events.error, err)
+ })
+ },
+ _getExec() {
+ let exec = this.db
+ if (this.action) {
+ exec = exec.action(this.action)
+ }
+
+ exec = exec.collection(this.collection)
+
+ if (!(!this.where || !Object.keys(this.where).length)) {
+ exec = exec.where(this.where)
+ }
+ if (this.field) {
+ exec = exec.field(this.field)
+ }
+ if (this.orderby) {
+ exec = exec.orderBy(this.orderby)
+ }
+
+ const {
+ current,
+ size
+ } = this.paginationInternal
+ exec = exec.skip(size * (current - 1)).limit(size).get({
+ getCount: this.getcount
+ })
+
+ return exec
+ },
+ _execRemove(id, action, callback) {
+ if (!this.collection || !id) {
+ return
+ }
+
+ const ids = Array.isArray(id) ? id : [id]
+ if (!ids.length) {
+ return
+ }
+
+ uni.showLoading({
+ mask: true
+ })
+
+ let exec = this.db
+ if (action) {
+ exec = exec.action(action)
+ }
+
+ exec.collection(this.collection).where({
+ _id: dbCmd.in(ids)
+ }).remove().then((res) => {
+ callback && callback(res.result)
+ if (this.pageData === pageMode.replace) {
+ this.refresh()
+ } else {
+ this.removeData(ids)
+ }
+ }).catch((err) => {
+ uni.showModal({
+ content: err.message,
+ showCancel: false
+ })
+ }).finally(() => {
+ uni.hideLoading()
+ })
+ },
+ removeData(ids) {
+ let il = ids.slice(0)
+ let dl = this.listData
+ for (let i = dl.length - 1; i >= 0; i--) {
+ let index = il.indexOf(dl[i]._id)
+ if (index >= 0) {
+ dl.splice(i, 1)
+ il.splice(index, 1)
+ }
+ }
+ },
+ _dispatchEvent(type, data) {
+ if (this._changeDataFunction) {
+ this._changeDataFunction(data, this._isEnded)
+ } else {
+ this.$emit(type, data, this._isEnded)
+ }
+ }
+ }
+}
diff --git a/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.vue b/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.vue
index 6e03c6e4..4da7bbeb 100644
--- a/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.vue
+++ b/uni_modules/uni-data-checkbox/components/uni-data-checkbox/uni-data-checkbox.vue
@@ -1,849 +1,853 @@
-
-
-
-
-
- {{mixinDatacomErrorMessage}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/uni_modules/uni-data-checkbox/package.json b/uni_modules/uni-data-checkbox/package.json
index fc15e8b2..f823e8b0 100644
--- a/uni_modules/uni-data-checkbox/package.json
+++ b/uni_modules/uni-data-checkbox/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-data-checkbox",
"displayName": "uni-data-checkbox 数据选择器",
- "version": "1.0.5",
+ "version": "1.0.6",
"description": "通过数据驱动的单选框和复选框",
"keywords": [
"uni-ui",
@@ -43,12 +43,15 @@
"platforms": {
"cloud": {
"tcb": "y",
- "aliyun": "y"
+ "aliyun": "y",
+ "alipay": "n"
},
"client": {
"App": {
- "app-vue": "y",
- "app-nvue": "y"
+ "app-vue": "y",
+ "app-nvue": "y",
+ "app-harmony": "u",
+ "app-uvue": "u"
},
"H5-mobile": {
"Safari": "y",
diff --git a/uni_modules/uni-data-picker/changelog.md b/uni_modules/uni-data-picker/changelog.md
index d7893b03..e095788a 100644
--- a/uni_modules/uni-data-picker/changelog.md
+++ b/uni_modules/uni-data-picker/changelog.md
@@ -1,77 +1,79 @@
-## 2.0.0(2023-12-14)
+## 2.0.1(2024-08-22)
+- 修复 uni-app-x v-model 没有更新传入值的 bug
+## 2.0.0(2023-12-11)
- 新增 支持 uni-app-x
-## 1.1.2(2023-04-11)
-- 修复 更改 modelValue 报错的 bug
-- 修复 v-for 未使用 key 值控制台 warning
-## 1.1.1(2023-02-21)
-- 修复代码合并时引发 value 属性为空时不渲染数据的问题
-## 1.1.0(2023-02-15)
-- 修复 localdata 不支持动态更新的bug
-## 1.0.9(2023-02-15)
-- 修复 localdata 不支持动态更新的bug
-## 1.0.8(2022-09-16)
-- 可以使用 uni-scss 控制主题色
-## 1.0.7(2022-07-06)
-- 优化 pc端图标位置不正确的问题
-## 1.0.6(2022-07-05)
-- 优化 显示样式
-## 1.0.5(2022-07-04)
-- 修复 uni-data-picker 在 uni-forms-item 中宽度不正确的bug
-## 1.0.4(2022-04-19)
-- 修复 字节小程序 本地数据无法选择下一级的Bug
-## 1.0.3(2022-02-25)
-- 修复 nvue 不支持的 v-show 的 bug
-## 1.0.2(2022-02-25)
-- 修复 条件编译 nvue 不支持的 css 样式
-## 1.0.1(2021-11-23)
-- 修复 由上个版本引发的map、v-model等属性不生效的bug
-## 1.0.0(2021-11-19)
-- 优化 组件 UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
-- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-data-picker](https://uniapp.dcloud.io/component/uniui/uni-data-picker)
-## 0.4.9(2021-10-28)
-- 修复 VUE2 v-model 概率无效的 bug
-## 0.4.8(2021-10-27)
-- 修复 v-model 概率无效的 bug
-## 0.4.7(2021-10-25)
-- 新增 属性 spaceInfo 服务空间配置 HBuilderX 3.2.11+
-- 修复 树型 uniCloud 数据类型为 int 时报错的 bug
-## 0.4.6(2021-10-19)
-- 修复 非 VUE3 v-model 为 0 时无法选中的 bug
-## 0.4.5(2021-09-26)
-- 新增 清除已选项的功能(通过 clearIcon 属性配置是否显示按钮),同时提供 clear 方法以供调用,二者等效
-- 修复 readonly 为 true 时报错的 bug
-## 0.4.4(2021-09-26)
-- 修复 上一版本造成的 map 属性失效的 bug
-- 新增 ellipsis 属性,支持配置 tab 选项长度过长时是否自动省略
-## 0.4.3(2021-09-24)
-- 修复 某些情况下级联未触发的 bug
-## 0.4.2(2021-09-23)
-- 新增 提供 show 和 hide 方法,开发者可以通过 ref 调用
-- 新增 选项内容过长自动添加省略号
-## 0.4.1(2021-09-15)
-- 新增 map 属性 字段映射,将 text/value 映射到数据中的其他字段
-## 0.4.0(2021-07-13)
-- 组件兼容 vue3,如何创建 vue3 项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
-## 0.3.5(2021-06-04)
-- 修复 无法加载云端数据的问题
-## 0.3.4(2021-05-28)
-- 修复 v-model 无效问题
-- 修复 loaddata 为空数据组时加载时间过长问题
-- 修复 上个版本引出的本地数据无法选择带有 children 的 2 级节点
-## 0.3.3(2021-05-12)
-- 新增 组件示例地址
-## 0.3.2(2021-04-22)
-- 修复 非树形数据有 where 属性查询报错的问题
-## 0.3.1(2021-04-15)
-- 修复 本地数据概率无法回显时问题
-## 0.3.0(2021-04-07)
-- 新增 支持云端非树形表结构数据
-- 修复 根节点 parent_field 字段等于 null 时选择界面错乱问题
-## 0.2.0(2021-03-15)
-- 修复 nodeclick、popupopened、popupclosed 事件无法触发的问题
-## 0.1.9(2021-03-09)
-- 修复 微信小程序某些情况下无法选择的问题
-## 0.1.8(2021-02-05)
-- 优化 部分样式在 nvue 上的兼容表现
-## 0.1.7(2021-02-05)
-- 调整为 uni_modules 目录规范
+## 1.1.2(2023-04-11)
+- 修复 更改 modelValue 报错的 bug
+- 修复 v-for 未使用 key 值控制台 warning
+## 1.1.1(2023-02-21)
+- 修复代码合并时引发 value 属性为空时不渲染数据的问题
+## 1.1.0(2023-02-15)
+- 修复 localdata 不支持动态更新的bug
+## 1.0.9(2023-02-15)
+- 修复 localdata 不支持动态更新的bug
+## 1.0.8(2022-09-16)
+- 可以使用 uni-scss 控制主题色
+## 1.0.7(2022-07-06)
+- 优化 pc端图标位置不正确的问题
+## 1.0.6(2022-07-05)
+- 优化 显示样式
+## 1.0.5(2022-07-04)
+- 修复 uni-data-picker 在 uni-forms-item 中宽度不正确的bug
+## 1.0.4(2022-04-19)
+- 修复 字节小程序 本地数据无法选择下一级的Bug
+## 1.0.3(2022-02-25)
+- 修复 nvue 不支持的 v-show 的 bug
+## 1.0.2(2022-02-25)
+- 修复 条件编译 nvue 不支持的 css 样式
+## 1.0.1(2021-11-23)
+- 修复 由上个版本引发的map、v-model等属性不生效的bug
+## 1.0.0(2021-11-19)
+- 优化 组件 UI,并提供设计资源,详见:[https://uniapp.dcloud.io/component/uniui/resource](https://uniapp.dcloud.io/component/uniui/resource)
+- 文档迁移,详见:[https://uniapp.dcloud.io/component/uniui/uni-data-picker](https://uniapp.dcloud.io/component/uniui/uni-data-picker)
+## 0.4.9(2021-10-28)
+- 修复 VUE2 v-model 概率无效的 bug
+## 0.4.8(2021-10-27)
+- 修复 v-model 概率无效的 bug
+## 0.4.7(2021-10-25)
+- 新增 属性 spaceInfo 服务空间配置 HBuilderX 3.2.11+
+- 修复 树型 uniCloud 数据类型为 int 时报错的 bug
+## 0.4.6(2021-10-19)
+- 修复 非 VUE3 v-model 为 0 时无法选中的 bug
+## 0.4.5(2021-09-26)
+- 新增 清除已选项的功能(通过 clearIcon 属性配置是否显示按钮),同时提供 clear 方法以供调用,二者等效
+- 修复 readonly 为 true 时报错的 bug
+## 0.4.4(2021-09-26)
+- 修复 上一版本造成的 map 属性失效的 bug
+- 新增 ellipsis 属性,支持配置 tab 选项长度过长时是否自动省略
+## 0.4.3(2021-09-24)
+- 修复 某些情况下级联未触发的 bug
+## 0.4.2(2021-09-23)
+- 新增 提供 show 和 hide 方法,开发者可以通过 ref 调用
+- 新增 选项内容过长自动添加省略号
+## 0.4.1(2021-09-15)
+- 新增 map 属性 字段映射,将 text/value 映射到数据中的其他字段
+## 0.4.0(2021-07-13)
+- 组件兼容 vue3,如何创建 vue3 项目,详见 [uni-app 项目支持 vue3 介绍](https://ask.dcloud.net.cn/article/37834)
+## 0.3.5(2021-06-04)
+- 修复 无法加载云端数据的问题
+## 0.3.4(2021-05-28)
+- 修复 v-model 无效问题
+- 修复 loaddata 为空数据组时加载时间过长问题
+- 修复 上个版本引出的本地数据无法选择带有 children 的 2 级节点
+## 0.3.3(2021-05-12)
+- 新增 组件示例地址
+## 0.3.2(2021-04-22)
+- 修复 非树形数据有 where 属性查询报错的问题
+## 0.3.1(2021-04-15)
+- 修复 本地数据概率无法回显时问题
+## 0.3.0(2021-04-07)
+- 新增 支持云端非树形表结构数据
+- 修复 根节点 parent_field 字段等于 null 时选择界面错乱问题
+## 0.2.0(2021-03-15)
+- 修复 nodeclick、popupopened、popupclosed 事件无法触发的问题
+## 0.1.9(2021-03-09)
+- 修复 微信小程序某些情况下无法选择的问题
+## 0.1.8(2021-02-05)
+- 优化 部分样式在 nvue 上的兼容表现
+## 0.1.7(2021-02-05)
+- 调整为 uni_modules 目录规范
diff --git a/uni_modules/uni-data-picker/components/uni-data-picker/keypress.js b/uni_modules/uni-data-picker/components/uni-data-picker/keypress.js
index a747b9fc..6ef26a26 100644
--- a/uni_modules/uni-data-picker/components/uni-data-picker/keypress.js
+++ b/uni_modules/uni-data-picker/components/uni-data-picker/keypress.js
@@ -1,45 +1,45 @@
-// #ifdef H5
-export default {
- name: 'Keypress',
- props: {
- disable: {
- type: Boolean,
- default: false
- }
- },
- mounted () {
- const keyNames = {
- esc: ['Esc', 'Escape'],
- tab: 'Tab',
- enter: 'Enter',
- space: [' ', 'Spacebar'],
- up: ['Up', 'ArrowUp'],
- left: ['Left', 'ArrowLeft'],
- right: ['Right', 'ArrowRight'],
- down: ['Down', 'ArrowDown'],
- delete: ['Backspace', 'Delete', 'Del']
- }
- const listener = ($event) => {
- if (this.disable) {
- return
- }
- const keyName = Object.keys(keyNames).find(key => {
- const keyName = $event.key
- const value = keyNames[key]
- return value === keyName || (Array.isArray(value) && value.includes(keyName))
- })
- if (keyName) {
- // 避免和其他按键事件冲突
- setTimeout(() => {
- this.$emit(keyName, {})
- }, 0)
- }
- }
- document.addEventListener('keyup', listener)
- this.$once('hook:beforeDestroy', () => {
- document.removeEventListener('keyup', listener)
- })
- },
- render: () => {}
-}
-// #endif
+// #ifdef H5
+export default {
+ name: 'Keypress',
+ props: {
+ disable: {
+ type: Boolean,
+ default: false
+ }
+ },
+ mounted () {
+ const keyNames = {
+ esc: ['Esc', 'Escape'],
+ tab: 'Tab',
+ enter: 'Enter',
+ space: [' ', 'Spacebar'],
+ up: ['Up', 'ArrowUp'],
+ left: ['Left', 'ArrowLeft'],
+ right: ['Right', 'ArrowRight'],
+ down: ['Down', 'ArrowDown'],
+ delete: ['Backspace', 'Delete', 'Del']
+ }
+ const listener = ($event) => {
+ if (this.disable) {
+ return
+ }
+ const keyName = Object.keys(keyNames).find(key => {
+ const keyName = $event.key
+ const value = keyNames[key]
+ return value === keyName || (Array.isArray(value) && value.includes(keyName))
+ })
+ if (keyName) {
+ // 避免和其他按键事件冲突
+ setTimeout(() => {
+ this.$emit(keyName, {})
+ }, 0)
+ }
+ }
+ document.addEventListener('keyup', listener)
+ this.$once('hook:beforeDestroy', () => {
+ document.removeEventListener('keyup', listener)
+ })
+ },
+ render: () => {}
+}
+// #endif
diff --git a/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.uvue b/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.uvue
index fda8103a..dcbfd5f0 100644
--- a/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.uvue
+++ b/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.uvue
@@ -1,380 +1,381 @@
-
-
-
-
-
- {{error!.errMsg}}
-
-
-
- {{item[mappingTextName]}}
- {{split}}
-
-
-
- {{placeholder}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{popupTitle}}
-
-
-
-
-
-
-
-
- {{error!.errMsg}}
-
-
-
-
-
- {{item[mappingTextName]}}
-
-
-
-
-
-
- {{item[mappingTextName]}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+ {{error!.errMsg}}
+
+
+
+ {{item[mappingTextName]}}
+ {{split}}
+
+
+
+ {{placeholder}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{popupTitle}}
+
+
+
+
+
+
+
+
+ {{error!.errMsg}}
+
+
+
+
+
+ {{item[mappingTextName]}}
+
+
+
+
+
+
+ {{item[mappingTextName]}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.vue b/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.vue
index c86d5476..179a4e0b 100644
--- a/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.vue
+++ b/uni_modules/uni-data-picker/components/uni-data-picker/uni-data-picker.vue
@@ -1,551 +1,551 @@
-
-
-
-
-
- {{errorMessage}}
-
-
-
-
-
-
- {{item.text}}{{split}}
-
-
-
- {{placeholder}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{popupTitle}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+ {{errorMessage}}
+
+
+
+
+
+
+ {{item.text}}{{split}}
+
+
+
+ {{placeholder}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{popupTitle}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-picker.js b/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-picker.js
index 4d9f95fb..cfae22a4 100644
--- a/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-picker.js
+++ b/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-picker.js
@@ -1,622 +1,622 @@
-export default {
- props: {
- localdata: {
- type: [Array, Object],
- default () {
- return []
- }
- },
- spaceInfo: {
- type: Object,
- default () {
- return {}
- }
- },
- collection: {
- type: String,
- default: ''
- },
- action: {
- type: String,
- default: ''
- },
- field: {
- type: String,
- default: ''
- },
- orderby: {
- type: String,
- default: ''
- },
- where: {
- type: [String, Object],
- default: ''
- },
- pageData: {
- type: String,
- default: 'add'
- },
- pageCurrent: {
- type: Number,
- default: 1
- },
- pageSize: {
- type: Number,
- default: 500
- },
- getcount: {
- type: [Boolean, String],
- default: false
- },
- getone: {
- type: [Boolean, String],
- default: false
- },
- gettree: {
- type: [Boolean, String],
- default: false
- },
- manual: {
- type: Boolean,
- default: false
- },
- value: {
- type: [Array, String, Number],
- default () {
- return []
- }
- },
- modelValue: {
- type: [Array, String, Number],
- default () {
- return []
- }
- },
- preload: {
- type: Boolean,
- default: false
- },
- stepSearh: {
- type: Boolean,
- default: true
- },
- selfField: {
- type: String,
- default: ''
- },
- parentField: {
- type: String,
- default: ''
- },
- multiple: {
- type: Boolean,
- default: false
- },
- map: {
- type: Object,
- default () {
- return {
- text: "text",
- value: "value"
- }
- }
- }
- },
- data() {
- return {
- loading: false,
- errorMessage: '',
- loadMore: {
- contentdown: '',
- contentrefresh: '',
- contentnomore: ''
- },
- dataList: [],
- selected: [],
- selectedIndex: 0,
- page: {
- current: this.pageCurrent,
- size: this.pageSize,
- count: 0
- }
- }
- },
- computed: {
- isLocalData() {
- return !this.collection.length;
- },
- isCloudData() {
- return this.collection.length > 0;
- },
- isCloudDataList() {
- return (this.isCloudData && (!this.parentField && !this.selfField));
- },
- isCloudDataTree() {
- return (this.isCloudData && this.parentField && this.selfField);
- },
- dataValue() {
- let isModelValue = Array.isArray(this.modelValue) ? (this.modelValue.length > 0) : (this.modelValue !== null ||
- this.modelValue !== undefined);
- return isModelValue ? this.modelValue : this.value;
- },
- hasValue() {
- if (typeof this.dataValue === 'number') {
- return true
- }
- return (this.dataValue != null) && (this.dataValue.length > 0)
- }
- },
- created() {
- this.$watch(() => {
- var al = [];
- ['pageCurrent',
- 'pageSize',
- 'spaceInfo',
- 'value',
- 'modelValue',
- 'localdata',
- 'collection',
- 'action',
- 'field',
- 'orderby',
- 'where',
- 'getont',
- 'getcount',
- 'gettree'
- ].forEach(key => {
- al.push(this[key])
- });
- return al
- }, (newValue, oldValue) => {
- let needReset = false
- for (let i = 2; i < newValue.length; i++) {
- if (newValue[i] != oldValue[i]) {
- needReset = true
- break
- }
- }
- if (newValue[0] != oldValue[0]) {
- this.page.current = this.pageCurrent
- }
- this.page.size = this.pageSize
-
- this.onPropsChange()
- })
- this._treeData = []
- },
- methods: {
- onPropsChange() {
- this._treeData = [];
- },
-
- // 填充 pickview 数据
- async loadData() {
- if (this.isLocalData) {
- this.loadLocalData();
- } else if (this.isCloudDataList) {
- this.loadCloudDataList();
- } else if (this.isCloudDataTree) {
- this.loadCloudDataTree();
- }
- },
-
- // 加载本地数据
- async loadLocalData() {
- this._treeData = [];
- this._extractTree(this.localdata, this._treeData);
-
- let inputValue = this.dataValue;
- if (inputValue === undefined) {
- return;
- }
-
- if (Array.isArray(inputValue)) {
- inputValue = inputValue[inputValue.length - 1];
- if (typeof inputValue === 'object' && inputValue[this.map.value]) {
- inputValue = inputValue[this.map.value];
- }
- }
-
- this.selected = this._findNodePath(inputValue, this.localdata);
- },
-
- // 加载 Cloud 数据 (单列)
- async loadCloudDataList() {
- if (this.loading) {
- return;
- }
- this.loading = true;
-
- try {
- let response = await this.getCommand();
- let responseData = response.result.data;
-
- this._treeData = responseData;
-
- this._updateBindData();
- this._updateSelected();
-
- this.onDataChange();
- } catch (e) {
- this.errorMessage = e;
- } finally {
- this.loading = false;
- }
- },
-
- // 加载 Cloud 数据 (树形)
- async loadCloudDataTree() {
- if (this.loading) {
- return;
- }
- this.loading = true;
-
- try {
- let commandOptions = {
- field: this._cloudDataPostField(),
- where: this._cloudDataTreeWhere()
- };
- if (this.gettree) {
- commandOptions.startwith = `${this.selfField}=='${this.dataValue}'`;
- }
-
- let response = await this.getCommand(commandOptions);
- let responseData = response.result.data;
-
- this._treeData = responseData;
- this._updateBindData();
- this._updateSelected();
-
- this.onDataChange();
- } catch (e) {
- this.errorMessage = e;
- } finally {
- this.loading = false;
- }
- },
-
- // 加载 Cloud 数据 (节点)
- async loadCloudDataNode(callback) {
- if (this.loading) {
- return;
- }
- this.loading = true;
-
- try {
- let commandOptions = {
- field: this._cloudDataPostField(),
- where: this._cloudDataNodeWhere()
- };
-
- let response = await this.getCommand(commandOptions);
- let responseData = response.result.data;
-
- callback(responseData);
- } catch (e) {
- this.errorMessage = e;
- } finally {
- this.loading = false;
- }
- },
-
- // 回显 Cloud 数据
- getCloudDataValue() {
- if (this.isCloudDataList) {
- return this.getCloudDataListValue();
- }
-
- if (this.isCloudDataTree) {
- return this.getCloudDataTreeValue();
- }
- },
-
- // 回显 Cloud 数据 (单列)
- getCloudDataListValue() {
- // 根据 field's as value标识匹配 where 条件
- let where = [];
- let whereField = this._getForeignKeyByField();
- if (whereField) {
- where.push(`${whereField} == '${this.dataValue}'`)
- }
-
- where = where.join(' || ');
-
- if (this.where) {
- where = `(${this.where}) && (${where})`
- }
-
- return this.getCommand({
- field: this._cloudDataPostField(),
- where
- }).then((res) => {
- this.selected = res.result.data;
- return res.result.data;
- });
- },
-
- // 回显 Cloud 数据 (树形)
- getCloudDataTreeValue() {
- return this.getCommand({
- field: this._cloudDataPostField(),
- getTreePath: {
- startWith: `${this.selfField}=='${this.dataValue}'`
- }
- }).then((res) => {
- let treePath = [];
- this._extractTreePath(res.result.data, treePath);
- this.selected = treePath;
- return treePath;
- });
- },
-
- getCommand(options = {}) {
- /* eslint-disable no-undef */
- let db = uniCloud.database(this.spaceInfo)
-
- const action = options.action || this.action
- if (action) {
- db = db.action(action)
- }
-
- const collection = options.collection || this.collection
- db = db.collection(collection)
-
- const where = options.where || this.where
- if (!(!where || !Object.keys(where).length)) {
- db = db.where(where)
- }
-
- const field = options.field || this.field
- if (field) {
- db = db.field(field)
- }
-
- const orderby = options.orderby || this.orderby
- if (orderby) {
- db = db.orderBy(orderby)
- }
-
- const current = options.pageCurrent !== undefined ? options.pageCurrent : this.page.current
- const size = options.pageSize !== undefined ? options.pageSize : this.page.size
- const getCount = options.getcount !== undefined ? options.getcount : this.getcount
- const getTree = options.gettree !== undefined ? options.gettree : this.gettree
-
- const getOptions = {
- getCount,
- getTree
- }
- if (options.getTreePath) {
- getOptions.getTreePath = options.getTreePath
- }
-
- db = db.skip(size * (current - 1)).limit(size).get(getOptions)
-
- return db
- },
-
- _cloudDataPostField() {
- let fields = [this.field];
- if (this.parentField) {
- fields.push(`${this.parentField} as parent_value`);
- }
- return fields.join(',');
- },
-
- _cloudDataTreeWhere() {
- let result = []
- let selected = this.selected
- let parentField = this.parentField
- if (parentField) {
- result.push(`${parentField} == null || ${parentField} == ""`)
- }
- if (selected.length) {
- for (var i = 0; i < selected.length - 1; i++) {
- result.push(`${parentField} == '${selected[i].value}'`)
- }
- }
-
- let where = []
- if (this.where) {
- where.push(`(${this.where})`)
- }
-
- if (result.length) {
- where.push(`(${result.join(' || ')})`)
- }
-
- return where.join(' && ')
- },
-
- _cloudDataNodeWhere() {
- let where = []
- let selected = this.selected;
- if (selected.length) {
- where.push(`${this.parentField} == '${selected[selected.length - 1].value}'`);
- }
-
- where = where.join(' || ');
-
- if (this.where) {
- return `(${this.where}) && (${where})`
- }
-
- return where
- },
-
- _getWhereByForeignKey() {
- let result = []
- let whereField = this._getForeignKeyByField();
- if (whereField) {
- result.push(`${whereField} == '${this.dataValue}'`)
- }
-
- if (this.where) {
- return `(${this.where}) && (${result.join(' || ')})`
- }
-
- return result.join(' || ')
- },
-
- _getForeignKeyByField() {
- let fields = this.field.split(',');
- let whereField = null;
- for (let i = 0; i < fields.length; i++) {
- const items = fields[i].split('as');
- if (items.length < 2) {
- continue;
- }
- if (items[1].trim() === 'value') {
- whereField = items[0].trim();
- break;
- }
- }
- return whereField;
- },
-
- _updateBindData(node) {
- const {
- dataList,
- hasNodes
- } = this._filterData(this._treeData, this.selected)
-
- let isleaf = this._stepSearh === false && !hasNodes
-
- if (node) {
- node.isleaf = isleaf
- }
-
- this.dataList = dataList
- this.selectedIndex = dataList.length - 1
-
- if (!isleaf && this.selected.length < dataList.length) {
- this.selected.push({
- value: null,
- text: "请选择"
- })
- }
-
- return {
- isleaf,
- hasNodes
- }
- },
-
- _updateSelected() {
- let dl = this.dataList
- let sl = this.selected
- let textField = this.map.text
- let valueField = this.map.value
- for (let i = 0; i < sl.length; i++) {
- let value = sl[i].value
- let dl2 = dl[i]
- for (let j = 0; j < dl2.length; j++) {
- let item2 = dl2[j]
- if (item2[valueField] === value) {
- sl[i].text = item2[textField]
- break
- }
- }
- }
- },
-
- _filterData(data, paths) {
- let dataList = []
- let hasNodes = true
-
- dataList.push(data.filter((item) => {
- return (item.parent_value === null || item.parent_value === undefined || item.parent_value === '')
- }))
- for (let i = 0; i < paths.length; i++) {
- let value = paths[i].value
- let nodes = data.filter((item) => {
- return item.parent_value === value
- })
-
- if (nodes.length) {
- dataList.push(nodes)
- } else {
- hasNodes = false
- }
- }
-
- return {
- dataList,
- hasNodes
- }
- },
-
- _extractTree(nodes, result, parent_value) {
- let list = result || []
- let valueField = this.map.value
- for (let i = 0; i < nodes.length; i++) {
- let node = nodes[i]
-
- let child = {}
- for (let key in node) {
- if (key !== 'children') {
- child[key] = node[key]
- }
- }
- if (parent_value !== null && parent_value !== undefined && parent_value !== '') {
- child.parent_value = parent_value
- }
- result.push(child)
-
- let children = node.children
- if (children) {
- this._extractTree(children, result, node[valueField])
- }
- }
- },
-
- _extractTreePath(nodes, result) {
- let list = result || []
- for (let i = 0; i < nodes.length; i++) {
- let node = nodes[i]
-
- let child = {}
- for (let key in node) {
- if (key !== 'children') {
- child[key] = node[key]
- }
- }
- result.push(child)
-
- let children = node.children
- if (children) {
- this._extractTreePath(children, result)
- }
- }
- },
-
- _findNodePath(key, nodes, path = []) {
- let textField = this.map.text
- let valueField = this.map.value
- for (let i = 0; i < nodes.length; i++) {
- let node = nodes[i]
- let children = node.children
- let text = node[textField]
- let value = node[valueField]
-
- path.push({
- value,
- text
- })
-
- if (value === key) {
- return path
- }
-
- if (children) {
- const p = this._findNodePath(key, children, path)
- if (p.length) {
- return p
- }
- }
-
- path.pop()
- }
- return []
- }
- }
-}
+export default {
+ props: {
+ localdata: {
+ type: [Array, Object],
+ default () {
+ return []
+ }
+ },
+ spaceInfo: {
+ type: Object,
+ default () {
+ return {}
+ }
+ },
+ collection: {
+ type: String,
+ default: ''
+ },
+ action: {
+ type: String,
+ default: ''
+ },
+ field: {
+ type: String,
+ default: ''
+ },
+ orderby: {
+ type: String,
+ default: ''
+ },
+ where: {
+ type: [String, Object],
+ default: ''
+ },
+ pageData: {
+ type: String,
+ default: 'add'
+ },
+ pageCurrent: {
+ type: Number,
+ default: 1
+ },
+ pageSize: {
+ type: Number,
+ default: 500
+ },
+ getcount: {
+ type: [Boolean, String],
+ default: false
+ },
+ getone: {
+ type: [Boolean, String],
+ default: false
+ },
+ gettree: {
+ type: [Boolean, String],
+ default: false
+ },
+ manual: {
+ type: Boolean,
+ default: false
+ },
+ value: {
+ type: [Array, String, Number],
+ default () {
+ return []
+ }
+ },
+ modelValue: {
+ type: [Array, String, Number],
+ default () {
+ return []
+ }
+ },
+ preload: {
+ type: Boolean,
+ default: false
+ },
+ stepSearh: {
+ type: Boolean,
+ default: true
+ },
+ selfField: {
+ type: String,
+ default: ''
+ },
+ parentField: {
+ type: String,
+ default: ''
+ },
+ multiple: {
+ type: Boolean,
+ default: false
+ },
+ map: {
+ type: Object,
+ default () {
+ return {
+ text: "text",
+ value: "value"
+ }
+ }
+ }
+ },
+ data() {
+ return {
+ loading: false,
+ errorMessage: '',
+ loadMore: {
+ contentdown: '',
+ contentrefresh: '',
+ contentnomore: ''
+ },
+ dataList: [],
+ selected: [],
+ selectedIndex: 0,
+ page: {
+ current: this.pageCurrent,
+ size: this.pageSize,
+ count: 0
+ }
+ }
+ },
+ computed: {
+ isLocalData() {
+ return !this.collection.length;
+ },
+ isCloudData() {
+ return this.collection.length > 0;
+ },
+ isCloudDataList() {
+ return (this.isCloudData && (!this.parentField && !this.selfField));
+ },
+ isCloudDataTree() {
+ return (this.isCloudData && this.parentField && this.selfField);
+ },
+ dataValue() {
+ let isModelValue = Array.isArray(this.modelValue) ? (this.modelValue.length > 0) : (this.modelValue !== null ||
+ this.modelValue !== undefined);
+ return isModelValue ? this.modelValue : this.value;
+ },
+ hasValue() {
+ if (typeof this.dataValue === 'number') {
+ return true
+ }
+ return (this.dataValue != null) && (this.dataValue.length > 0)
+ }
+ },
+ created() {
+ this.$watch(() => {
+ var al = [];
+ ['pageCurrent',
+ 'pageSize',
+ 'spaceInfo',
+ 'value',
+ 'modelValue',
+ 'localdata',
+ 'collection',
+ 'action',
+ 'field',
+ 'orderby',
+ 'where',
+ 'getont',
+ 'getcount',
+ 'gettree'
+ ].forEach(key => {
+ al.push(this[key])
+ });
+ return al
+ }, (newValue, oldValue) => {
+ let needReset = false
+ for (let i = 2; i < newValue.length; i++) {
+ if (newValue[i] != oldValue[i]) {
+ needReset = true
+ break
+ }
+ }
+ if (newValue[0] != oldValue[0]) {
+ this.page.current = this.pageCurrent
+ }
+ this.page.size = this.pageSize
+
+ this.onPropsChange()
+ })
+ this._treeData = []
+ },
+ methods: {
+ onPropsChange() {
+ this._treeData = [];
+ },
+
+ // 填充 pickview 数据
+ async loadData() {
+ if (this.isLocalData) {
+ this.loadLocalData();
+ } else if (this.isCloudDataList) {
+ this.loadCloudDataList();
+ } else if (this.isCloudDataTree) {
+ this.loadCloudDataTree();
+ }
+ },
+
+ // 加载本地数据
+ async loadLocalData() {
+ this._treeData = [];
+ this._extractTree(this.localdata, this._treeData);
+
+ let inputValue = this.dataValue;
+ if (inputValue === undefined) {
+ return;
+ }
+
+ if (Array.isArray(inputValue)) {
+ inputValue = inputValue[inputValue.length - 1];
+ if (typeof inputValue === 'object' && inputValue[this.map.value]) {
+ inputValue = inputValue[this.map.value];
+ }
+ }
+
+ this.selected = this._findNodePath(inputValue, this.localdata);
+ },
+
+ // 加载 Cloud 数据 (单列)
+ async loadCloudDataList() {
+ if (this.loading) {
+ return;
+ }
+ this.loading = true;
+
+ try {
+ let response = await this.getCommand();
+ let responseData = response.result.data;
+
+ this._treeData = responseData;
+
+ this._updateBindData();
+ this._updateSelected();
+
+ this.onDataChange();
+ } catch (e) {
+ this.errorMessage = e;
+ } finally {
+ this.loading = false;
+ }
+ },
+
+ // 加载 Cloud 数据 (树形)
+ async loadCloudDataTree() {
+ if (this.loading) {
+ return;
+ }
+ this.loading = true;
+
+ try {
+ let commandOptions = {
+ field: this._cloudDataPostField(),
+ where: this._cloudDataTreeWhere()
+ };
+ if (this.gettree) {
+ commandOptions.startwith = `${this.selfField}=='${this.dataValue}'`;
+ }
+
+ let response = await this.getCommand(commandOptions);
+ let responseData = response.result.data;
+
+ this._treeData = responseData;
+ this._updateBindData();
+ this._updateSelected();
+
+ this.onDataChange();
+ } catch (e) {
+ this.errorMessage = e;
+ } finally {
+ this.loading = false;
+ }
+ },
+
+ // 加载 Cloud 数据 (节点)
+ async loadCloudDataNode(callback) {
+ if (this.loading) {
+ return;
+ }
+ this.loading = true;
+
+ try {
+ let commandOptions = {
+ field: this._cloudDataPostField(),
+ where: this._cloudDataNodeWhere()
+ };
+
+ let response = await this.getCommand(commandOptions);
+ let responseData = response.result.data;
+
+ callback(responseData);
+ } catch (e) {
+ this.errorMessage = e;
+ } finally {
+ this.loading = false;
+ }
+ },
+
+ // 回显 Cloud 数据
+ getCloudDataValue() {
+ if (this.isCloudDataList) {
+ return this.getCloudDataListValue();
+ }
+
+ if (this.isCloudDataTree) {
+ return this.getCloudDataTreeValue();
+ }
+ },
+
+ // 回显 Cloud 数据 (单列)
+ getCloudDataListValue() {
+ // 根据 field's as value标识匹配 where 条件
+ let where = [];
+ let whereField = this._getForeignKeyByField();
+ if (whereField) {
+ where.push(`${whereField} == '${this.dataValue}'`)
+ }
+
+ where = where.join(' || ');
+
+ if (this.where) {
+ where = `(${this.where}) && (${where})`
+ }
+
+ return this.getCommand({
+ field: this._cloudDataPostField(),
+ where
+ }).then((res) => {
+ this.selected = res.result.data;
+ return res.result.data;
+ });
+ },
+
+ // 回显 Cloud 数据 (树形)
+ getCloudDataTreeValue() {
+ return this.getCommand({
+ field: this._cloudDataPostField(),
+ getTreePath: {
+ startWith: `${this.selfField}=='${this.dataValue}'`
+ }
+ }).then((res) => {
+ let treePath = [];
+ this._extractTreePath(res.result.data, treePath);
+ this.selected = treePath;
+ return treePath;
+ });
+ },
+
+ getCommand(options = {}) {
+ /* eslint-disable no-undef */
+ let db = uniCloud.database(this.spaceInfo)
+
+ const action = options.action || this.action
+ if (action) {
+ db = db.action(action)
+ }
+
+ const collection = options.collection || this.collection
+ db = db.collection(collection)
+
+ const where = options.where || this.where
+ if (!(!where || !Object.keys(where).length)) {
+ db = db.where(where)
+ }
+
+ const field = options.field || this.field
+ if (field) {
+ db = db.field(field)
+ }
+
+ const orderby = options.orderby || this.orderby
+ if (orderby) {
+ db = db.orderBy(orderby)
+ }
+
+ const current = options.pageCurrent !== undefined ? options.pageCurrent : this.page.current
+ const size = options.pageSize !== undefined ? options.pageSize : this.page.size
+ const getCount = options.getcount !== undefined ? options.getcount : this.getcount
+ const getTree = options.gettree !== undefined ? options.gettree : this.gettree
+
+ const getOptions = {
+ getCount,
+ getTree
+ }
+ if (options.getTreePath) {
+ getOptions.getTreePath = options.getTreePath
+ }
+
+ db = db.skip(size * (current - 1)).limit(size).get(getOptions)
+
+ return db
+ },
+
+ _cloudDataPostField() {
+ let fields = [this.field];
+ if (this.parentField) {
+ fields.push(`${this.parentField} as parent_value`);
+ }
+ return fields.join(',');
+ },
+
+ _cloudDataTreeWhere() {
+ let result = []
+ let selected = this.selected
+ let parentField = this.parentField
+ if (parentField) {
+ result.push(`${parentField} == null || ${parentField} == ""`)
+ }
+ if (selected.length) {
+ for (var i = 0; i < selected.length - 1; i++) {
+ result.push(`${parentField} == '${selected[i].value}'`)
+ }
+ }
+
+ let where = []
+ if (this.where) {
+ where.push(`(${this.where})`)
+ }
+
+ if (result.length) {
+ where.push(`(${result.join(' || ')})`)
+ }
+
+ return where.join(' && ')
+ },
+
+ _cloudDataNodeWhere() {
+ let where = []
+ let selected = this.selected;
+ if (selected.length) {
+ where.push(`${this.parentField} == '${selected[selected.length - 1].value}'`);
+ }
+
+ where = where.join(' || ');
+
+ if (this.where) {
+ return `(${this.where}) && (${where})`
+ }
+
+ return where
+ },
+
+ _getWhereByForeignKey() {
+ let result = []
+ let whereField = this._getForeignKeyByField();
+ if (whereField) {
+ result.push(`${whereField} == '${this.dataValue}'`)
+ }
+
+ if (this.where) {
+ return `(${this.where}) && (${result.join(' || ')})`
+ }
+
+ return result.join(' || ')
+ },
+
+ _getForeignKeyByField() {
+ let fields = this.field.split(',');
+ let whereField = null;
+ for (let i = 0; i < fields.length; i++) {
+ const items = fields[i].split('as');
+ if (items.length < 2) {
+ continue;
+ }
+ if (items[1].trim() === 'value') {
+ whereField = items[0].trim();
+ break;
+ }
+ }
+ return whereField;
+ },
+
+ _updateBindData(node) {
+ const {
+ dataList,
+ hasNodes
+ } = this._filterData(this._treeData, this.selected)
+
+ let isleaf = this._stepSearh === false && !hasNodes
+
+ if (node) {
+ node.isleaf = isleaf
+ }
+
+ this.dataList = dataList
+ this.selectedIndex = dataList.length - 1
+
+ if (!isleaf && this.selected.length < dataList.length) {
+ this.selected.push({
+ value: null,
+ text: "请选择"
+ })
+ }
+
+ return {
+ isleaf,
+ hasNodes
+ }
+ },
+
+ _updateSelected() {
+ let dl = this.dataList
+ let sl = this.selected
+ let textField = this.map.text
+ let valueField = this.map.value
+ for (let i = 0; i < sl.length; i++) {
+ let value = sl[i].value
+ let dl2 = dl[i]
+ for (let j = 0; j < dl2.length; j++) {
+ let item2 = dl2[j]
+ if (item2[valueField] === value) {
+ sl[i].text = item2[textField]
+ break
+ }
+ }
+ }
+ },
+
+ _filterData(data, paths) {
+ let dataList = []
+ let hasNodes = true
+
+ dataList.push(data.filter((item) => {
+ return (item.parent_value === null || item.parent_value === undefined || item.parent_value === '')
+ }))
+ for (let i = 0; i < paths.length; i++) {
+ let value = paths[i].value
+ let nodes = data.filter((item) => {
+ return item.parent_value === value
+ })
+
+ if (nodes.length) {
+ dataList.push(nodes)
+ } else {
+ hasNodes = false
+ }
+ }
+
+ return {
+ dataList,
+ hasNodes
+ }
+ },
+
+ _extractTree(nodes, result, parent_value) {
+ let list = result || []
+ let valueField = this.map.value
+ for (let i = 0; i < nodes.length; i++) {
+ let node = nodes[i]
+
+ let child = {}
+ for (let key in node) {
+ if (key !== 'children') {
+ child[key] = node[key]
+ }
+ }
+ if (parent_value !== null && parent_value !== undefined && parent_value !== '') {
+ child.parent_value = parent_value
+ }
+ result.push(child)
+
+ let children = node.children
+ if (children) {
+ this._extractTree(children, result, node[valueField])
+ }
+ }
+ },
+
+ _extractTreePath(nodes, result) {
+ let list = result || []
+ for (let i = 0; i < nodes.length; i++) {
+ let node = nodes[i]
+
+ let child = {}
+ for (let key in node) {
+ if (key !== 'children') {
+ child[key] = node[key]
+ }
+ }
+ result.push(child)
+
+ let children = node.children
+ if (children) {
+ this._extractTreePath(children, result)
+ }
+ }
+ },
+
+ _findNodePath(key, nodes, path = []) {
+ let textField = this.map.text
+ let valueField = this.map.value
+ for (let i = 0; i < nodes.length; i++) {
+ let node = nodes[i]
+ let children = node.children
+ let text = node[textField]
+ let value = node[valueField]
+
+ path.push({
+ value,
+ text
+ })
+
+ if (value === key) {
+ return path
+ }
+
+ if (children) {
+ const p = this._findNodePath(key, children, path)
+ if (p.length) {
+ return p
+ }
+ }
+
+ path.pop()
+ }
+ return []
+ }
+ }
+}
diff --git a/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-picker.uts b/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-picker.uts
index 1c78a40e..857408de 100644
--- a/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-picker.uts
+++ b/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-picker.uts
@@ -1,693 +1,692 @@
-export type PaginationType = {
- current : number,
- size : number,
- count : number
-}
-
-export type LoadMoreType = {
- contentdown : string,
- contentrefresh : string,
- contentnomore : string
-}
-
-export type SelectedItemType = {
- name : string,
- value : string,
-}
-
-export type GetCommandOptions = {
- collection ?: UTSJSONObject,
- field ?: string,
- orderby ?: string,
- where ?: any,
- pageData ?: string,
- pageCurrent ?: number,
- pageSize ?: number,
- getCount ?: boolean,
- getTree ?: any,
- getTreePath ?: UTSJSONObject,
- startwith ?: string,
- limitlevel ?: number,
- groupby ?: string,
- groupField ?: string,
- distinct ?: boolean,
- pageIndistinct ?: boolean,
- foreignKey ?: string,
- loadtime ?: string,
- manual ?: boolean
-}
-
-const DefaultSelectedNode = {
- text: '请选择',
- value: ''
-}
-
-export const dataPicker = defineMixin({
- props: {
- localdata: {
- type: Array as PropType>,
- default: [] as Array
- },
- collection: {
- type: Object,
- default: ''
- },
- field: {
- type: String,
- default: ''
- },
- orderby: {
- type: String,
- default: ''
- },
- where: {
- type: Object,
- default: ''
- },
- pageData: {
- type: String,
- default: 'add'
- },
- pageCurrent: {
- type: Number,
- default: 1
- },
- pageSize: {
- type: Number,
- default: 20
- },
- getcount: {
- type: Boolean,
- default: false
- },
- gettree: {
- type: Object,
- default: ''
- },
- gettreepath: {
- type: Object,
- default: ''
- },
- startwith: {
- type: String,
- default: ''
- },
- limitlevel: {
- type: Number,
- default: 10
- },
- groupby: {
- type: String,
- default: ''
- },
- groupField: {
- type: String,
- default: ''
- },
- distinct: {
- type: Boolean,
- default: false
- },
- pageIndistinct: {
- type: Boolean,
- default: false
- },
- foreignKey: {
- type: String,
- default: ''
- },
- loadtime: {
- type: String,
- default: 'auto'
- },
- manual: {
- type: Boolean,
- default: false
- },
- preload: {
- type: Boolean,
- default: false
- },
- stepSearh: {
- type: Boolean,
- default: true
- },
- selfField: {
- type: String,
- default: ''
- },
- parentField: {
- type: String,
- default: ''
- },
- multiple: {
- type: Boolean,
- default: false
- },
- value: {
- type: Object,
- default: ''
- },
- modelValue: {
- type: Object,
- default: ''
- },
- defaultProps: {
- type: Object as PropType,
- }
- },
- data() {
- return {
- loading: false,
- error: null as UniCloudError | null,
- treeData: [] as Array,
- selectedIndex: 0,
- selectedNodes: [] as Array,
- selectedPages: [] as Array[],
- selectedValue: '',
- selectedPaths: [] as Array,
- pagination: {
- current: 1,
- size: 20,
- count: 0
- } as PaginationType
- }
- },
- computed: {
- mappingTextName() : string {
- // TODO
- return (this.defaultProps != null) ? this.defaultProps!.getString('text', 'text') : 'text'
- },
- mappingValueName() : string {
- // TODO
- return (this.defaultProps != null) ? this.defaultProps!.getString('value', 'value') : 'value'
- },
- currentDataList() : Array {
- if (this.selectedIndex > this.selectedPages.length - 1) {
- return [] as Array
- }
- return this.selectedPages[this.selectedIndex]
- },
- isLocalData() : boolean {
- return this.localdata.length > 0
- },
- isCloudData() : boolean {
- return this._checkIsNotNull(this.collection)
- },
- isCloudDataList() : boolean {
- return (this.isCloudData && (this.parentField.length == 0 && this.selfField.length == 0))
- },
- isCloudDataTree() : boolean {
- return (this.isCloudData && this.parentField.length > 0 && this.selfField.length > 0)
- },
- dataValue() : any {
- return this.hasModelValue ? this.modelValue : this.value
- },
- hasCloudTreeData() : boolean {
- return this.treeData.length > 0
- },
- hasModelValue() : boolean {
- if (typeof this.modelValue == 'string') {
- const valueString = this.modelValue as string
- return (valueString.length > 0)
- } else if (Array.isArray(this.modelValue)) {
- const valueArray = this.modelValue as Array
- return (valueArray.length > 0)
- }
- return false
- },
- hasCloudDataValue() : boolean {
- if (typeof this.dataValue == 'string') {
- const valueString = this.dataValue as string
- return (valueString.length > 0)
- }
- return false
- }
- },
- created() {
- this.pagination.current = this.pageCurrent
- this.pagination.size = this.pageSize
-
- this.$watch(
- () : any => [
- this.pageCurrent,
- this.pageSize,
+export type PaginationType = {
+ current : number,
+ size : number,
+ count : number
+}
+
+export type LoadMoreType = {
+ contentdown : string,
+ contentrefresh : string,
+ contentnomore : string
+}
+
+export type SelectedItemType = {
+ name : string,
+ value : string,
+}
+
+export type GetCommandOptions = {
+ collection ?: UTSJSONObject,
+ field ?: string,
+ orderby ?: string,
+ where ?: any,
+ pageData ?: string,
+ pageCurrent ?: number,
+ pageSize ?: number,
+ getCount ?: boolean,
+ getTree ?: any,
+ getTreePath ?: UTSJSONObject,
+ startwith ?: string,
+ limitlevel ?: number,
+ groupby ?: string,
+ groupField ?: string,
+ distinct ?: boolean,
+ pageIndistinct ?: boolean,
+ foreignKey ?: string,
+ loadtime ?: string,
+ manual ?: boolean
+}
+
+const DefaultSelectedNode = {
+ text: '请选择',
+ value: ''
+}
+
+export const dataPicker = defineMixin({
+ props: {
+ localdata: {
+ type: Array as PropType>,
+ default: [] as Array
+ },
+ collection: {
+ type: Object,
+ default: ''
+ },
+ field: {
+ type: String,
+ default: ''
+ },
+ orderby: {
+ type: String,
+ default: ''
+ },
+ where: {
+ type: Object,
+ default: ''
+ },
+ pageData: {
+ type: String,
+ default: 'add'
+ },
+ pageCurrent: {
+ type: Number,
+ default: 1
+ },
+ pageSize: {
+ type: Number,
+ default: 20
+ },
+ getcount: {
+ type: Boolean,
+ default: false
+ },
+ gettree: {
+ type: Object,
+ default: ''
+ },
+ gettreepath: {
+ type: Object,
+ default: ''
+ },
+ startwith: {
+ type: String,
+ default: ''
+ },
+ limitlevel: {
+ type: Number,
+ default: 10
+ },
+ groupby: {
+ type: String,
+ default: ''
+ },
+ groupField: {
+ type: String,
+ default: ''
+ },
+ distinct: {
+ type: Boolean,
+ default: false
+ },
+ pageIndistinct: {
+ type: Boolean,
+ default: false
+ },
+ foreignKey: {
+ type: String,
+ default: ''
+ },
+ loadtime: {
+ type: String,
+ default: 'auto'
+ },
+ manual: {
+ type: Boolean,
+ default: false
+ },
+ preload: {
+ type: Boolean,
+ default: false
+ },
+ stepSearh: {
+ type: Boolean,
+ default: true
+ },
+ selfField: {
+ type: String,
+ default: ''
+ },
+ parentField: {
+ type: String,
+ default: ''
+ },
+ multiple: {
+ type: Boolean,
+ default: false
+ },
+ value: {
+ type: Object,
+ default: ''
+ },
+ modelValue: {
+ type: Object,
+ default: ''
+ },
+ defaultProps: {
+ type: Object as PropType,
+ }
+ },
+ data() {
+ return {
+ loading: false,
+ error: null as UniCloudError | null,
+ treeData: [] as Array,
+ selectedIndex: 0,
+ selectedNodes: [] as Array,
+ selectedPages: [] as Array[],
+ selectedValue: '',
+ selectedPaths: [] as Array,
+ pagination: {
+ current: 1,
+ size: 20,
+ count: 0
+ } as PaginationType
+ }
+ },
+ computed: {
+ mappingTextName() : string {
+ // TODO
+ return (this.defaultProps != null) ? this.defaultProps!.getString('text', 'text') : 'text'
+ },
+ mappingValueName() : string {
+ // TODO
+ return (this.defaultProps != null) ? this.defaultProps!.getString('value', 'value') : 'value'
+ },
+ currentDataList() : Array {
+ if (this.selectedIndex > this.selectedPages.length - 1) {
+ return [] as Array
+ }
+ return this.selectedPages[this.selectedIndex]
+ },
+ isLocalData() : boolean {
+ return this.localdata.length > 0
+ },
+ isCloudData() : boolean {
+ return this._checkIsNotNull(this.collection)
+ },
+ isCloudDataList() : boolean {
+ return (this.isCloudData && (this.parentField.length == 0 && this.selfField.length == 0))
+ },
+ isCloudDataTree() : boolean {
+ return (this.isCloudData && this.parentField.length > 0 && this.selfField.length > 0)
+ },
+ dataValue() : any {
+ return this.hasModelValue ? this.modelValue : this.value
+ },
+ hasCloudTreeData() : boolean {
+ return this.treeData.length > 0
+ },
+ hasModelValue() : boolean {
+ if (typeof this.modelValue == 'string') {
+ const valueString = this.modelValue as string
+ return (valueString.length > 0)
+ } else if (Array.isArray(this.modelValue)) {
+ const valueArray = this.modelValue as Array
+ return (valueArray.length > 0)
+ }
+ return false
+ },
+ hasCloudDataValue() : boolean {
+ if (typeof this.dataValue == 'string') {
+ const valueString = this.dataValue as string
+ return (valueString.length > 0)
+ }
+ return false
+ }
+ },
+ created() {
+ this.pagination.current = this.pageCurrent
+ this.pagination.size = this.pageSize
+
+ this.$watch(
+ () : any => [
+ this.pageCurrent,
+ this.pageSize,
this.localdata,
- this.value,
- this.collection,
- this.field,
- this.getcount,
- this.orderby,
- this.where,
- this.groupby,
- this.groupField,
- this.distinct
- ],
- (newValue : Array, oldValue : Array) => {
- this.pagination.size = this.pageSize
- if (newValue[0] !== oldValue[0]) {
- this.pagination.current = this.pageCurrent
- }
-
- this.onPropsChange()
- }
- )
- },
- methods: {
- onPropsChange() {
- this.selectedIndex = 0
- this.treeData.length = 0
- this.selectedNodes.length = 0
- this.selectedPages.length = 0
- this.selectedPaths.length = 0
-
- // 加载数据
- this.$nextTick(() => {
- this.loadData()
- })
- },
-
- onTabSelect(index : number) {
- this.selectedIndex = index
- },
-
- onNodeClick(nodeData : UTSJSONObject) {
- if (nodeData.getBoolean('disable', false)) {
- return
- }
-
- const isLeaf = this._checkIsLeafNode(nodeData)
-
- this._trimSelectedNodes(nodeData)
-
- this.$emit('nodeclick', nodeData)
-
- if (this.isLocalData) {
- if (isLeaf || !this._checkHasChildren(nodeData)) {
- this.onFinish()
- }
- } else if (this.isCloudDataList) {
- this.onFinish()
- } else if (this.isCloudDataTree) {
- if (isLeaf) {
- this.onFinish()
- } else if (!this._checkHasChildren(nodeData)) {
- // 尝试请求一次,如果没有返回数据标记为叶子节点
- this.loadCloudDataNode(nodeData)
- }
- }
- },
-
- getChangeNodes(): Array {
- const nodes: Array = []
- this.selectedNodes.forEach((node : UTSJSONObject) => {
- const newNode: UTSJSONObject = {}
- newNode[this.mappingTextName] = node.getString(this.mappingTextName)
- newNode[this.mappingValueName] = node.getString(this.mappingValueName)
- nodes.push(newNode)
- })
- return nodes
- },
-
- onFinish() { },
-
- // 加载数据(自动判定环境)
- loadData() {
- if (this.isLocalData) {
- this.loadLocalData()
- } else if (this.isCloudDataList) {
- this.loadCloudDataList()
- } else if (this.isCloudDataTree) {
- this.loadCloudDataTree()
- }
- },
-
- // 加载本地数据
- loadLocalData() {
- this.treeData = this.localdata
- if (Array.isArray(this.dataValue)) {
- const value = this.dataValue as Array
- this.selectedPaths = value.slice(0)
- this._pushSelectedTreeNodes(value, this.localdata)
- } else {
- this._pushSelectedNodes(this.localdata)
- }
- },
-
- // 加载 Cloud 数据 (单列)
- loadCloudDataList() {
- this._loadCloudData(null, (data : Array) => {
- this.treeData = data
- this._pushSelectedNodes(data)
- })
- },
-
- // 加载 Cloud 数据 (树形)
- loadCloudDataTree() {
- let commandOptions = {
- field: this._cloudDataPostField(),
- where: this._cloudDataTreeWhere(),
- getTree: true
- } as GetCommandOptions
- if (this._checkIsNotNull(this.gettree)) {
- commandOptions.startwith = `${this.selfField}=='${this.dataValue as string}'`
- }
- this._loadCloudData(commandOptions, (data : Array) => {
- this.treeData = data
- if (this.selectedPaths.length > 0) {
- this._pushSelectedTreeNodes(this.selectedPaths, data)
- } else {
- this._pushSelectedNodes(data)
- }
- })
- },
-
- // 加载 Cloud 数据 (节点)
- loadCloudDataNode(nodeData : UTSJSONObject) {
- const commandOptions = {
- field: this._cloudDataPostField(),
- where: this._cloudDataNodeWhere()
- } as GetCommandOptions
- this._loadCloudData(commandOptions, (data : Array) => {
- nodeData['children'] = data
- if (data.length == 0) {
- nodeData['isleaf'] = true
- this.onFinish()
- } else {
- this._pushSelectedNodes(data)
- }
- })
- },
-
- // 回显 Cloud Tree Path
- loadCloudDataPath() {
- if (!this.hasCloudDataValue) {
- return
- }
-
- const command : GetCommandOptions = {}
-
- // 单列
- if (this.isCloudDataList) {
- // 根据 field's as value标识匹配 where 条件
- let where : Array = [];
- let whereField = this._getForeignKeyByField();
- if (whereField.length > 0) {
- where.push(`${whereField} == '${this.dataValue as string}'`)
- }
-
- let whereString = where.join(' || ')
- if (this._checkIsNotNull(this.where)) {
- whereString = `(${this.where}) && (${whereString})`
- }
-
- command.field = this._cloudDataPostField()
- command.where = whereString
- }
-
- // 树形
- if (this.isCloudDataTree) {
- command.field = this._cloudDataPostField()
- command.getTreePath = {
- startWith: `${this.selfField}=='${this.dataValue as string}'`
- }
- }
-
- this._loadCloudData(command, (data : Array) => {
- this._extractTreePath(data, this.selectedPaths)
- })
- },
-
- _loadCloudData(options ?: GetCommandOptions, callback ?: ((data : Array) => void)) {
- if (this.loading) {
- return
- }
- this.loading = true
-
- this.error = null
-
- this._getCommand(options).then((response : UniCloudDBGetResult) => {
- callback?.(response.data)
- }).catch((err : any | null) => {
- this.error = err as UniCloudError
- }).finally(() => {
- this.loading = false
- })
- },
-
- _cloudDataPostField() : string {
- let fields = [this.field];
- if (this.parentField.length > 0) {
- fields.push(`${this.parentField} as parent_value`)
- }
- return fields.join(',')
- },
-
- _cloudDataTreeWhere() : string {
- let result : Array = []
- let selectedNodes = this.selectedNodes.length > 0 ? this.selectedNodes : this.selectedPaths
- let parentField = this.parentField
- if (parentField.length > 0) {
- result.push(`${parentField} == null || ${parentField} == ""`)
- }
- if (selectedNodes.length > 0) {
- for (var i = 0; i < selectedNodes.length - 1; i++) {
- const parentFieldValue = selectedNodes[i].getString('value', '')
- result.push(`${parentField} == '${parentFieldValue}'`)
- }
- }
-
- let where : Array = []
- if (this._checkIsNotNull(this.where)) {
- where.push(`(${this.where as string})`)
- }
-
- if (result.length > 0) {
- where.push(`(${result.join(' || ')})`)
- }
-
- return where.join(' && ')
- },
-
- _cloudDataNodeWhere() : string {
- const where : Array = []
- if (this.selectedNodes.length > 0) {
- const value = this.selectedNodes[this.selectedNodes.length - 1].getString('value', '')
- where.push(`${this.parentField} == '${value}'`)
- }
-
- let whereString = where.join(' || ')
- if (this._checkIsNotNull(this.where)) {
- return `(${this.where as string}) && (${whereString})`
- }
-
- return whereString
- },
-
- _getWhereByForeignKey() : string {
- let result : Array = []
- let whereField = this._getForeignKeyByField();
- if (whereField.length > 0) {
- result.push(`${whereField} == '${this.dataValue as string}'`)
- }
-
- if (this._checkIsNotNull(this.where)) {
- return `(${this.where}) && (${result.join(' || ')})`
- }
-
- return result.join(' || ')
- },
-
- _getForeignKeyByField() : string {
- const fields = this.field.split(',')
- let whereField = ''
- for (let i = 0; i < fields.length; i++) {
- const items = fields[i].split('as')
- if (items.length < 2) {
- continue
- }
- if (items[1].trim() === 'value') {
- whereField = items[0].trim()
- break
- }
- }
- return whereField
- },
-
- _getCommand(options ?: GetCommandOptions) : Promise {
- let db = uniCloud.databaseForJQL()
-
- let collection = Array.isArray(this.collection) ? db.collection(...(this.collection as Array)) : db.collection(this.collection)
-
- let filter : UniCloudDBFilter | null = null
- if (this.foreignKey.length > 0) {
- filter = collection.foreignKey(this.foreignKey)
- }
-
- const where : any = options?.where ?? this.where
- if (typeof where == 'string') {
- const whereString = where as string
- if (whereString.length > 0) {
- filter = (filter != null) ? filter.where(where) : collection.where(where)
- }
- } else {
- filter = (filter != null) ? filter.where(where) : collection.where(where)
- }
-
- let query : UniCloudDBQuery | null = null
- if (this.field.length > 0) {
- query = (filter != null) ? filter.field(this.field) : collection.field(this.field)
- }
- if (this.groupby.length > 0) {
- if (query != null) {
- query = query.groupBy(this.groupby)
- } else if (filter != null) {
- query = filter.groupBy(this.groupby)
- }
- }
- if (this.groupField.length > 0) {
- if (query != null) {
- query = query.groupField(this.groupField)
- } else if (filter != null) {
- query = filter.groupField(this.groupField)
- }
- }
- if (this.distinct == true) {
- if (query != null) {
- query = query.distinct(this.field)
- } else if (filter != null) {
- query = filter.distinct(this.field)
- }
- }
- if (this.orderby.length > 0) {
- if (query != null) {
- query = query.orderBy(this.orderby)
- } else if (filter != null) {
- query = filter.orderBy(this.orderby)
- }
- }
-
- const size = this.pagination.size
- const current = this.pagination.current
- if (query != null) {
- query = query.skip(size * (current - 1)).limit(size)
- } else if (filter != null) {
- query = filter.skip(size * (current - 1)).limit(size)
- } else {
- query = collection.skip(size * (current - 1)).limit(size)
- }
-
- const getOptions = {}
- const treeOptions = {
- limitLevel: this.limitlevel,
- startWith: this.startwith
- }
- if (this.getcount == true) {
- getOptions['getCount'] = this.getcount
- }
-
- const getTree : any = options?.getTree ?? this.gettree
- if (typeof getTree == 'string') {
- const getTreeString = getTree as string
- if (getTreeString.length > 0) {
- getOptions['getTree'] = treeOptions
- }
- } else if (typeof getTree == 'object') {
- getOptions['getTree'] = treeOptions
- } else {
- getOptions['getTree'] = getTree
- }
-
- const getTreePath = options?.getTreePath ?? this.gettreepath
- if (typeof getTreePath == 'string') {
- const getTreePathString = getTreePath as string
- if (getTreePathString.length > 0) {
- getOptions['getTreePath'] = getTreePath
- }
- } else {
- getOptions['getTreePath'] = getTreePath
- }
-
- return query.get(getOptions)
- },
-
- _checkIsNotNull(value : any) : boolean {
- if (typeof value == 'string') {
- const valueString = value as string
- return (valueString.length > 0)
- } else if (value instanceof UTSJSONObject) {
- return true
- }
- return false
- },
-
- _checkIsLeafNode(nodeData : UTSJSONObject) : boolean {
- if (this.selectedIndex >= this.limitlevel) {
- return true
- }
-
- if (nodeData.getBoolean('isleaf', false)) {
- return true
- }
-
- return false
- },
-
- _checkHasChildren(nodeData : UTSJSONObject) : boolean {
- const children = nodeData.getArray('children') ?? ([] as Array)
- return children.length > 0
- },
-
- _pushSelectedNodes(nodes : Array) {
- this.selectedNodes.push(DefaultSelectedNode)
- this.selectedPages.push(nodes)
- this.selectedIndex = this.selectedPages.length - 1
- },
-
- _trimSelectedNodes(nodeData : UTSJSONObject) {
- this.selectedNodes.splice(this.selectedIndex)
- this.selectedNodes.push(nodeData)
-
- if (this.selectedPages.length > 0) {
- this.selectedPages.splice(this.selectedIndex + 1)
- }
-
- const children = nodeData.getArray('children') ?? ([] as Array)
- if (children.length > 0) {
- this.selectedNodes.push(DefaultSelectedNode)
- this.selectedPages.push(children)
- }
-
- this.selectedIndex = this.selectedPages.length - 1
- },
-
- _pushSelectedTreeNodes(paths : Array, nodes : Array) {
- let children : Array = nodes
- paths.forEach((node : UTSJSONObject) => {
- const findNode = children.find((item : UTSJSONObject) : boolean => {
- return (item.getString(this.mappingValueName) == node.getString(this.mappingValueName))
- })
- if (findNode != null) {
- this.selectedPages.push(children)
- this.selectedNodes.push(node)
- children = findNode.getArray('children') ?? ([] as Array)
- }
- })
- this.selectedIndex = this.selectedPages.length - 1
- },
-
- _extractTreePath(nodes : Array, result : Array) {
- if (nodes.length == 0) {
- return
- }
-
- const node = nodes[0]
- result.push(node)
-
- const children = node.getArray('children')
- if (Array.isArray(children) && children!.length > 0) {
- this._extractTreePath(children, result)
- }
- }
- }
+ this.value,
+ this.collection,
+ this.field,
+ this.getcount,
+ this.orderby,
+ this.where,
+ this.groupby,
+ this.groupField,
+ this.distinct
+ ],
+ (newValue : Array, oldValue : Array) => {
+ this.pagination.size = this.pageSize
+ if (newValue[0] !== oldValue[0]) {
+ this.pagination.current = this.pageCurrent
+ }
+
+ this.onPropsChange()
+ }
+ )
+ },
+ methods: {
+ onPropsChange() {
+ this.selectedIndex = 0
+ this.selectedNodes.length = 0
+ this.selectedPages.length = 0
+ this.selectedPaths.length = 0
+
+ // 加载数据
+ this.$nextTick(() => {
+ this.loadData()
+ })
+ },
+
+ onTabSelect(index : number) {
+ this.selectedIndex = index
+ },
+
+ onNodeClick(nodeData : UTSJSONObject) {
+ if (nodeData.getBoolean('disable', false)) {
+ return
+ }
+
+ const isLeaf = this._checkIsLeafNode(nodeData)
+
+ this._trimSelectedNodes(nodeData)
+
+ this.$emit('nodeclick', nodeData)
+
+ if (this.isLocalData) {
+ if (isLeaf || !this._checkHasChildren(nodeData)) {
+ this.onFinish()
+ }
+ } else if (this.isCloudDataList) {
+ this.onFinish()
+ } else if (this.isCloudDataTree) {
+ if (isLeaf) {
+ this.onFinish()
+ } else if (!this._checkHasChildren(nodeData)) {
+ // 尝试请求一次,如果没有返回数据标记为叶子节点
+ this.loadCloudDataNode(nodeData)
+ }
+ }
+ },
+
+ getChangeNodes(): Array {
+ const nodes: Array = []
+ this.selectedNodes.forEach((node : UTSJSONObject) => {
+ const newNode: UTSJSONObject = {}
+ newNode[this.mappingTextName] = node.getString(this.mappingTextName)
+ newNode[this.mappingValueName] = node.getString(this.mappingValueName)
+ nodes.push(newNode)
+ })
+ return nodes
+ },
+
+ onFinish() { },
+
+ // 加载数据(自动判定环境)
+ loadData() {
+ if (this.isLocalData) {
+ this.loadLocalData()
+ } else if (this.isCloudDataList) {
+ this.loadCloudDataList()
+ } else if (this.isCloudDataTree) {
+ this.loadCloudDataTree()
+ }
+ },
+
+ // 加载本地数据
+ loadLocalData() {
+ this.treeData = this.localdata
+ if (Array.isArray(this.dataValue)) {
+ const value = this.dataValue as Array
+ this.selectedPaths = value.slice(0)
+ this._pushSelectedTreeNodes(value, this.localdata)
+ } else {
+ this._pushSelectedNodes(this.localdata)
+ }
+ },
+
+ // 加载 Cloud 数据 (单列)
+ loadCloudDataList() {
+ this._loadCloudData(null, (data : Array) => {
+ this.treeData = data
+ this._pushSelectedNodes(data)
+ })
+ },
+
+ // 加载 Cloud 数据 (树形)
+ loadCloudDataTree() {
+ let commandOptions = {
+ field: this._cloudDataPostField(),
+ where: this._cloudDataTreeWhere(),
+ getTree: true
+ } as GetCommandOptions
+ if (this._checkIsNotNull(this.gettree)) {
+ commandOptions.startwith = `${this.selfField}=='${this.dataValue as string}'`
+ }
+ this._loadCloudData(commandOptions, (data : Array) => {
+ this.treeData = data
+ if (this.selectedPaths.length > 0) {
+ this._pushSelectedTreeNodes(this.selectedPaths, data)
+ } else {
+ this._pushSelectedNodes(data)
+ }
+ })
+ },
+
+ // 加载 Cloud 数据 (节点)
+ loadCloudDataNode(nodeData : UTSJSONObject) {
+ const commandOptions = {
+ field: this._cloudDataPostField(),
+ where: this._cloudDataNodeWhere()
+ } as GetCommandOptions
+ this._loadCloudData(commandOptions, (data : Array) => {
+ nodeData['children'] = data
+ if (data.length == 0) {
+ nodeData['isleaf'] = true
+ this.onFinish()
+ } else {
+ this._pushSelectedNodes(data)
+ }
+ })
+ },
+
+ // 回显 Cloud Tree Path
+ loadCloudDataPath() {
+ if (!this.hasCloudDataValue) {
+ return
+ }
+
+ const command : GetCommandOptions = {}
+
+ // 单列
+ if (this.isCloudDataList) {
+ // 根据 field's as value标识匹配 where 条件
+ let where : Array = [];
+ let whereField = this._getForeignKeyByField();
+ if (whereField.length > 0) {
+ where.push(`${whereField} == '${this.dataValue as string}'`)
+ }
+
+ let whereString = where.join(' || ')
+ if (this._checkIsNotNull(this.where)) {
+ whereString = `(${this.where}) && (${whereString})`
+ }
+
+ command.field = this._cloudDataPostField()
+ command.where = whereString
+ }
+
+ // 树形
+ if (this.isCloudDataTree) {
+ command.field = this._cloudDataPostField()
+ command.getTreePath = {
+ startWith: `${this.selfField}=='${this.dataValue as string}'`
+ }
+ }
+
+ this._loadCloudData(command, (data : Array) => {
+ this._extractTreePath(data, this.selectedPaths)
+ })
+ },
+
+ _loadCloudData(options ?: GetCommandOptions, callback ?: ((data : Array) => void)) {
+ if (this.loading) {
+ return
+ }
+ this.loading = true
+
+ this.error = null
+
+ this._getCommand(options).then((response : UniCloudDBGetResult) => {
+ callback?.(response.data)
+ }).catch((err : any | null) => {
+ this.error = err as UniCloudError
+ }).finally(() => {
+ this.loading = false
+ })
+ },
+
+ _cloudDataPostField() : string {
+ let fields = [this.field];
+ if (this.parentField.length > 0) {
+ fields.push(`${this.parentField} as parent_value`)
+ }
+ return fields.join(',')
+ },
+
+ _cloudDataTreeWhere() : string {
+ let result : Array = []
+ let selectedNodes = this.selectedNodes.length > 0 ? this.selectedNodes : this.selectedPaths
+ let parentField = this.parentField
+ if (parentField.length > 0) {
+ result.push(`${parentField} == null || ${parentField} == ""`)
+ }
+ if (selectedNodes.length > 0) {
+ for (var i = 0; i < selectedNodes.length - 1; i++) {
+ const parentFieldValue = selectedNodes[i].getString('value', '')
+ result.push(`${parentField} == '${parentFieldValue}'`)
+ }
+ }
+
+ let where : Array = []
+ if (this._checkIsNotNull(this.where)) {
+ where.push(`(${this.where as string})`)
+ }
+
+ if (result.length > 0) {
+ where.push(`(${result.join(' || ')})`)
+ }
+
+ return where.join(' && ')
+ },
+
+ _cloudDataNodeWhere() : string {
+ const where : Array = []
+ if (this.selectedNodes.length > 0) {
+ const value = this.selectedNodes[this.selectedNodes.length - 1].getString('value', '')
+ where.push(`${this.parentField} == '${value}'`)
+ }
+
+ let whereString = where.join(' || ')
+ if (this._checkIsNotNull(this.where)) {
+ return `(${this.where as string}) && (${whereString})`
+ }
+
+ return whereString
+ },
+
+ _getWhereByForeignKey() : string {
+ let result : Array = []
+ let whereField = this._getForeignKeyByField();
+ if (whereField.length > 0) {
+ result.push(`${whereField} == '${this.dataValue as string}'`)
+ }
+
+ if (this._checkIsNotNull(this.where)) {
+ return `(${this.where}) && (${result.join(' || ')})`
+ }
+
+ return result.join(' || ')
+ },
+
+ _getForeignKeyByField() : string {
+ const fields = this.field.split(',')
+ let whereField = ''
+ for (let i = 0; i < fields.length; i++) {
+ const items = fields[i].split('as')
+ if (items.length < 2) {
+ continue
+ }
+ if (items[1].trim() === 'value') {
+ whereField = items[0].trim()
+ break
+ }
+ }
+ return whereField
+ },
+
+ _getCommand(options ?: GetCommandOptions) : Promise {
+ let db = uniCloud.databaseForJQL()
+
+ let collection = Array.isArray(this.collection) ? db.collection(...(this.collection as Array)) : db.collection(this.collection)
+
+ let filter : UniCloudDBFilter | null = null
+ if (this.foreignKey.length > 0) {
+ filter = collection.foreignKey(this.foreignKey)
+ }
+
+ const where : any = options?.where ?? this.where
+ if (typeof where == 'string') {
+ const whereString = where as string
+ if (whereString.length > 0) {
+ filter = (filter != null) ? filter.where(where) : collection.where(where)
+ }
+ } else {
+ filter = (filter != null) ? filter.where(where) : collection.where(where)
+ }
+
+ let query : UniCloudDBQuery | null = null
+ if (this.field.length > 0) {
+ query = (filter != null) ? filter.field(this.field) : collection.field(this.field)
+ }
+ if (this.groupby.length > 0) {
+ if (query != null) {
+ query = query.groupBy(this.groupby)
+ } else if (filter != null) {
+ query = filter.groupBy(this.groupby)
+ }
+ }
+ if (this.groupField.length > 0) {
+ if (query != null) {
+ query = query.groupField(this.groupField)
+ } else if (filter != null) {
+ query = filter.groupField(this.groupField)
+ }
+ }
+ if (this.distinct == true) {
+ if (query != null) {
+ query = query.distinct(this.field)
+ } else if (filter != null) {
+ query = filter.distinct(this.field)
+ }
+ }
+ if (this.orderby.length > 0) {
+ if (query != null) {
+ query = query.orderBy(this.orderby)
+ } else if (filter != null) {
+ query = filter.orderBy(this.orderby)
+ }
+ }
+
+ const size = this.pagination.size
+ const current = this.pagination.current
+ if (query != null) {
+ query = query.skip(size * (current - 1)).limit(size)
+ } else if (filter != null) {
+ query = filter.skip(size * (current - 1)).limit(size)
+ } else {
+ query = collection.skip(size * (current - 1)).limit(size)
+ }
+
+ const getOptions = {}
+ const treeOptions = {
+ limitLevel: this.limitlevel,
+ startWith: this.startwith
+ }
+ if (this.getcount == true) {
+ getOptions['getCount'] = this.getcount
+ }
+
+ const getTree : any = options?.getTree ?? this.gettree
+ if (typeof getTree == 'string') {
+ const getTreeString = getTree as string
+ if (getTreeString.length > 0) {
+ getOptions['getTree'] = treeOptions
+ }
+ } else if (typeof getTree == 'object') {
+ getOptions['getTree'] = treeOptions
+ } else {
+ getOptions['getTree'] = getTree
+ }
+
+ const getTreePath = options?.getTreePath ?? this.gettreepath
+ if (typeof getTreePath == 'string') {
+ const getTreePathString = getTreePath as string
+ if (getTreePathString.length > 0) {
+ getOptions['getTreePath'] = getTreePath
+ }
+ } else {
+ getOptions['getTreePath'] = getTreePath
+ }
+
+ return query.get(getOptions)
+ },
+
+ _checkIsNotNull(value : any) : boolean {
+ if (typeof value == 'string') {
+ const valueString = value as string
+ return (valueString.length > 0)
+ } else if (value instanceof UTSJSONObject) {
+ return true
+ }
+ return false
+ },
+
+ _checkIsLeafNode(nodeData : UTSJSONObject) : boolean {
+ if (this.selectedIndex >= this.limitlevel) {
+ return true
+ }
+
+ if (nodeData.getBoolean('isleaf', false)) {
+ return true
+ }
+
+ return false
+ },
+
+ _checkHasChildren(nodeData : UTSJSONObject) : boolean {
+ const children = nodeData.getArray('children') ?? ([] as Array)
+ return children.length > 0
+ },
+
+ _pushSelectedNodes(nodes : Array) {
+ this.selectedNodes.push(DefaultSelectedNode)
+ this.selectedPages.push(nodes)
+ this.selectedIndex = this.selectedPages.length - 1
+ },
+
+ _trimSelectedNodes(nodeData : UTSJSONObject) {
+ this.selectedNodes.splice(this.selectedIndex)
+ this.selectedNodes.push(nodeData)
+
+ if (this.selectedPages.length > 0) {
+ this.selectedPages.splice(this.selectedIndex + 1)
+ }
+
+ const children = nodeData.getArray('children') ?? ([] as Array)
+ if (children.length > 0) {
+ this.selectedNodes.push(DefaultSelectedNode)
+ this.selectedPages.push(children)
+ }
+
+ this.selectedIndex = this.selectedPages.length - 1
+ },
+
+ _pushSelectedTreeNodes(paths : Array, nodes : Array) {
+ let children : Array = nodes
+ paths.forEach((node : UTSJSONObject) => {
+ const findNode = children.find((item : UTSJSONObject) : boolean => {
+ return (item.getString(this.mappingValueName) == node.getString(this.mappingValueName))
+ })
+ if (findNode != null) {
+ this.selectedPages.push(children)
+ this.selectedNodes.push(node)
+ children = findNode.getArray('children') ?? ([] as Array)
+ }
+ })
+ this.selectedIndex = this.selectedPages.length - 1
+ },
+
+ _extractTreePath(nodes : Array, result : Array) {
+ if (nodes.length == 0) {
+ return
+ }
+
+ const node = nodes[0]
+ result.push(node)
+
+ const children = node.getArray('children')
+ if (Array.isArray(children) && children!.length > 0) {
+ this._extractTreePath(children, result)
+ }
+ }
+ }
})
diff --git a/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-pickerview.css b/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-pickerview.css
index 1a9c12e1..39fe1c3a 100644
--- a/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-pickerview.css
+++ b/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-pickerview.css
@@ -1,76 +1,76 @@
-.uni-data-pickerview {
- position: relative;
- flex-direction: column;
- overflow: hidden;
-}
-
-.loading-cover {
- position: absolute;
- left: 0;
- top: 0;
- right: 0;
- bottom: 0;
- align-items: center;
- justify-content: center;
- background-color: rgba(150, 150, 150, .1);
-}
-
-.error {
- background-color: #fff;
- padding: 15px;
-}
-
-.error-text {
- color: #DD524D;
-}
-
-.selected-node-list {
- flex-direction: row;
- flex-wrap: nowrap;
-}
-
-.selected-node-item {
- margin-left: 10px;
- margin-right: 10px;
- padding: 8px 10px 8px 10px;
- border-bottom: 2px solid transparent;
-}
-
-.selected-node-item-active {
- color: #007aff;
- border-bottom-color: #007aff;
-}
-
-.list-view {
- flex: 1;
-}
-
-.list-item {
- flex-direction: row;
- justify-content: space-between;
- padding: 12px 15px;
- border-bottom: 1px solid #f0f0f0;
-}
-
-.item-text {
- color: #333333;
-}
-
-.item-text-disabled {
- opacity: .5;
-}
-
-.item-text-overflow {
- overflow: hidden;
-}
-
-.check {
- margin-right: 5px;
- border: 2px solid #007aff;
- border-left: 0;
- border-top: 0;
- height: 12px;
- width: 6px;
- transform-origin: center;
- transform: rotate(45deg);
-}
+.uni-data-pickerview {
+ position: relative;
+ flex-direction: column;
+ overflow: hidden;
+}
+
+.loading-cover {
+ position: absolute;
+ left: 0;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ align-items: center;
+ justify-content: center;
+ background-color: rgba(150, 150, 150, .1);
+}
+
+.error {
+ background-color: #fff;
+ padding: 15px;
+}
+
+.error-text {
+ color: #DD524D;
+}
+
+.selected-node-list {
+ flex-direction: row;
+ flex-wrap: nowrap;
+}
+
+.selected-node-item {
+ margin-left: 10px;
+ margin-right: 10px;
+ padding: 8px 10px 8px 10px;
+ border-bottom: 2px solid transparent;
+}
+
+.selected-node-item-active {
+ color: #007aff;
+ border-bottom-color: #007aff;
+}
+
+.list-view {
+ flex: 1;
+}
+
+.list-item {
+ flex-direction: row;
+ justify-content: space-between;
+ padding: 12px 15px;
+ border-bottom: 1px solid #f0f0f0;
+}
+
+.item-text {
+ color: #333333;
+}
+
+.item-text-disabled {
+ opacity: .5;
+}
+
+.item-text-overflow {
+ overflow: hidden;
+}
+
+.check {
+ margin-right: 5px;
+ border: 2px solid #007aff;
+ border-left: 0;
+ border-top: 0;
+ height: 12px;
+ width: 6px;
+ transform-origin: center;
+ transform: rotate(45deg);
+}
diff --git a/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-pickerview.uvue b/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-pickerview.uvue
index 653f8ddc..f4780f36 100644
--- a/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-pickerview.uvue
+++ b/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-pickerview.uvue
@@ -1,69 +1,69 @@
-
-
-
- {{error!.errMsg}}
-
-
-
-
-
- {{item[mappingTextName]}}
-
-
-
-
-
-
- {{item[mappingTextName]}}
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ {{error!.errMsg}}
+
+
+
+
+
+ {{item[mappingTextName]}}
+
+
+
+
+
+
+ {{item[mappingTextName]}}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-pickerview.vue b/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-pickerview.vue
index d3acf921..6ebced92 100644
--- a/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-pickerview.vue
+++ b/uni_modules/uni-data-picker/components/uni-data-pickerview/uni-data-pickerview.vue
@@ -1,323 +1,323 @@
-
-
-
-
-
- {{item.text || ''}}
-
-
-
-
-
-
- {{item[map.text]}}
-
-
-
-
-
-
-
-
- {{errorMessage}}
-
-
-
-
-
-
-
-
+
+
+
+
+
+ {{item.text || ''}}
+
+
+
+
+
+
+ {{item[map.text]}}
+
+
+
+
+
+
+
+
+ {{errorMessage}}
+
+
+
+
+
+
+
+
diff --git a/uni_modules/uni-data-picker/package.json b/uni_modules/uni-data-picker/package.json
index cb895b10..efc60c23 100644
--- a/uni_modules/uni-data-picker/package.json
+++ b/uni_modules/uni-data-picker/package.json
@@ -1,91 +1,91 @@
-{
- "id": "uni-data-picker",
- "displayName": "uni-data-picker 数据驱动的picker选择器",
- "version": "2.0.0",
- "description": "单列、多列级联选择器,常用于省市区城市选择、公司部门选择、多级分类等场景",
- "keywords": [
- "uni-ui",
- "uniui",
- "picker",
- "级联",
- "省市区",
- ""
-],
- "repository": "https://github.com/dcloudio/uni-ui",
- "engines": {
- "HBuilderX": ""
- },
- "directories": {
- "example": "../../temps/example_temps"
- },
-"dcloudext": {
- "sale": {
- "regular": {
- "price": "0.00"
- },
- "sourcecode": {
- "price": "0.00"
- }
- },
- "contact": {
- "qq": ""
- },
- "declaration": {
- "ads": "无",
- "data": "无",
- "permissions": "无"
- },
- "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
- "type": "component-vue"
- },
- "uni_modules": {
- "dependencies": [
- "uni-load-more",
- "uni-icons",
- "uni-scss"
- ],
- "encrypt": [],
- "platforms": {
- "cloud": {
- "tcb": "y",
- "aliyun": "y"
- },
- "client": {
- "App": {
- "app-vue": "y",
- "app-nvue": "y",
- "app-uvue": "y"
- },
- "H5-mobile": {
- "Safari": "y",
- "Android Browser": "y",
- "微信浏览器(Android)": "y",
- "QQ浏览器(Android)": "y"
- },
- "H5-pc": {
- "Chrome": "y",
- "IE": "y",
- "Edge": "y",
- "Firefox": "y",
- "Safari": "y"
- },
- "小程序": {
- "微信": "y",
- "阿里": "y",
- "百度": "y",
- "字节跳动": "y",
- "QQ": "y",
- "京东": "u"
- },
- "快应用": {
- "华为": "u",
- "联盟": "u"
- },
- "Vue": {
- "vue2": "y",
- "vue3": "y"
- }
- }
- }
- }
-}
+{
+ "id": "uni-data-picker",
+ "displayName": "uni-data-picker 数据驱动的picker选择器",
+ "version": "2.0.1",
+ "description": "单列、多列级联选择器,常用于省市区城市选择、公司部门选择、多级分类等场景",
+ "keywords": [
+ "uni-ui",
+ "uniui",
+ "picker",
+ "级联",
+ "省市区",
+ ""
+],
+ "repository": "https://github.com/dcloudio/uni-ui",
+ "engines": {
+ "HBuilderX": ""
+ },
+ "directories": {
+ "example": "../../temps/example_temps"
+ },
+"dcloudext": {
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "无",
+ "data": "无",
+ "permissions": "无"
+ },
+ "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
+ "type": "component-vue"
+ },
+ "uni_modules": {
+ "dependencies": [
+ "uni-load-more",
+ "uni-icons",
+ "uni-scss"
+ ],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "y",
+ "aliyun": "y",
+ "alipay": "n"
+ },
+ "client": {
+ "App": {
+ "app-vue": "y",
+ "app-nvue": "y"
+ },
+ "H5-mobile": {
+ "Safari": "y",
+ "Android Browser": "y",
+ "微信浏览器(Android)": "y",
+ "QQ浏览器(Android)": "y"
+ },
+ "H5-pc": {
+ "Chrome": "y",
+ "IE": "y",
+ "Edge": "y",
+ "Firefox": "y",
+ "Safari": "y"
+ },
+ "小程序": {
+ "微信": "y",
+ "阿里": "y",
+ "百度": "y",
+ "字节跳动": "y",
+ "QQ": "y",
+ "京东": "u"
+ },
+ "快应用": {
+ "华为": "u",
+ "联盟": "u"
+ },
+ "Vue": {
+ "vue2": "y",
+ "vue3": "y"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/uni_modules/uni-data-picker/readme.md b/uni_modules/uni-data-picker/readme.md
index 002227c0..19dd0e83 100644
--- a/uni_modules/uni-data-picker/readme.md
+++ b/uni_modules/uni-data-picker/readme.md
@@ -1,22 +1,22 @@
-## DataPicker 级联选择
-> **组件名:uni-data-picker**
-> 代码块: `uDataPicker`
-> 关联组件:`uni-data-pickerview`、`uni-load-more`。
-
-
-`` 是一个选择类[datacom组件](https://uniapp.dcloud.net.cn/component/datacom)。
-
-支持单列、和多列级联选择。列数没有限制,如果屏幕显示不全,顶部tab区域会左右滚动。
-
-候选数据支持一次性加载完毕,也支持懒加载,比如示例图中,选择了“北京”后,动态加载北京的区县数据。
-
-`` 组件尤其适用于地址选择、分类选择等选择类。
-
-`` 支持本地数据、云端静态数据(json),uniCloud云数据库数据。
-
-`` 可以通过JQL直连uniCloud云数据库,配套[DB Schema](https://uniapp.dcloud.net.cn/uniCloud/schema),可在schema2code中自动生成前端页面,还支持服务器端校验。
-
-在uniCloud数据表中新建表“uni-id-address”和“opendb-city-china”,这2个表的schema自带foreignKey关联。在“uni-id-address”表的表结构页面使用schema2code生成前端页面,会自动生成地址管理的维护页面,自动从“opendb-city-china”表包含的中国所有省市区信息里选择地址。
-
-### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-data-picker)
+## DataPicker 级联选择
+> **组件名:uni-data-picker**
+> 代码块: `uDataPicker`
+> 关联组件:`uni-data-pickerview`、`uni-load-more`。
+
+
+`` 是一个选择类[datacom组件](https://uniapp.dcloud.net.cn/component/datacom)。
+
+支持单列、和多列级联选择。列数没有限制,如果屏幕显示不全,顶部tab区域会左右滚动。
+
+候选数据支持一次性加载完毕,也支持懒加载,比如示例图中,选择了“北京”后,动态加载北京的区县数据。
+
+`` 组件尤其适用于地址选择、分类选择等选择类。
+
+`` 支持本地数据、云端静态数据(json),uniCloud云数据库数据。
+
+`` 可以通过JQL直连uniCloud云数据库,配套[DB Schema](https://uniapp.dcloud.net.cn/uniCloud/schema),可在schema2code中自动生成前端页面,还支持服务器端校验。
+
+在uniCloud数据表中新建表“uni-id-address”和“opendb-city-china”,这2个表的schema自带foreignKey关联。在“uni-id-address”表的表结构页面使用schema2code生成前端页面,会自动生成地址管理的维护页面,自动从“opendb-city-china”表包含的中国所有省市区信息里选择地址。
+
+### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-data-picker)
#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
\ No newline at end of file
diff --git a/uni_modules/uni-datetime-picker/changelog.md b/uni_modules/uni-datetime-picker/changelog.md
index 8798e937..102ddb1f 100644
--- a/uni_modules/uni-datetime-picker/changelog.md
+++ b/uni_modules/uni-datetime-picker/changelog.md
@@ -1,3 +1,11 @@
+## 2.2.38(2024-10-15)
+- 修复 微信小程序中的getSystemInfo警告
+## 2.2.37(2024-10-12)
+- 修复 微信小程序中的getSystemInfo警告
+## 2.2.36(2024-10-12)
+- 修复 微信小程序中的getSystemInfo警告
+## 2.2.35(2024-09-21)
+- 修复 没有选中日期时点击确定直接报错的Bug [详情](https://ask.dcloud.net.cn/question/198168)
## 2.2.34(2024-04-24)
- 新增 日期点击事件,在点击日期时会触发该事件。
## 2.2.33(2024-04-15)
diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue
index 11fc45a9..6843e807 100644
--- a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue
+++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue
@@ -464,9 +464,16 @@
this.isPhone = navigator.userAgent.toLowerCase().indexOf('mobile') !== -1
return
}
+ // #ifdef MP-WEIXIN
+ const {
+ windowWidth
+ } = uni.getWindowInfo()
+ // #endif
+ // #ifndef MP-WEIXIN
const {
windowWidth
} = uni.getSystemInfoSync()
+ // #endif
this.isPhone = windowWidth <= 500
this.windowWidth = windowWidth
},
@@ -698,11 +705,11 @@
startString = getDateTime(this.start, this.hideSecond)
}
[startDate, startTime] = startString.split(' ')
- if (this.start && !dateCompare(this.start, this.tempRange.startDate)) {
+ if (this.start && !dateCompare(this.start, `${this.tempRange.startDate} ${this.tempRange.startTime}`)) {
startDateLaterRangeStartDate = true
this.tempRange.startDate = startDate
}
- if (this.start && !dateCompare(this.start, this.tempRange.endDate)) {
+ if (this.start && !dateCompare(this.start, `${this.tempRange.endDate} ${this.tempRange.endTime}`)) {
startDateLaterRangeEndDate = true
this.tempRange.endDate = startDate
}
@@ -717,11 +724,11 @@
}
[endDate, endTime] = endString.split(' ')
- if (this.end && !dateCompare(this.tempRange.startDate, this.end)) {
+ if (this.end && !dateCompare(`${this.tempRange.startDate} ${this.tempRange.startTime}`, this.end)) {
endDateEarlierRangeStartDate = true
this.tempRange.startDate = endDate
}
- if (this.end && !dateCompare(this.tempRange.endDate, this.end)) {
+ if (this.end && !dateCompare(`${this.tempRange.endDate} ${this.tempRange.endTime}`, this.end)) {
endDateEarlierRangeEndDate = true
this.tempRange.endDate = endDate
}
diff --git a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js
index acf7e4ba..bc9d481e 100644
--- a/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js
+++ b/uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js
@@ -182,8 +182,8 @@ class Calendar {
if (!date) {
date = new Date()
}
-
- return this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate)
+ const res = this.calendar.find(item => item.fullDate === this.getDateObj(date).fullDate)
+ return res ? res : this.getDateObj(date)
}
/**
diff --git a/uni_modules/uni-datetime-picker/package.json b/uni_modules/uni-datetime-picker/package.json
index 4d1b05c5..a886f1b5 100644
--- a/uni_modules/uni-datetime-picker/package.json
+++ b/uni_modules/uni-datetime-picker/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-datetime-picker",
"displayName": "uni-datetime-picker 日期选择器",
- "version": "2.2.34",
+ "version": "2.2.38",
"description": "uni-datetime-picker 日期时间选择器,支持日历,支持范围选择",
"keywords": [
"uni-datetime-picker",
diff --git a/uni_modules/uni-easyinput/changelog.md b/uni_modules/uni-easyinput/changelog.md
index 6677b079..84c72eb7 100644
--- a/uni_modules/uni-easyinput/changelog.md
+++ b/uni_modules/uni-easyinput/changelog.md
@@ -1,3 +1,5 @@
+## 1.1.19(2024-07-18)
+- 修复 初始值传入 null 导致input报错的bug
## 1.1.18(2024-04-11)
- 修复 easyinput组件双向绑定问题
## 1.1.17(2024-03-28)
diff --git a/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue b/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue
index d41411b0..05ae27d9 100644
--- a/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue
+++ b/uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue
@@ -1,693 +1,676 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/uni_modules/uni-easyinput/package.json b/uni_modules/uni-easyinput/package.json
index 62bbff56..2939256a 100644
--- a/uni_modules/uni-easyinput/package.json
+++ b/uni_modules/uni-easyinput/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-easyinput",
"displayName": "uni-easyinput 增强输入框",
- "version": "1.1.18",
+ "version": "1.1.19",
"description": "Easyinput 组件是对原生input组件的增强",
"keywords": [
"uni-ui",
diff --git a/uni_modules/uni-fab/changelog.md b/uni_modules/uni-fab/changelog.md
index 9bd47292..8a228070 100644
--- a/uni_modules/uni-fab/changelog.md
+++ b/uni_modules/uni-fab/changelog.md
@@ -1,3 +1,5 @@
+## 1.2.6(2024-10-12)
+- 修复 微信小程序中的getSystemInfo警告
## 1.2.5(2023-03-29)
- 新增 pattern.icon 属性,可自定义图标
## 1.2.4(2022-09-07)
diff --git a/uni_modules/uni-fab/components/uni-fab/uni-fab.vue b/uni_modules/uni-fab/components/uni-fab/uni-fab.vue
index 43b45314..0cc2ef3d 100644
--- a/uni_modules/uni-fab/components/uni-fab/uni-fab.vue
+++ b/uni_modules/uni-fab/components/uni-fab/uni-fab.vue
@@ -163,9 +163,9 @@
return this.getPosition(2, 'horizontal', 'right')
},
// 计算 nvue bottom
- nvueBottom() {
- const safeBottom = uni.getSystemInfoSync().windowBottom;
- // #ifdef APP-NVUE
+ nvueBottom() {
+ // #ifdef APP-NVUE
+ const safeBottom = uni.getSystemInfoSync().windowBottom;
return 30 + safeBottom
// #endif
// #ifndef APP-NVUE
diff --git a/uni_modules/uni-fab/package.json b/uni_modules/uni-fab/package.json
index 18c08102..1b8543c4 100644
--- a/uni_modules/uni-fab/package.json
+++ b/uni_modules/uni-fab/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-fab",
"displayName": "uni-fab 悬浮按钮",
- "version": "1.2.5",
+ "version": "1.2.6",
"description": "悬浮按钮 fab button ,点击可展开一个图标按钮菜单。",
"keywords": [
"uni-ui",
@@ -43,7 +43,8 @@
"platforms": {
"cloud": {
"tcb": "y",
- "aliyun": "y"
+ "aliyun": "y",
+ "alipay": "n"
},
"client": {
"App": {
diff --git a/uni_modules/uni-file-picker/changelog.md b/uni_modules/uni-file-picker/changelog.md
index 24fd817a..00a76cce 100644
--- a/uni_modules/uni-file-picker/changelog.md
+++ b/uni_modules/uni-file-picker/changelog.md
@@ -1,3 +1,9 @@
+## 1.0.11(2024-07-19)
+- 修复 vue3 使用value报错的bug
+## 1.0.10(2024-07-09)
+- 优化 vue3兼容性
+## 1.0.9(2024-07-09)
+- 修复 value 属性不兼容vue3的bug
## 1.0.8(2024-03-20)
- 补充 删除文件时返回文件下标
## 1.0.7(2024-02-21)
diff --git a/uni_modules/uni-file-picker/components/uni-file-picker/choose-and-upload-file.js b/uni_modules/uni-file-picker/components/uni-file-picker/choose-and-upload-file.js
index dd60f18a..c4ff85dd 100644
--- a/uni_modules/uni-file-picker/components/uni-file-picker/choose-and-upload-file.js
+++ b/uni_modules/uni-file-picker/components/uni-file-picker/choose-and-upload-file.js
@@ -82,11 +82,11 @@ function chooseVideo(opts) {
name: item.name || '',
path: item.tempFilePath,
thumbTempFilePath: item.thumbTempFilePath,
- size: item.size,
+ size:item.size,
type: (res.tempFile && res.tempFile.type) || '',
- width: item.width,
- height: item.height,
- duration: item.duration,
+ width:item.width,
+ height:item.height,
+ duration:item.duration,
fileType: 'video',
cloudPath: '',
}
@@ -224,32 +224,6 @@ function uploadCloudFiles(files, max = 5, onUploadProgress) {
.then(res => {
fileItem.url = res.fileID
fileItem.index = index
-
- // if (isPrivate) {
- // if (!domain) {
- // uni.showToast({
- // title: "私有化上传开启时域名不能为空",
- // icon: "error"
- // })
- // return;
- // }
- // const extStorageManager = uniCloud.getExtStorageManager({
- // provider: "qiniu",
- // domain, // 域名地址
- // });
- // extStorageManager.updateFileStatus({
- // fileID: fileItem.cloudPath, // 待修改的文件
- // isPrivate: true, // true 私有 false 公共
- // }).then(res => {
- // console.log(res);
- // if (res.errCode !== 0) {
- // uni.showToast({
- // title: res.errMsg,
- // icon: "error"
- // })
- // }
- // })
- // }
if (cur < len) {
next()
}
diff --git a/uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.vue b/uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.vue
index bd099c7e..95eaf304 100644
--- a/uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.vue
+++ b/uni_modules/uni-file-picker/components/uni-file-picker/uni-file-picker.vue
@@ -89,24 +89,18 @@
},
emits: ['select', 'success', 'fail', 'progress', 'delete', 'update:modelValue', 'input'],
props: {
- // #ifdef VUE3
modelValue: {
type: [Array, Object],
default () {
return []
}
},
- // #endif
-
- // #ifndef VUE3
value: {
type: [Array, Object],
default () {
return []
}
},
- // #endif
-
disabled: {
type: Boolean,
default: false
@@ -204,22 +198,18 @@
}
},
watch: {
- // #ifndef VUE3
value: {
handler(newVal, oldVal) {
this.setValue(newVal, oldVal)
},
immediate: true
},
- // #endif
- // #ifdef VUE3
modelValue: {
handler(newVal, oldVal) {
this.setValue(newVal, oldVal)
},
immediate: true
},
- // #endif
},
computed: {
filesList() {
diff --git a/uni_modules/uni-file-picker/package.json b/uni_modules/uni-file-picker/package.json
index 9bcf4309..b3650748 100644
--- a/uni_modules/uni-file-picker/package.json
+++ b/uni_modules/uni-file-picker/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-file-picker",
"displayName": "uni-file-picker 文件选择上传",
- "version": "1.0.8",
+ "version": "1.0.11",
"description": "文件选择上传组件,可以选择图片、视频等任意文件并上传到当前绑定的服务空间",
"keywords": [
"uni-ui",
@@ -42,7 +42,8 @@
"platforms": {
"cloud": {
"tcb": "y",
- "aliyun": "y"
+ "aliyun": "y",
+ "alipay": "n"
},
"client": {
"App": {
diff --git a/uni_modules/uni-forms/changelog.md b/uni_modules/uni-forms/changelog.md
index 3d998bcf..0b58ab86 100644
--- a/uni_modules/uni-forms/changelog.md
+++ b/uni_modules/uni-forms/changelog.md
@@ -1,3 +1,9 @@
+## 1.4.13(2024-10-08)
+- 修复 校验规则在抖音开发者工具上不生效的bug,详见:[https://ask.dcloud.net.cn/question/191933](https://ask.dcloud.net.cn/question/191933)
+## 1.4.12 (2024-9-21)
+- 修复 form上次修改的问题
+## 1.4.11 (2024-9-14)
+- 修复 binddata的兼容性问题
## 1.4.10(2023-11-03)
- 优化 labelWidth 描述错误
## 1.4.9(2023-02-10)
diff --git a/uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue b/uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue
index 59b0528d..6af50aaa 100644
--- a/uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue
+++ b/uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue
@@ -56,8 +56,13 @@
export default {
name: 'uniFormsItem',
- options: {
- virtualHost: true
+ options: {
+ // #ifdef MP-TOUTIAO
+ virtualHost: false,
+ // #endif
+ // #ifndef MP-TOUTIAO
+ virtualHost: true
+ // #endif
},
provide() {
return {
diff --git a/uni_modules/uni-forms/components/uni-forms/uni-forms.vue b/uni_modules/uni-forms/components/uni-forms/uni-forms.vue
index b484cc9d..64dde2a7 100644
--- a/uni_modules/uni-forms/components/uni-forms/uni-forms.vue
+++ b/uni_modules/uni-forms/components/uni-forms/uni-forms.vue
@@ -67,8 +67,13 @@
export default {
name: 'uniForms',
emits: ['validate', 'submit'],
- options: {
- virtualHost: true
+ options: {
+ // #ifdef MP-TOUTIAO
+ virtualHost: false,
+ // #endif
+ // #ifndef MP-TOUTIAO
+ virtualHost: true
+ // #endif
},
props: {
// 即将弃用
@@ -180,15 +185,17 @@
}
}
if (!formVm) return console.error('当前 uni-froms 组件缺少 ref 属性');
- formVm.setValue(name, value);
+ if(formVm.model)formVm.model[name] = value
+ if(formVm.modelValue)formVm.modelValue[name] = value
+ if(formVm.value)formVm.value[name] = value
}
}
}
// #endif
// 子组件实例数组
- this.childrens = []
- // TODO 兼容旧版 uni-data-picker ,新版本中无效,只是避免报错
+ this.childrens = []
+ // TODO 兼容旧版 uni-data-picker ,新版本中无效,只是避免报错
this.inputChildrens = []
this.setRules(this.rules)
},
@@ -394,4 +401,4 @@
+
diff --git a/uni_modules/uni-forms/package.json b/uni_modules/uni-forms/package.json
index 464b4e6c..0d72c632 100644
--- a/uni_modules/uni-forms/package.json
+++ b/uni_modules/uni-forms/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-forms",
"displayName": "uni-forms 表单",
- "version": "1.4.10",
+ "version": "1.4.13",
"description": "由输入框、选择器、单选框、多选框等控件组成,用以收集、校验、提交数据",
"keywords": [
"uni-ui",
@@ -46,7 +46,8 @@
"platforms": {
"cloud": {
"tcb": "y",
- "aliyun": "y"
+ "aliyun": "y",
+ "alipay": "n"
},
"client": {
"App": {
diff --git a/uni_modules/uni-icons/changelog.md b/uni_modules/uni-icons/changelog.md
index 620ab027..02611315 100644
--- a/uni_modules/uni-icons/changelog.md
+++ b/uni_modules/uni-icons/changelog.md
@@ -1,3 +1,5 @@
+## 2.0.10(2024-06-07)
+- 优化 uni-app x 中,size 属性的类型
## 2.0.9(2024-01-12)
fix: 修复图标大小默认值错误的问题
## 2.0.8(2023-12-14)
diff --git a/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue b/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue
index a975b4a9..ce307c17 100644
--- a/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue
+++ b/uni_modules/uni-icons/components/uni-icons/uni-icons.uvue
@@ -1,91 +1,91 @@
-
- {{unicode}}
-
+
+ {{unicode}}
+
diff --git a/uni_modules/uni-icons/package.json b/uni_modules/uni-icons/package.json
index 397be839..6b681b42 100644
--- a/uni_modules/uni-icons/package.json
+++ b/uni_modules/uni-icons/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-icons",
"displayName": "uni-icons 图标",
- "version": "2.0.9",
+ "version": "2.0.10",
"description": "图标组件,用于展示移动端常见的图标,可自定义颜色、大小。",
"keywords": [
"uni-ui",
@@ -42,7 +42,8 @@
"platforms": {
"cloud": {
"tcb": "y",
- "aliyun": "y"
+ "aliyun": "y",
+ "alipay": "n"
},
"client": {
"App": {
diff --git a/uni_modules/uni-id/changelog.md b/uni_modules/uni-id/changelog.md
index 8761e543..5c0274de 100644
--- a/uni_modules/uni-id/changelog.md
+++ b/uni_modules/uni-id/changelog.md
@@ -1,3 +1,7 @@
+## 3.3.33(2025-01-08)
+- 修改文档图片链接
+## 3.3.32(2024-04-26)
+- 兼容uni-app-x对客户端uniPlatform的调整(uni-app-x内uniPlatform区分app-android、app-ios)
## 3.3.31(2023-12-13)
- 移除无用文件
## 3.3.30(2023-12-13)
@@ -63,55 +67,55 @@
- 移除部分接口的废弃提示
## 3.3.6(2021-09-08)
- 修复 邀请码可能重复的Bug
-## 3.3.5(2021-08-10)
-- 修复版本号错误
-## 3.3.4(2021-08-10)
-- 微信、QQ、支付宝登录新增type参数用于指定当前是登录还是注册
-## 3.3.3(2021-08-04)
-- 修复使用数组形式的配置文件报错的Bug
-## 3.3.2(2021-08-03)
-- 修复上3.3.0版本引出的createInstance接口传入配置不生效的Bug 感谢[hmh](https://gitee.com/hmh)
-## 3.3.1(2021-07-30)
-- 修复 将设置用户允许登录的应用列表时传入空数组报错的Bug
-## 3.3.0(2021-07-30)
-- 新增 不同端应用配置隔离 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=isolate-config)
-- 新增 不同端用户隔离 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=isolate-user)
- + 此版本升级需要开发者处理一下用户数据,请参考 [补齐用户dcloud_appid字段](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=makeup-dcloud-appid)
-- 新增 QQ登录、注册相关功能 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=qq)
-- 调整 不再支持绑定手机、邮箱时不填验证码直接绑定
-## 3.2.1(2021-07-09)
-- 撤销3.2.0版本所做的调整
-## 3.2.0(2021-07-09)
-- 【重要】支持不同端(管理端、用户端等)用户隔离 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=isolate-user)
-- 支持不同端(管理端、用户端等)配置文件隔离 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=isolate-config)
-## 3.1.3(2021-07-08)
-- 移除插件内误传的node_modules
-## 3.1.2(2021-07-08)
-- 修复 微信小程序绑定微信账号时报错的Bug
-## 3.1.1(2021-07-01)
-- 使用新的错误码规范,兼容旧版 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=errcode)
-- 修复微信登录、绑定时未返回用户accessToken的Bug
-## 3.1.0(2021-04-19)
-- 增加对用户名、邮箱、密码字段的两端去空格
-- 默认忽略用户名、邮箱的大小写 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=case-sensitive)
-- 修复 customToken导出async方法报错的Bug
-## 3.0.12(2021-04-13)
-- 调整bindTokenToDevice默认值为false
-## 3.0.11(2021-04-12)
-- 修复3.0.7版本引出的多个用户访问时可能出现30201报错的Bug
-## 3.0.10(2021-04-08)
-- 优化错误提示
-## 3.0.9(2021-04-08)
-- bindMobile接口支持通过一键登录的方式绑定
-- 优化错误提示
-## 3.0.8(2021-03-19)
-- 修复 3.0.7版本某些情况下生成token报错的Bug
-## 3.0.7(2021-03-19)
-- 新增 支持uni-config-center,更新uni-id无须再担心配置被覆盖 [详情](https://uniapp.dcloud.io/uniCloud/uni-id?id=uni-config-center)
-- 新增 自定义token内容,可以缓存角色权限之外的更多信息到客户端 [详情](https://uniapp.dcloud.io/uniCloud/uni-id?id=custom-token)
-- 新增 支持传入context获取uni-id实例,防止单实例多并发时全局context混乱 [详情](https://uniapp.dcloud.io/uniCloud/uni-id?id=create-instance)
-## 3.0.6(2021-03-05)
-- 新增[uniID.wxBizDataCrypt](https://uniapp.dcloud.io/uniCloud/uni-id?id=%e5%be%ae%e4%bf%a1%e6%95%b0%e6%8d%ae%e8%a7%a3%e5%af%86)方法
-- 优化loginByApple方法,提高接口响应速度
-## 3.0.5(2021-02-03)
-- 调整为uni_modules目录规范
+## 3.3.5(2021-08-10)
+- 修复版本号错误
+## 3.3.4(2021-08-10)
+- 微信、QQ、支付宝登录新增type参数用于指定当前是登录还是注册
+## 3.3.3(2021-08-04)
+- 修复使用数组形式的配置文件报错的Bug
+## 3.3.2(2021-08-03)
+- 修复上3.3.0版本引出的createInstance接口传入配置不生效的Bug 感谢[hmh](https://gitee.com/hmh)
+## 3.3.1(2021-07-30)
+- 修复 将设置用户允许登录的应用列表时传入空数组报错的Bug
+## 3.3.0(2021-07-30)
+- 新增 不同端应用配置隔离 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=isolate-config)
+- 新增 不同端用户隔离 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=isolate-user)
+ + 此版本升级需要开发者处理一下用户数据,请参考 [补齐用户dcloud_appid字段](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=makeup-dcloud-appid)
+- 新增 QQ登录、注册相关功能 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=qq)
+- 调整 不再支持绑定手机、邮箱时不填验证码直接绑定
+## 3.2.1(2021-07-09)
+- 撤销3.2.0版本所做的调整
+## 3.2.0(2021-07-09)
+- 【重要】支持不同端(管理端、用户端等)用户隔离 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=isolate-user)
+- 支持不同端(管理端、用户端等)配置文件隔离 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=isolate-config)
+## 3.1.3(2021-07-08)
+- 移除插件内误传的node_modules
+## 3.1.2(2021-07-08)
+- 修复 微信小程序绑定微信账号时报错的Bug
+## 3.1.1(2021-07-01)
+- 使用新的错误码规范,兼容旧版 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=errcode)
+- 修复微信登录、绑定时未返回用户accessToken的Bug
+## 3.1.0(2021-04-19)
+- 增加对用户名、邮箱、密码字段的两端去空格
+- 默认忽略用户名、邮箱的大小写 [详情](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=case-sensitive)
+- 修复 customToken导出async方法报错的Bug
+## 3.0.12(2021-04-13)
+- 调整bindTokenToDevice默认值为false
+## 3.0.11(2021-04-12)
+- 修复3.0.7版本引出的多个用户访问时可能出现30201报错的Bug
+## 3.0.10(2021-04-08)
+- 优化错误提示
+## 3.0.9(2021-04-08)
+- bindMobile接口支持通过一键登录的方式绑定
+- 优化错误提示
+## 3.0.8(2021-03-19)
+- 修复 3.0.7版本某些情况下生成token报错的Bug
+## 3.0.7(2021-03-19)
+- 新增 支持uni-config-center,更新uni-id无须再担心配置被覆盖 [详情](https://uniapp.dcloud.io/uniCloud/uni-id?id=uni-config-center)
+- 新增 自定义token内容,可以缓存角色权限之外的更多信息到客户端 [详情](https://uniapp.dcloud.io/uniCloud/uni-id?id=custom-token)
+- 新增 支持传入context获取uni-id实例,防止单实例多并发时全局context混乱 [详情](https://uniapp.dcloud.io/uniCloud/uni-id?id=create-instance)
+## 3.0.6(2021-03-05)
+- 新增[uniID.wxBizDataCrypt](https://uniapp.dcloud.io/uniCloud/uni-id?id=%e5%be%ae%e4%bf%a1%e6%95%b0%e6%8d%ae%e8%a7%a3%e5%af%86)方法
+- 优化loginByApple方法,提高接口响应速度
+## 3.0.5(2021-02-03)
+- 调整为uni_modules目录规范
diff --git a/uni_modules/uni-id/package.json b/uni_modules/uni-id/package.json
index 11882b6d..7f999213 100644
--- a/uni_modules/uni-id/package.json
+++ b/uni_modules/uni-id/package.json
@@ -1,85 +1,88 @@
-{
- "id": "uni-id",
- "displayName": "uni-id",
- "version": "3.3.31",
- "description": "简单、统一、可扩展的用户中心",
- "keywords": [
- "uniid",
- "uni-id",
- "用户管理",
- "用户中心",
- "短信验证码"
-],
- "repository": "https://gitee.com/dcloud/uni-id.git",
- "engines": {
- "HBuilderX": "^3.1.0"
- },
- "dcloudext": {
- "sale": {
- "regular": {
- "price": "0.00"
- },
- "sourcecode": {
- "price": "0.00"
- }
- },
- "contact": {
- "qq": ""
- },
- "declaration": {
- "ads": "无",
- "data": "无",
- "permissions": "无"
- },
- "npmurl": "",
- "type": "unicloud-template-function"
- },
- "uni_modules": {
- "dependencies": ["uni-config-center", "uni-open-bridge-common"],
- "encrypt": [],
- "platforms": {
- "cloud": {
- "tcb": "y",
- "aliyun": "y"
- },
- "client": {
- "App": {
- "app-vue": "u",
- "app-nvue": "u"
- },
- "H5-mobile": {
- "Safari": "u",
- "Android Browser": "u",
- "微信浏览器(Android)": "u",
- "QQ浏览器(Android)": "u"
- },
- "H5-pc": {
- "Chrome": "u",
- "IE": "u",
- "Edge": "u",
- "Firefox": "u",
- "Safari": "u"
- },
- "小程序": {
- "微信": "u",
- "阿里": "u",
- "百度": "u",
- "字节跳动": "u",
- "QQ": "u",
- "钉钉": "u",
- "快手": "u",
- "飞书": "u",
- "京东": "u"
- },
- "快应用": {
- "华为": "u",
- "联盟": "u"
- },
- "Vue": {
- "vue2": "y",
- "vue3": "u"
- }
- }
- }
- }
+{
+ "id": "uni-id",
+ "displayName": "uni-id",
+ "version": "3.3.33",
+ "description": "简单、统一、可扩展的用户中心",
+ "keywords": [
+ "uniid",
+ "uni-id",
+ "用户管理",
+ "用户中心",
+ "短信验证码"
+],
+ "repository": "https://gitee.com/dcloud/uni-id.git",
+ "engines": {
+ "HBuilderX": "^3.1.0"
+ },
+ "dcloudext": {
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "无",
+ "data": "无",
+ "permissions": "无"
+ },
+ "npmurl": "",
+ "type": "unicloud-template-function"
+ },
+ "uni_modules": {
+ "dependencies": ["uni-config-center", "uni-open-bridge-common"],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "y",
+ "aliyun": "y",
+ "alipay": "y"
+ },
+ "client": {
+ "App": {
+ "app-vue": "u",
+ "app-nvue": "u",
+ "app-harmony": "u",
+ "app-uvue": "u"
+ },
+ "H5-mobile": {
+ "Safari": "u",
+ "Android Browser": "u",
+ "微信浏览器(Android)": "u",
+ "QQ浏览器(Android)": "u"
+ },
+ "H5-pc": {
+ "Chrome": "u",
+ "IE": "u",
+ "Edge": "u",
+ "Firefox": "u",
+ "Safari": "u"
+ },
+ "小程序": {
+ "微信": "u",
+ "阿里": "u",
+ "百度": "u",
+ "字节跳动": "u",
+ "QQ": "u",
+ "钉钉": "u",
+ "快手": "u",
+ "飞书": "u",
+ "京东": "u"
+ },
+ "快应用": {
+ "华为": "u",
+ "联盟": "u"
+ },
+ "Vue": {
+ "vue2": "y",
+ "vue3": "u"
+ }
+ }
+ }
+ }
}
diff --git a/uni_modules/uni-id/readme.md b/uni_modules/uni-id/readme.md
index 68901213..5bcfd098 100644
--- a/uni_modules/uni-id/readme.md
+++ b/uni_modules/uni-id/readme.md
@@ -1,33 +1,33 @@
-**文档已移至[uni-id文档](https://uniapp.dcloud.net.cn/uniCloud/uni-id)**
-
-> 一般uni-id升级大版本时为不兼容更新,从低版本迁移到高版本请参考:[uni-id迁移指南](https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=migration)
-
-## 重要升级说明
-
-**uni-id 3.x版本,搭配的uniCloud admin版本需大于1.2.10。**
-
-### 缓存角色权限
-
-自`uni-id 3.0.0`起,支持在token内缓存用户的角色权限,默认开启此功能,各登录接口的needPermission参数不再生效。如需关闭请在config内配置`"removePermissionAndRoleFromToken": true`。
-
-为什么要缓存角色权限?要知道云数据库是按照读写次数来收取费用的,并且读写数据库会拖慢接口响应速度。未配置`"removePermissionAndRoleFromToken": true`的情况下,可以在调用checkToken接口时不查询数据库获取用户角色权限。
-
-详细checkToken流程如下:
-
-
-
-可以看出,旧版token(removePermissionAndRoleFromToken为true时生成的)在checkToken时如需返回权限需要进行两次数据库查询。新版token不需要查库即可返回权限信息。
-
-**注意**
-
-- 由于角色权限缓存在token内,可能会存在权限已经更新但是用户token未过期之前依然是旧版角色权限的情况。可以调短一些token过期时间来减少这种情况的影响。
-- admin角色token内不包含permission,如需自行判断用户是否有某个权限,要注意admin角色需要额外判断一下,写法如下
- ```js
- const {
- role,
- permission
- } = await uniID.checkToken(event.uniIdToken)
- if(role.includes('admin') || permission.includes('your permission id')) {
- // 当前角色拥有'your permission id'对应的权限
- }
+**文档已移至[uni-id文档](https://doc.dcloud.net.cn/uniCloud/uni-id/old.html)**
+
+> 一般uni-id升级大版本时为不兼容更新,从低版本迁移到高版本请参考:[uni-id迁移指南](https://doc.dcloud.net.cn/uniCloud/uni-id/old.html#m1to2)
+
+## 重要升级说明
+
+**uni-id 3.x版本,搭配的uniCloud admin版本需大于1.2.10。**
+
+### 缓存角色权限
+
+自`uni-id 3.0.0`起,支持在token内缓存用户的角色权限,默认开启此功能,各登录接口的needPermission参数不再生效。如需关闭请在config内配置`"removePermissionAndRoleFromToken": true`。
+
+为什么要缓存角色权限?要知道云数据库是按照读写次数来收取费用的,并且读写数据库会拖慢接口响应速度。未配置`"removePermissionAndRoleFromToken": true`的情况下,可以在调用checkToken接口时不查询数据库获取用户角色权限。
+
+详细checkToken流程如下:
+
+
+
+可以看出,旧版token(removePermissionAndRoleFromToken为true时生成的)在checkToken时如需返回权限需要进行两次数据库查询。新版token不需要查库即可返回权限信息。
+
+**注意**
+
+- 由于角色权限缓存在token内,可能会存在权限已经更新但是用户token未过期之前依然是旧版角色权限的情况。可以调短一些token过期时间来减少这种情况的影响。
+- admin角色token内不包含permission,如需自行判断用户是否有某个权限,要注意admin角色需要额外判断一下,写法如下
+ ```js
+ const {
+ role,
+ permission
+ } = await uniID.checkToken(event.uniIdToken)
+ if(role.includes('admin') || permission.includes('your permission id')) {
+ // 当前角色拥有'your permission id'对应的权限
+ }
```
\ No newline at end of file
diff --git a/uni_modules/uni-id/uni-id.zip b/uni_modules/uni-id/uni-id.zip
deleted file mode 100644
index 82cc8993..00000000
Binary files a/uni_modules/uni-id/uni-id.zip and /dev/null differ
diff --git a/uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/LICENSE.md b/uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/LICENSE.md
index 29f81d81..261eeb9e 100644
--- a/uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/LICENSE.md
+++ b/uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/LICENSE.md
@@ -1,201 +1,201 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/index.js b/uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/index.js
index a8534bf2..c9b8e483 100644
--- a/uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/index.js
+++ b/uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/index.js
@@ -1 +1 @@
-"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("crypto")),r=e(require("buffer")),n=e(require("stream")),i=e(require("util"));const o={PARAM_ERROR:{errCode:"param-error"},PARAM_REQUIRED:{errCode:"param-required"},USER_NOT_EXIST:{errCode:"user-not-exist"},ROLE_NOT_EXIST:{errCode:"role-not-exist"},PERMISSION_NOT_EXIST:{errCode:"permission-not-exist"},MULTI_USER_MATCHED:{errCode:"multi-user-matched"},USER_INFO_ERROR:{errCode:"user-info-error"},USER_ACCOUNT_CONFLICT:{errCode:"user-account-conflict"},USER_ACCOUNT_CLOSED:{errCode:"user-account-closed"},ACCOUNT_EXISTS:{errCode:"account-exists"},ACCOUNT_NOT_EXISTS:{errCode:"account-not-exists"},ACCOUNT_BOUND:{errCode:"account-bound"},UNBIND_FAILED:{errCode:"unbind-failed"},INVALID_INVITE_CODE:{errCode:"invalid-invite-code"},SET_INVITE_CODE_FAILED:{errCode:"set-invite-code-failed"},GET_THIRD_PARTY_ACCOUNT_FAILED:{errCode:"get-third-party-account-failed"},GET_THIRD_PARTY_USER_INFO_FAILED:{errCode:"get-third-party-user-info-failed"}},s={0:{errCode:0,errMsg:""},10001:{errCode:"account-banned"},10002:o.USER_NOT_EXIST,10003:o.MULTI_USER_MATCHED,10004:o.USER_INFO_ERROR,10005:o.USER_ACCOUNT_CONFLICT,10006:o.USER_ACCOUNT_CLOSED,10102:{errCode:"password-error"},10103:{errCode:"password-error-exceed-limit"},10201:o.ACCOUNT_EXISTS,10202:o.ACCOUNT_NOT_EXISTS,10203:o.INVALID_INVITE_CODE,10301:o.ACCOUNT_EXISTS,10302:o.ACCOUNT_NOT_EXISTS,10401:o.GET_THIRD_PARTY_ACCOUNT_FAILED,10402:o.ACCOUNT_EXISTS,10403:o.ACCOUNT_NOT_EXISTS,10501:o.GET_THIRD_PARTY_ACCOUNT_FAILED,10502:o.ACCOUNT_EXISTS,10503:o.ACCOUNT_NOT_EXISTS,10601:o.ACCOUNT_EXISTS,10602:o.ACCOUNT_NOT_EXISTS,10701:o.GET_THIRD_PARTY_ACCOUNT_FAILED,10702:o.GET_THIRD_PARTY_ACCOUNT_FAILED,10703:o.ACCOUNT_EXISTS,10704:o.ACCOUNT_NOT_EXISTS,10705:o.GET_THIRD_PARTY_ACCOUNT_FAILED,10706:o.GET_THIRD_PARTY_ACCOUNT_FAILED,10801:o.GET_THIRD_PARTY_ACCOUNT_FAILED,10802:o.ACCOUNT_EXISTS,10803:o.ACCOUNT_NOT_EXISTS,20101:o.PARAM_REQUIRED,20102:o.ACCOUNT_EXISTS,30101:o.PARAM_REQUIRED,30201:{errCode:"check-device-feature-failed"},30202:{errCode:"token-not-exist"},30203:{errCode:"token-expired"},30204:{errCode:"check-token-failed"},40201:o.USER_NOT_EXIST,40202:{errCode:"invalid-old-password"},50101:o.PARAM_REQUIRED,50102:o.PARAM_ERROR,50201:o.PARAM_REQUIRED,50203:o.PARAM_ERROR,50202:{errCode:"invalid-verify-code"},50301:{errCode:"send-sms-code-failed"},60101:o.ACCOUNT_BOUND,60201:o.ACCOUNT_BOUND,60301:o.GET_THIRD_PARTY_ACCOUNT_FAILED,60302:o.ACCOUNT_BOUND,60401:o.GET_THIRD_PARTY_ACCOUNT_FAILED,60402:o.ACCOUNT_BOUND,60501:o.GET_THIRD_PARTY_ACCOUNT_FAILED,60502:o.ACCOUNT_BOUND,70101:o.UNBIND_FAILED,70201:o.UNBIND_FAILED,70301:o.UNBIND_FAILED,70401:o.UNBIND_FAILED,70501:o.UNBIND_FAILED,80301:o.USER_NOT_EXIST,80401:o.SET_INVITE_CODE_FAILED,80402:o.SET_INVITE_CODE_FAILED,80501:o.INVALID_INVITE_CODE,80502:o.USER_NOT_EXIST,80503:{errCode:"modify-invite-code-is-not-allowed"},80601:o.GET_THIRD_PARTY_ACCOUNT_FAILED,80602:o.GET_THIRD_PARTY_ACCOUNT_FAILED,80701:o.GET_THIRD_PARTY_ACCOUNT_FAILED,80702:o.GET_THIRD_PARTY_ACCOUNT_FAILED,80801:{errCode:"decrypt-weixin-data-failed"},80802:{errCode:"decrypt-weixin-data-failed"},80803:{errCode:"invalid-weixin-appid"},80804:o.PARAM_REQUIRED,80805:o.PARAM_REQUIRED,80806:o.PARAM_REQUIRED,80901:o.GET_THIRD_PARTY_USER_INFO_FAILED,90001:{errCode:"database-operation-failed"},90002:o.PARAM_REQUIRED,90003:o.PARAM_ERROR,90004:o.USER_NOT_EXIST,90005:o.ROLE_NOT_EXIST,90006:o.PERMISSION_NOT_EXIST};class a extends Error{constructor(e){super(e.message),this.errMsg=e.message||"",Object.defineProperties(this,{message:{get(){return`errCode: ${e.code||""} | errMsg: `+this.errMsg},set(e){this.errMsg=e}}})}}const c=Object.prototype.toString,u=Object.prototype.hasOwnProperty;function d(e,t){return u.call(e,t)}function p(e){return"[object Object]"===c.call(e)}function l(e){return"function"==typeof e}function f(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}function m(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}const h=/_(\w)/g,g=/[A-Z]/g;function y(e){return e.replace(h,(e,t)=>t?t.toUpperCase():"")}function w(e){return e.replace(g,e=>"_"+e.toLowerCase())}function _(e,t){let r,n;switch(t){case"snake2camel":n=y,r=h;break;case"camel2snake":n=w,r=g}for(const i in e)if(d(e,i)&&r.test(i)){const r=n(i);e[r]=e[i],delete e[i],p(e[r])?e[r]=_(e[r],t):Array.isArray(e[r])&&(e[r]=e[r].map(e=>_(e,t)))}return e}function v(e){return _(e,"snake2camel")}function b(e){return _(e,"camel2snake")}function T(e){return function(e,t="-"){e=e||new Date;const r=[];return r.push(e.getFullYear()),r.push(("00"+(e.getMonth()+1)).substr(-2)),r.push(("00"+e.getDate()).substr(-2)),r.join(t)}(e=e||new Date)+" "+function(e,t=":"){e=e||new Date;const r=[];return r.push(("00"+e.getHours()).substr(-2)),r.push(("00"+e.getMinutes()).substr(-2)),r.push(("00"+e.getSeconds()).substr(-2)),r.join(t)}(e)}function E(){"development"===process.env.NODE_ENV&&console.log(...arguments)}function C(e=6){let t="";for(let r=0;r-1?"&":"?"}access_token=${t.accessToken}`}return`${e}${r}`}class G{constructor(e){this.options=Object.assign({baseUrl:"https://api.weixin.qq.com",timeout:5e3},e)}async _requestWxOpenapi({name:e,url:t,data:r,options:n}){const i={method:"GET",dataType:"json",dataAsQueryString:!0,timeout:this.options.timeout};return await H({name:"auth."+e,url:`${this.options.baseUrl}${K(t,r)}`,data:r,options:n,defaultOptions:i})}async code2Session(e){return await this._requestWxOpenapi({name:"code2Session",url:"/sns/jscode2session",data:{grant_type:"authorization_code",appid:this.options.appId,secret:this.options.secret,js_code:e}})}async getOauthAccessToken(e){const t=await this._requestWxOpenapi({name:"getOauthAccessToken",url:"/sns/oauth2/access_token",data:{grant_type:"authorization_code",appid:this.options.appId,secret:this.options.secret,code:e}});return t.expiresIn&&(t.expired=Date.now()+1e3*t.expiresIn),t}async getUserInfo({accessToken:e,openid:t}={}){const{nickname:r,headimgurl:n}=await this._requestWxOpenapi({name:"getUserInfo",url:"/sns/userinfo",data:{accessToken:e,openid:t,appid:this.options.appId,secret:this.options.secret,scope:"snsapi_userinfo"}});return{nickname:r,avatar:n}}}async function Q({name:e,url:t,data:r,options:n,defaultOptions:i}){let o;n=Object.assign({},i,n,{data:b(Object.assign({},r))});try{o=await uniCloud.httpclient.request(t,n)}catch(t){return function(e,t){throw new a({code:t.code||-2,message:t.message||e+" fail"})}(e,t)}let s=o.data;const c=o.headers["content-type"];if(!Buffer.isBuffer(s)||0!==c.indexOf("text/plain")&&0!==c.indexOf("application/json"))Buffer.isBuffer(s)&&(s={buffer:s,contentType:c});else try{s=JSON.parse(s.toString())}catch(e){s=s.toString()}return v(function(e,t){if(t.ret||t.error){const r=t.ret||t.error||t.errcode||-2,n=t.msg||t.error_description||t.errmsg||e+" fail";throw new a({code:r,message:n})}return delete t.ret,delete t.msg,delete t.error,delete t.error_description,delete t.errcode,delete t.errmsg,{...t,errMsg:e+" ok",errCode:0}}(e,s||{errCode:-2,errMsg:"Request failed"}))}class X{constructor(e){this.options=Object.assign({baseUrl:"https://graph.qq.com",timeout:5e3},e)}async _requestQQOpenapi({name:e,url:t,data:r,options:n}){const i={method:"GET",dataType:"json",dataAsQueryString:!0,timeout:this.options.timeout};var o,s;return await Q({name:"auth."+e,url:(o=this.options.baseUrl,s=t,/^https?:/.test(s)?s:o+s),data:r,options:n,defaultOptions:i})}async getOpenidByToken({accessToken:e}={}){const t=await this._requestQQOpenapi({name:"getOpenidByToken",url:"/oauth2.0/me",data:{accessToken:e,unionid:1,fmt:"json"}});if(t.clientId!==this.options.appId)throw new a({code:"APPID_NOT_MATCH",message:"appid not match"});return{openid:t.openid,unionid:t.unionid}}async code2Session({code:e}={}){return await this._requestQQOpenapi({name:"getOpenidByToken",url:"https://api.q.qq.com/sns/jscode2session",data:{grant_type:"authorization_code",appid:this.options.appId,secret:this.options.secret,js_code:e}})}}const Y={RSA:"RSA-SHA1",RSA2:"RSA-SHA256"};var z={code2Session:{returnValue:{openid:"userId"}}};class W extends class{constructor(e={}){if(!e.appId)throw new Error("appId required");if(!e.privateKey)throw new Error("privateKey required");const t={gateway:"https://openapi.alipay.com/gateway.do",timeout:5e3,charset:"utf-8",version:"1.0",signType:"RSA2",timeOffset:-(new Date).getTimezoneOffset()/60,keyType:"PKCS8"};e.sandbox&&(e.gateway="https://openapi.alipaydev.com/gateway.do"),this.options=Object.assign({},t,e);const r="PKCS8"===this.options.keyType?"PRIVATE KEY":"RSA PRIVATE KEY";this.options.privateKey=this._formatKey(this.options.privateKey,r),this.options.alipayPublicKey&&(this.options.alipayPublicKey=this._formatKey(this.options.alipayPublicKey,"PUBLIC KEY"))}_formatKey(e,t){return`-----BEGIN ${t}-----\n${e}\n-----END ${t}-----`}_formatUrl(e,t){let r=e;const n=["app_id","method","format","charset","sign_type","sign","timestamp","version","notify_url","return_url","auth_token","app_auth_token"];for(const e in t)if(n.indexOf(e)>-1){const n=encodeURIComponent(t[e]);r=`${r}${r.includes("?")?"&":"?"}${e}=${n}`,delete t[e]}return{execParams:t,url:r}}_getSign(e,r){const n=r.bizContent||null;delete r.bizContent;const i=Object.assign({method:e,appId:this.options.appId,charset:this.options.charset,version:this.options.version,signType:this.options.signType,timestamp:T((o=this.options.timeOffset,new Date(Date.now()+6e4*((new Date).getTimezoneOffset()+60*(o||0)))))},r);var o;n&&(i.bizContent=JSON.stringify(b(n)));const s=b(i),a=Object.keys(s).sort().map(e=>{let t=s[e];return"[object String]"!==Array.prototype.toString.call(t)&&(t=JSON.stringify(t)),`${e}=${t}`}).join("&"),c=t.createSign(Y[this.options.signType]).update(a,"utf8").sign(this.options.privateKey,"base64");return Object.assign(s,{sign:c})}async _exec(e,t={},r={}){const n=this._getSign(e,t),{url:i,execParams:o}=this._formatUrl(this.options.gateway,n),{status:s,data:a}=await uniCloud.httpclient.request(i,{method:"POST",data:o,dataType:"text",timeout:this.options.timeout});if(200!==s)throw new Error("request fail");const c=JSON.parse(a),u=e.replace(/\./g,"_")+"_response",d=c[u],p=c.error_response;if(d){if(!r.validateSign||this._checkResponseSign(a,u)){if(!d.code||"10000"===d.code){return{errCode:0,errMsg:d.msg||"",...v(d)}}const e=d.sub_code?`${d.sub_code} ${d.sub_msg}`:""+(d.msg||"unkonwn error");throw new Error(e)}throw new Error("check sign error")}if(p)throw new Error(p.sub_msg||p.msg||"request fail");throw new Error("request fail")}_checkResponseSign(e,r){if(!this.options.alipayPublicKey||""===this.options.alipayPublicKey)return console.warn("options.alipayPublicKey is empty"),!0;if(!e)return!1;const n=this._getSignStr(e,r),i=JSON.parse(e).sign,o=t.createVerify(Y[this.options.signType]);return o.update(n,"utf8"),o.verify(this.options.alipayPublicKey,i,"base64")}_getSignStr(e,t){let r=e.trim();const n=e.indexOf(t+'"'),i=e.lastIndexOf('"sign"');return r=r.substr(n+t.length+1),r=r.substr(0,i),r=r.replace(/^[^{]*{/g,"{"),r=r.replace(/\}([^}]*)$/g,"}"),r}}{constructor(e){super(e),this._protocols=z}async code2Session(e){return await this._exec("alipay.system.oauth.token",{grantType:"authorization_code",code:e})}}function J(e){var t=e[0];return t<"0"||t>"7"?"00"+e:e}function Z(e){var t=e.toString(16);return t.length%2?"0"+t:t}function ee(e){if(e<=127)return Z(e);var t=Z(e);return Z(128+t.length/2)+t}function te(e,t){return e(t={exports:{}},t.exports),t.exports}var re=te((function(e,t){var n=r.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=o),o.prototype=Object.create(n.prototype),i(n,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}})),ne=(re.Buffer,re.Buffer);function ie(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=ne.alloc(0),this;if("function"==typeof e.pipe)return this.buffer=ne.alloc(0),e.pipe(this),this;if(e.length||"object"==typeof e)return this.buffer=e,this.writable=!1,process.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof e+")")}i.inherits(ie,n),ie.prototype.write=function(e){this.buffer=ne.concat([this.buffer,ne.from(e)]),this.emit("data",e)},ie.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1};var oe=ie,se=r.Buffer,ae=r.SlowBuffer,ce=ue;function ue(e,t){if(!se.isBuffer(e)||!se.isBuffer(t))return!1;if(e.length!==t.length)return!1;for(var r=0,n=0;n=128&&--n,n}var we={derToJose:function(e,t){e=ge(e);var r=me(t),n=r+1,i=e.length,o=0;if(48!==e[o++])throw new Error('Could not find expected "seq"');var s=e[o++];if(129===s&&(s=e[o++]),i-o0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*mt;case"hours":case"hour":case"hrs":case"hr":case"h":return r*ft;case"minutes":case"minute":case"mins":case"min":case"m":return r*lt;case"seconds":case"second":case"secs":case"sec":case"s":return r*pt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=mt)return gt(e,t,mt,"day");if(t>=ft)return gt(e,t,ft,"hour");if(t>=lt)return gt(e,t,lt,"minute");if(t>=pt)return gt(e,t,pt,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=mt)return Math.round(e/mt)+"d";if(t>=ft)return Math.round(e/ft)+"h";if(t>=lt)return Math.round(e/lt)+"m";if(t>=pt)return Math.round(e/pt)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function gt(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var yt=function(e,t){var r=t||Math.floor(Date.now()/1e3);if("string"==typeof e){var n=ht(e);if(void 0===n)return;return Math.floor(r+n/1e3)}return"number"==typeof e?r+e:void 0},wt=te((function(e,t){var r;t=e.exports=G,r="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?function(){var e=Array.prototype.slice.call(arguments,0);e.unshift("SEMVER"),console.log.apply(console,e)}:function(){},t.SEMVER_SPEC_VERSION="2.0.0";var n=Number.MAX_SAFE_INTEGER||9007199254740991,i=t.re=[],o=t.src=[],s=0,a=s++;o[a]="0|[1-9]\\d*";var c=s++;o[c]="[0-9]+";var u=s++;o[u]="\\d*[a-zA-Z-][a-zA-Z0-9-]*";var d=s++;o[d]="("+o[a]+")\\.("+o[a]+")\\.("+o[a]+")";var p=s++;o[p]="("+o[c]+")\\.("+o[c]+")\\.("+o[c]+")";var l=s++;o[l]="(?:"+o[a]+"|"+o[u]+")";var f=s++;o[f]="(?:"+o[c]+"|"+o[u]+")";var m=s++;o[m]="(?:-("+o[l]+"(?:\\."+o[l]+")*))";var h=s++;o[h]="(?:-?("+o[f]+"(?:\\."+o[f]+")*))";var g=s++;o[g]="[0-9A-Za-z-]+";var y=s++;o[y]="(?:\\+("+o[g]+"(?:\\."+o[g]+")*))";var w=s++,_="v?"+o[d]+o[m]+"?"+o[y]+"?";o[w]="^"+_+"$";var v="[v=\\s]*"+o[p]+o[h]+"?"+o[y]+"?",b=s++;o[b]="^"+v+"$";var T=s++;o[T]="((?:<|>)?=?)";var E=s++;o[E]=o[c]+"|x|X|\\*";var C=s++;o[C]=o[a]+"|x|X|\\*";var A=s++;o[A]="[v=\\s]*("+o[C]+")(?:\\.("+o[C]+")(?:\\.("+o[C]+")(?:"+o[m]+")?"+o[y]+"?)?)?";var x=s++;o[x]="[v=\\s]*("+o[E]+")(?:\\.("+o[E]+")(?:\\.("+o[E]+")(?:"+o[h]+")?"+o[y]+"?)?)?";var I=s++;o[I]="^"+o[T]+"\\s*"+o[A]+"$";var S=s++;o[S]="^"+o[T]+"\\s*"+o[x]+"$";var k=s++;o[k]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var O=s++;o[O]="(?:~>?)";var P=s++;o[P]="(\\s*)"+o[O]+"\\s+",i[P]=new RegExp(o[P],"g");var R=s++;o[R]="^"+o[O]+o[A]+"$";var j=s++;o[j]="^"+o[O]+o[x]+"$";var D=s++;o[D]="(?:\\^)";var q=s++;o[q]="(\\s*)"+o[D]+"\\s+",i[q]=new RegExp(o[q],"g");var N=s++;o[N]="^"+o[D]+o[A]+"$";var U=s++;o[U]="^"+o[D]+o[x]+"$";var L=s++;o[L]="^"+o[T]+"\\s*("+v+")$|^$";var V=s++;o[V]="^"+o[T]+"\\s*("+_+")$|^$";var M=s++;o[M]="(\\s*)"+o[T]+"\\s*("+v+"|"+o[A]+")",i[M]=new RegExp(o[M],"g");var B=s++;o[B]="^\\s*("+o[A]+")\\s+-\\s+("+o[A]+")\\s*$";var F=s++;o[F]="^\\s*("+o[x]+")\\s+-\\s+("+o[x]+")\\s*$";var $=s++;o[$]="(<|>)?=?\\s*\\*";for(var H=0;H<35;H++)r(H,o[H]),i[H]||(i[H]=new RegExp(o[H]));function K(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof G)return e;if("string"!=typeof e)return null;if(e.length>256)return null;if(!(t.loose?i[b]:i[w]).test(e))return null;try{return new G(e,t)}catch(e){return null}}function G(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof G){if(e.loose===t.loose)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>256)throw new TypeError("version is longer than 256 characters");if(!(this instanceof G))return new G(e,t);r("SemVer",e,t),this.options=t,this.loose=!!t.loose;var o=e.trim().match(t.loose?i[b]:i[w]);if(!o)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+o[1],this.minor=+o[2],this.patch=+o[3],this.major>n||this.major<0)throw new TypeError("Invalid major version");if(this.minor>n||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>n||this.patch<0)throw new TypeError("Invalid patch version");o[4]?this.prerelease=o[4].split(".").map((function(e){if(/^[0-9]+$/.test(e)){var t=+e;if(t>=0&&t=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);-1===r&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},t.inc=function(e,t,r,n){"string"==typeof r&&(n=r,r=void 0);try{return new G(e,r).inc(t,n).version}catch(e){return null}},t.diff=function(e,t){if(J(e,t))return null;var r=K(e),n=K(t),i="";if(r.prerelease.length||n.prerelease.length){i="pre";var o="prerelease"}for(var s in r)if(("major"===s||"minor"===s||"patch"===s)&&r[s]!==n[s])return i+s;return o},t.compareIdentifiers=X;var Q=/^[0-9]+$/;function X(e,t){var r=Q.test(e),n=Q.test(t);return r&&n&&(e=+e,t=+t),e===t?0:r&&!n?-1:n&&!r?1:e0}function W(e,t,r){return Y(e,t,r)<0}function J(e,t,r){return 0===Y(e,t,r)}function Z(e,t,r){return 0!==Y(e,t,r)}function ee(e,t,r){return Y(e,t,r)>=0}function te(e,t,r){return Y(e,t,r)<=0}function re(e,t,r,n){switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e===r;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e!==r;case"":case"=":case"==":return J(e,r,n);case"!=":return Z(e,r,n);case">":return z(e,r,n);case">=":return ee(e,r,n);case"<":return W(e,r,n);case"<=":return te(e,r,n);default:throw new TypeError("Invalid operator: "+t)}}function ne(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof ne){if(e.loose===!!t.loose)return e;e=e.value}if(!(this instanceof ne))return new ne(e,t);r("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===ie?this.value="":this.value=this.operator+this.semver.version,r("comp",this)}t.rcompareIdentifiers=function(e,t){return X(t,e)},t.major=function(e,t){return new G(e,t).major},t.minor=function(e,t){return new G(e,t).minor},t.patch=function(e,t){return new G(e,t).patch},t.compare=Y,t.compareLoose=function(e,t){return Y(e,t,!0)},t.rcompare=function(e,t,r){return Y(t,e,r)},t.sort=function(e,r){return e.sort((function(e,n){return t.compare(e,n,r)}))},t.rsort=function(e,r){return e.sort((function(e,n){return t.rcompare(e,n,r)}))},t.gt=z,t.lt=W,t.eq=J,t.neq=Z,t.gte=ee,t.lte=te,t.cmp=re,t.Comparator=ne;var ie={};function oe(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof oe)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new oe(e.raw,t);if(e instanceof ne)return new oe(e.value,t);if(!(this instanceof oe))return new oe(e,t);if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e,this.set=e.split(/\s*\|\|\s*/).map((function(e){return this.parseRange(e.trim())}),this).filter((function(e){return e.length})),!this.set.length)throw new TypeError("Invalid SemVer Range: "+e);this.format()}function se(e){return!e||"x"===e.toLowerCase()||"*"===e}function ae(e,t,r,n,i,o,s,a,c,u,d,p,l){return((t=se(r)?"":se(n)?">="+r+".0.0":se(i)?">="+r+"."+n+".0":">="+t)+" "+(a=se(c)?"":se(u)?"<"+(+c+1)+".0.0":se(d)?"<"+c+"."+(+u+1)+".0":p?"<="+c+"."+u+"."+d+"-"+p:"<="+a)).trim()}function ce(e,t,n){for(var i=0;i0){var o=e[i].semver;if(o.major===t.major&&o.minor===t.minor&&o.patch===t.patch)return!0}return!1}return!0}function ue(e,t,r){try{t=new oe(t,r)}catch(e){return!1}return t.test(e)}function de(e,t,r,n){var i,o,s,a,c;switch(e=new G(e,n),t=new oe(t,n),r){case">":i=z,o=te,s=W,a=">",c=">=";break;case"<":i=W,o=ee,s=z,a="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(ue(e,t,n))return!1;for(var u=0;u=0.0.0")),p=p||e,l=l||e,i(e.semver,p.semver,n)?p=e:s(e.semver,l.semver,n)&&(l=e)})),p.operator===a||p.operator===c)return!1;if((!l.operator||l.operator===a)&&o(e,l.semver))return!1;if(l.operator===c&&s(e,l.semver))return!1}return!0}ne.prototype.parse=function(e){var t=this.options.loose?i[L]:i[V],r=e.match(t);if(!r)throw new TypeError("Invalid comparator: "+e);this.operator=r[1],"="===this.operator&&(this.operator=""),r[2]?this.semver=new G(r[2],this.options.loose):this.semver=ie},ne.prototype.toString=function(){return this.value},ne.prototype.test=function(e){return r("Comparator.test",e,this.options.loose),this.semver===ie||("string"==typeof e&&(e=new G(e,this.options)),re(e,this.operator,this.semver,this.options))},ne.prototype.intersects=function(e,t){if(!(e instanceof ne))throw new TypeError("a Comparator is required");var r;if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),""===this.operator)return r=new oe(e.value,t),ue(this.value,r,t);if(""===e.operator)return r=new oe(this.value,t),ue(e.semver,r,t);var n=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),i=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),o=this.semver.version===e.semver.version,s=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),a=re(this.semver,"<",e.semver,t)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),c=re(this.semver,">",e.semver,t)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return n||i||o&&s||a||c},t.Range=oe,oe.prototype.format=function(){return this.range=this.set.map((function(e){return e.join(" ").trim()})).join("||").trim(),this.range},oe.prototype.toString=function(){return this.range},oe.prototype.parseRange=function(e){var t=this.options.loose;e=e.trim();var n=t?i[F]:i[B];e=e.replace(n,ae),r("hyphen replace",e),e=e.replace(i[M],"$1$2$3"),r("comparator trim",e,i[M]),e=(e=(e=e.replace(i[P],"$1~")).replace(i[q],"$1^")).split(/\s+/).join(" ");var o=t?i[L]:i[V],s=e.split(" ").map((function(e){return function(e,t){return r("comp",e,t),e=function(e,t){return e.trim().split(/\s+/).map((function(e){return function(e,t){r("caret",e,t);var n=t.loose?i[U]:i[N];return e.replace(n,(function(t,n,i,o,s){var a;return r("caret",e,t,n,i,o,s),se(n)?a="":se(i)?a=">="+n+".0.0 <"+(+n+1)+".0.0":se(o)?a="0"===n?">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0":">="+n+"."+i+".0 <"+(+n+1)+".0.0":s?(r("replaceCaret pr",s),a="0"===n?"0"===i?">="+n+"."+i+"."+o+"-"+s+" <"+n+"."+i+"."+(+o+1):">="+n+"."+i+"."+o+"-"+s+" <"+n+"."+(+i+1)+".0":">="+n+"."+i+"."+o+"-"+s+" <"+(+n+1)+".0.0"):(r("no pr"),a="0"===n?"0"===i?">="+n+"."+i+"."+o+" <"+n+"."+i+"."+(+o+1):">="+n+"."+i+"."+o+" <"+n+"."+(+i+1)+".0":">="+n+"."+i+"."+o+" <"+(+n+1)+".0.0"),r("caret return",a),a}))}(e,t)})).join(" ")}(e,t),r("caret",e),e=function(e,t){return e.trim().split(/\s+/).map((function(e){return function(e,t){var n=t.loose?i[j]:i[R];return e.replace(n,(function(t,n,i,o,s){var a;return r("tilde",e,t,n,i,o,s),se(n)?a="":se(i)?a=">="+n+".0.0 <"+(+n+1)+".0.0":se(o)?a=">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0":s?(r("replaceTilde pr",s),a=">="+n+"."+i+"."+o+"-"+s+" <"+n+"."+(+i+1)+".0"):a=">="+n+"."+i+"."+o+" <"+n+"."+(+i+1)+".0",r("tilde return",a),a}))}(e,t)})).join(" ")}(e,t),r("tildes",e),e=function(e,t){return r("replaceXRanges",e,t),e.split(/\s+/).map((function(e){return function(e,t){e=e.trim();var n=t.loose?i[S]:i[I];return e.replace(n,(function(t,n,i,o,s,a){r("xRange",e,t,n,i,o,s,a);var c=se(i),u=c||se(o),d=u||se(s);return"="===n&&d&&(n=""),c?t=">"===n||"<"===n?"<0.0.0":"*":n&&d?(u&&(o=0),s=0,">"===n?(n=">=",u?(i=+i+1,o=0,s=0):(o=+o+1,s=0)):"<="===n&&(n="<",u?i=+i+1:o=+o+1),t=n+i+"."+o+"."+s):u?t=">="+i+".0.0 <"+(+i+1)+".0.0":d&&(t=">="+i+"."+o+".0 <"+i+"."+(+o+1)+".0"),r("xRange return",t),t}))}(e,t)})).join(" ")}(e,t),r("xrange",e),e=function(e,t){return r("replaceStars",e,t),e.trim().replace(i[$],"")}(e,t),r("stars",e),e}(e,this.options)}),this).join(" ").split(/\s+/);return this.options.loose&&(s=s.filter((function(e){return!!e.match(o)}))),s=s.map((function(e){return new ne(e,this.options)}),this)},oe.prototype.intersects=function(e,t){if(!(e instanceof oe))throw new TypeError("a Range is required");return this.set.some((function(r){return r.every((function(r){return e.set.some((function(e){return e.every((function(e){return r.intersects(e,t)}))}))}))}))},t.toComparators=function(e,t){return new oe(e,t).set.map((function(e){return e.map((function(e){return e.value})).join(" ").trim().split(" ")}))},oe.prototype.test=function(e){if(!e)return!1;"string"==typeof e&&(e=new G(e,this.options));for(var t=0;t":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":r&&!z(r,t)||(r=t);break;case"<":case"<=":break;default:throw new Error("Unexpected operation: "+e.operator)}}))}if(r&&e.test(r))return r;return null},t.validRange=function(e,t){try{return new oe(e,t).range||"*"}catch(e){return null}},t.ltr=function(e,t,r){return de(e,t,"<",r)},t.gtr=function(e,t,r){return de(e,t,">",r)},t.outside=de,t.prerelease=function(e,t){var r=K(e,t);return r&&r.prerelease.length?r.prerelease:null},t.intersects=function(e,t,r){return e=new oe(e,r),t=new oe(t,r),e.intersects(t)},t.coerce=function(e){if(e instanceof G)return e;if("string"!=typeof e)return null;var t=e.match(i[k]);if(null==t)return null;return K(t[1]+"."+(t[2]||"0")+"."+(t[3]||"0"))}})),_t=(wt.SEMVER_SPEC_VERSION,wt.re,wt.src,wt.parse,wt.valid,wt.clean,wt.SemVer,wt.inc,wt.diff,wt.compareIdentifiers,wt.rcompareIdentifiers,wt.major,wt.minor,wt.patch,wt.compare,wt.compareLoose,wt.rcompare,wt.sort,wt.rsort,wt.gt,wt.lt,wt.eq,wt.neq,wt.gte,wt.lte,wt.cmp,wt.Comparator,wt.Range,wt.toComparators,wt.satisfies,wt.maxSatisfying,wt.minSatisfying,wt.minVersion,wt.validRange,wt.ltr,wt.gtr,wt.outside,wt.prerelease,wt.intersects,wt.coerce,wt.satisfies(process.version,"^6.12.0 || >=8.0.0")),vt=["RS256","RS384","RS512","ES256","ES384","ES512"],bt=["RS256","RS384","RS512"],Tt=["HS256","HS384","HS512"];_t&&(vt.splice(3,0,"PS256","PS384","PS512"),bt.splice(3,0,"PS256","PS384","PS512"));var Et=/^\s+|\s+$/g,Ct=/^[-+]0x[0-9a-f]+$/i,At=/^0b[01]+$/i,xt=/^0o[0-7]+$/i,It=/^(?:0|[1-9]\d*)$/,St=parseInt;function kt(e){return e!=e}function Ot(e,t){return function(e,t){for(var r=-1,n=e?e.length:0,i=Array(n);++r-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}(e.length)&&!function(e){var t=Ht(e)?qt.call(e):"";return"[object Function]"==t||"[object GeneratorFunction]"==t}(e)}function Ht(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Kt(e){return!!e&&"object"==typeof e}var Gt=function(e,t,r,n){var i;e=$t(e)?e:(i=e)?Ot(i,function(e){return $t(e)?Vt(e):Mt(e)}(i)):[],r=r&&!n?function(e){var t=function(e){if(!e)return 0===e?e:0;if((e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||Kt(e)&&"[object Symbol]"==qt.call(e)}(e))return NaN;if(Ht(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Ht(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(Et,"");var r=At.test(e);return r||xt.test(e)?St(e.slice(2),r?2:8):Ct.test(e)?NaN:+e}(e))===1/0||e===-1/0){return 17976931348623157e292*(e<0?-1:1)}return e==e?e:0}(e),r=t%1;return t==t?r?t-r:t:0}(r):0;var o=e.length;return r<0&&(r=Lt(o+r,0)),function(e){return"string"==typeof e||!Ft(e)&&Kt(e)&&"[object String]"==qt.call(e)}(e)?r<=o&&e.indexOf(t,r)>-1:!!o&&function(e,t,r){if(t!=t)return function(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o-1},Qt=Object.prototype.toString;var Xt=function(e){return!0===e||!1===e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Boolean]"==Qt.call(e)},Yt=/^\s+|\s+$/g,zt=/^[-+]0x[0-9a-f]+$/i,Wt=/^0b[01]+$/i,Jt=/^0o[0-7]+$/i,Zt=parseInt,er=Object.prototype.toString;function tr(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}var rr=function(e){return"number"==typeof e&&e==function(e){var t=function(e){if(!e)return 0===e?e:0;if((e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==er.call(e)}(e))return NaN;if(tr(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=tr(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(Yt,"");var r=Wt.test(e);return r||Jt.test(e)?Zt(e.slice(2),r?2:8):zt.test(e)?NaN:+e}(e))===1/0||e===-1/0){return 17976931348623157e292*(e<0?-1:1)}return e==e?e:0}(e),r=t%1;return t==t?r?t-r:t:0}(e)},nr=Object.prototype.toString;var ir=function(e){return"number"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Number]"==nr.call(e)};var or=Function.prototype,sr=Object.prototype,ar=or.toString,cr=sr.hasOwnProperty,ur=ar.call(Object),dr=sr.toString,pr=function(e,t){return function(r){return e(t(r))}}(Object.getPrototypeOf,Object);var lr=function(e){if(!function(e){return!!e&&"object"==typeof e}(e)||"[object Object]"!=dr.call(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e))return!1;var t=pr(e);if(null===t)return!0;var r=cr.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&ar.call(r)==ur},fr=Object.prototype.toString,mr=Array.isArray;var hr=function(e){return"string"==typeof e||!mr(e)&&function(e){return!!e&&"object"==typeof e}(e)&&"[object String]"==fr.call(e)},gr=/^\s+|\s+$/g,yr=/^[-+]0x[0-9a-f]+$/i,wr=/^0b[01]+$/i,_r=/^0o[0-7]+$/i,vr=parseInt,br=Object.prototype.toString;function Tr(e,t){var r;if("function"!=typeof t)throw new TypeError("Expected a function");return e=function(e){var t=function(e){if(!e)return 0===e?e:0;if((e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==br.call(e)}(e))return NaN;if(Er(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Er(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(gr,"");var r=wr.test(e);return r||_r.test(e)?vr(e.slice(2),r?2:8):yr.test(e)?NaN:+e}(e))===1/0||e===-1/0){return 17976931348623157e292*(e<0?-1:1)}return e==e?e:0}(e),r=t%1;return t==t?r?t-r:t:0}(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=void 0),r}}function Er(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}var Cr=function(e){return Tr(2,e)},Ar=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];_t&&Ar.splice(3,0,"PS256","PS384","PS512");var xr={expiresIn:{isValid:function(e){return rr(e)||hr(e)&&e},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(e){return rr(e)||hr(e)&&e},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(e){return hr(e)||Array.isArray(e)},message:'"audience" must be a string or array'},algorithm:{isValid:Gt.bind(null,Ar),message:'"algorithm" must be a valid string enum value'},header:{isValid:lr,message:'"header" must be an object'},encoding:{isValid:hr,message:'"encoding" must be a string'},issuer:{isValid:hr,message:'"issuer" must be a string'},subject:{isValid:hr,message:'"subject" must be a string'},jwtid:{isValid:hr,message:'"jwtid" must be a string'},noTimestamp:{isValid:Xt,message:'"noTimestamp" must be a boolean'},keyid:{isValid:hr,message:'"keyid" must be a string'},mutatePayload:{isValid:Xt,message:'"mutatePayload" must be a boolean'}},Ir={iat:{isValid:ir,message:'"iat" should be a number of seconds'},exp:{isValid:ir,message:'"exp" should be a number of seconds'},nbf:{isValid:ir,message:'"nbf" should be a number of seconds'}};function Sr(e,t,r,n){if(!lr(r))throw new Error('Expected "'+n+'" to be a plain object.');Object.keys(r).forEach((function(i){var o=e[i];if(o){if(!o.isValid(r[i]))throw new Error(o.message)}else if(!t)throw new Error('"'+i+'" is not allowed in "'+n+'"')}))}var kr={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},Or=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"],Pr=function(e,t,r,n){var i;if("function"!=typeof r||n||(n=r,r={}),r||(r={}),r=Object.assign({},r),i=n||function(e,t){if(e)throw e;return t},r.clockTimestamp&&"number"!=typeof r.clockTimestamp)return i(new st("clockTimestamp must be a number"));if(void 0!==r.nonce&&("string"!=typeof r.nonce||""===r.nonce.trim()))return i(new st("nonce must be a non-empty string"));var o=r.clockTimestamp||Math.floor(Date.now()/1e3);if(!e)return i(new st("jwt must be provided"));if("string"!=typeof e)return i(new st("jwt must be a string"));var s,a=e.split(".");if(3!==a.length)return i(new st("jwt malformed"));try{s=it(e,{complete:!0})}catch(e){return i(e)}if(!s)return i(new st("invalid token"));var c,u=s.header;if("function"==typeof t){if(!n)return i(new st("verify must be called asynchronous if secret or public key is provided as a callback"));c=t}else c=function(e,r){return r(null,t)};return c(u,(function(t,n){if(t)return i(new st("error in secret or public key callback: "+t.message));var c,d=""!==a[2].trim();if(!d&&n)return i(new st("jwt signature is required"));if(d&&!n)return i(new st("secret or public key must be provided"));if(d||r.algorithms||(r.algorithms=["none"]),r.algorithms||(r.algorithms=~n.toString().indexOf("BEGIN CERTIFICATE")||~n.toString().indexOf("BEGIN PUBLIC KEY")?vt:~n.toString().indexOf("BEGIN RSA PUBLIC KEY")?bt:Tt),!~r.algorithms.indexOf(s.header.alg))return i(new st("invalid algorithm"));try{c=nt.verify(e,s.header.alg,n)}catch(e){return i(e)}if(!c)return i(new st("invalid signature"));var p=s.payload;if(void 0!==p.nbf&&!r.ignoreNotBefore){if("number"!=typeof p.nbf)return i(new st("invalid nbf value"));if(p.nbf>o+(r.clockTolerance||0))return i(new ct("jwt not active",new Date(1e3*p.nbf)))}if(void 0!==p.exp&&!r.ignoreExpiration){if("number"!=typeof p.exp)return i(new st("invalid exp value"));if(o>=p.exp+(r.clockTolerance||0))return i(new dt("jwt expired",new Date(1e3*p.exp)))}if(r.audience){var l=Array.isArray(r.audience)?r.audience:[r.audience];if(!(Array.isArray(p.aud)?p.aud:[p.aud]).some((function(e){return l.some((function(t){return t instanceof RegExp?t.test(e):t===e}))})))return i(new st("jwt audience invalid. expected: "+l.join(" or ")))}if(r.issuer&&("string"==typeof r.issuer&&p.iss!==r.issuer||Array.isArray(r.issuer)&&-1===r.issuer.indexOf(p.iss)))return i(new st("jwt issuer invalid. expected: "+r.issuer));if(r.subject&&p.sub!==r.subject)return i(new st("jwt subject invalid. expected: "+r.subject));if(r.jwtid&&p.jti!==r.jwtid)return i(new st("jwt jwtid invalid. expected: "+r.jwtid));if(r.nonce&&p.nonce!==r.nonce)return i(new st("jwt nonce invalid. expected: "+r.nonce));if(r.maxAge){if("number"!=typeof p.iat)return i(new st("iat required when maxAge is specified"));var f=yt(r.maxAge,p.iat);if(void 0===f)return i(new st('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(o>=f+(r.clockTolerance||0))return i(new dt("maxAge exceeded",new Date(1e3*f)))}if(!0===r.complete){var m=s.signature;return i(null,{header:u,payload:p,signature:m})}return i(null,p)}))},Rr=function(e,t,r,n){"function"==typeof r?(n=r,r={}):r=r||{};var i="object"==typeof e&&!Buffer.isBuffer(e),o=Object.assign({alg:r.algorithm||"HS256",typ:i?"JWT":void 0,kid:r.keyid},r.header);function s(e){if(n)return n(e);throw e}if(!t&&"none"!==r.algorithm)return s(new Error("secretOrPrivateKey must have a value"));if(void 0===e)return s(new Error("payload is required"));if(i){try{!function(e){Sr(Ir,!0,e,"payload")}(e)}catch(e){return s(e)}r.mutatePayload||(e=Object.assign({},e))}else{var a=Or.filter((function(e){return void 0!==r[e]}));if(a.length>0)return s(new Error("invalid "+a.join(",")+" option for "+typeof e+" payload"))}if(void 0!==e.exp&&void 0!==r.expiresIn)return s(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(void 0!==e.nbf&&void 0!==r.notBefore)return s(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{!function(e){Sr(xr,!1,e,"options")}(r)}catch(e){return s(e)}var c=e.iat||Math.floor(Date.now()/1e3);if(r.noTimestamp?delete e.iat:i&&(e.iat=c),void 0!==r.notBefore){try{e.nbf=yt(r.notBefore,c)}catch(e){return s(e)}if(void 0===e.nbf)return s(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(void 0!==r.expiresIn&&"object"==typeof e){try{e.exp=yt(r.expiresIn,c)}catch(e){return s(e)}if(void 0===e.exp)return s(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(kr).forEach((function(t){var n=kr[t];if(void 0!==r[t]){if(void 0!==e[n])return s(new Error('Bad "options.'+t+'" option. The payload already has an "'+n+'" property.'));e[n]=r[t]}}));var u=r.encoding||"utf8";if("function"!=typeof n)return nt.sign({header:o,payload:e,secret:t,encoding:u});n=n&&Cr(n),nt.createSign({header:o,privateKey:t,payload:e,encoding:u}).once("error",n).once("done",(function(e){n(null,e)}))};let jr=[];class Dr{constructor(e){this.options=Object.assign({baseUrl:"https://appleid.apple.com",timeout:1e4},e)}async _fetch(e,t){const{baseUrl:r}=this.options;return uniCloud.httpclient.request(r+e,t)}async verifyIdentityToken(e){const t=e.split(".")[0],{kid:r}=JSON.parse(Buffer.from(t,"base64").toString());if(!jr.length)try{jr=await this.getAuthKeys()}catch(e){return{code:10705,msg:e.message}}const n=this.getUsedKey(jr,r);if(!Object.keys(n).length&&!this.fetched)try{jr=await this.getAuthKeys()}catch(e){return{code:10705,msg:e.message}}let i=null;try{i=Pr(e,function(e,t){var r=Buffer.from(e,"base64"),n=Buffer.from(t,"base64"),i=r.toString("hex"),o=n.toString("hex");i=J(i),o=J(o);var s=i.length/2,a=o.length/2,c=ee(s),u=ee(a),d="30"+ee(s+a+c.length/2+u.length/2+2)+"02"+c+i+"02"+u+o;return"-----BEGIN RSA PUBLIC KEY-----\n"+Buffer.from(d,"hex").toString("base64").match(/.{1,64}/g).join("\n")+"\n-----END RSA PUBLIC KEY-----\n"}(n.n,n.e),{algorithms:n.alg})}catch(e){return{code:10705,msg:e.message}}return{code:0,msg:i}}async getAuthKeys(){const{status:e,data:t}=await this._fetch("/auth/keys",{method:"GET",dataType:"json",timeout:this.options.timeout});if(200!==e)throw new Error("request https://appleid.apple.com/auth/keys fail");return t.keys}getUsedKey(e,t){let r={};for(let n=0;nvoid 0===e))return{code:N,messageValues:{param:this.t("dcloud-appid")}};const r=await P.doc(e).get(),n=r&&r.data&&r.data[0];if(!n)return{code:10002};const i=Object.keys(q).reduce((e,t)=>{const r=t,i=function(e,t){return t.split(".").reduce((e,t)=>e&&e[t],e)}(n,t);return i&&e.push({[r]:i}),e},[]);let o;const s={dcloud_appid:Br.in(t),_id:Br.neq(n._id)},a={dcloud_appid:Br.exists(!1),_id:Br.neq(n._id)};switch(i.length){case 0:return{code:10004};case 1:o=Br.or([Br.and([i[0],s]),Br.and([i[0],a])]);break;default:o=Br.or([Br.and([Br.or(i),s]),Br.and([Br.or(i),a])])}const c=await P.where(o).limit(1).get();return c&&c.data&&c.data[0]?{code:10005}:{code:0}}const $r=uniCloud.database().command;const Hr=uniCloud.database();const Kr=uniCloud.database().command;const Gr=uniCloud.database();const Qr=uniCloud.database();async function Xr(e){if(!e.openid||!e.access_token)throw new Error(this.t("config-param-required",{param:"openid, access_token"}));return function(e,t){const r={0:"",4e3:"缺失参数",4001:"apiKey不存在",4002:"sign校验不通过",4003:"appid不存在",4004:"应用未开通一键登录服务",4005:"应用开通的一键登录服务正在审核中",4006:"服务空间不在白名单中",4100:"账户余额不足",5e3:"获取手机号失败,请稍后重试(或其他未知错误)"};return{...e,msg:r[e.code]?"[getPhoneNumber] 获取手机号: "+r[e.code]:e.errMsg}}(await uniCloud.getPhoneNumber({provider:"univerify",...e}))}const Yr=uniCloud.database();const zr=uniCloud.database();const Wr=uniCloud.database();const Jr=uniCloud.database().command;const Zr=uniCloud.database();const en=uniCloud.database();const tn=uniCloud.database();const rn=uniCloud.database();const nn=uniCloud.database();const on=uniCloud.database();const sn=uniCloud.database();const an={"mobile-code":function(e){return!(!e.service||!e.service.sms)},univerify:function(e){return!(!e.service||!e.service.univerify)},weixin:function(e){return!!(e.oauth&&e.oauth.weixin&&e.oauth.weixin.appsecret)},qq:function(e){return!!(e.oauth&&e.oauth.qq&&e.oauth.qq.appsecret)},apple:function(e){return!!(e.oauth&&e.oauth.apple&&e.oauth.apple.bundleId)},alipay:function(e){return!!(e.oauth&&e.oauth.alipay&&e.oauth.alipay.privateKey)}};const cn=uniCloud.database();var un=Object.freeze({__proto__:null,addUser:async function({username:e,nickname:t,password:r,mobile:n,email:i,role:o=[],authorizedApp:s=[]}={}){const a=O.command,c=[];if(!e&&!n&&!i)throw new Error("username, mobile or email required");let u;if(e&&c.push({username:e}),n&&c.push({mobile:n,mobile_confirmed:1}),i&&c.push({email:i,email_confirmed:1}),s.length>0){u=a.and(a.or(c),a.or({dcloud_appid:a.in(s)},{dcloud_appid:a.exists(!1)}));if((await P.where(u).limit(1).get()).data.length>0)return{code:10201,messageValues:{type:this.t("username")}}}const d={role:o,nickname:t,dcloud_appid:s,register_date:Date.now()};if(e&&(d.username=e),r){const{passwordHash:e,version:t}=this.encryptPwd(r);d.password=e,t&&(d.password_secret_version=t)}return n&&(d.mobile=n,d.mobile_confirmed=1),i&&(d.email=i,d.email_confirmed=1),{code:0,uid:(await P.add(d)).id}},getUserInfo:async function({uid:e,field:t}){if(!e)return{code:N,messageValues:{param:this.t("user-id")}};let r;if(t&&t.length){const n={};for(let e=0;evoid 0===e.dcloud_appid||e.dcloud_appid.includes(this.context.APPID));if(0===i.length)return{code:10002};if(i.length>1)return{code:10005};const o=i[0]._id;return this.resetPwd({uid:o,password:r})},setAvatar:async function(e){return await P.doc(e.uid).update({avatar:e.avatar}),{code:0,msg:""}},updatePwd:async function(e){const t=await P.doc(e.uid).get();if(t&&t.data&&t.data.length>0){if(0===this._checkPwd(t.data[0],e.oldPassword).code){const{passwordHash:r,version:n}=this.encryptPwd(e.newPassword),i={password:r,token:[]};n&&(i.password_secret_version=n);return E("upRes",await P.doc(t.data[0]._id).update(i)),{code:0,msg:""}}return{code:40202}}return{code:40201}},updateUser:async function(e){const t=e.uid;if(!t)return{code:N,messageValues:{param:this.t("user-id")}};delete e.uid;const{username:r,email:n}=e,{usernameToLowerCase:i,emailToLowerCase:o}=this._getConfig();let s=r&&r.trim(),a=n&&n.trim();return s&&(i&&(s=s.toLowerCase()),e.username=s),a&&(o&&(a=a.toLowerCase()),e.email=a),E("update -> upRes",await P.doc(t).update(e)),{code:0,msg:""}},banAccount:async function({uid:e}={}){return $.call(this,{uid:e,status:B})},unbanAccount:async function({uid:e}={}){return $.call(this,{uid:e,status:M})},closeAccount:async function({uid:e}={}){return $.call(this,{uid:e,status:F})},openAccount:async function({uid:e}={}){return $.call(this,{uid:e,status:M})},_getAlipayApi:function(){const e=this.context.PLATFORM,t=this._getConfig();if(!t.oauth||!t.oauth.alipay)throw new Error(this.t("config-param-require",{param:e+".alipay"}));return["appid","privateKey"].forEach(r=>{if(!t.oauth.alipay[r])throw new Error(this.t("config-param-require",{param:`${e}.alipay.${r}`}))}),Ur({...t.oauth.alipay})},_getValidInviteCode:async function({inviteCode:e}={}){if(e){return await Mr(e)?{code:0,inviteCode:e}:{code:80401}}return async function(){let e,t=10,r=!1;for(;t>0&&!r;){t--,e=Vr();if(await Mr(e)){r=!0;break}}return r?{code:0,inviteCode:e}:{code:80402}}()},_addUser:async function(e,{needPermission:t,autoSetDcloudAppid:r=!0}={}){const n=this._getConfig(),i={...e,dcloud_appid:r?[this.context.APPID]:[],register_date:Date.now()},o=(await P.add(i)).id;let s;if(n.removePermissionAndRoleFromToken)s=await this.createToken({uid:o,needPermission:t});else{const t=e.role||[];let r;r=0===t.length||t.includes("admin")?[]:await this._getPermissionListByRoleList(t),s=await this.createToken({uid:o,role:t,permission:r})}const{token:a,tokenExpired:c}=s;return await P.doc(o).update({token:[a]}),{token:a,tokenExpired:c,uid:o,type:"register",userInfo:Object.assign({},i,{token:[a]})}},_loginExec:async function(e,t={}){if(e.status===B)return{code:10001};if(e.status===F)return{code:10006};const r=this._getConfig();let n=e.token||[];"string"==typeof n&&(n=[n]);const i=this._getExpiredToken(n);let o;if(n=n.filter(e=>-1===i.indexOf(e)),r.removePermissionAndRoleFromToken){const r=t.needPermission;o=await this.createToken({uid:e._id,needPermission:r})}else{const t=e.role||[];let r;r=0===t.length||t.includes("admin")?[]:await this._getPermissionListByRoleList(t),o=await this.createToken({uid:e._id,role:t,permission:r})}const{token:s,tokenExpired:a}=o;n.push(s),e.token=n;const c={last_login_date:Date.now(),last_login_ip:this.context.CLIENTIP,token:n,...t.extraData};await P.doc(e._id).update(c);const u=Object.assign({},e,c);return{code:0,msg:"",token:s,uid:u._id,username:u.username,type:"login",userInfo:u,tokenExpired:a}},_registerExec:async function(e,{needPermission:t,autoSetDcloudAppid:r=!0}={}){const{my_invite_code:n}=e;if(this._getConfig().autoSetInviteCode||n){const t=await this._getValidInviteCode({inviteCode:n});if(t.code)return t;e.my_invite_code=t.inviteCode}const{PLATFORM:i,appId:o,appid:s,APPID:a,uniPlatform:c,appName:u,appVersion:d,appVersionCode:p,channel:l,clientIP:f,CLIENTIP:m,OS:h,osName:g}=this.context;return e.register_env={appid:o||s||a||"",uni_platform:c||i||"",os_name:g||h||"",app_name:u||"",app_version:d||"",app_version_code:p||"",channel:l?l+"":"",client_ip:f||m||""},{code:0,msg:"",...await this._addUser(e,{needPermission:t,autoSetDcloudAppid:r})}},_getWeixinApi:function(){const e=this.context.PLATFORM,t=this._getConfig();if(!t.oauth||!t.oauth.weixin)throw new Error(this.t("config-param-require",{param:e+".weixin"}));return["appid","appsecret"].forEach(r=>{if(!t.oauth.weixin[r])throw new Error(this.t("config-param-require",{param:`${e}.weixin.${r}`}))}),qr({...t.oauth.weixin})},_getQQApi:function(){const e=this.context.PLATFORM,t=this._getConfig();if(!t.oauth||!t.oauth.qq)throw new Error(this.t("config-param-require",{param:e+".qq"}));return["appid","appsecret"].forEach(r=>{if(!t.oauth.qq[r])throw new Error(this.t("config-param-require",{param:`${e}.qq.${r}`}))}),Nr({...t.oauth.qq})},_getMatchedUser:function(e,t){if(0===e.length)return{code:10002};let r;const n={},i={};for(let r=e.length-1;r>=0;r--){const o=e[r];for(let s=0;s0?{code:10003,messageValues:{target:"用户"}}:{code:0,msg:"",userMatched:r,fieldMatched:s,isFallbackValueMatched:!!s&&i[s]}},_getCurrentAppUser:function(e){const t=this.context.APPID;return e.filter(e=>void 0===e.dcloud_appid||null===e.dcloud_appid||e.dcloud_appid.indexOf(t)>-1||e.dcloud_appid.indexOf(null)>-1)},_checkLoginUserList:function(e){if(e&&1!==e.length)return e[0].status===F?{code:10006}:{code:10005}},setAuthorizedAppLogin:async function({uid:e,dcloudAppidList:t}={}){if("array"!==m(t))return{code:U,messageValues:{param:"dcloudAppidList",reason:this.t("type-array-required",{param:this.t("dcloud-appid-list")})}};if(t&&0!==t.length){const r=await Fr.bind(this)({uid:e,dcloudAppidList:t});if(r.code)return r}return await P.doc(e).update({dcloud_appid:Br.set(t)}),{code:0}},authorizeAppLogin:async function({uid:e,dcloudAppid:t}={}){const r=await Fr.bind(this)({uid:e,dcloudAppidList:[t]});return r.code?r:(await P.doc(e).update({dcloud_appid:Br.push(t)}),{code:0})},forbidAppLogin:async function({uid:e,dcloudAppid:t}={}){return e?(await P.doc(e).update({dcloud_appid:Br.pull(t)}),{code:0}):{code:N,messageValues:{param:this.t("user-id")}}},acceptInvite:async function({uid:e,inviteCode:t}){const r=await P.where({_id:$r.neq(e),inviter_uid:$r.not($r.all([e])),my_invite_code:t}).get();if(1!==r.data.length)return{code:80501,msg:"邀请码无效"};const n=[r.data[0]._id].concat(r.data[0].inviter_uid||[]),i=await P.doc(e).field({my_invite_code:!0,inviter_uid:!0}).get();if(0===i.data.length)return{code:80502};if(i.data[0].inviter_uid&&i.data[0].inviter_uid.length>0)return{code:80503,msg:"邀请码不可修改"};const o=Date.now();return await P.doc(e).update({inviter_uid:n,invite_time:o}),await P.where({inviter_uid:e}).update({inviter_uid:$r.push(n)}),{code:0,msg:""}},getInvitedUser:async function({uid:e,level:t=1,limit:r=20,offset:n=0,needTotal:i=!1}){const o={code:0,msg:"",invitedUser:(await P.where({["inviter_uid."+(t-1)]:e}).field({_id:!0,username:!0,mobile:!0,invite_time:!0}).orderBy("invite_time","desc").skip(n).limit(r).get()).data};if(i){const r=await P.where({["inviter_uid."+(t-1)]:e}).count();o.total=r.total}return o},setUserInviteCode:async function({uid:e,myInviteCode:t}){const r=await this._getValidInviteCode({inviteCode:t});return r.code?r:(await P.doc(e).update({my_invite_code:r.inviteCode}),{code:0,msg:"",myInviteCode:r.inviteCode})},loginByAlipay:async function(e){"string"==typeof e&&(e={code:e});const{needPermission:t,code:r,myInviteCode:n,role:i,type:o}=e,{openid:s}=await this._getAlipayApi().code2Session(r);if(!s)return{code:10501,messageValues:{account:this.t("alipay-account")}};let a=await P.where({ali_openid:s}).get();if(a=this._getCurrentAppUser(a.data),a&&a.length>0){if("register"===o)return{code:10502,messageValues:{type:this.t("alipay-account")}};if(1!==a.length)return{code:10005};const e=a[0],r=await this._loginExec(e,{needPermission:t});if(0!==r.code)return r;const{userInfo:n}=r;return{...r,openid:s,mobileConfirmed:1===n.mobile_confirmed,emailConfirmed:1===n.email_confirmed}}{if("login"===o)return{code:10503,messageValues:{type:this.t("alipay-account")}};const e={ali_openid:s};e.my_invite_code=n,e.role=i;const r=await this._registerExec(e,{needPermission:t});return 0!==r.code?r:{...r,openid:s,mobileConfirmed:!1,emailConfirmed:!1}}},loginByEmail:async function(e){let{email:t,code:r,password:n,myInviteCode:i,type:o,needPermission:s,role:a}=e||{};if(t=t&&t.trim(),!t)return{code:N,messageValues:{param:"邮箱"}};const{emailToLowerCase:c}=this._getConfig();let u=t;c&&(u=t.toLowerCase());const d=await this.verifyCode({email:u,code:r,type:o||"login"});if(0!==d.code)return d;let p={email:t,email_confirmed:1};const l={field:"email",value:t},f=Hr.command;u!==t&&(p=f.or(p,{email:u,email_confirmed:1}),l.fallbackValue=u);let m=await P.where(p).get();if(m=this._getCurrentAppUser(m.data),m&&m.length>0){if("register"===o)return{code:10301,messageValues:{type:"邮箱"}};const e=this._getMatchedUser(m,[l]);if(e.code)return e;const{userMatched:t}=e,r=await this._loginExec(t,{needPermission:s});return 0!==r.code?r:{...r,email:u}}{if("login"===o)return{code:10302,messageValues:{type:"邮箱"}};const e={email:u,email_confirmed:1},t=n&&n.trim();if(t){const{passwordHash:r,version:n}=this.encryptPwd(t);e.password=r,n&&(e.password_secret_version=n)}e.my_invite_code=i,e.role=a;const r=await this._registerExec(e,{needPermission:s});return 0!==r.code?r:{...r,email:u}}},loginBySms:async function({mobile:e,code:t,password:r,inviteCode:n,myInviteCode:i,type:o,needPermission:s,role:a}){if(!(e=e&&e.trim()))return{code:N,messageValues:{param:this.t("mobile")}};const c=this._getConfig();if(c.forceInviteCode&&!o)throw new Error(this.t("login-with-invite-type-required"));const u=await this.verifyCode({mobile:e,code:t,type:o||"login"});if(0!==u.code)return u;const d={mobile:e,mobile_confirmed:1};let p=await P.where(d).get();if(p=this._getCurrentAppUser(p.data),p&&p.length>0){if("register"===o)return{code:10201,messageValues:{type:this.t("mobile")}};if(1!==p.length)return{code:10005};const t=p[0],r=await this._loginExec(t,{needPermission:s});return 0!==r.code?r:{...r,mobile:e}}{const t=Date.now();if("login"===o)return{code:10202,messageValues:{type:this.t("mobile")}};const u={mobile:e,mobile_confirmed:1,register_ip:this.context.CLIENTIP,register_date:t},d=r&&r.trim();if(d){const{passwordHash:e,version:t}=this.encryptPwd(d);u.password=e,t&&(u.password_secret_version=t)}if(n){const e=await P.where({my_invite_code:n}).get();if(1!==e.data.length)return{code:10203};u.inviter_uid=[e.data[0]._id].concat(e.data[0].inviter_uid||[]),u.invite_time=t}else if(c.forceInviteCode)return{code:10203};u.my_invite_code=i,u.role=a;const p=await this._registerExec(u,{needPermission:s});return 0!==p.code?p:{...p,mobile:e}}},loginByWeixin:async function(e){"string"==typeof e&&(e={code:e});const{needPermission:t,platform:r,code:n,myInviteCode:i,role:o,type:s}=e,a=r||this.context.PLATFORM,c=function({clientPlatform:e,userAgent:t}={}){switch(e){case"app":case"app-plus":return"app";case"mp-weixin":return"mp";case"h5":case"web":return t.indexOf("MicroMessenger")>-1?"h5":"web";default:throw new Error("Unsupported weixin platform")}}({clientPlatform:a,userAgent:this.context.CLIENTUA}),u="mp-weixin"===a,{openid:d,unionid:p,sessionKey:l,accessToken:f,refreshToken:m,expired:h}=await this._getWeixinApi()[u?"code2Session":"getOauthAccessToken"](n);if(!d)return{code:10401,messageValues:{account:"微信openid"}};const g={dcloudAppid:this.context.APPID,openid:d,platform:"weixin-"+c},y=require("uni-open-bridge-common");let w;u?(w={sessionKey:l},await y.setSessionKey(g,{session_key:l},2592e3)):(w={accessToken:f,refreshToken:m,accessTokenExpired:h},await y.setUserAccessToken(g,{access_token:f,refresh_token:m,access_token_expired:h},2592e3));const _=Gr.command,v=[{wx_openid:{[a]:d}}];p&&v.push({wx_unionid:p});let b=await P.where(_.or(...v)).get();if(b=this._getCurrentAppUser(b.data),b&&b.length>0){if("register"===s)return{code:10402,messageValues:{type:this.t("wechat-account")}};if(1!==b.length)return{code:10005};const e=b[0],r={wx_openid:{[a]:d}};p&&(r.wx_unionid=p);const n=await this._loginExec(e,{needPermission:t,extraData:r});if(0!==n.code)return n;const{userInfo:i}=n;return{...n,openid:d,unionid:p,...w,mobileConfirmed:1===i.mobile_confirmed,emailConfirmed:1===i.email_confirmed}}{if("login"===s)return{code:10403,messageValues:{type:this.t("wechat-account")}};const e={wx_openid:{[a]:d},wx_unionid:p};e.my_invite_code=i,e.role=o;const r=await this._registerExec(e,{needPermission:t});return 0!==r.code?r:{...r,openid:d,unionid:p,...w,mobileConfirmed:!1,emailConfirmed:!1}}},loginByQQ:async function({code:e,accessToken:t,accessTokenExpired:r,myInviteCode:n,needPermission:i,role:o,type:s}={}){const a=this.context.PLATFORM,c="mp-qq"===a,{openid:u,unionid:d,sessionKey:p}=await this._getQQApi()[c?"code2Session":"getOpenidByToken"]({code:e,accessToken:t});if(!u)return{code:10801,messageValues:{account:"qq openid"}};const l=function({clientPlatform:e}={}){switch(e){case"app":case"app-plus":return"app";case"mp-qq":return"mp";default:throw new Error("Unsupported qq platform")}}({clientPlatform:a}),f={dcloudAppid:this.context.APPID,openid:u,platform:"qq-"+l},m=require("uni-open-bridge-common");let h;c?(h={sessionKey:p},await m.setSessionKey(f,{session_key:p},2592e3)):(h={accessToken:t,accessTokenExpired:r},await m.setUserAccessToken(f,{access_token:t,access_token_expired:r},r?Math.floor((r-Date.now())/1e3):2592e3));const g=Qr.command,y=[{qq_openid:{[a]:u}}];d&&y.push({qq_unionid:d});let w=await P.where(g.or(...y)).get();if(w=this._getCurrentAppUser(w.data),w&&w.length>0){if("register"===s)return{code:10802,messageValues:{type:this.t("qq-account")}};if(1!==w.length)return{code:10005};const e=w[0],t={qq_openid:{[a]:u}};d&&(t.qq_unionid=d);const r=await this._loginExec(e,{needPermission:i,extraData:t});if(0!==r.code)return r;const{userInfo:n}=r;return{...r,openid:u,unionid:d,...h,mobileConfirmed:1===n.mobile_confirmed,emailConfirmed:1===n.email_confirmed}}{if("login"===s)return{code:10803,messageValues:{type:this.t("qq-account")}};const e={qq_openid:{[a]:u},qq_unionid:d};e.my_invite_code=n,e.role=o;const t=await this._registerExec(e);return 0!==t.code?t:{...t,openid:u,unionid:d,...h,mobileConfirmed:!1,emailConfirmed:!1}}},loginByUniverify:async function({openid:e,access_token:t,password:r,inviteCode:n,myInviteCode:i,type:o,needPermission:s,role:a}){const c=this._getConfig(),u=c&&c.service&&c.service.univerify;if(!u)throw new Error(this.t("uni-verify-config-required"));if(c.forceInviteCode&&!o)throw new Error(this.t("login-with-invite-type-required"));const d=await Xr.bind(this)({...u,openid:e,access_token:t});if(0!==d.code)return d;const p=String(d.phoneNumber);let l=await P.where({mobile:p,mobile_confirmed:1}).get();if(l=this._getCurrentAppUser(l.data),l&&l.length>0){if("register"===o)return{code:10601,messageValues:{type:this.t("mobile")}};if(1!==l.length)return{code:10005};const e=l[0],t=await this._loginExec(e,{needPermission:s});return 0!==t.code?t:{...t,mobile:p}}if("login"===o)return{code:10602,messageValues:{type:this.t("mobile")}};const f=Date.now(),m={mobile:p,my_invite_code:i,mobile_confirmed:1,role:a},h=r&&r.trim();if(h){const{passwordHash:e,version:t}=this.encryptPwd(h);m.password=e,t&&(m.password_secret_version=t)}if(n){let e=await P.where({my_invite_code:n}).get();if(1!==e.data.length)return{code:10203};e=e.data[0],m.inviter_uid=[e._id].concat(e.inviter_uid||[]),m.invite_time=f}else if(c.forceInviteCode)return{code:10203};m.my_invite_code=i;const g=await this._registerExec(m,{needPermission:s});return 0!==g.code?g:{...g,mobile:p}},loginByApple:async function({nickName:e,fullName:t,identityToken:r,myInviteCode:n,type:i,needPermission:o,role:s}){const a=this._getConfig(),c=a&&a.oauth&&a.oauth.apple,u=c&&c.bundleId;if(!u)throw new Error(this.t("config-param-require",{param:"(app || app-plus).apple.bundleId"}));if(!r)return{code:N,messageValues:{param:"identityToken"}};t=e||(t&&Object.keys(t).length>0?t.familyName+t.givenName:"");const{code:d,msg:p}=await Lr().verifyIdentityToken(r);if(0!==d)return{code:d,msg:p,messageValues:{account:this.t("apple-account")}};const{iss:l,sub:f,aud:m,email:h}=p;if("https://appleid.apple.com"!==l)return{code:10706,messageValues:{account:this.t("apple-account")}};if(!f)return{code:10701,messageValues:{account:this.t("apple-account")}};if(u!==m)return{code:10702,messageValues:{account:this.t("apple-account")}};const g=t||"User-"+(h?h.split("@")[0]:Math.random().toString(32).slice(2));let y=await P.where({apple_openid:f}).get();if(y=this._getCurrentAppUser(y.data),y&&y.length>0){if("register"===i)return{code:10703,messageValues:{type:this.t("apple-account")}};if(1!==y.length)return{code:10005};const e=y[0],t=await this._loginExec(e,{needPermission:o});return 0!==t.code?t:{...t,openid:f}}if("login"===i)return{code:10704,messageValues:{type:this.t("apple-account")}};const w={nickname:g,apple_openid:f,my_invite_code:n,role:s},_=await this._registerExec(w,{needPermission:o});return 0!==_.code?_:{..._,openid:f}},login:async function({username:e,password:t,queryField:r=[],needPermission:n}){const i=Yr.command,o=[];r&&r.length||(r=["username"]),r.length>1&&console.warn(this.t("query-field-warning"));const{usernameToLowerCase:s,emailToLowerCase:a,passwordErrorLimit:c,passwordErrorRetryTime:u}=this._getConfig(),d={email:{email_confirmed:1},mobile:{mobile_confirmed:1}},p={},l=e&&e.trim();if(!l)return{code:N,messageValues:{param:this.t("username")}};s&&(p.username=l.toLowerCase()),a&&(p.email=l.toLowerCase());const f=[];r.forEach(t=>{o.push({[t]:e,...d[t]});const r={field:t,value:e};"username"===t&&p.username!==e?(o.push({[t]:p.username,...d[t]}),r.fallbackValue=p.username):"email"===t&&p.email!==e&&(o.push({[t]:p.email,...d[t]}),r.fallbackValue=p.email),f.push(r)});let m=await P.where(i.or(...o)).get();m=this._getCurrentAppUser(m.data);const h=this.context.CLIENTIP,g=this._getMatchedUser(m,f);if(g.code)return g;const{userMatched:y}=g;let w=y.login_ip_limit||[];w=w.filter(e=>e.last_error_time>Date.now()-1e3*u);let _=w.find(e=>e.ip===h);if(_&&_.error_times>=c)return{code:10103};const v=t&&t.trim();if(!v)return{code:N,messageValues:{param:"密码"}};const b=this._checkPwd(y,v);if(0===b.code){const e=w.indexOf(_);e>-1&&w.splice(e,1);const t={login_ip_limit:w},{passwordHash:r,passwordVersion:i}=b;r&&i&&(t.password=r,t.password_secret_version=i);const o=await this._loginExec(y,{needPermission:n,extraData:t});return o.code,o}return _?(_.error_times++,_.last_error_time=Date.now()):(_={ip:h,error_times:1,last_error_time:Date.now()},w.push(_)),await P.doc(y._id).update({login_ip_limit:w}),{code:10102,msg:"密码错误"}},register:async function(e){const t=[],r=[{name:"username",desc:this.t("username")},{name:"email",desc:this.t("email"),extraCond:{email_confirmed:1}},{name:"mobile",desc:this.t("mobile"),extraCond:{mobile_confirmed:1}}],{usernameToLowerCase:n,emailToLowerCase:i}=this._getConfig();r.forEach(r=>{const o=r.name;let s=e[o]&&e[o].trim();s?(("username"===r.name&&n||"email"===r.name&&i)&&(s=s.toLowerCase()),e[o]=s,t.push({[o]:s,...r.extraCond})):delete e[o]});const{username:o,email:s,mobile:a,myInviteCode:c,needPermission:u,autoSetDcloudAppid:d=!0}=e;if("needPermission"in e&&delete e.needPermission,"autoSetDcloudAppid"in e&&delete e.autoSetDcloudAppid,0===t.length)return{code:20101,messageValues:{param:this.t("user-unique-param")}};const p=zr.command;let l=await P.where(p.or(...t)).get();if(l=this._getCurrentAppUser(l.data),l&&l.length>0){const t=l[0];if(t.status===F)return{code:10006};for(let n=0;nt[e]===i.extraCond[e])),t[i.name]===e[i.name]&&o)return{code:20102,messageValues:{type:i.desc}}}}const f=e.password&&e.password.trim();if(!f)return{code:N,messageValues:{param:this.t("password")}};const{passwordHash:m,version:h}=this.encryptPwd(f);e.password=m,h&&(e.password_secret_version=h),e.my_invite_code=c,delete e.myInviteCode;const g=await this._registerExec(e,{needPermission:u,autoSetDcloudAppid:d});return 0!==g.code?g:{...g,username:o,email:s,mobile:a}},logout:async function(e){const t=await this.checkToken(e);if(t.code)return t;const r=Wr.command;return await P.doc(t.uid).update({token:r.pull(e)}),{code:0,msg:""}},getRoleByUid:async function({uid:e}){if(!e)return{code:N,messageValues:{param:this.t("user-id")}};const t=await P.doc(e).get();return 0===t.data.length?{code:L}:{code:0,msg:"",role:t.data[0].role||[]}},getPermissionByRole:async function({roleID:e}){if(!e)return{code:N,messageValues:{param:"roleID"}};if("admin"===e){return{code:0,msg:"",permission:(await D.limit(1e3).get()).data.map(e=>e.permission_id)}}const t=await j.where({role_id:e}).get();return 0===t.data.length?{code:V}:{code:0,msg:"",permission:t.data[0].permission||[]}},getPermissionByUid:async function({uid:e}={}){const t=await P.aggregate().match({_id:e}).project({role:!0}).unwind("$role").lookup({from:"uni-id-roles",localField:"role",foreignField:"role_id",as:"roleDetail"}).unwind("$roleDetail").replaceRoot({newRoot:"$roleDetail"}).end(),r=[],n=[];return t.data.forEach(e=>{n.push(e.role_id),r.push(...e.permission)}),{code:0,msg:"",role:n,permission:A(r)}},bindRole:async function({uid:e,roleList:t,reset:r=!1}){const n={};return"string"==typeof t&&(t=[t]),n.role=r?t:Jr.push(t),await P.doc(e).update(n),{code:0,msg:""}},bindPermission:async function({roleID:e,permissionList:t,reset:r=!1}){const n={};return"string"==typeof t&&(t=[t]),n.permission=r?t:Jr.push(t),await j.where({role_id:e}).update(n),{code:0,msg:""}},unbindRole:async function({uid:e,roleList:t}){return"string"==typeof t&&(t=[t]),await P.doc(e).update({role:Jr.pull(Jr.in(t))}),{code:0,msg:""}},unbindPermission:async function({roleID:e,permissionList:t}){return"string"==typeof t&&(t=[t]),await j.where({role_id:e}).update({permission:Jr.pull(Jr.in(t))}),{code:0,msg:""}},addRole:async function({roleID:e,roleName:t,comment:r,permission:n=[]}){return e?"admin"===e?{code:U,messageValues:{param:"roleID",reason:this.t("add-role-admin-is-not-allowed")}}:(await j.add({role_id:e,role_name:t,comment:r,permission:n,create_date:Date.now()}),{code:0,msg:""}):{code:N,messageValues:{param:this.t("role-id")}}},addPermission:async function({permissionID:e,permissionName:t,comment:r}){return e?(await D.add({permission_id:e,permission_name:t,comment:r,create_date:Date.now()}),{code:0,msg:""}):{code:N,messageValues:{param:this.t("permission-id")}}},getRoleList:async function({limit:e=20,offset:t=0,needTotal:r=!0}){const n={code:0,msg:"",roleList:(await j.skip(t).limit(e).get()).data};if(r){const{total:e}=await j.where({_id:Jr.exists(!0)}).count();n.total=e}return n},getRoleInfo:async function(e){const t=await j.where({role_id:e}).get();return 0===t.data.length?{code:V}:{code:0,...t.data[0]}},updateRole:async function({roleID:e,roleName:t,comment:r,permission:n}){return e?(await j.where({role_id:e}).update({role_name:t,comment:r,permission:n}),{code:0,msg:""}):{code:N,messageValues:{param:this.t("role-id")}}},deleteRole:async function({roleID:e}){const t=m(e);if("string"===t)e=[e];else if("array"!==t)throw new Error("typeof roleID must be array or string");return await j.where({role_id:Jr.in(e)}).remove(),await P.where({role:Jr.elemMatch(Jr.in(e))}).update({role:Jr.pullAll(e)}),{code:0,msg:""}},getPermissionList:async function({limit:e=20,offset:t=0,needTotal:r=!0}){const n={code:0,msg:"",permissionList:(await D.skip(t).limit(e).get()).data};if(r){const{total:e}=await D.where({_id:Jr.exists(!0)}).count();n.total=e}return n},getPermissionInfo:async function(e){const t=await D.where({permission_id:e}).get();return 0===t.data.length?{code:N,messageValues:{param:this.t("permission-id")}}:{code:0,...t.data[0]}},updatePermission:async function({permissionID:e,permissionName:t,comment:r}){return e?(await D.where({permission_id:e}).update({permission_name:t,comment:r}),{code:0,msg:""}):{code:N,messageValues:{param:this.t("permission-id")}}},deletePermission:async function({permissionID:e}){const t=m(e);if("string"===t)e=[e];else if("array"!==t)throw new Error("typeof permissionID must be array or string");return await D.where({permission_id:Jr.in(e)}).remove(),await j.where({permission:Jr.elemMatch(Jr.in(e))}).update({permission:Jr.pullAll(e)}),{code:0,msg:""}},bindAlipay:async function({uid:e,code:t,platform:r}){const n=r||this.context.PLATFORM,{openid:i}=await this._getAlipayApi({platform:n}).code2Session(t);if(!i)return{code:60401,messageValues:{account:this.t("alipay-account")}};let o=await P.where({ali_openid:i}).get();return o=this._getCurrentAppUser(o.data),o&&o.length>0?{code:60402,messageValues:{type:this.t("alipay-account")}}:(await P.doc(e).update({ali_openid:i}),{code:0,openid:i,msg:""})},bindEmail:async function(e){let{uid:t,email:r,code:n}=e||{};if(r=r&&r.trim(),!r)return{code:N,messageValues:{param:this.t("email")}};if(!n)return{code:N,messageValues:{param:this.t("verify-code")}};const{emailToLowerCase:i}=this._getConfig();i&&(r=r.toLowerCase());let o=await P.where({email:r,email_confirmed:1}).get();if(o=this._getCurrentAppUser(o.data),o&&o.length>0)return{code:60201,messageValues:{type:this.t("email")}};const s=await this.verifyCode({email:r,code:n,type:"bind"});return 0!==s.code?s:(await P.doc(t).update({email:r,email_confirmed:1}),{code:0,msg:"",email:r})},bindMobile:async function(e){let{uid:t,mobile:r,code:n,openid:i,access_token:o,type:s="sms"}=e||{};if("univerify"===s){const e=this._getConfig(),t=e&&e.service&&e.service.univerify;if(!t)throw new Error("请在config.json中配置service.univerify下一键登录相关参数");const n=await Xr.bind(this)({...t,openid:i,access_token:o});if(0!==n.code)return n;r=""+n.phoneNumber}let a=await P.where({mobile:r,mobile_confirmed:1}).get();if(a=this._getCurrentAppUser(a.data),a&&a.length>0)return{code:60101,messageValues:{type:"手机号"}};if("sms"===s&&"code"in e){if(!r)return{code:N,messageValues:{param:this.t("mobile")}};if(!n)return{code:N,messageValues:{param:this.t("verify-code")}};const e=await this.verifyCode({mobile:r,code:n,type:"bind"});if(0!==e.code)return e}return await P.doc(t).update({mobile:r,mobile_confirmed:1}),{code:0,msg:"",mobile:r}},bindWeixin:async function({uid:e,code:t,platform:r}){const n=r||this.context.PLATFORM,i="mp-weixin"===n,{openid:o,unionid:s,sessionKey:a,accessToken:c,refreshToken:u,expired:d}=await this._getWeixinApi({platform:n})[i?"code2Session":"getOauthAccessToken"](t);if(!o)return{code:60301,messageValues:{account:"微信openid"}};const p=Zr.command,l=[{wx_openid:{[n]:o}}];s&&l.push({wx_unionid:s});let f=await P.where(p.or(...l)).get();if(f=this._getCurrentAppUser(f.data),f&&f.length>0)return{code:60302,messageValues:{type:this.t("wechat-account")}};const m={wx_openid:{[n]:o}};let h;return s&&(m.wx_unionid=s),await P.doc(e).update(m),h=i?{sessionKey:a}:{accessToken:c,refreshToken:u,accessTokenExpired:d},{code:0,msg:"",openid:o,unionid:s,...h}},bindQQ:async function({uid:e,code:t,accessToken:r,platform:n}={}){const i=n||this.context.PLATFORM,o="mp-qq"===i,{openid:s,unionid:a,sessionKey:c}=await this._getQQApi()[o?"code2Session":"getOpenidByToken"]({code:t,accessToken:r});if(!s)return{code:60501,messageValues:{account:"qq openid"}};const u=en.command,d=[{qq_openid:{[i]:s}}];a&&d.push({qq_unionid:a});let p=await P.where(u.or(...d)).get();if(p=this._getCurrentAppUser(p.data),p&&p.length>0)return{code:60502,messageValues:{type:this.t("qq-account")}};const l={qq_openid:{[i]:s}};return a&&(l.qq_unionid=a),await P.doc(e).update(l),{code:0,msg:"",openid:s,unionid:a,...{accessToken:r,sessionKey:c}}},unbindAlipay:async function(e){const t=tn.command,r=await P.doc(e).update({ali_openid:t.remove()});return E("upRes:",r),1===r.updated?{code:0,msg:""}:{code:70401}},unbindEmail:async function(e){let{uid:t,email:r,code:n}=e||{};if(r=r&&r.trim(),!t||!r)return{code:N,messageValues:{param:t?this.t("email"):this.t("user-id")}};const{emailToLowerCase:i}=this._getConfig();if("code"in e){const e=await this.verifyCode({email:r,code:n,type:"unbind"});if(0!==e.code)return e}const o=rn.command;let s={_id:t,email:r};if(i){const e=r.toLowerCase();e!==r&&(s=o.or(s,{_id:t,email:e}))}return 1===(await P.where(s).update({email:o.remove(),email_confirmed:o.remove()})).updated?{code:0,msg:""}:{code:70201}},unbindMobile:async function(e){const{uid:t,mobile:r,code:n}=e||{};if("code"in e){const e=await this.verifyCode({mobile:r,code:n,type:"unbind"});if(0!==e.code)return e}const i=nn.command;return 1===(await P.where({_id:t,mobile:r}).update({mobile:i.remove(),mobile_confirmed:i.remove()})).updated?{code:0,msg:""}:{code:70101}},unbindWeixin:async function(e){const t=on.command,r=await P.doc(e).update({wx_openid:t.remove(),wx_unionid:t.remove()});return E("upRes:",r),1===r.updated?{code:0,msg:""}:{code:70301}},unbindQQ:async function(e){const t=sn.command,r=await P.doc(e).update({qq_openid:t.remove(),qq_unionid:t.remove()});return E("upRes:",r),1===r.updated?{code:0,msg:""}:{code:70501}},getSupportedLoginType:function({appid:e,platform:t}={}){if(!e||!t)throw new Error("Parameter appid and platform is required");const r=this._getConfig({appid:e,platform:t}),n=["username-password","mobile-password","email-password"];for(const e in an)an[e](r)&&n.push(e);return{supportedLoginType:n}},code2SessionAlipay:async function(e){let t=e;"string"==typeof e&&(t={code:e});try{const e=t.platform||this.context.PLATFORM,r=await this._getAlipayApi({platform:e}).code2Session(t.code);return r.openid?{code:0,msg:"",...r}:{code:80701,messageValues:{account:this.t("alipay-account")}}}catch(e){return console.error(e),{code:80702,messageValues:{account:this.t("alipay-account")}}}},code2SessionWeixin:async function(e){let t=e;"string"==typeof e&&(t={code:e});try{const e=t.platform||this.context.PLATFORM,r=await this._getWeixinApi({platform:e})["mp-weixin"===e?"code2Session":"getOauthAccessToken"](t.code);return r.openid?{code:0,msg:"",...r}:{code:80601,messageValues:{account:"微信openid"}}}catch(e){return console.error(e),{code:80602,messageValues:{account:"微信openid"}}}},verifyAppleIdentityToken:async function({identityToken:e,platform:t}){const r=t||this.context.PLATFORM,{code:n,msg:i}=await Lr({clientType:r}).verifyIdentityToken(e);return 0!==n?{code:n,msg:i}:{code:n,msg:"验证通过",...i}},wxBizDataCrypt:async function({code:e,sessionKey:r,encryptedData:n,iv:i}){if(!n)return{code:N,messageValues:{param:"encryptedData"}};if(!i)return{code:N,messageValues:{param:"iv"}};if(!e&&!r)return{code:N,messageValues:{param:"sessionKey"}};const o=this._getWeixinApi();if(!r){const t=await o.code2Session(e);if(!t.sessionKey)return{code:80801};r=t.sessionKey}r=Buffer.from(r,"base64"),n=Buffer.from(n,"base64"),i=Buffer.from(i,"base64");try{var s=t.createDecipheriv("aes-128-cbc",r,i);s.setAutoPadding(!0);var a=s.update(n,"binary","utf8");a+=s.final("utf8"),a=JSON.parse(a)}catch(e){return console.error(e),{code:80802}}return a.watermark.appid!==o.options.appId?{code:80803}:{code:0,msg:"",...a}},getWeixinUserInfo:async function({accessToken:e,openid:t}={}){const r=this.context.PLATFORM;if("app"!==r&&"app-plus"!==r)throw new Error(this.t("limit-client-platform"));try{return{code:0,msg:"",...await this._getWeixinApi().getUserInfo({accessToken:e,openid:t})}}catch(e){return console.error(e),{code:80901}}},encryptPwd:function(e,{value:r,version:n}={}){if(!(e=e&&e.trim()))throw new Error(this.t("param-required",{param:this.t("password")}));if(!r){const e=this._getConfig(),{passwordSecret:t}=e;if("array"===m(t)){const e=t.sort((e,t)=>e.version-t.version);r=e[e.length-1].value,n=e[e.length-1].version}else r=t}if(!r)throw new Error(this.t("param-error",{param:"passwordSecret",reason:"invalid passwordSecret"}));const i=t.createHmac("sha1",r.toString("ascii"));return i.update(e),{passwordHash:i.digest("hex"),version:n}},checkToken:async function(e,{needPermission:t,needUserInfo:r=!0}={}){const n=this._getConfig(),i=this._verifyToken(e);if(i.code)return i;const{uid:o,needPermission:s,role:a,permission:c,exp:u,iat:d,...p}=i,l=a&&c;t=void 0===t?s:t;const f=n.removePermissionAndRoleFromToken||!l||r,m=!n.removePermissionAndRoleFromToken&&!l||n.removePermissionAndRoleFromToken&&l||n.tokenExpiresThreshold&&u-Date.now()/1e3this._createTokenInternal({signContent:e,config:o})):this._createTokenInternal({signContent:a,config:o})},_updateToken:async function({uid:e,tokenList:t,removeToken:r=[],addToken:n=[]}={}){if(!t){const r=await P.doc(e).get(),n=r.data&&r.data[0];t=n&&n.token||[]}"string"==typeof t&&(t=[t]);const i=this._getExpiredToken(t);(t=t.filter(e=>-1===i.indexOf(e))).push(...n);for(let e=0;ee.version-t.version);let c;if(c=n?a.find(e=>e.version===n):a[0],!c)return{code:3};const u=a[a.length-1],{passwordHash:d}=this.encryptPwd(t,c);if(d===r){const e={code:0};if(c!==u){const{passwordHash:r,version:n}=this.encryptPwd(t,u);e.passwordHash=r,e.passwordVersion=n}return e}return{code:4,message:""}},_verifyToken:function(e){const t=this._getConfig();let r;try{r=Pr(e,t.tokenSecret)}catch(e){return"TokenExpiredError"===e.name?{code:30203,err:e}:{code:30204,err:e}}return t.bindTokenToDevice&&r.clientId&&r.clientId!==this._getClientUaHash()?{code:30201}:{code:0,message:"",...r}},_getExpiredToken:function(e){const t=this._getConfig(),r=[];return e.forEach(e=>{try{Pr(e,t.tokenSecret)}catch(t){r.push(e)}}),r},_getPermissionListByRoleList:async function(e){if(!Array.isArray(e))return[];if(0===e.length)return[];if(e.includes("admin")){return(await D.limit(500).get()).data.map(e=>e.permission_id)}const t=await j.where({role_id:Kr.in(e)}).get(),r=[];return t.data.forEach(e=>{Array.prototype.push.apply(r,e.permission)}),A(r)},_getClientUaHash:function(){const e=t.createHash("md5"),r=/MicroMessenger/i.test(this.context.CLIENTUA)?this.context.CLIENTUA.replace(/(MicroMessenger\S+).*/i,"$1"):this.context.CLIENTUA;return e.update(r),e.digest("hex")},_createTokenInternal:function({signContent:e,config:t}){if(t.tokenExpiresIn&&t.tokenExpiresThreshold&&t.tokenExpiresIn<=t.tokenExpiresThreshold)throw new Error(this.t("token-expires-config-warning"));return"object"===m(e)&&e.uid?(t.bindTokenToDevice&&(e.clientId=this._getClientUaHash()),{token:Rr(e,t.tokenSecret,{expiresIn:t.tokenExpiresIn}),tokenExpired:Date.now()+1e3*t.tokenExpiresIn}):{code:30101,messageValues:{param:this.t("user-id")}}},setVerifyCode:async function({mobile:e,email:t,code:r,expiresIn:n,type:i}){if(t=t&&t.trim(),e=e&&e.trim(),t){const{emailToLowerCase:e}=this._getConfig();e&&(t=t.toLowerCase())}if(!e&&!t)return{code:50101,messageValues:{param:"手机号或邮箱"}};if(e&&t)return{code:50102,messageValues:{param:"参数",reason:"手机号和邮箱不可同时存在"}};r||(r=C()),n||(n=180);const o=Date.now(),s={mobile:e,email:t,type:i,code:r,state:0,ip:this.context.CLIENTIP,created_at:o,expired_at:o+1e3*n};return await R.add(s),{code:0,mobile:e,email:t}},verifyCode:async function({mobile:e,email:t,code:r,type:n}){if(t=t&&t.trim(),e=e&&e.trim(),t){const{emailToLowerCase:e}=this._getConfig();e&&(t=t.toLowerCase())}if(!e&&!t)return{code:50201,messageValues:{param:"手机号或邮箱"}};if(e&&t)return{code:50203,messageValues:{param:"参数",reason:"手机号和邮箱不可同时存在"}};if(!r)return{code:50202,messageValues:{type:this.t(e?"sms":"email")}};const i=cn.command,o=Date.now(),s={mobile:e,email:t,type:n,code:r,state:0,expired_at:i.gt(o)},a=await R.where(s).orderBy("created_at","desc").limit(1).get();if(a&&a.data&&a.data.length>0){const e=a.data[0];return await R.doc(e._id).update({state:1}),{code:0,msg:"验证通过"}}return{code:50202,messageValues:{type:this.t(e?"sms":"email")}}},sendSmsCode:async function({mobile:e,code:t,type:r,templateId:n}){if(!e)return{code:N,messageValues:{param:this.t("mobile")}};if(t||(t=C()),!r)return{code:N,messageValues:{param:this.t("verify-code-type")}};const i=this._getConfig();let o=i&&i.service&&i.service.sms;if(!o)throw new Error(this.t("config-param-required",{param:"service.sms"}));o=Object.assign({codeExpiresIn:300},o);const{name:s,smsKey:a,smsSecret:c,codeExpiresIn:u}=o;let d;switch(r){case"login":d=this.t("login");break;default:d=this.t("verify-mobile")}try{const i={name:s,code:t,action:d,expMinute:""+Math.round(u/60)};s&&(i.name=s),await uniCloud.sendSms({smsKey:a,smsSecret:c,phone:e,templateId:n||"uniID_code",data:i});const o=await this.setVerifyCode({mobile:e,code:t,expiresIn:u,type:r});return o.code>=0?o:{code:0,msg:""}}catch(e){return console.error(e),{code:50301}}}});let dn;try{dn=require("uni-config-center")}catch(e){throw new Error("Plugin[uni-config-center] was not found")}class pn{constructor({context:e,clientInfo:t,config:r}={}){const n=dn({pluginId:"uni-id"});this.pluginConfig=n,this.config=r||this._getConfigContent(),this._configCache={},Object.defineProperty(this,"context",{get(){let r;r=t?{OS:t.os,CLIENTIP:t.clientIP,CLIENTUA:t.userAgent,PLATFORM:t.platform,APPID:t.appId,LOCALE:t.locale,DEVICEID:t.deviceId}:Object.assign({},e||global.__ctx__||{});const n=["CLIENTIP","PLATFORM","APPID","LOCALE"];for(let e=0;ee.dcloudAppid===t)||e.find(e=>e.isDefaultConfig):e}_parseConfigContent(e){return Array.isArray(e)?e:e[0]?Object.values(e):e}_getConfigContent(){if(this.pluginConfig&&this.pluginConfig.hasFile("config.json")){let e;try{e=this.pluginConfig.config()}catch(e){throw new Error("Invalid uni-id config file\n"+e.message)}return this._parseConfigContent(e)}{let e;try{e=require("./config.json")}catch(e){if("MODULE_NOT_FOUND"===e.code||"ENOENT"===e.code)throw new Error("uni-id config file[uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json] not found");throw e}return this._parseConfigContent(e)}}init(){throw new Error("uniID.init has been deprecated, use uniID.createInstance instead")}setInterceptor(e,t){this.interceptorMap.set(e,t)}_getConfig({appid:e,platform:t}={}){const r=`${e=e||this.context.APPID}_${t=t||this.context.PLATFORM}`;if(this._configCache[r])return this._configCache[r];if(!(this.config&&0!==Object.keys(this.config).length))throw new Error(this.t("config-file-not-found"));const n=this._getAppConfig(this.config,e);"app"!==t&&"app-plus"!==t||(t=n.preferedAppPlatform||t),"web"!==t&&"h5"!==t||(t=n.preferedWebPlatform||t);const i=Object.assign(n,n[t])||{},o=Object.assign({bindTokenToDevice:!1,tokenExpiresIn:7200,tokenExpiresThreshold:1200,passwordErrorLimit:6,passwordErrorRetryTime:3600,usernameToLowerCase:!0,emailToLowerCase:!0},i);return["passwordSecret","tokenSecret","tokenExpiresIn","passwordErrorLimit","passwordErrorRetryTime"].forEach(e=>{if(!o||!o[e])throw new Error(this.t("config-param-required",{param:e}))}),this._configCache[r]=o,o}}for(const e in un)pn.prototype[e]=un[e];function ln(e){const t=new pn(e);return new Proxy(t,{get(e,t){if(t in e&&0!==t.indexOf("_")){if("function"==typeof e[t])return(r=e[t],function(){const e=r.apply(this,arguments);return f(e)?e.then(e=>(S.bind(this)(e),e)):(S.bind(this)(e),e)}).bind(e);if("context"!==t&&"config"!==t)return e[t]}var r}})}pn.prototype.createInstance=ln;var fn=ln();module.exports=fn;
+"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("crypto")),r=e(require("buffer")),n=e(require("stream")),i=e(require("util"));const o={PARAM_ERROR:{errCode:"param-error"},PARAM_REQUIRED:{errCode:"param-required"},USER_NOT_EXIST:{errCode:"user-not-exist"},ROLE_NOT_EXIST:{errCode:"role-not-exist"},PERMISSION_NOT_EXIST:{errCode:"permission-not-exist"},MULTI_USER_MATCHED:{errCode:"multi-user-matched"},USER_INFO_ERROR:{errCode:"user-info-error"},USER_ACCOUNT_CONFLICT:{errCode:"user-account-conflict"},USER_ACCOUNT_CLOSED:{errCode:"user-account-closed"},ACCOUNT_EXISTS:{errCode:"account-exists"},ACCOUNT_NOT_EXISTS:{errCode:"account-not-exists"},ACCOUNT_BOUND:{errCode:"account-bound"},UNBIND_FAILED:{errCode:"unbind-failed"},INVALID_INVITE_CODE:{errCode:"invalid-invite-code"},SET_INVITE_CODE_FAILED:{errCode:"set-invite-code-failed"},GET_THIRD_PARTY_ACCOUNT_FAILED:{errCode:"get-third-party-account-failed"},GET_THIRD_PARTY_USER_INFO_FAILED:{errCode:"get-third-party-user-info-failed"}},s={0:{errCode:0,errMsg:""},10001:{errCode:"account-banned"},10002:o.USER_NOT_EXIST,10003:o.MULTI_USER_MATCHED,10004:o.USER_INFO_ERROR,10005:o.USER_ACCOUNT_CONFLICT,10006:o.USER_ACCOUNT_CLOSED,10102:{errCode:"password-error"},10103:{errCode:"password-error-exceed-limit"},10201:o.ACCOUNT_EXISTS,10202:o.ACCOUNT_NOT_EXISTS,10203:o.INVALID_INVITE_CODE,10301:o.ACCOUNT_EXISTS,10302:o.ACCOUNT_NOT_EXISTS,10401:o.GET_THIRD_PARTY_ACCOUNT_FAILED,10402:o.ACCOUNT_EXISTS,10403:o.ACCOUNT_NOT_EXISTS,10501:o.GET_THIRD_PARTY_ACCOUNT_FAILED,10502:o.ACCOUNT_EXISTS,10503:o.ACCOUNT_NOT_EXISTS,10601:o.ACCOUNT_EXISTS,10602:o.ACCOUNT_NOT_EXISTS,10701:o.GET_THIRD_PARTY_ACCOUNT_FAILED,10702:o.GET_THIRD_PARTY_ACCOUNT_FAILED,10703:o.ACCOUNT_EXISTS,10704:o.ACCOUNT_NOT_EXISTS,10705:o.GET_THIRD_PARTY_ACCOUNT_FAILED,10706:o.GET_THIRD_PARTY_ACCOUNT_FAILED,10801:o.GET_THIRD_PARTY_ACCOUNT_FAILED,10802:o.ACCOUNT_EXISTS,10803:o.ACCOUNT_NOT_EXISTS,20101:o.PARAM_REQUIRED,20102:o.ACCOUNT_EXISTS,30101:o.PARAM_REQUIRED,30201:{errCode:"check-device-feature-failed"},30202:{errCode:"token-not-exist"},30203:{errCode:"token-expired"},30204:{errCode:"check-token-failed"},40201:o.USER_NOT_EXIST,40202:{errCode:"invalid-old-password"},50101:o.PARAM_REQUIRED,50102:o.PARAM_ERROR,50201:o.PARAM_REQUIRED,50203:o.PARAM_ERROR,50202:{errCode:"invalid-verify-code"},50301:{errCode:"send-sms-code-failed"},60101:o.ACCOUNT_BOUND,60201:o.ACCOUNT_BOUND,60301:o.GET_THIRD_PARTY_ACCOUNT_FAILED,60302:o.ACCOUNT_BOUND,60401:o.GET_THIRD_PARTY_ACCOUNT_FAILED,60402:o.ACCOUNT_BOUND,60501:o.GET_THIRD_PARTY_ACCOUNT_FAILED,60502:o.ACCOUNT_BOUND,70101:o.UNBIND_FAILED,70201:o.UNBIND_FAILED,70301:o.UNBIND_FAILED,70401:o.UNBIND_FAILED,70501:o.UNBIND_FAILED,80301:o.USER_NOT_EXIST,80401:o.SET_INVITE_CODE_FAILED,80402:o.SET_INVITE_CODE_FAILED,80501:o.INVALID_INVITE_CODE,80502:o.USER_NOT_EXIST,80503:{errCode:"modify-invite-code-is-not-allowed"},80601:o.GET_THIRD_PARTY_ACCOUNT_FAILED,80602:o.GET_THIRD_PARTY_ACCOUNT_FAILED,80701:o.GET_THIRD_PARTY_ACCOUNT_FAILED,80702:o.GET_THIRD_PARTY_ACCOUNT_FAILED,80801:{errCode:"decrypt-weixin-data-failed"},80802:{errCode:"decrypt-weixin-data-failed"},80803:{errCode:"invalid-weixin-appid"},80804:o.PARAM_REQUIRED,80805:o.PARAM_REQUIRED,80806:o.PARAM_REQUIRED,80901:o.GET_THIRD_PARTY_USER_INFO_FAILED,90001:{errCode:"database-operation-failed"},90002:o.PARAM_REQUIRED,90003:o.PARAM_ERROR,90004:o.USER_NOT_EXIST,90005:o.ROLE_NOT_EXIST,90006:o.PERMISSION_NOT_EXIST};class a extends Error{constructor(e){super(e.message),this.errMsg=e.message||"",Object.defineProperties(this,{message:{get(){return`errCode: ${e.code||""} | errMsg: `+this.errMsg},set(e){this.errMsg=e}}})}}const c=Object.prototype.toString,u=Object.prototype.hasOwnProperty;function d(e,t){return u.call(e,t)}function p(e){return"[object Object]"===c.call(e)}function l(e){return"function"==typeof e}function f(e){return!!e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}function m(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}const h=/_(\w)/g,g=/[A-Z]/g;function y(e){return e.replace(h,(e,t)=>t?t.toUpperCase():"")}function w(e){return e.replace(g,e=>"_"+e.toLowerCase())}function v(e,t){let r,n;switch(t){case"snake2camel":n=y,r=h;break;case"camel2snake":n=w,r=g}for(const i in e)if(d(e,i)&&r.test(i)){const r=n(i);e[r]=e[i],delete e[i],p(e[r])?e[r]=v(e[r],t):Array.isArray(e[r])&&(e[r]=e[r].map(e=>v(e,t)))}return e}function _(e){return v(e,"snake2camel")}function b(e){return v(e,"camel2snake")}function T(e){return function(e,t="-"){e=e||new Date;const r=[];return r.push(e.getFullYear()),r.push(("00"+(e.getMonth()+1)).substr(-2)),r.push(("00"+e.getDate()).substr(-2)),r.join(t)}(e=e||new Date)+" "+function(e,t=":"){e=e||new Date;const r=[];return r.push(("00"+e.getHours()).substr(-2)),r.push(("00"+e.getMinutes()).substr(-2)),r.push(("00"+e.getSeconds()).substr(-2)),r.join(t)}(e)}function E(){"development"===process.env.NODE_ENV&&console.log(...arguments)}function C(e=6){let t="";for(let r=0;r-1?"&":"?"}access_token=${t.accessToken}`}return`${e}${r}`}class G{constructor(e){this.options=Object.assign({baseUrl:"https://api.weixin.qq.com",timeout:5e3},e)}async _requestWxOpenapi({name:e,url:t,data:r,options:n}){const i={method:"GET",dataType:"json",dataAsQueryString:!0,timeout:this.options.timeout};return await H({name:"auth."+e,url:`${this.options.baseUrl}${K(t,r)}`,data:r,options:n,defaultOptions:i})}async code2Session(e){return await this._requestWxOpenapi({name:"code2Session",url:"/sns/jscode2session",data:{grant_type:"authorization_code",appid:this.options.appId,secret:this.options.secret,js_code:e}})}async getOauthAccessToken(e){const t=await this._requestWxOpenapi({name:"getOauthAccessToken",url:"/sns/oauth2/access_token",data:{grant_type:"authorization_code",appid:this.options.appId,secret:this.options.secret,code:e}});return t.expiresIn&&(t.expired=Date.now()+1e3*t.expiresIn),t}async getUserInfo({accessToken:e,openid:t}={}){const{nickname:r,headimgurl:n}=await this._requestWxOpenapi({name:"getUserInfo",url:"/sns/userinfo",data:{accessToken:e,openid:t,appid:this.options.appId,secret:this.options.secret,scope:"snsapi_userinfo"}});return{nickname:r,avatar:n}}}async function Q({name:e,url:t,data:r,options:n,defaultOptions:i}){let o;n=Object.assign({},i,n,{data:b(Object.assign({},r))});try{o=await uniCloud.httpclient.request(t,n)}catch(t){return function(e,t){throw new a({code:t.code||-2,message:t.message||e+" fail"})}(e,t)}let s=o.data;const c=o.headers["content-type"];if(!Buffer.isBuffer(s)||0!==c.indexOf("text/plain")&&0!==c.indexOf("application/json"))Buffer.isBuffer(s)&&(s={buffer:s,contentType:c});else try{s=JSON.parse(s.toString())}catch(e){s=s.toString()}return _(function(e,t){if(t.ret||t.error){const r=t.ret||t.error||t.errcode||-2,n=t.msg||t.error_description||t.errmsg||e+" fail";throw new a({code:r,message:n})}return delete t.ret,delete t.msg,delete t.error,delete t.error_description,delete t.errcode,delete t.errmsg,{...t,errMsg:e+" ok",errCode:0}}(e,s||{errCode:-2,errMsg:"Request failed"}))}class X{constructor(e){this.options=Object.assign({baseUrl:"https://graph.qq.com",timeout:5e3},e)}async _requestQQOpenapi({name:e,url:t,data:r,options:n}){const i={method:"GET",dataType:"json",dataAsQueryString:!0,timeout:this.options.timeout};var o,s;return await Q({name:"auth."+e,url:(o=this.options.baseUrl,s=t,/^https?:/.test(s)?s:o+s),data:r,options:n,defaultOptions:i})}async getOpenidByToken({accessToken:e}={}){const t=await this._requestQQOpenapi({name:"getOpenidByToken",url:"/oauth2.0/me",data:{accessToken:e,unionid:1,fmt:"json"}});if(t.clientId!==this.options.appId)throw new a({code:"APPID_NOT_MATCH",message:"appid not match"});return{openid:t.openid,unionid:t.unionid}}async code2Session({code:e}={}){return await this._requestQQOpenapi({name:"getOpenidByToken",url:"https://api.q.qq.com/sns/jscode2session",data:{grant_type:"authorization_code",appid:this.options.appId,secret:this.options.secret,js_code:e}})}}const Y={RSA:"RSA-SHA1",RSA2:"RSA-SHA256"};var z={code2Session:{returnValue:{openid:"userId"}}};class W extends class{constructor(e={}){if(!e.appId)throw new Error("appId required");if(!e.privateKey)throw new Error("privateKey required");const t={gateway:"https://openapi.alipay.com/gateway.do",timeout:5e3,charset:"utf-8",version:"1.0",signType:"RSA2",timeOffset:-(new Date).getTimezoneOffset()/60,keyType:"PKCS8"};e.sandbox&&(e.gateway="https://openapi.alipaydev.com/gateway.do"),this.options=Object.assign({},t,e);const r="PKCS8"===this.options.keyType?"PRIVATE KEY":"RSA PRIVATE KEY";this.options.privateKey=this._formatKey(this.options.privateKey,r),this.options.alipayPublicKey&&(this.options.alipayPublicKey=this._formatKey(this.options.alipayPublicKey,"PUBLIC KEY"))}_formatKey(e,t){return`-----BEGIN ${t}-----\n${e}\n-----END ${t}-----`}_formatUrl(e,t){let r=e;const n=["app_id","method","format","charset","sign_type","sign","timestamp","version","notify_url","return_url","auth_token","app_auth_token"];for(const e in t)if(n.indexOf(e)>-1){const n=encodeURIComponent(t[e]);r=`${r}${r.includes("?")?"&":"?"}${e}=${n}`,delete t[e]}return{execParams:t,url:r}}_getSign(e,r){const n=r.bizContent||null;delete r.bizContent;const i=Object.assign({method:e,appId:this.options.appId,charset:this.options.charset,version:this.options.version,signType:this.options.signType,timestamp:T((o=this.options.timeOffset,new Date(Date.now()+6e4*((new Date).getTimezoneOffset()+60*(o||0)))))},r);var o;n&&(i.bizContent=JSON.stringify(b(n)));const s=b(i),a=Object.keys(s).sort().map(e=>{let t=s[e];return"[object String]"!==Array.prototype.toString.call(t)&&(t=JSON.stringify(t)),`${e}=${t}`}).join("&"),c=t.createSign(Y[this.options.signType]).update(a,"utf8").sign(this.options.privateKey,"base64");return Object.assign(s,{sign:c})}async _exec(e,t={},r={}){const n=this._getSign(e,t),{url:i,execParams:o}=this._formatUrl(this.options.gateway,n),{status:s,data:a}=await uniCloud.httpclient.request(i,{method:"POST",data:o,dataType:"text",timeout:this.options.timeout});if(200!==s)throw new Error("request fail");const c=JSON.parse(a),u=e.replace(/\./g,"_")+"_response",d=c[u],p=c.error_response;if(d){if(!r.validateSign||this._checkResponseSign(a,u)){if(!d.code||"10000"===d.code){return{errCode:0,errMsg:d.msg||"",..._(d)}}const e=d.sub_code?`${d.sub_code} ${d.sub_msg}`:""+(d.msg||"unkonwn error");throw new Error(e)}throw new Error("check sign error")}if(p)throw new Error(p.sub_msg||p.msg||"request fail");throw new Error("request fail")}_checkResponseSign(e,r){if(!this.options.alipayPublicKey||""===this.options.alipayPublicKey)return console.warn("options.alipayPublicKey is empty"),!0;if(!e)return!1;const n=this._getSignStr(e,r),i=JSON.parse(e).sign,o=t.createVerify(Y[this.options.signType]);return o.update(n,"utf8"),o.verify(this.options.alipayPublicKey,i,"base64")}_getSignStr(e,t){let r=e.trim();const n=e.indexOf(t+'"'),i=e.lastIndexOf('"sign"');return r=r.substr(n+t.length+1),r=r.substr(0,i),r=r.replace(/^[^{]*{/g,"{"),r=r.replace(/\}([^}]*)$/g,"}"),r}}{constructor(e){super(e),this._protocols=z}async code2Session(e){return await this._exec("alipay.system.oauth.token",{grantType:"authorization_code",code:e})}}function J(e){var t=e[0];return t<"0"||t>"7"?"00"+e:e}function Z(e){var t=e.toString(16);return t.length%2?"0"+t:t}function ee(e){if(e<=127)return Z(e);var t=Z(e);return Z(128+t.length/2)+t}function te(e,t){return e(t={exports:{}},t.exports),t.exports}var re=te((function(e,t){var n=r.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=o),o.prototype=Object.create(n.prototype),i(n,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=n(e);return void 0!==t?"string"==typeof r?i.fill(t,r):i.fill(t):i.fill(0),i},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}})),ne=(re.Buffer,re.Buffer);function ie(e){if(this.buffer=null,this.writable=!0,this.readable=!0,!e)return this.buffer=ne.alloc(0),this;if("function"==typeof e.pipe)return this.buffer=ne.alloc(0),e.pipe(this),this;if(e.length||"object"==typeof e)return this.buffer=e,this.writable=!1,process.nextTick(function(){this.emit("end",e),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof e+")")}i.inherits(ie,n),ie.prototype.write=function(e){this.buffer=ne.concat([this.buffer,ne.from(e)]),this.emit("data",e)},ie.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1};var oe=ie,se=r.Buffer,ae=r.SlowBuffer,ce=ue;function ue(e,t){if(!se.isBuffer(e)||!se.isBuffer(t))return!1;if(e.length!==t.length)return!1;for(var r=0,n=0;n=128&&--n,n}var we={derToJose:function(e,t){e=ge(e);var r=me(t),n=r+1,i=e.length,o=0;if(48!==e[o++])throw new Error('Could not find expected "seq"');var s=e[o++];if(129===s&&(s=e[o++]),i-o0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*r;case"weeks":case"week":case"w":return 6048e5*r;case"days":case"day":case"d":return r*mt;case"hours":case"hour":case"hrs":case"hr":case"h":return r*ft;case"minutes":case"minute":case"mins":case"min":case"m":return r*lt;case"seconds":case"second":case"secs":case"sec":case"s":return r*pt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}(e);if("number"===r&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=mt)return gt(e,t,mt,"day");if(t>=ft)return gt(e,t,ft,"hour");if(t>=lt)return gt(e,t,lt,"minute");if(t>=pt)return gt(e,t,pt,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=mt)return Math.round(e/mt)+"d";if(t>=ft)return Math.round(e/ft)+"h";if(t>=lt)return Math.round(e/lt)+"m";if(t>=pt)return Math.round(e/pt)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function gt(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}var yt=function(e,t){var r=t||Math.floor(Date.now()/1e3);if("string"==typeof e){var n=ht(e);if(void 0===n)return;return Math.floor(r+n/1e3)}return"number"==typeof e?r+e:void 0},wt=te((function(e,t){var r;t=e.exports=Y,r="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?function(){var e=Array.prototype.slice.call(arguments,0);e.unshift("SEMVER"),console.log.apply(console,e)}:function(){},t.SEMVER_SPEC_VERSION="2.0.0";var n=Number.MAX_SAFE_INTEGER||9007199254740991,i=t.re=[],o=t.safeRe=[],s=t.src=[],a=0,c=[["\\s",1],["\\d",256],["[a-zA-Z0-9-]",250]];function u(e){for(var t=0;t)?=?)";var x=a++;s[x]=s[p]+"|x|X|\\*";var I=a++;s[I]=s[d]+"|x|X|\\*";var S=a++;s[S]="[v=\\s]*("+s[I]+")(?:\\.("+s[I]+")(?:\\.("+s[I]+")(?:"+s[y]+")?"+s[_]+"?)?)?";var k=a++;s[k]="[v=\\s]*("+s[x]+")(?:\\.("+s[x]+")(?:\\.("+s[x]+")(?:"+s[w]+")?"+s[_]+"?)?)?";var O=a++;s[O]="^"+s[A]+"\\s*"+s[S]+"$";var P=a++;s[P]="^"+s[A]+"\\s*"+s[k]+"$";var R=a++;s[R]="(?:^|[^\\d])(\\d{1,16})(?:\\.(\\d{1,16}))?(?:\\.(\\d{1,16}))?(?:$|[^\\d])";var j=a++;s[j]="(?:~>?)";var D=a++;s[D]="(\\s*)"+s[j]+"\\s+",i[D]=new RegExp(s[D],"g"),o[D]=new RegExp(u(s[D]),"g");var q=a++;s[q]="^"+s[j]+s[S]+"$";var N=a++;s[N]="^"+s[j]+s[k]+"$";var U=a++;s[U]="(?:\\^)";var L=a++;s[L]="(\\s*)"+s[U]+"\\s+",i[L]=new RegExp(s[L],"g"),o[L]=new RegExp(u(s[L]),"g");var V=a++;s[V]="^"+s[U]+s[S]+"$";var M=a++;s[M]="^"+s[U]+s[k]+"$";var B=a++;s[B]="^"+s[A]+"\\s*("+E+")$|^$";var F=a++;s[F]="^"+s[A]+"\\s*("+T+")$|^$";var $=a++;s[$]="(\\s*)"+s[A]+"\\s*("+E+"|"+s[S]+")",i[$]=new RegExp(s[$],"g"),o[$]=new RegExp(u(s[$]),"g");var H=a++;s[H]="^\\s*("+s[S]+")\\s+-\\s+("+s[S]+")\\s*$";var K=a++;s[K]="^\\s*("+s[k]+")\\s+-\\s+("+s[k]+")\\s*$";var G=a++;s[G]="(<|>)?=?\\s*\\*";for(var Q=0;Q<35;Q++)r(Q,s[Q]),i[Q]||(i[Q]=new RegExp(s[Q]),o[Q]=new RegExp(u(s[Q])));function X(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof Y)return e;if("string"!=typeof e)return null;if(e.length>256)return null;if(!(t.loose?o[C]:o[b]).test(e))return null;try{return new Y(e,t)}catch(e){return null}}function Y(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof Y){if(e.loose===t.loose)return e;e=e.version}else if("string"!=typeof e)throw new TypeError("Invalid Version: "+e);if(e.length>256)throw new TypeError("version is longer than 256 characters");if(!(this instanceof Y))return new Y(e,t);r("SemVer",e,t),this.options=t,this.loose=!!t.loose;var i=e.trim().match(t.loose?o[C]:o[b]);if(!i)throw new TypeError("Invalid Version: "+e);if(this.raw=e,this.major=+i[1],this.minor=+i[2],this.patch=+i[3],this.major>n||this.major<0)throw new TypeError("Invalid major version");if(this.minor>n||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>n||this.patch<0)throw new TypeError("Invalid patch version");i[4]?this.prerelease=i[4].split(".").map((function(e){if(/^[0-9]+$/.test(e)){var t=+e;if(t>=0&&t=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);-1===r&&this.prerelease.push(0)}t&&(this.prerelease[0]===t?isNaN(this.prerelease[1])&&(this.prerelease=[t,0]):this.prerelease=[t,0]);break;default:throw new Error("invalid increment argument: "+e)}return this.format(),this.raw=this.version,this},t.inc=function(e,t,r,n){"string"==typeof r&&(n=r,r=void 0);try{return new Y(e,r).inc(t,n).version}catch(e){return null}},t.diff=function(e,t){if(te(e,t))return null;var r=X(e),n=X(t),i="";if(r.prerelease.length||n.prerelease.length){i="pre";var o="prerelease"}for(var s in r)if(("major"===s||"minor"===s||"patch"===s)&&r[s]!==n[s])return i+s;return o},t.compareIdentifiers=W;var z=/^[0-9]+$/;function W(e,t){var r=z.test(e),n=z.test(t);return r&&n&&(e=+e,t=+t),e===t?0:r&&!n?-1:n&&!r?1:e0}function ee(e,t,r){return J(e,t,r)<0}function te(e,t,r){return 0===J(e,t,r)}function re(e,t,r){return 0!==J(e,t,r)}function ne(e,t,r){return J(e,t,r)>=0}function ie(e,t,r){return J(e,t,r)<=0}function oe(e,t,r,n){switch(t){case"===":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e===r;case"!==":return"object"==typeof e&&(e=e.version),"object"==typeof r&&(r=r.version),e!==r;case"":case"=":case"==":return te(e,r,n);case"!=":return re(e,r,n);case">":return Z(e,r,n);case">=":return ne(e,r,n);case"<":return ee(e,r,n);case"<=":return ie(e,r,n);default:throw new TypeError("Invalid operator: "+t)}}function se(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof se){if(e.loose===!!t.loose)return e;e=e.value}if(!(this instanceof se))return new se(e,t);e=e.trim().split(/\s+/).join(" "),r("comparator",e,t),this.options=t,this.loose=!!t.loose,this.parse(e),this.semver===ae?this.value="":this.value=this.operator+this.semver.version,r("comp",this)}t.rcompareIdentifiers=function(e,t){return W(t,e)},t.major=function(e,t){return new Y(e,t).major},t.minor=function(e,t){return new Y(e,t).minor},t.patch=function(e,t){return new Y(e,t).patch},t.compare=J,t.compareLoose=function(e,t){return J(e,t,!0)},t.rcompare=function(e,t,r){return J(t,e,r)},t.sort=function(e,r){return e.sort((function(e,n){return t.compare(e,n,r)}))},t.rsort=function(e,r){return e.sort((function(e,n){return t.rcompare(e,n,r)}))},t.gt=Z,t.lt=ee,t.eq=te,t.neq=re,t.gte=ne,t.lte=ie,t.cmp=oe,t.Comparator=se;var ae={};function ce(e,t){if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),e instanceof ce)return e.loose===!!t.loose&&e.includePrerelease===!!t.includePrerelease?e:new ce(e.raw,t);if(e instanceof se)return new ce(e.value,t);if(!(this instanceof ce))return new ce(e,t);if(this.options=t,this.loose=!!t.loose,this.includePrerelease=!!t.includePrerelease,this.raw=e.trim().split(/\s+/).join(" "),this.set=this.raw.split("||").map((function(e){return this.parseRange(e.trim())}),this).filter((function(e){return e.length})),!this.set.length)throw new TypeError("Invalid SemVer Range: "+this.raw);this.format()}function ue(e){return!e||"x"===e.toLowerCase()||"*"===e}function de(e,t,r,n,i,o,s,a,c,u,d,p,l){return((t=ue(r)?"":ue(n)?">="+r+".0.0":ue(i)?">="+r+"."+n+".0":">="+t)+" "+(a=ue(c)?"":ue(u)?"<"+(+c+1)+".0.0":ue(d)?"<"+c+"."+(+u+1)+".0":p?"<="+c+"."+u+"."+d+"-"+p:"<="+a)).trim()}function pe(e,t,n){for(var i=0;i0){var o=e[i].semver;if(o.major===t.major&&o.minor===t.minor&&o.patch===t.patch)return!0}return!1}return!0}function le(e,t,r){try{t=new ce(t,r)}catch(e){return!1}return t.test(e)}function fe(e,t,r,n){var i,o,s,a,c;switch(e=new Y(e,n),t=new ce(t,n),r){case">":i=Z,o=ie,s=ee,a=">",c=">=";break;case"<":i=ee,o=ne,s=Z,a="<",c="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(le(e,t,n))return!1;for(var u=0;u=0.0.0")),p=p||e,l=l||e,i(e.semver,p.semver,n)?p=e:s(e.semver,l.semver,n)&&(l=e)})),p.operator===a||p.operator===c)return!1;if((!l.operator||l.operator===a)&&o(e,l.semver))return!1;if(l.operator===c&&s(e,l.semver))return!1}return!0}se.prototype.parse=function(e){var t=this.options.loose?o[B]:o[F],r=e.match(t);if(!r)throw new TypeError("Invalid comparator: "+e);this.operator=r[1],"="===this.operator&&(this.operator=""),r[2]?this.semver=new Y(r[2],this.options.loose):this.semver=ae},se.prototype.toString=function(){return this.value},se.prototype.test=function(e){return r("Comparator.test",e,this.options.loose),this.semver===ae||("string"==typeof e&&(e=new Y(e,this.options)),oe(e,this.operator,this.semver,this.options))},se.prototype.intersects=function(e,t){if(!(e instanceof se))throw new TypeError("a Comparator is required");var r;if(t&&"object"==typeof t||(t={loose:!!t,includePrerelease:!1}),""===this.operator)return r=new ce(e.value,t),le(this.value,r,t);if(""===e.operator)return r=new ce(this.value,t),le(e.semver,r,t);var n=!(">="!==this.operator&&">"!==this.operator||">="!==e.operator&&">"!==e.operator),i=!("<="!==this.operator&&"<"!==this.operator||"<="!==e.operator&&"<"!==e.operator),o=this.semver.version===e.semver.version,s=!(">="!==this.operator&&"<="!==this.operator||">="!==e.operator&&"<="!==e.operator),a=oe(this.semver,"<",e.semver,t)&&(">="===this.operator||">"===this.operator)&&("<="===e.operator||"<"===e.operator),c=oe(this.semver,">",e.semver,t)&&("<="===this.operator||"<"===this.operator)&&(">="===e.operator||">"===e.operator);return n||i||o&&s||a||c},t.Range=ce,ce.prototype.format=function(){return this.range=this.set.map((function(e){return e.join(" ").trim()})).join("||").trim(),this.range},ce.prototype.toString=function(){return this.range},ce.prototype.parseRange=function(e){var t=this.options.loose,n=t?o[K]:o[H];e=e.replace(n,de),r("hyphen replace",e),e=e.replace(o[$],"$1$2$3"),r("comparator trim",e,o[$]),e=(e=e.replace(o[D],"$1~")).replace(o[L],"$1^");var i=t?o[B]:o[F],s=e.split(" ").map((function(e){return function(e,t){return r("comp",e,t),e=function(e,t){return e.trim().split(/\s+/).map((function(e){return function(e,t){r("caret",e,t);var n=t.loose?o[M]:o[V];return e.replace(n,(function(t,n,i,o,s){var a;return r("caret",e,t,n,i,o,s),ue(n)?a="":ue(i)?a=">="+n+".0.0 <"+(+n+1)+".0.0":ue(o)?a="0"===n?">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0":">="+n+"."+i+".0 <"+(+n+1)+".0.0":s?(r("replaceCaret pr",s),a="0"===n?"0"===i?">="+n+"."+i+"."+o+"-"+s+" <"+n+"."+i+"."+(+o+1):">="+n+"."+i+"."+o+"-"+s+" <"+n+"."+(+i+1)+".0":">="+n+"."+i+"."+o+"-"+s+" <"+(+n+1)+".0.0"):(r("no pr"),a="0"===n?"0"===i?">="+n+"."+i+"."+o+" <"+n+"."+i+"."+(+o+1):">="+n+"."+i+"."+o+" <"+n+"."+(+i+1)+".0":">="+n+"."+i+"."+o+" <"+(+n+1)+".0.0"),r("caret return",a),a}))}(e,t)})).join(" ")}(e,t),r("caret",e),e=function(e,t){return e.trim().split(/\s+/).map((function(e){return function(e,t){var n=t.loose?o[N]:o[q];return e.replace(n,(function(t,n,i,o,s){var a;return r("tilde",e,t,n,i,o,s),ue(n)?a="":ue(i)?a=">="+n+".0.0 <"+(+n+1)+".0.0":ue(o)?a=">="+n+"."+i+".0 <"+n+"."+(+i+1)+".0":s?(r("replaceTilde pr",s),a=">="+n+"."+i+"."+o+"-"+s+" <"+n+"."+(+i+1)+".0"):a=">="+n+"."+i+"."+o+" <"+n+"."+(+i+1)+".0",r("tilde return",a),a}))}(e,t)})).join(" ")}(e,t),r("tildes",e),e=function(e,t){return r("replaceXRanges",e,t),e.split(/\s+/).map((function(e){return function(e,t){e=e.trim();var n=t.loose?o[P]:o[O];return e.replace(n,(function(t,n,i,o,s,a){r("xRange",e,t,n,i,o,s,a);var c=ue(i),u=c||ue(o),d=u||ue(s);return"="===n&&d&&(n=""),c?t=">"===n||"<"===n?"<0.0.0":"*":n&&d?(u&&(o=0),s=0,">"===n?(n=">=",u?(i=+i+1,o=0,s=0):(o=+o+1,s=0)):"<="===n&&(n="<",u?i=+i+1:o=+o+1),t=n+i+"."+o+"."+s):u?t=">="+i+".0.0 <"+(+i+1)+".0.0":d&&(t=">="+i+"."+o+".0 <"+i+"."+(+o+1)+".0"),r("xRange return",t),t}))}(e,t)})).join(" ")}(e,t),r("xrange",e),e=function(e,t){return r("replaceStars",e,t),e.trim().replace(o[G],"")}(e,t),r("stars",e),e}(e,this.options)}),this).join(" ").split(/\s+/);return this.options.loose&&(s=s.filter((function(e){return!!e.match(i)}))),s=s.map((function(e){return new se(e,this.options)}),this)},ce.prototype.intersects=function(e,t){if(!(e instanceof ce))throw new TypeError("a Range is required");return this.set.some((function(r){return r.every((function(r){return e.set.some((function(e){return e.every((function(e){return r.intersects(e,t)}))}))}))}))},t.toComparators=function(e,t){return new ce(e,t).set.map((function(e){return e.map((function(e){return e.value})).join(" ").trim().split(" ")}))},ce.prototype.test=function(e){if(!e)return!1;"string"==typeof e&&(e=new Y(e,this.options));for(var t=0;t":0===t.prerelease.length?t.patch++:t.prerelease.push(0),t.raw=t.format();case"":case">=":r&&!Z(r,t)||(r=t);break;case"<":case"<=":break;default:throw new Error("Unexpected operation: "+e.operator)}}))}if(r&&e.test(r))return r;return null},t.validRange=function(e,t){try{return new ce(e,t).range||"*"}catch(e){return null}},t.ltr=function(e,t,r){return fe(e,t,"<",r)},t.gtr=function(e,t,r){return fe(e,t,">",r)},t.outside=fe,t.prerelease=function(e,t){var r=X(e,t);return r&&r.prerelease.length?r.prerelease:null},t.intersects=function(e,t,r){return e=new ce(e,r),t=new ce(t,r),e.intersects(t)},t.coerce=function(e){if(e instanceof Y)return e;if("string"!=typeof e)return null;var t=e.match(o[R]);if(null==t)return null;return X(t[1]+"."+(t[2]||"0")+"."+(t[3]||"0"))}})),vt=(wt.SEMVER_SPEC_VERSION,wt.re,wt.safeRe,wt.src,wt.parse,wt.valid,wt.clean,wt.SemVer,wt.inc,wt.diff,wt.compareIdentifiers,wt.rcompareIdentifiers,wt.major,wt.minor,wt.patch,wt.compare,wt.compareLoose,wt.rcompare,wt.sort,wt.rsort,wt.gt,wt.lt,wt.eq,wt.neq,wt.gte,wt.lte,wt.cmp,wt.Comparator,wt.Range,wt.toComparators,wt.satisfies,wt.maxSatisfying,wt.minSatisfying,wt.minVersion,wt.validRange,wt.ltr,wt.gtr,wt.outside,wt.prerelease,wt.intersects,wt.coerce,wt.satisfies(process.version,"^6.12.0 || >=8.0.0")),_t=["RS256","RS384","RS512","ES256","ES384","ES512"],bt=["RS256","RS384","RS512"],Tt=["HS256","HS384","HS512"];vt&&(_t.splice(3,0,"PS256","PS384","PS512"),bt.splice(3,0,"PS256","PS384","PS512"));var Et=/^\s+|\s+$/g,Ct=/^[-+]0x[0-9a-f]+$/i,At=/^0b[01]+$/i,xt=/^0o[0-7]+$/i,It=/^(?:0|[1-9]\d*)$/,St=parseInt;function kt(e){return e!=e}function Ot(e,t){return function(e,t){for(var r=-1,n=e?e.length:0,i=Array(n);++r-1&&e%1==0&&e-1&&e%1==0&&e<=9007199254740991}(e.length)&&!function(e){var t=Ht(e)?qt.call(e):"";return"[object Function]"==t||"[object GeneratorFunction]"==t}(e)}function Ht(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Kt(e){return!!e&&"object"==typeof e}var Gt=function(e,t,r,n){var i;e=$t(e)?e:(i=e)?Ot(i,function(e){return $t(e)?Vt(e):Mt(e)}(i)):[],r=r&&!n?function(e){var t=function(e){if(!e)return 0===e?e:0;if((e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||Kt(e)&&"[object Symbol]"==qt.call(e)}(e))return NaN;if(Ht(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Ht(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(Et,"");var r=At.test(e);return r||xt.test(e)?St(e.slice(2),r?2:8):Ct.test(e)?NaN:+e}(e))===1/0||e===-1/0){return 17976931348623157e292*(e<0?-1:1)}return e==e?e:0}(e),r=t%1;return t==t?r?t-r:t:0}(r):0;var o=e.length;return r<0&&(r=Lt(o+r,0)),function(e){return"string"==typeof e||!Ft(e)&&Kt(e)&&"[object String]"==qt.call(e)}(e)?r<=o&&e.indexOf(t,r)>-1:!!o&&function(e,t,r){if(t!=t)return function(e,t,r,n){for(var i=e.length,o=r+(n?1:-1);n?o--:++o-1},Qt=Object.prototype.toString;var Xt=function(e){return!0===e||!1===e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Boolean]"==Qt.call(e)},Yt=/^\s+|\s+$/g,zt=/^[-+]0x[0-9a-f]+$/i,Wt=/^0b[01]+$/i,Jt=/^0o[0-7]+$/i,Zt=parseInt,er=Object.prototype.toString;function tr(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}var rr=function(e){return"number"==typeof e&&e==function(e){var t=function(e){if(!e)return 0===e?e:0;if((e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==er.call(e)}(e))return NaN;if(tr(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=tr(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(Yt,"");var r=Wt.test(e);return r||Jt.test(e)?Zt(e.slice(2),r?2:8):zt.test(e)?NaN:+e}(e))===1/0||e===-1/0){return 17976931348623157e292*(e<0?-1:1)}return e==e?e:0}(e),r=t%1;return t==t?r?t-r:t:0}(e)},nr=Object.prototype.toString;var ir=function(e){return"number"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Number]"==nr.call(e)};var or=Function.prototype,sr=Object.prototype,ar=or.toString,cr=sr.hasOwnProperty,ur=ar.call(Object),dr=sr.toString,pr=function(e,t){return function(r){return e(t(r))}}(Object.getPrototypeOf,Object);var lr=function(e){if(!function(e){return!!e&&"object"==typeof e}(e)||"[object Object]"!=dr.call(e)||function(e){var t=!1;if(null!=e&&"function"!=typeof e.toString)try{t=!!(e+"")}catch(e){}return t}(e))return!1;var t=pr(e);if(null===t)return!0;var r=cr.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&ar.call(r)==ur},fr=Object.prototype.toString,mr=Array.isArray;var hr=function(e){return"string"==typeof e||!mr(e)&&function(e){return!!e&&"object"==typeof e}(e)&&"[object String]"==fr.call(e)},gr=/^\s+|\s+$/g,yr=/^[-+]0x[0-9a-f]+$/i,wr=/^0b[01]+$/i,vr=/^0o[0-7]+$/i,_r=parseInt,br=Object.prototype.toString;function Tr(e,t){var r;if("function"!=typeof t)throw new TypeError("Expected a function");return e=function(e){var t=function(e){if(!e)return 0===e?e:0;if((e=function(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==br.call(e)}(e))return NaN;if(Er(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Er(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(gr,"");var r=wr.test(e);return r||vr.test(e)?_r(e.slice(2),r?2:8):yr.test(e)?NaN:+e}(e))===1/0||e===-1/0){return 17976931348623157e292*(e<0?-1:1)}return e==e?e:0}(e),r=t%1;return t==t?r?t-r:t:0}(e),function(){return--e>0&&(r=t.apply(this,arguments)),e<=1&&(t=void 0),r}}function Er(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}var Cr=function(e){return Tr(2,e)},Ar=["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512","none"];vt&&Ar.splice(3,0,"PS256","PS384","PS512");var xr={expiresIn:{isValid:function(e){return rr(e)||hr(e)&&e},message:'"expiresIn" should be a number of seconds or string representing a timespan'},notBefore:{isValid:function(e){return rr(e)||hr(e)&&e},message:'"notBefore" should be a number of seconds or string representing a timespan'},audience:{isValid:function(e){return hr(e)||Array.isArray(e)},message:'"audience" must be a string or array'},algorithm:{isValid:Gt.bind(null,Ar),message:'"algorithm" must be a valid string enum value'},header:{isValid:lr,message:'"header" must be an object'},encoding:{isValid:hr,message:'"encoding" must be a string'},issuer:{isValid:hr,message:'"issuer" must be a string'},subject:{isValid:hr,message:'"subject" must be a string'},jwtid:{isValid:hr,message:'"jwtid" must be a string'},noTimestamp:{isValid:Xt,message:'"noTimestamp" must be a boolean'},keyid:{isValid:hr,message:'"keyid" must be a string'},mutatePayload:{isValid:Xt,message:'"mutatePayload" must be a boolean'}},Ir={iat:{isValid:ir,message:'"iat" should be a number of seconds'},exp:{isValid:ir,message:'"exp" should be a number of seconds'},nbf:{isValid:ir,message:'"nbf" should be a number of seconds'}};function Sr(e,t,r,n){if(!lr(r))throw new Error('Expected "'+n+'" to be a plain object.');Object.keys(r).forEach((function(i){var o=e[i];if(o){if(!o.isValid(r[i]))throw new Error(o.message)}else if(!t)throw new Error('"'+i+'" is not allowed in "'+n+'"')}))}var kr={audience:"aud",issuer:"iss",subject:"sub",jwtid:"jti"},Or=["expiresIn","notBefore","noTimestamp","audience","issuer","subject","jwtid"],Pr=function(e,t,r,n){var i;if("function"!=typeof r||n||(n=r,r={}),r||(r={}),r=Object.assign({},r),i=n||function(e,t){if(e)throw e;return t},r.clockTimestamp&&"number"!=typeof r.clockTimestamp)return i(new st("clockTimestamp must be a number"));if(void 0!==r.nonce&&("string"!=typeof r.nonce||""===r.nonce.trim()))return i(new st("nonce must be a non-empty string"));var o=r.clockTimestamp||Math.floor(Date.now()/1e3);if(!e)return i(new st("jwt must be provided"));if("string"!=typeof e)return i(new st("jwt must be a string"));var s,a=e.split(".");if(3!==a.length)return i(new st("jwt malformed"));try{s=it(e,{complete:!0})}catch(e){return i(e)}if(!s)return i(new st("invalid token"));var c,u=s.header;if("function"==typeof t){if(!n)return i(new st("verify must be called asynchronous if secret or public key is provided as a callback"));c=t}else c=function(e,r){return r(null,t)};return c(u,(function(t,n){if(t)return i(new st("error in secret or public key callback: "+t.message));var c,d=""!==a[2].trim();if(!d&&n)return i(new st("jwt signature is required"));if(d&&!n)return i(new st("secret or public key must be provided"));if(d||r.algorithms||(r.algorithms=["none"]),r.algorithms||(r.algorithms=~n.toString().indexOf("BEGIN CERTIFICATE")||~n.toString().indexOf("BEGIN PUBLIC KEY")?_t:~n.toString().indexOf("BEGIN RSA PUBLIC KEY")?bt:Tt),!~r.algorithms.indexOf(s.header.alg))return i(new st("invalid algorithm"));try{c=nt.verify(e,s.header.alg,n)}catch(e){return i(e)}if(!c)return i(new st("invalid signature"));var p=s.payload;if(void 0!==p.nbf&&!r.ignoreNotBefore){if("number"!=typeof p.nbf)return i(new st("invalid nbf value"));if(p.nbf>o+(r.clockTolerance||0))return i(new ct("jwt not active",new Date(1e3*p.nbf)))}if(void 0!==p.exp&&!r.ignoreExpiration){if("number"!=typeof p.exp)return i(new st("invalid exp value"));if(o>=p.exp+(r.clockTolerance||0))return i(new dt("jwt expired",new Date(1e3*p.exp)))}if(r.audience){var l=Array.isArray(r.audience)?r.audience:[r.audience];if(!(Array.isArray(p.aud)?p.aud:[p.aud]).some((function(e){return l.some((function(t){return t instanceof RegExp?t.test(e):t===e}))})))return i(new st("jwt audience invalid. expected: "+l.join(" or ")))}if(r.issuer&&("string"==typeof r.issuer&&p.iss!==r.issuer||Array.isArray(r.issuer)&&-1===r.issuer.indexOf(p.iss)))return i(new st("jwt issuer invalid. expected: "+r.issuer));if(r.subject&&p.sub!==r.subject)return i(new st("jwt subject invalid. expected: "+r.subject));if(r.jwtid&&p.jti!==r.jwtid)return i(new st("jwt jwtid invalid. expected: "+r.jwtid));if(r.nonce&&p.nonce!==r.nonce)return i(new st("jwt nonce invalid. expected: "+r.nonce));if(r.maxAge){if("number"!=typeof p.iat)return i(new st("iat required when maxAge is specified"));var f=yt(r.maxAge,p.iat);if(void 0===f)return i(new st('"maxAge" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'));if(o>=f+(r.clockTolerance||0))return i(new dt("maxAge exceeded",new Date(1e3*f)))}if(!0===r.complete){var m=s.signature;return i(null,{header:u,payload:p,signature:m})}return i(null,p)}))},Rr=function(e,t,r,n){"function"==typeof r?(n=r,r={}):r=r||{};var i="object"==typeof e&&!Buffer.isBuffer(e),o=Object.assign({alg:r.algorithm||"HS256",typ:i?"JWT":void 0,kid:r.keyid},r.header);function s(e){if(n)return n(e);throw e}if(!t&&"none"!==r.algorithm)return s(new Error("secretOrPrivateKey must have a value"));if(void 0===e)return s(new Error("payload is required"));if(i){try{!function(e){Sr(Ir,!0,e,"payload")}(e)}catch(e){return s(e)}r.mutatePayload||(e=Object.assign({},e))}else{var a=Or.filter((function(e){return void 0!==r[e]}));if(a.length>0)return s(new Error("invalid "+a.join(",")+" option for "+typeof e+" payload"))}if(void 0!==e.exp&&void 0!==r.expiresIn)return s(new Error('Bad "options.expiresIn" option the payload already has an "exp" property.'));if(void 0!==e.nbf&&void 0!==r.notBefore)return s(new Error('Bad "options.notBefore" option the payload already has an "nbf" property.'));try{!function(e){Sr(xr,!1,e,"options")}(r)}catch(e){return s(e)}var c=e.iat||Math.floor(Date.now()/1e3);if(r.noTimestamp?delete e.iat:i&&(e.iat=c),void 0!==r.notBefore){try{e.nbf=yt(r.notBefore,c)}catch(e){return s(e)}if(void 0===e.nbf)return s(new Error('"notBefore" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}if(void 0!==r.expiresIn&&"object"==typeof e){try{e.exp=yt(r.expiresIn,c)}catch(e){return s(e)}if(void 0===e.exp)return s(new Error('"expiresIn" should be a number of seconds or string representing a timespan eg: "1d", "20h", 60'))}Object.keys(kr).forEach((function(t){var n=kr[t];if(void 0!==r[t]){if(void 0!==e[n])return s(new Error('Bad "options.'+t+'" option. The payload already has an "'+n+'" property.'));e[n]=r[t]}}));var u=r.encoding||"utf8";if("function"!=typeof n)return nt.sign({header:o,payload:e,secret:t,encoding:u});n=n&&Cr(n),nt.createSign({header:o,privateKey:t,payload:e,encoding:u}).once("error",n).once("done",(function(e){n(null,e)}))};let jr=[];class Dr{constructor(e){this.options=Object.assign({baseUrl:"https://appleid.apple.com",timeout:1e4},e)}async _fetch(e,t){const{baseUrl:r}=this.options;return uniCloud.httpclient.request(r+e,t)}async verifyIdentityToken(e){const t=e.split(".")[0],{kid:r}=JSON.parse(Buffer.from(t,"base64").toString());if(!jr.length)try{jr=await this.getAuthKeys()}catch(e){return{code:10705,msg:e.message}}const n=this.getUsedKey(jr,r);if(!Object.keys(n).length&&!this.fetched)try{jr=await this.getAuthKeys()}catch(e){return{code:10705,msg:e.message}}let i=null;try{i=Pr(e,function(e,t){var r=Buffer.from(e,"base64"),n=Buffer.from(t,"base64"),i=r.toString("hex"),o=n.toString("hex");i=J(i),o=J(o);var s=i.length/2,a=o.length/2,c=ee(s),u=ee(a),d="30"+ee(s+a+c.length/2+u.length/2+2)+"02"+c+i+"02"+u+o;return"-----BEGIN RSA PUBLIC KEY-----\n"+Buffer.from(d,"hex").toString("base64").match(/.{1,64}/g).join("\n")+"\n-----END RSA PUBLIC KEY-----\n"}(n.n,n.e),{algorithms:n.alg})}catch(e){return{code:10705,msg:e.message}}return{code:0,msg:i}}async getAuthKeys(){const{status:e,data:t}=await this._fetch("/auth/keys",{method:"GET",dataType:"json",timeout:this.options.timeout});if(200!==e)throw new Error("request https://appleid.apple.com/auth/keys fail");return t.keys}getUsedKey(e,t){let r={};for(let n=0;nvoid 0===e))return{code:N,messageValues:{param:this.t("dcloud-appid")}};const r=await P.doc(e).get(),n=r&&r.data&&r.data[0];if(!n)return{code:10002};const i=Object.keys(q).reduce((e,t)=>{const r=t,i=function(e,t){return t.split(".").reduce((e,t)=>e&&e[t],e)}(n,t);return i&&e.push({[r]:i}),e},[]);let o;const s={dcloud_appid:Br.in(t),_id:Br.neq(n._id)},a={dcloud_appid:Br.exists(!1),_id:Br.neq(n._id)};switch(i.length){case 0:return{code:10004};case 1:o=Br.or([Br.and([i[0],s]),Br.and([i[0],a])]);break;default:o=Br.or([Br.and([Br.or(i),s]),Br.and([Br.or(i),a])])}const c=await P.where(o).limit(1).get();return c&&c.data&&c.data[0]?{code:10005}:{code:0}}const $r=uniCloud.database().command;const Hr=uniCloud.database();const Kr=uniCloud.database().command;const Gr=uniCloud.database();const Qr=uniCloud.database();async function Xr(e){if(!e.openid||!e.access_token)throw new Error(this.t("config-param-required",{param:"openid, access_token"}));return function(e,t){const r={0:"",4e3:"缺失参数",4001:"apiKey不存在",4002:"sign校验不通过",4003:"appid不存在",4004:"应用未开通一键登录服务",4005:"应用开通的一键登录服务正在审核中",4006:"服务空间不在白名单中",4100:"账户余额不足",5e3:"获取手机号失败,请稍后重试(或其他未知错误)"};return{...e,msg:r[e.code]?"[getPhoneNumber] 获取手机号: "+r[e.code]:e.errMsg}}(await uniCloud.getPhoneNumber({provider:"univerify",...e}))}const Yr=uniCloud.database();const zr=uniCloud.database();const Wr=uniCloud.database();const Jr=uniCloud.database().command;const Zr=uniCloud.database();const en=uniCloud.database();const tn=uniCloud.database();const rn=uniCloud.database();const nn=uniCloud.database();const on=uniCloud.database();const sn=uniCloud.database();const an={"mobile-code":function(e){return!(!e.service||!e.service.sms)},univerify:function(e){return!(!e.service||!e.service.univerify)},weixin:function(e){return!!(e.oauth&&e.oauth.weixin&&e.oauth.weixin.appsecret)},qq:function(e){return!!(e.oauth&&e.oauth.qq&&e.oauth.qq.appsecret)},apple:function(e){return!!(e.oauth&&e.oauth.apple&&e.oauth.apple.bundleId)},alipay:function(e){return!!(e.oauth&&e.oauth.alipay&&e.oauth.alipay.privateKey)}};const cn=uniCloud.database();var un=Object.freeze({__proto__:null,addUser:async function({username:e,nickname:t,password:r,mobile:n,email:i,role:o=[],authorizedApp:s=[]}={}){const a=O.command,c=[];if(!e&&!n&&!i)throw new Error("username, mobile or email required");let u;if(e&&c.push({username:e}),n&&c.push({mobile:n,mobile_confirmed:1}),i&&c.push({email:i,email_confirmed:1}),s.length>0){u=a.and(a.or(c),a.or({dcloud_appid:a.in(s)},{dcloud_appid:a.exists(!1)}));if((await P.where(u).limit(1).get()).data.length>0)return{code:10201,messageValues:{type:this.t("username")}}}const d={role:o,nickname:t,dcloud_appid:s,register_date:Date.now()};if(e&&(d.username=e),r){const{passwordHash:e,version:t}=this.encryptPwd(r);d.password=e,t&&(d.password_secret_version=t)}return n&&(d.mobile=n,d.mobile_confirmed=1),i&&(d.email=i,d.email_confirmed=1),{code:0,uid:(await P.add(d)).id}},getUserInfo:async function({uid:e,field:t}){if(!e)return{code:N,messageValues:{param:this.t("user-id")}};let r;if(t&&t.length){const n={};for(let e=0;evoid 0===e.dcloud_appid||e.dcloud_appid.includes(this.context.APPID));if(0===i.length)return{code:10002};if(i.length>1)return{code:10005};const o=i[0]._id;return this.resetPwd({uid:o,password:r})},setAvatar:async function(e){return await P.doc(e.uid).update({avatar:e.avatar}),{code:0,msg:""}},updatePwd:async function(e){const t=await P.doc(e.uid).get();if(t&&t.data&&t.data.length>0){if(0===this._checkPwd(t.data[0],e.oldPassword).code){const{passwordHash:r,version:n}=this.encryptPwd(e.newPassword),i={password:r,token:[]};n&&(i.password_secret_version=n);return E("upRes",await P.doc(t.data[0]._id).update(i)),{code:0,msg:""}}return{code:40202}}return{code:40201}},updateUser:async function(e){const t=e.uid;if(!t)return{code:N,messageValues:{param:this.t("user-id")}};delete e.uid;const{username:r,email:n}=e,{usernameToLowerCase:i,emailToLowerCase:o}=this._getConfig();let s=r&&r.trim(),a=n&&n.trim();return s&&(i&&(s=s.toLowerCase()),e.username=s),a&&(o&&(a=a.toLowerCase()),e.email=a),E("update -> upRes",await P.doc(t).update(e)),{code:0,msg:""}},banAccount:async function({uid:e}={}){return $.call(this,{uid:e,status:B})},unbanAccount:async function({uid:e}={}){return $.call(this,{uid:e,status:M})},closeAccount:async function({uid:e}={}){return $.call(this,{uid:e,status:F})},openAccount:async function({uid:e}={}){return $.call(this,{uid:e,status:M})},_getAlipayApi:function(){const e=this.context.PLATFORM,t=this._getConfig();if(!t.oauth||!t.oauth.alipay)throw new Error(this.t("config-param-require",{param:e+".alipay"}));return["appid","privateKey"].forEach(r=>{if(!t.oauth.alipay[r])throw new Error(this.t("config-param-require",{param:`${e}.alipay.${r}`}))}),Ur({...t.oauth.alipay})},_getValidInviteCode:async function({inviteCode:e}={}){if(e){return await Mr(e)?{code:0,inviteCode:e}:{code:80401}}return async function(){let e,t=10,r=!1;for(;t>0&&!r;){t--,e=Vr();if(await Mr(e)){r=!0;break}}return r?{code:0,inviteCode:e}:{code:80402}}()},_addUser:async function(e,{needPermission:t,autoSetDcloudAppid:r=!0}={}){const n=this._getConfig(),i={...e,dcloud_appid:r?[this.context.APPID]:[],register_date:Date.now()},o=(await P.add(i)).id;let s;if(n.removePermissionAndRoleFromToken)s=await this.createToken({uid:o,needPermission:t});else{const t=e.role||[];let r;r=0===t.length||t.includes("admin")?[]:await this._getPermissionListByRoleList(t),s=await this.createToken({uid:o,role:t,permission:r})}const{token:a,tokenExpired:c}=s;return await P.doc(o).update({token:[a]}),{token:a,tokenExpired:c,uid:o,type:"register",userInfo:Object.assign({},i,{token:[a]})}},_loginExec:async function(e,t={}){if(e.status===B)return{code:10001};if(e.status===F)return{code:10006};const r=this._getConfig();let n=e.token||[];"string"==typeof n&&(n=[n]);const i=this._getExpiredToken(n);let o;if(n=n.filter(e=>-1===i.indexOf(e)),r.removePermissionAndRoleFromToken){const r=t.needPermission;o=await this.createToken({uid:e._id,needPermission:r})}else{const t=e.role||[];let r;r=0===t.length||t.includes("admin")?[]:await this._getPermissionListByRoleList(t),o=await this.createToken({uid:e._id,role:t,permission:r})}const{token:s,tokenExpired:a}=o;n.push(s),e.token=n;const c={last_login_date:Date.now(),last_login_ip:this.context.CLIENTIP,token:n,...t.extraData};await P.doc(e._id).update(c);const u=Object.assign({},e,c);return{code:0,msg:"",token:s,uid:u._id,username:u.username,type:"login",userInfo:u,tokenExpired:a}},_registerExec:async function(e,{needPermission:t,autoSetDcloudAppid:r=!0}={}){const{my_invite_code:n}=e;if(this._getConfig().autoSetInviteCode||n){const t=await this._getValidInviteCode({inviteCode:n});if(t.code)return t;e.my_invite_code=t.inviteCode}const{PLATFORM:i,appId:o,appid:s,APPID:a,uniPlatform:c,appName:u,appVersion:d,appVersionCode:p,channel:l,clientIP:f,CLIENTIP:m,OS:h,osName:g}=this.context;return e.register_env={appid:o||s||a||"",uni_platform:c||i||"",os_name:g||h||"",app_name:u||"",app_version:d||"",app_version_code:p||"",channel:l?l+"":"",client_ip:f||m||""},{code:0,msg:"",...await this._addUser(e,{needPermission:t,autoSetDcloudAppid:r})}},_getWeixinApi:function(){const e=this.context.PLATFORM,t=this._getConfig();if(!t.oauth||!t.oauth.weixin)throw new Error(this.t("config-param-require",{param:e+".weixin"}));return["appid","appsecret"].forEach(r=>{if(!t.oauth.weixin[r])throw new Error(this.t("config-param-require",{param:`${e}.weixin.${r}`}))}),qr({...t.oauth.weixin})},_getQQApi:function(){const e=this.context.PLATFORM,t=this._getConfig();if(!t.oauth||!t.oauth.qq)throw new Error(this.t("config-param-require",{param:e+".qq"}));return["appid","appsecret"].forEach(r=>{if(!t.oauth.qq[r])throw new Error(this.t("config-param-require",{param:`${e}.qq.${r}`}))}),Nr({...t.oauth.qq})},_getMatchedUser:function(e,t){if(0===e.length)return{code:10002};let r;const n={},i={};for(let r=e.length-1;r>=0;r--){const o=e[r];for(let s=0;s0?{code:10003,messageValues:{target:"用户"}}:{code:0,msg:"",userMatched:r,fieldMatched:s,isFallbackValueMatched:!!s&&i[s]}},_getCurrentAppUser:function(e){const t=this.context.APPID;return e.filter(e=>void 0===e.dcloud_appid||null===e.dcloud_appid||e.dcloud_appid.indexOf(t)>-1||e.dcloud_appid.indexOf(null)>-1)},_checkLoginUserList:function(e){if(e&&1!==e.length)return e[0].status===F?{code:10006}:{code:10005}},setAuthorizedAppLogin:async function({uid:e,dcloudAppidList:t}={}){if("array"!==m(t))return{code:U,messageValues:{param:"dcloudAppidList",reason:this.t("type-array-required",{param:this.t("dcloud-appid-list")})}};if(t&&0!==t.length){const r=await Fr.bind(this)({uid:e,dcloudAppidList:t});if(r.code)return r}return await P.doc(e).update({dcloud_appid:Br.set(t)}),{code:0}},authorizeAppLogin:async function({uid:e,dcloudAppid:t}={}){const r=await Fr.bind(this)({uid:e,dcloudAppidList:[t]});return r.code?r:(await P.doc(e).update({dcloud_appid:Br.push(t)}),{code:0})},forbidAppLogin:async function({uid:e,dcloudAppid:t}={}){return e?(await P.doc(e).update({dcloud_appid:Br.pull(t)}),{code:0}):{code:N,messageValues:{param:this.t("user-id")}}},acceptInvite:async function({uid:e,inviteCode:t}){const r=await P.where({_id:$r.neq(e),inviter_uid:$r.not($r.all([e])),my_invite_code:t}).get();if(1!==r.data.length)return{code:80501,msg:"邀请码无效"};const n=[r.data[0]._id].concat(r.data[0].inviter_uid||[]),i=await P.doc(e).field({my_invite_code:!0,inviter_uid:!0}).get();if(0===i.data.length)return{code:80502};if(i.data[0].inviter_uid&&i.data[0].inviter_uid.length>0)return{code:80503,msg:"邀请码不可修改"};const o=Date.now();return await P.doc(e).update({inviter_uid:n,invite_time:o}),await P.where({inviter_uid:e}).update({inviter_uid:$r.push(n)}),{code:0,msg:""}},getInvitedUser:async function({uid:e,level:t=1,limit:r=20,offset:n=0,needTotal:i=!1}){const o={code:0,msg:"",invitedUser:(await P.where({["inviter_uid."+(t-1)]:e}).field({_id:!0,username:!0,mobile:!0,invite_time:!0}).orderBy("invite_time","desc").skip(n).limit(r).get()).data};if(i){const r=await P.where({["inviter_uid."+(t-1)]:e}).count();o.total=r.total}return o},setUserInviteCode:async function({uid:e,myInviteCode:t}){const r=await this._getValidInviteCode({inviteCode:t});return r.code?r:(await P.doc(e).update({my_invite_code:r.inviteCode}),{code:0,msg:"",myInviteCode:r.inviteCode})},loginByAlipay:async function(e){"string"==typeof e&&(e={code:e});const{needPermission:t,code:r,myInviteCode:n,role:i,type:o}=e,{openid:s}=await this._getAlipayApi().code2Session(r);if(!s)return{code:10501,messageValues:{account:this.t("alipay-account")}};let a=await P.where({ali_openid:s}).get();if(a=this._getCurrentAppUser(a.data),a&&a.length>0){if("register"===o)return{code:10502,messageValues:{type:this.t("alipay-account")}};if(1!==a.length)return{code:10005};const e=a[0],r=await this._loginExec(e,{needPermission:t});if(0!==r.code)return r;const{userInfo:n}=r;return{...r,openid:s,mobileConfirmed:1===n.mobile_confirmed,emailConfirmed:1===n.email_confirmed}}{if("login"===o)return{code:10503,messageValues:{type:this.t("alipay-account")}};const e={ali_openid:s};e.my_invite_code=n,e.role=i;const r=await this._registerExec(e,{needPermission:t});return 0!==r.code?r:{...r,openid:s,mobileConfirmed:!1,emailConfirmed:!1}}},loginByEmail:async function(e){let{email:t,code:r,password:n,myInviteCode:i,type:o,needPermission:s,role:a}=e||{};if(t=t&&t.trim(),!t)return{code:N,messageValues:{param:"邮箱"}};const{emailToLowerCase:c}=this._getConfig();let u=t;c&&(u=t.toLowerCase());const d=await this.verifyCode({email:u,code:r,type:o||"login"});if(0!==d.code)return d;let p={email:t,email_confirmed:1};const l={field:"email",value:t},f=Hr.command;u!==t&&(p=f.or(p,{email:u,email_confirmed:1}),l.fallbackValue=u);let m=await P.where(p).get();if(m=this._getCurrentAppUser(m.data),m&&m.length>0){if("register"===o)return{code:10301,messageValues:{type:"邮箱"}};const e=this._getMatchedUser(m,[l]);if(e.code)return e;const{userMatched:t}=e,r=await this._loginExec(t,{needPermission:s});return 0!==r.code?r:{...r,email:u}}{if("login"===o)return{code:10302,messageValues:{type:"邮箱"}};const e={email:u,email_confirmed:1},t=n&&n.trim();if(t){const{passwordHash:r,version:n}=this.encryptPwd(t);e.password=r,n&&(e.password_secret_version=n)}e.my_invite_code=i,e.role=a;const r=await this._registerExec(e,{needPermission:s});return 0!==r.code?r:{...r,email:u}}},loginBySms:async function({mobile:e,code:t,password:r,inviteCode:n,myInviteCode:i,type:o,needPermission:s,role:a}){if(!(e=e&&e.trim()))return{code:N,messageValues:{param:this.t("mobile")}};const c=this._getConfig();if(c.forceInviteCode&&!o)throw new Error(this.t("login-with-invite-type-required"));const u=await this.verifyCode({mobile:e,code:t,type:o||"login"});if(0!==u.code)return u;const d={mobile:e,mobile_confirmed:1};let p=await P.where(d).get();if(p=this._getCurrentAppUser(p.data),p&&p.length>0){if("register"===o)return{code:10201,messageValues:{type:this.t("mobile")}};if(1!==p.length)return{code:10005};const t=p[0],r=await this._loginExec(t,{needPermission:s});return 0!==r.code?r:{...r,mobile:e}}{const t=Date.now();if("login"===o)return{code:10202,messageValues:{type:this.t("mobile")}};const u={mobile:e,mobile_confirmed:1,register_ip:this.context.CLIENTIP,register_date:t},d=r&&r.trim();if(d){const{passwordHash:e,version:t}=this.encryptPwd(d);u.password=e,t&&(u.password_secret_version=t)}if(n){const e=await P.where({my_invite_code:n}).get();if(1!==e.data.length)return{code:10203};u.inviter_uid=[e.data[0]._id].concat(e.data[0].inviter_uid||[]),u.invite_time=t}else if(c.forceInviteCode)return{code:10203};u.my_invite_code=i,u.role=a;const p=await this._registerExec(u,{needPermission:s});return 0!==p.code?p:{...p,mobile:e}}},loginByWeixin:async function(e){"string"==typeof e&&(e={code:e});const{needPermission:t,platform:r,code:n,myInviteCode:i,role:o,type:s}=e,a=r||this.context.PLATFORM,c=function({clientPlatform:e,userAgent:t}={}){switch(e){case"app":case"app-plus":return"app";case"mp-weixin":return"mp";case"h5":case"web":return t.indexOf("MicroMessenger")>-1?"h5":"web";default:throw new Error("Unsupported weixin platform")}}({clientPlatform:a,userAgent:this.context.CLIENTUA}),u="mp-weixin"===a,{openid:d,unionid:p,sessionKey:l,accessToken:f,refreshToken:m,expired:h}=await this._getWeixinApi()[u?"code2Session":"getOauthAccessToken"](n);if(!d)return{code:10401,messageValues:{account:"微信openid"}};const g={dcloudAppid:this.context.APPID,openid:d,platform:"weixin-"+c},y=require("uni-open-bridge-common");let w;u?(w={sessionKey:l},await y.setSessionKey(g,{session_key:l},2592e3)):(w={accessToken:f,refreshToken:m,accessTokenExpired:h},await y.setUserAccessToken(g,{access_token:f,refresh_token:m,access_token_expired:h},2592e3));const v=Gr.command,_=[{wx_openid:{[a]:d}}];p&&_.push({wx_unionid:p});let b=await P.where(v.or(..._)).get();if(b=this._getCurrentAppUser(b.data),b&&b.length>0){if("register"===s)return{code:10402,messageValues:{type:this.t("wechat-account")}};if(1!==b.length)return{code:10005};const e=b[0],r={wx_openid:{[a]:d}};p&&(r.wx_unionid=p);const n=await this._loginExec(e,{needPermission:t,extraData:r});if(0!==n.code)return n;const{userInfo:i}=n;return{...n,openid:d,unionid:p,...w,mobileConfirmed:1===i.mobile_confirmed,emailConfirmed:1===i.email_confirmed}}{if("login"===s)return{code:10403,messageValues:{type:this.t("wechat-account")}};const e={wx_openid:{[a]:d},wx_unionid:p};e.my_invite_code=i,e.role=o;const r=await this._registerExec(e,{needPermission:t});return 0!==r.code?r:{...r,openid:d,unionid:p,...w,mobileConfirmed:!1,emailConfirmed:!1}}},loginByQQ:async function({code:e,accessToken:t,accessTokenExpired:r,myInviteCode:n,needPermission:i,role:o,type:s}={}){const a=this.context.PLATFORM,c="mp-qq"===a,{openid:u,unionid:d,sessionKey:p}=await this._getQQApi()[c?"code2Session":"getOpenidByToken"]({code:e,accessToken:t});if(!u)return{code:10801,messageValues:{account:"qq openid"}};const l=function({clientPlatform:e}={}){switch(e){case"app":case"app-plus":return"app";case"mp-qq":return"mp";default:throw new Error("Unsupported qq platform")}}({clientPlatform:a}),f={dcloudAppid:this.context.APPID,openid:u,platform:"qq-"+l},m=require("uni-open-bridge-common");let h;c?(h={sessionKey:p},await m.setSessionKey(f,{session_key:p},2592e3)):(h={accessToken:t,accessTokenExpired:r},await m.setUserAccessToken(f,{access_token:t,access_token_expired:r},r?Math.floor((r-Date.now())/1e3):2592e3));const g=Qr.command,y=[{qq_openid:{[a]:u}}];d&&y.push({qq_unionid:d});let w=await P.where(g.or(...y)).get();if(w=this._getCurrentAppUser(w.data),w&&w.length>0){if("register"===s)return{code:10802,messageValues:{type:this.t("qq-account")}};if(1!==w.length)return{code:10005};const e=w[0],t={qq_openid:{[a]:u}};d&&(t.qq_unionid=d);const r=await this._loginExec(e,{needPermission:i,extraData:t});if(0!==r.code)return r;const{userInfo:n}=r;return{...r,openid:u,unionid:d,...h,mobileConfirmed:1===n.mobile_confirmed,emailConfirmed:1===n.email_confirmed}}{if("login"===s)return{code:10803,messageValues:{type:this.t("qq-account")}};const e={qq_openid:{[a]:u},qq_unionid:d};e.my_invite_code=n,e.role=o;const t=await this._registerExec(e);return 0!==t.code?t:{...t,openid:u,unionid:d,...h,mobileConfirmed:!1,emailConfirmed:!1}}},loginByUniverify:async function({openid:e,access_token:t,password:r,inviteCode:n,myInviteCode:i,type:o,needPermission:s,role:a}){const c=this._getConfig(),u=c&&c.service&&c.service.univerify;if(!u)throw new Error(this.t("uni-verify-config-required"));if(c.forceInviteCode&&!o)throw new Error(this.t("login-with-invite-type-required"));const d=await Xr.bind(this)({...u,openid:e,access_token:t});if(0!==d.code)return d;const p=String(d.phoneNumber);let l=await P.where({mobile:p,mobile_confirmed:1}).get();if(l=this._getCurrentAppUser(l.data),l&&l.length>0){if("register"===o)return{code:10601,messageValues:{type:this.t("mobile")}};if(1!==l.length)return{code:10005};const e=l[0],t=await this._loginExec(e,{needPermission:s});return 0!==t.code?t:{...t,mobile:p}}if("login"===o)return{code:10602,messageValues:{type:this.t("mobile")}};const f=Date.now(),m={mobile:p,my_invite_code:i,mobile_confirmed:1,role:a},h=r&&r.trim();if(h){const{passwordHash:e,version:t}=this.encryptPwd(h);m.password=e,t&&(m.password_secret_version=t)}if(n){let e=await P.where({my_invite_code:n}).get();if(1!==e.data.length)return{code:10203};e=e.data[0],m.inviter_uid=[e._id].concat(e.inviter_uid||[]),m.invite_time=f}else if(c.forceInviteCode)return{code:10203};m.my_invite_code=i;const g=await this._registerExec(m,{needPermission:s});return 0!==g.code?g:{...g,mobile:p}},loginByApple:async function({nickName:e,fullName:t,identityToken:r,myInviteCode:n,type:i,needPermission:o,role:s}){const a=this._getConfig(),c=a&&a.oauth&&a.oauth.apple,u=c&&c.bundleId;if(!u)throw new Error(this.t("config-param-require",{param:"(app || app-plus).apple.bundleId"}));if(!r)return{code:N,messageValues:{param:"identityToken"}};t=e||(t&&Object.keys(t).length>0?t.familyName+t.givenName:"");const{code:d,msg:p}=await Lr().verifyIdentityToken(r);if(0!==d)return{code:d,msg:p,messageValues:{account:this.t("apple-account")}};const{iss:l,sub:f,aud:m,email:h}=p;if("https://appleid.apple.com"!==l)return{code:10706,messageValues:{account:this.t("apple-account")}};if(!f)return{code:10701,messageValues:{account:this.t("apple-account")}};if(u!==m)return{code:10702,messageValues:{account:this.t("apple-account")}};const g=t||"User-"+(h?h.split("@")[0]:Math.random().toString(32).slice(2));let y=await P.where({apple_openid:f}).get();if(y=this._getCurrentAppUser(y.data),y&&y.length>0){if("register"===i)return{code:10703,messageValues:{type:this.t("apple-account")}};if(1!==y.length)return{code:10005};const e=y[0],t=await this._loginExec(e,{needPermission:o});return 0!==t.code?t:{...t,openid:f}}if("login"===i)return{code:10704,messageValues:{type:this.t("apple-account")}};const w={nickname:g,apple_openid:f,my_invite_code:n,role:s},v=await this._registerExec(w,{needPermission:o});return 0!==v.code?v:{...v,openid:f}},login:async function({username:e,password:t,queryField:r=[],needPermission:n}){const i=Yr.command,o=[];r&&r.length||(r=["username"]),r.length>1&&console.warn(this.t("query-field-warning"));const{usernameToLowerCase:s,emailToLowerCase:a,passwordErrorLimit:c,passwordErrorRetryTime:u}=this._getConfig(),d={email:{email_confirmed:1},mobile:{mobile_confirmed:1}},p={},l=e&&e.trim();if(!l)return{code:N,messageValues:{param:this.t("username")}};s&&(p.username=l.toLowerCase()),a&&(p.email=l.toLowerCase());const f=[];r.forEach(t=>{o.push({[t]:e,...d[t]});const r={field:t,value:e};"username"===t&&p.username!==e?(o.push({[t]:p.username,...d[t]}),r.fallbackValue=p.username):"email"===t&&p.email!==e&&(o.push({[t]:p.email,...d[t]}),r.fallbackValue=p.email),f.push(r)});let m=await P.where(i.or(...o)).get();m=this._getCurrentAppUser(m.data);const h=this.context.CLIENTIP,g=this._getMatchedUser(m,f);if(g.code)return g;const{userMatched:y}=g;let w=y.login_ip_limit||[];w=w.filter(e=>e.last_error_time>Date.now()-1e3*u);let v=w.find(e=>e.ip===h);if(v&&v.error_times>=c)return{code:10103};const _=t&&t.trim();if(!_)return{code:N,messageValues:{param:"密码"}};const b=this._checkPwd(y,_);if(0===b.code){const e=w.indexOf(v);e>-1&&w.splice(e,1);const t={login_ip_limit:w},{passwordHash:r,passwordVersion:i}=b;r&&i&&(t.password=r,t.password_secret_version=i);const o=await this._loginExec(y,{needPermission:n,extraData:t});return o.code,o}return v?(v.error_times++,v.last_error_time=Date.now()):(v={ip:h,error_times:1,last_error_time:Date.now()},w.push(v)),await P.doc(y._id).update({login_ip_limit:w}),{code:10102,msg:"密码错误"}},register:async function(e){const t=[],r=[{name:"username",desc:this.t("username")},{name:"email",desc:this.t("email"),extraCond:{email_confirmed:1}},{name:"mobile",desc:this.t("mobile"),extraCond:{mobile_confirmed:1}}],{usernameToLowerCase:n,emailToLowerCase:i}=this._getConfig();r.forEach(r=>{const o=r.name;let s=e[o]&&e[o].trim();s?(("username"===r.name&&n||"email"===r.name&&i)&&(s=s.toLowerCase()),e[o]=s,t.push({[o]:s,...r.extraCond})):delete e[o]});const{username:o,email:s,mobile:a,myInviteCode:c,needPermission:u,autoSetDcloudAppid:d=!0}=e;if("needPermission"in e&&delete e.needPermission,"autoSetDcloudAppid"in e&&delete e.autoSetDcloudAppid,0===t.length)return{code:20101,messageValues:{param:this.t("user-unique-param")}};const p=zr.command;let l=await P.where(p.or(...t)).get();if(l=this._getCurrentAppUser(l.data),l&&l.length>0){const t=l[0];if(t.status===F)return{code:10006};for(let n=0;nt[e]===i.extraCond[e])),t[i.name]===e[i.name]&&o)return{code:20102,messageValues:{type:i.desc}}}}const f=e.password&&e.password.trim();if(!f)return{code:N,messageValues:{param:this.t("password")}};const{passwordHash:m,version:h}=this.encryptPwd(f);e.password=m,h&&(e.password_secret_version=h),e.my_invite_code=c,delete e.myInviteCode;const g=await this._registerExec(e,{needPermission:u,autoSetDcloudAppid:d});return 0!==g.code?g:{...g,username:o,email:s,mobile:a}},logout:async function(e){const t=await this.checkToken(e);if(t.code)return t;const r=Wr.command;return await P.doc(t.uid).update({token:r.pull(e)}),{code:0,msg:""}},getRoleByUid:async function({uid:e}){if(!e)return{code:N,messageValues:{param:this.t("user-id")}};const t=await P.doc(e).get();return 0===t.data.length?{code:L}:{code:0,msg:"",role:t.data[0].role||[]}},getPermissionByRole:async function({roleID:e}){if(!e)return{code:N,messageValues:{param:"roleID"}};if("admin"===e){return{code:0,msg:"",permission:(await D.limit(1e3).get()).data.map(e=>e.permission_id)}}const t=await j.where({role_id:e}).get();return 0===t.data.length?{code:V}:{code:0,msg:"",permission:t.data[0].permission||[]}},getPermissionByUid:async function({uid:e}={}){const t=await P.aggregate().match({_id:e}).project({role:!0}).unwind("$role").lookup({from:"uni-id-roles",localField:"role",foreignField:"role_id",as:"roleDetail"}).unwind("$roleDetail").replaceRoot({newRoot:"$roleDetail"}).end(),r=[],n=[];return t.data.forEach(e=>{n.push(e.role_id),r.push(...e.permission)}),{code:0,msg:"",role:n,permission:A(r)}},bindRole:async function({uid:e,roleList:t,reset:r=!1}){const n={};return"string"==typeof t&&(t=[t]),n.role=r?t:Jr.push(t),await P.doc(e).update(n),{code:0,msg:""}},bindPermission:async function({roleID:e,permissionList:t,reset:r=!1}){const n={};return"string"==typeof t&&(t=[t]),n.permission=r?t:Jr.push(t),await j.where({role_id:e}).update(n),{code:0,msg:""}},unbindRole:async function({uid:e,roleList:t}){return"string"==typeof t&&(t=[t]),await P.doc(e).update({role:Jr.pull(Jr.in(t))}),{code:0,msg:""}},unbindPermission:async function({roleID:e,permissionList:t}){return"string"==typeof t&&(t=[t]),await j.where({role_id:e}).update({permission:Jr.pull(Jr.in(t))}),{code:0,msg:""}},addRole:async function({roleID:e,roleName:t,comment:r,permission:n=[]}){return e?"admin"===e?{code:U,messageValues:{param:"roleID",reason:this.t("add-role-admin-is-not-allowed")}}:(await j.add({role_id:e,role_name:t,comment:r,permission:n,create_date:Date.now()}),{code:0,msg:""}):{code:N,messageValues:{param:this.t("role-id")}}},addPermission:async function({permissionID:e,permissionName:t,comment:r}){return e?(await D.add({permission_id:e,permission_name:t,comment:r,create_date:Date.now()}),{code:0,msg:""}):{code:N,messageValues:{param:this.t("permission-id")}}},getRoleList:async function({limit:e=20,offset:t=0,needTotal:r=!0}){const n={code:0,msg:"",roleList:(await j.skip(t).limit(e).get()).data};if(r){const{total:e}=await j.where({_id:Jr.exists(!0)}).count();n.total=e}return n},getRoleInfo:async function(e){const t=await j.where({role_id:e}).get();return 0===t.data.length?{code:V}:{code:0,...t.data[0]}},updateRole:async function({roleID:e,roleName:t,comment:r,permission:n}){return e?(await j.where({role_id:e}).update({role_name:t,comment:r,permission:n}),{code:0,msg:""}):{code:N,messageValues:{param:this.t("role-id")}}},deleteRole:async function({roleID:e}){const t=m(e);if("string"===t)e=[e];else if("array"!==t)throw new Error("typeof roleID must be array or string");return await j.where({role_id:Jr.in(e)}).remove(),await P.where({role:Jr.elemMatch(Jr.in(e))}).update({role:Jr.pullAll(e)}),{code:0,msg:""}},getPermissionList:async function({limit:e=20,offset:t=0,needTotal:r=!0}){const n={code:0,msg:"",permissionList:(await D.skip(t).limit(e).get()).data};if(r){const{total:e}=await D.where({_id:Jr.exists(!0)}).count();n.total=e}return n},getPermissionInfo:async function(e){const t=await D.where({permission_id:e}).get();return 0===t.data.length?{code:N,messageValues:{param:this.t("permission-id")}}:{code:0,...t.data[0]}},updatePermission:async function({permissionID:e,permissionName:t,comment:r}){return e?(await D.where({permission_id:e}).update({permission_name:t,comment:r}),{code:0,msg:""}):{code:N,messageValues:{param:this.t("permission-id")}}},deletePermission:async function({permissionID:e}){const t=m(e);if("string"===t)e=[e];else if("array"!==t)throw new Error("typeof permissionID must be array or string");return await D.where({permission_id:Jr.in(e)}).remove(),await j.where({permission:Jr.elemMatch(Jr.in(e))}).update({permission:Jr.pullAll(e)}),{code:0,msg:""}},bindAlipay:async function({uid:e,code:t,platform:r}){const n=r||this.context.PLATFORM,{openid:i}=await this._getAlipayApi({platform:n}).code2Session(t);if(!i)return{code:60401,messageValues:{account:this.t("alipay-account")}};let o=await P.where({ali_openid:i}).get();return o=this._getCurrentAppUser(o.data),o&&o.length>0?{code:60402,messageValues:{type:this.t("alipay-account")}}:(await P.doc(e).update({ali_openid:i}),{code:0,openid:i,msg:""})},bindEmail:async function(e){let{uid:t,email:r,code:n}=e||{};if(r=r&&r.trim(),!r)return{code:N,messageValues:{param:this.t("email")}};if(!n)return{code:N,messageValues:{param:this.t("verify-code")}};const{emailToLowerCase:i}=this._getConfig();i&&(r=r.toLowerCase());let o=await P.where({email:r,email_confirmed:1}).get();if(o=this._getCurrentAppUser(o.data),o&&o.length>0)return{code:60201,messageValues:{type:this.t("email")}};const s=await this.verifyCode({email:r,code:n,type:"bind"});return 0!==s.code?s:(await P.doc(t).update({email:r,email_confirmed:1}),{code:0,msg:"",email:r})},bindMobile:async function(e){let{uid:t,mobile:r,code:n,openid:i,access_token:o,type:s="sms"}=e||{};if("univerify"===s){const e=this._getConfig(),t=e&&e.service&&e.service.univerify;if(!t)throw new Error("请在config.json中配置service.univerify下一键登录相关参数");const n=await Xr.bind(this)({...t,openid:i,access_token:o});if(0!==n.code)return n;r=""+n.phoneNumber}let a=await P.where({mobile:r,mobile_confirmed:1}).get();if(a=this._getCurrentAppUser(a.data),a&&a.length>0)return{code:60101,messageValues:{type:"手机号"}};if("sms"===s&&"code"in e){if(!r)return{code:N,messageValues:{param:this.t("mobile")}};if(!n)return{code:N,messageValues:{param:this.t("verify-code")}};const e=await this.verifyCode({mobile:r,code:n,type:"bind"});if(0!==e.code)return e}return await P.doc(t).update({mobile:r,mobile_confirmed:1}),{code:0,msg:"",mobile:r}},bindWeixin:async function({uid:e,code:t,platform:r}){const n=r||this.context.PLATFORM,i="mp-weixin"===n,{openid:o,unionid:s,sessionKey:a,accessToken:c,refreshToken:u,expired:d}=await this._getWeixinApi({platform:n})[i?"code2Session":"getOauthAccessToken"](t);if(!o)return{code:60301,messageValues:{account:"微信openid"}};const p=Zr.command,l=[{wx_openid:{[n]:o}}];s&&l.push({wx_unionid:s});let f=await P.where(p.or(...l)).get();if(f=this._getCurrentAppUser(f.data),f&&f.length>0)return{code:60302,messageValues:{type:this.t("wechat-account")}};const m={wx_openid:{[n]:o}};let h;return s&&(m.wx_unionid=s),await P.doc(e).update(m),h=i?{sessionKey:a}:{accessToken:c,refreshToken:u,accessTokenExpired:d},{code:0,msg:"",openid:o,unionid:s,...h}},bindQQ:async function({uid:e,code:t,accessToken:r,platform:n}={}){const i=n||this.context.PLATFORM,o="mp-qq"===i,{openid:s,unionid:a,sessionKey:c}=await this._getQQApi()[o?"code2Session":"getOpenidByToken"]({code:t,accessToken:r});if(!s)return{code:60501,messageValues:{account:"qq openid"}};const u=en.command,d=[{qq_openid:{[i]:s}}];a&&d.push({qq_unionid:a});let p=await P.where(u.or(...d)).get();if(p=this._getCurrentAppUser(p.data),p&&p.length>0)return{code:60502,messageValues:{type:this.t("qq-account")}};const l={qq_openid:{[i]:s}};return a&&(l.qq_unionid=a),await P.doc(e).update(l),{code:0,msg:"",openid:s,unionid:a,...{accessToken:r,sessionKey:c}}},unbindAlipay:async function(e){const t=tn.command,r=await P.doc(e).update({ali_openid:t.remove()});return E("upRes:",r),1===r.updated?{code:0,msg:""}:{code:70401}},unbindEmail:async function(e){let{uid:t,email:r,code:n}=e||{};if(r=r&&r.trim(),!t||!r)return{code:N,messageValues:{param:t?this.t("email"):this.t("user-id")}};const{emailToLowerCase:i}=this._getConfig();if("code"in e){const e=await this.verifyCode({email:r,code:n,type:"unbind"});if(0!==e.code)return e}const o=rn.command;let s={_id:t,email:r};if(i){const e=r.toLowerCase();e!==r&&(s=o.or(s,{_id:t,email:e}))}return 1===(await P.where(s).update({email:o.remove(),email_confirmed:o.remove()})).updated?{code:0,msg:""}:{code:70201}},unbindMobile:async function(e){const{uid:t,mobile:r,code:n}=e||{};if("code"in e){const e=await this.verifyCode({mobile:r,code:n,type:"unbind"});if(0!==e.code)return e}const i=nn.command;return 1===(await P.where({_id:t,mobile:r}).update({mobile:i.remove(),mobile_confirmed:i.remove()})).updated?{code:0,msg:""}:{code:70101}},unbindWeixin:async function(e){const t=on.command,r=await P.doc(e).update({wx_openid:t.remove(),wx_unionid:t.remove()});return E("upRes:",r),1===r.updated?{code:0,msg:""}:{code:70301}},unbindQQ:async function(e){const t=sn.command,r=await P.doc(e).update({qq_openid:t.remove(),qq_unionid:t.remove()});return E("upRes:",r),1===r.updated?{code:0,msg:""}:{code:70501}},getSupportedLoginType:function({appid:e,platform:t}={}){if(!e||!t)throw new Error("Parameter appid and platform is required");const r=this._getConfig({appid:e,platform:t}),n=["username-password","mobile-password","email-password"];for(const e in an)an[e](r)&&n.push(e);return{supportedLoginType:n}},code2SessionAlipay:async function(e){let t=e;"string"==typeof e&&(t={code:e});try{const e=t.platform||this.context.PLATFORM,r=await this._getAlipayApi({platform:e}).code2Session(t.code);return r.openid?{code:0,msg:"",...r}:{code:80701,messageValues:{account:this.t("alipay-account")}}}catch(e){return console.error(e),{code:80702,messageValues:{account:this.t("alipay-account")}}}},code2SessionWeixin:async function(e){let t=e;"string"==typeof e&&(t={code:e});try{const e=t.platform||this.context.PLATFORM,r=await this._getWeixinApi({platform:e})["mp-weixin"===e?"code2Session":"getOauthAccessToken"](t.code);return r.openid?{code:0,msg:"",...r}:{code:80601,messageValues:{account:"微信openid"}}}catch(e){return console.error(e),{code:80602,messageValues:{account:"微信openid"}}}},verifyAppleIdentityToken:async function({identityToken:e,platform:t}){const r=t||this.context.PLATFORM,{code:n,msg:i}=await Lr({clientType:r}).verifyIdentityToken(e);return 0!==n?{code:n,msg:i}:{code:n,msg:"验证通过",...i}},wxBizDataCrypt:async function({code:e,sessionKey:r,encryptedData:n,iv:i}){if(!n)return{code:N,messageValues:{param:"encryptedData"}};if(!i)return{code:N,messageValues:{param:"iv"}};if(!e&&!r)return{code:N,messageValues:{param:"sessionKey"}};const o=this._getWeixinApi();if(!r){const t=await o.code2Session(e);if(!t.sessionKey)return{code:80801};r=t.sessionKey}r=Buffer.from(r,"base64"),n=Buffer.from(n,"base64"),i=Buffer.from(i,"base64");try{var s=t.createDecipheriv("aes-128-cbc",r,i);s.setAutoPadding(!0);var a=s.update(n,"binary","utf8");a+=s.final("utf8"),a=JSON.parse(a)}catch(e){return console.error(e),{code:80802}}return a.watermark.appid!==o.options.appId?{code:80803}:{code:0,msg:"",...a}},getWeixinUserInfo:async function({accessToken:e,openid:t}={}){const r=this.context.PLATFORM;if("app"!==r&&"app-plus"!==r)throw new Error(this.t("limit-client-platform"));try{return{code:0,msg:"",...await this._getWeixinApi().getUserInfo({accessToken:e,openid:t})}}catch(e){return console.error(e),{code:80901}}},encryptPwd:function(e,{value:r,version:n}={}){if(!(e=e&&e.trim()))throw new Error(this.t("param-required",{param:this.t("password")}));if(!r){const e=this._getConfig(),{passwordSecret:t}=e;if("array"===m(t)){const e=t.sort((e,t)=>e.version-t.version);r=e[e.length-1].value,n=e[e.length-1].version}else r=t}if(!r)throw new Error(this.t("param-error",{param:"passwordSecret",reason:"invalid passwordSecret"}));const i=t.createHmac("sha1",r.toString("ascii"));return i.update(e),{passwordHash:i.digest("hex"),version:n}},checkToken:async function(e,{needPermission:t,needUserInfo:r=!0}={}){const n=this._getConfig(),i=this._verifyToken(e);if(i.code)return i;const{uid:o,needPermission:s,role:a,permission:c,exp:u,iat:d,...p}=i,l=a&&c;t=void 0===t?s:t;const f=n.removePermissionAndRoleFromToken||!l||r,m=!n.removePermissionAndRoleFromToken&&!l||n.removePermissionAndRoleFromToken&&l||n.tokenExpiresThreshold&&u-Date.now()/1e3this._createTokenInternal({signContent:e,config:o})):this._createTokenInternal({signContent:a,config:o})},_updateToken:async function({uid:e,tokenList:t,removeToken:r=[],addToken:n=[]}={}){if(!t){const r=await P.doc(e).get(),n=r.data&&r.data[0];t=n&&n.token||[]}"string"==typeof t&&(t=[t]);const i=this._getExpiredToken(t);(t=t.filter(e=>-1===i.indexOf(e))).push(...n);for(let e=0;ee.version-t.version);let c;if(c=n?a.find(e=>e.version===n):a[0],!c)return{code:3};const u=a[a.length-1],{passwordHash:d}=this.encryptPwd(t,c);if(d===r){const e={code:0};if(c!==u){const{passwordHash:r,version:n}=this.encryptPwd(t,u);e.passwordHash=r,e.passwordVersion=n}return e}return{code:4,message:""}},_verifyToken:function(e){const t=this._getConfig();let r;try{r=Pr(e,t.tokenSecret)}catch(e){return"TokenExpiredError"===e.name?{code:30203,err:e}:{code:30204,err:e}}return t.bindTokenToDevice&&r.clientId&&r.clientId!==this._getClientUaHash()?{code:30201}:{code:0,message:"",...r}},_getExpiredToken:function(e){const t=this._getConfig(),r=[];return e.forEach(e=>{try{Pr(e,t.tokenSecret)}catch(t){r.push(e)}}),r},_getPermissionListByRoleList:async function(e){if(!Array.isArray(e))return[];if(0===e.length)return[];if(e.includes("admin")){return(await D.limit(500).get()).data.map(e=>e.permission_id)}const t=await j.where({role_id:Kr.in(e)}).get(),r=[];return t.data.forEach(e=>{Array.prototype.push.apply(r,e.permission)}),A(r)},_getClientUaHash:function(){const e=t.createHash("md5"),r=/MicroMessenger/i.test(this.context.CLIENTUA)?this.context.CLIENTUA.replace(/(MicroMessenger\S+).*/i,"$1"):this.context.CLIENTUA;return e.update(r),e.digest("hex")},_createTokenInternal:function({signContent:e,config:t}){if(t.tokenExpiresIn&&t.tokenExpiresThreshold&&t.tokenExpiresIn<=t.tokenExpiresThreshold)throw new Error(this.t("token-expires-config-warning"));return"object"===m(e)&&e.uid?(t.bindTokenToDevice&&(e.clientId=this._getClientUaHash()),{token:Rr(e,t.tokenSecret,{expiresIn:t.tokenExpiresIn}),tokenExpired:Date.now()+1e3*t.tokenExpiresIn}):{code:30101,messageValues:{param:this.t("user-id")}}},setVerifyCode:async function({mobile:e,email:t,code:r,expiresIn:n,type:i}){if(t=t&&t.trim(),e=e&&e.trim(),t){const{emailToLowerCase:e}=this._getConfig();e&&(t=t.toLowerCase())}if(!e&&!t)return{code:50101,messageValues:{param:"手机号或邮箱"}};if(e&&t)return{code:50102,messageValues:{param:"参数",reason:"手机号和邮箱不可同时存在"}};r||(r=C()),n||(n=180);const o=Date.now(),s={mobile:e,email:t,type:i,code:r,state:0,ip:this.context.CLIENTIP,created_at:o,expired_at:o+1e3*n};return await R.add(s),{code:0,mobile:e,email:t}},verifyCode:async function({mobile:e,email:t,code:r,type:n}){if(t=t&&t.trim(),e=e&&e.trim(),t){const{emailToLowerCase:e}=this._getConfig();e&&(t=t.toLowerCase())}if(!e&&!t)return{code:50201,messageValues:{param:"手机号或邮箱"}};if(e&&t)return{code:50203,messageValues:{param:"参数",reason:"手机号和邮箱不可同时存在"}};if(!r)return{code:50202,messageValues:{type:this.t(e?"sms":"email")}};const i=cn.command,o=Date.now(),s={mobile:e,email:t,type:n,code:r,state:0,expired_at:i.gt(o)},a=await R.where(s).orderBy("created_at","desc").limit(1).get();if(a&&a.data&&a.data.length>0){const e=a.data[0];return await R.doc(e._id).update({state:1}),{code:0,msg:"验证通过"}}return{code:50202,messageValues:{type:this.t(e?"sms":"email")}}},sendSmsCode:async function({mobile:e,code:t,type:r,templateId:n}){if(!e)return{code:N,messageValues:{param:this.t("mobile")}};if(t||(t=C()),!r)return{code:N,messageValues:{param:this.t("verify-code-type")}};const i=this._getConfig();let o=i&&i.service&&i.service.sms;if(!o)throw new Error(this.t("config-param-required",{param:"service.sms"}));o=Object.assign({codeExpiresIn:300},o);const{name:s,smsKey:a,smsSecret:c,codeExpiresIn:u}=o;let d;switch(r){case"login":d=this.t("login");break;default:d=this.t("verify-mobile")}try{const i={name:s,code:t,action:d,expMinute:""+Math.round(u/60)};s&&(i.name=s),await uniCloud.sendSms({smsKey:a,smsSecret:c,phone:e,templateId:n||"uniID_code",data:i});const o=await this.setVerifyCode({mobile:e,code:t,expiresIn:u,type:r});return o.code>=0?o:{code:0,msg:""}}catch(e){return console.error(e),{code:50301}}}});let dn;try{dn=require("uni-config-center")}catch(e){throw new Error("Plugin[uni-config-center] was not found")}class pn{constructor({context:e,clientInfo:t,config:r}={}){const n=dn({pluginId:"uni-id"});this.pluginConfig=n,this.config=r||this._getConfigContent(),this._configCache={},Object.defineProperty(this,"context",{get(){let r;r=t?{OS:t.os,CLIENTIP:t.clientIP,CLIENTUA:t.userAgent,PLATFORM:t.platform,APPID:t.appId,LOCALE:t.locale,DEVICEID:t.deviceId}:Object.assign({},e||global.__ctx__||{});const n=["CLIENTIP","PLATFORM","APPID","LOCALE"];for(let e=0;ee.dcloudAppid===t)||e.find(e=>e.isDefaultConfig):e}_parseConfigContent(e){return Array.isArray(e)?e:e[0]?Object.values(e):e}_getConfigContent(){if(this.pluginConfig&&this.pluginConfig.hasFile("config.json")){let e;try{e=this.pluginConfig.config()}catch(e){throw new Error("Invalid uni-id config file\n"+e.message)}return this._parseConfigContent(e)}{let e;try{e=require("./config.json")}catch(e){if("MODULE_NOT_FOUND"===e.code||"ENOENT"===e.code)throw new Error("uni-id config file[uniCloud/cloudfunctions/common/uni-config-center/uni-id/config.json] not found");throw e}return this._parseConfigContent(e)}}init(){throw new Error("uniID.init has been deprecated, use uniID.createInstance instead")}setInterceptor(e,t){this.interceptorMap.set(e,t)}_getConfig({appid:e,platform:t}={}){const r=`${e=e||this.context.APPID}_${t=t||this.context.PLATFORM}`;if(this._configCache[r])return this._configCache[r];if(!(this.config&&0!==Object.keys(this.config).length))throw new Error(this.t("config-file-not-found"));const n=this._getAppConfig(this.config,e);"app"!==t&&"app-plus"!==t||(t=n.preferedAppPlatform||t),"web"!==t&&"h5"!==t||(t=n.preferedWebPlatform||t);const i=Object.assign(n,n[t])||{},o=Object.assign({bindTokenToDevice:!1,tokenExpiresIn:7200,tokenExpiresThreshold:1200,passwordErrorLimit:6,passwordErrorRetryTime:3600,usernameToLowerCase:!0,emailToLowerCase:!0},i);return["passwordSecret","tokenSecret","tokenExpiresIn","passwordErrorLimit","passwordErrorRetryTime"].forEach(e=>{if(!o||!o[e])throw new Error(this.t("config-param-required",{param:e}))}),this._configCache[r]=o,o}}for(const e in un)pn.prototype[e]=un[e];function ln(e){const t=new pn(e);return new Proxy(t,{get(e,t){if(t in e&&0!==t.indexOf("_")){if("function"==typeof e[t])return(r=e[t],function(){const e=r.apply(this,arguments);return f(e)?e.then(e=>(S.bind(this)(e),e)):(S.bind(this)(e),e)}).bind(e);if("context"!==t&&"config"!==t)return e[t]}var r}})}pn.prototype.createInstance=ln;var fn=ln();module.exports=fn;
diff --git a/uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/package.json b/uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/package.json
index 2fc9ff6d..544f2360 100644
--- a/uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/package.json
+++ b/uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/package.json
@@ -1,16 +1,20 @@
{
- "name": "uni-id",
- "version": "3.3.30",
- "description": "uni-id for uniCloud",
- "main": "index.js",
- "homepage": "https://uniapp.dcloud.io/uniCloud/uni-id",
- "repository": {
- "type": "git",
- "url": "git+https://gitee.com/dcloud/uni-id.git"
- },
- "author": "",
- "license": "Apache-2.0",
- "dependencies": {
- "uni-config-center": "file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
- }
+ "name": "uni-id",
+ "version": "3.3.32",
+ "description": "uni-id for uniCloud",
+ "main": "index.js",
+ "homepage": "https:\/\/uniapp.dcloud.io\/uniCloud\/uni-id",
+ "repository": {
+ "type": "git",
+ "url": "git+https:\/\/gitee.com\/dcloud\/uni-id.git"
+ },
+ "author": "",
+ "license": "Apache-2.0",
+ "dependencies": {
+ "uni-config-center": "file:..\/..\/..\/..\/..\/uni-config-center\/uniCloud\/cloudfunctions\/common\/uni-config-center"
+ },
+ "origin-plugin-dev-name": "uni-id",
+ "origin-plugin-version": "3.3.33",
+ "plugin-dev-name": "uni-id",
+ "plugin-version": "3.3.33"
}
\ No newline at end of file
diff --git a/uni_modules/uni-list/changelog.md b/uni_modules/uni-list/changelog.md
index 8254a185..ddf45a47 100644
--- a/uni_modules/uni-list/changelog.md
+++ b/uni_modules/uni-list/changelog.md
@@ -1,3 +1,5 @@
+## 1.2.15(2025-01-08)
+- 修复 示例中过期图片地址
## 1.2.14(2023-04-14)
- 优化 uni-list-chat 具名插槽`header` 非app端套一层元素,方便使用时通过外层元素定位实现样式修改
## 1.2.13(2023-03-03)
diff --git a/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue b/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue
index c25779e4..2322373b 100644
--- a/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue
+++ b/uni_modules/uni-list/components/uni-list-item/uni-list-item.vue
@@ -167,7 +167,7 @@
return {
type: '',
color: '#000000',
- size: 20,
+ size: 20,
customPrefix: ''
};
}
@@ -184,7 +184,7 @@
backgroundColor: '#FFFFFF'
}
}
- },
+ },
keepScrollPosition: {
type: Boolean,
default: false
@@ -192,34 +192,34 @@
},
watch: {
'customStyle.padding': {
- handler(padding) {
- if(typeof padding == 'number'){
- padding += ''
- }
+ handler(padding) {
+ if(typeof padding == 'number'){
+ padding += ''
+ }
let paddingArr = padding.split(' ')
if (paddingArr.length === 1) {
- const allPadding = paddingArr[0]
- this.padding = {
- "top": allPadding,
- "right": allPadding,
- "bottom": allPadding,
- "left": allPadding
+ const allPadding = paddingArr[0]
+ this.padding = {
+ "top": allPadding,
+ "right": allPadding,
+ "bottom": allPadding,
+ "left": allPadding
}
} else if (paddingArr.length === 2) {
- const [verticalPadding, horizontalPadding] = paddingArr;
- this.padding = {
- "top": verticalPadding,
- "right": horizontalPadding,
- "bottom": verticalPadding,
- "left": horizontalPadding
+ const [verticalPadding, horizontalPadding] = paddingArr;
+ this.padding = {
+ "top": verticalPadding,
+ "right": horizontalPadding,
+ "bottom": verticalPadding,
+ "left": horizontalPadding
}
} else if (paddingArr.length === 4) {
- const [topPadding, rightPadding, bottomPadding, leftPadding] = paddingArr;
- this.padding = {
- "top": topPadding,
- "right": rightPadding,
- "bottom": bottomPadding,
- "left": leftPadding
+ const [topPadding, rightPadding, bottomPadding, leftPadding] = paddingArr;
+ this.padding = {
+ "top": topPadding,
+ "right": rightPadding,
+ "bottom": bottomPadding,
+ "left": leftPadding
}
}
},
@@ -352,7 +352,7 @@
}
.uni-list-item--hover {
- background-color: $uni-bg-color-hover !important;
+ background-color: $uni-bg-color-hover;
}
.uni-list-item__container {
diff --git a/uni_modules/uni-list/package.json b/uni_modules/uni-list/package.json
index 8350efce..5ebe1569 100644
--- a/uni_modules/uni-list/package.json
+++ b/uni_modules/uni-list/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-list",
"displayName": "uni-list 列表",
- "version": "1.2.14",
+ "version": "1.2.15",
"description": "List 组件 ,帮助使用者快速构建列表。",
"keywords": [
"",
@@ -47,12 +47,15 @@
"platforms": {
"cloud": {
"tcb": "y",
- "aliyun": "y"
+ "aliyun": "y",
+ "alipay": "n"
},
"client": {
"App": {
- "app-vue": "y",
- "app-nvue": "y"
+ "app-vue": "y",
+ "app-nvue": "y",
+ "app-harmony": "u",
+ "app-uvue": "u"
},
"H5-mobile": {
"Safari": "y",
diff --git a/uni_modules/uni-list/readme.md b/uni_modules/uni-list/readme.md
index 32c28654..ae499e66 100644
--- a/uni_modules/uni-list/readme.md
+++ b/uni_modules/uni-list/readme.md
@@ -20,304 +20,8 @@ uni-list-item有很多风格,uni-list-item组件通过内置的属性,满足
uni-list不包含下拉刷新和上拉翻页。上拉翻页另见组件:[uni-load-more](https://ext.dcloud.net.cn/plugin?id=29)
-
-### 安装方式
-
-本组件符合[easycom](https://uniapp.dcloud.io/collocation/pages?id=easycom)规范,`HBuilderX 2.5.5`起,只需将本组件导入项目,在页面`template`中即可直接使用,无需在页面中`import`和注册`components`。
-
-如需通过`npm`方式使用`uni-ui`组件,另见文档:[https://ext.dcloud.net.cn/plugin?id=55](https://ext.dcloud.net.cn/plugin?id=55)
-
-> **注意事项**
-> 为了避免错误使用,给大家带来不好的开发体验,请在使用组件前仔细阅读下面的注意事项,可以帮你避免一些错误。
-> - 组件需要依赖 `sass` 插件 ,请自行手动安装
-> - 组件内部依赖 `'uni-icons'` 、`uni-badge` 组件
-> - `uni-list` 和 `uni-list-item` 需要配套使用,暂不支持单独使用 `uni-list-item`
-> - 只有开启点击反馈后,会有点击选中效果
-> - 使用插槽时,可以完全自定义内容
-> - note 、rightText 属性暂时没做限制,不支持文字溢出隐藏,使用时应该控制长度显示或通过默认插槽自行扩展
-> - 支付宝小程序平台需要在支付宝小程序开发者工具里开启 component2 编译模式,开启方式: 详情 --> 项目配置 --> 启用 component2 编译
-> - 如果需要修改 `switch`、`badge` 样式,请使用插槽自定义
-> - 在 `HBuilderX` 低版本中,可能会出现组件显示 `undefined` 的问题,请升级最新的 `HBuilderX` 或者 `cli`
-> - 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
-
-
-### 基本用法
-
-- 设置 `title` 属性,可以显示列表标题
-- 设置 `disabled` 属性,可以禁用当前项
-
-```html
-
-
-
-
-
-```
-
-### 多行内容显示
-
-- 设置 `note` 属性 ,可以在第二行显示描述文本信息
-
-```html
-
-
-
-
-
-```
-
-### 右侧显示角标、switch
-
-- 设置 `show-badge` 属性 ,可以显示角标内容
-- 设置 `show-switch` 属性,可以显示 switch 开关
-
-```html
-
-
-
-
-
-```
-
-### 左侧显示略缩图、图标
-
-- 设置 `thumb` 属性 ,可以在列表左侧显示略缩图
-- 设置 `show-extra-icon` 属性,并指定 `extra-icon` 可以在左侧显示图标
-
-```html
-
-
-
-
-```
-
-### 开启点击反馈和右侧箭头
-- 设置 `clickable` 为 `true` ,则表示这是一个可点击的列表,会默认给一个点击效果,并可以监听 `click` 事件
-- 设置 `link` 属性,会自动开启点击反馈,并给列表右侧添加一个箭头
-- 设置 `to` 属性,可以跳转页面,`link` 的值表示跳转方式,如果不指定,默认为 `navigateTo`
-
-```html
-
-
-
-
-
-
-
-```
-
-
-### 聊天列表示例
-- 设置 `clickable` 为 `true` ,则表示这是一个可点击的列表,会默认给一个点击效果,并可以监听 `click` 事件
-- 设置 `link` 属性,会自动开启点击反馈,`link` 的值表示跳转方式,如果不指定,默认为 `navigateTo`
-- 设置 `to` 属性,可以跳转页面
-- `time` 属性,通常会设置成时间显示,但是这个属性不仅仅可以设置时间,你可以传入任何文本,注意文本长度可能会影响显示
-- `avatar` 和 `avatarList` 属性同时只会有一个生效,同时设置的话,`avatarList` 属性的长度大于1 ,`avatar` 属性将失效
-- 可以通过默认插槽自定义列表右侧内容
-
-```html
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 刚刚
-
-
-
-
-
-
-
-```
-
-```javascript
-
-export default {
- components: {},
- data() {
- return {
- avatarList: [{
- url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png'
- }, {
- url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png'
- }, {
- url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/460d46d0-4fcc-11eb-8ff1-d5dcf8779628.png'
- }]
- }
- }
-}
-
-```
-
-
-```css
-
-.chat-custom-right {
- flex: 1;
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- flex-direction: column;
- justify-content: space-between;
- align-items: flex-end;
-}
-
-.chat-custom-text {
- font-size: 12px;
- color: #999;
-}
-
-```
-
-## API
-
-### List Props
-
-属性名 |类型 |默认值 | 说明
-:-: |:-: |:-: | :-:
-border |Boolean |true | 是否显示边框
-
-
-### ListItem Props
-
-属性名 |类型 |默认值 | 说明
-:-: |:-: |:-: | :-:
-title |String |- | 标题
-note |String |- | 描述
-ellipsis |Number |0 | title 是否溢出隐藏,可选值,0:默认; 1:显示一行; 2:显示两行;【nvue 暂不支持】
-thumb |String |- | 左侧缩略图,若thumb有值,则不会显示扩展图标
-thumbSize |String |medium | 略缩图尺寸,可选值,lg:大图; medium:一般; sm:小图;
-showBadge |Boolean |false | 是否显示数字角标
-badgeText |String |- | 数字角标内容
-badgeType |String |- | 数字角标类型,参考[uni-icons](https://ext.dcloud.net.cn/plugin?id=21)
-badgeStyle |Object |- | 数字角标样式,使用uni-badge的custom-style参数
-rightText |String |- | 右侧文字内容
-disabled |Boolean |false | 是否禁用
-showArrow |Boolean |true | 是否显示箭头图标
-link |String |navigateTo | 新页面跳转方式,可选值见下表
-to |String |- | 新页面跳转地址,如填写此属性,click 会返回页面是否跳转成功
-clickable |Boolean |false | 是否开启点击反馈
-showSwitch |Boolean |false | 是否显示Switch
-switchChecked |Boolean |false | Switch是否被选中
-showExtraIcon |Boolean |false | 左侧是否显示扩展图标
-extraIcon |Object |- | 扩展图标参数,格式为 ``{color: '#4cd964',size: '22',type: 'spinner'}``,参考 [uni-icons](https://ext.dcloud.net.cn/plugin?id=28)
-direction | String |row | 排版方向,可选值,row:水平排列; column:垂直排列; 3个插槽是水平排还是垂直排,也受此属性控制
-
-
-#### Link Options
-
-属性名 | 说明
-:-: | :-:
-navigateTo | 同 uni.navigateTo()
-redirectTo | 同 uni.reLaunch()
-reLaunch | 同 uni.reLaunch()
-switchTab | 同 uni.switchTab()
-
-### ListItem Events
-
-事件称名 |说明 |返回参数
-:-: |:-: |:-:
-click |点击 uniListItem 触发事件,需开启点击反馈 |-
-switchChange |点击切换 Switch 时触发,需显示 switch |e={value:checked}
-
-
-
-### ListItem Slots
-
-名称 | 说明
-:-: | :-:
-header | 左/上内容插槽,可完全自定义默认显示
-body | 中间内容插槽,可完全自定义中间内容
-footer | 右/下内容插槽,可完全自定义右侧内容
-
-
-> **通过插槽扩展**
-> 需要注意的是当使用插槽时,内置样式将会失效,只保留排版样式,此时的样式需要开发者自己实现
-> 如果 `uni-list-item` 组件内置属性样式无法满足需求,可以使用插槽来自定义uni-list-item里的内容。
-> uni-list-item提供了3个可扩展的插槽:`header`、`body`、`footer`
-> - 当 `direction` 属性为 `row` 时表示水平排列,此时 `header` 表示列表的左边部分,`body` 表示列表的中间部分,`footer` 表示列表的右边部分
-> - 当 `direction` 属性为 `column` 时表示垂直排列,此时 `header` 表示列表的上边部分,`body` 表示列表的中间部分,`footer` 表示列表的下边部分
-> 开发者可以只用1个插槽,也可以3个一起使用。在插槽中可自主编写view标签,实现自己所需的效果。
-
-
-**示例**
-
-```html
-
-
-
-
-
-
-
-
-
-
- 自定义插槽
-
-
-
-
-
-
-```
-
-
-
-
-
-### ListItemChat Props
-
-属性名 |类型 |默认值 | 说明
-:-: |:-: |:-: | :-:
-title |String |- | 标题
-note |String |- | 描述
-clickable |Boolean |false | 是否开启点击反馈
-badgeText |String |- | 数字角标内容,设置为 `dot` 将显示圆点
-badgePositon |String |right | 角标位置
-link |String |navigateTo | 是否展示右侧箭头并开启点击反馈,可选值见下表
-clickable |Boolean |false | 是否开启点击反馈
-to |String |- | 跳转页面地址,如填写此属性,click 会返回页面是否跳转成功
-time |String |- | 右侧时间显示
-avatarCircle |Boolean |false | 是否显示圆形头像
-avatar |String |- | 头像地址,avatarCircle 不填时生效
-avatarList |Array |- | 头像组,格式为 [{url:''}]
-
-#### Link Options
-
-属性名 | 说明
-:-: | :-:
-navigateTo | 同 uni.navigateTo()
-redirectTo | 同 uni.reLaunch()
-reLaunch | 同 uni.reLaunch()
-switchTab | 同 uni.switchTab()
-
-### ListItemChat Slots
-
-名称 | 说明
-:- | :-
-default | 自定义列表右侧内容(包括时间和角标显示)
-
-### ListItemChat Events
-事件称名 | 说明 | 返回参数
-:-: | :-: | :-:
-@click | 点击 uniListChat 触发事件 | {data:{}} ,如有 to 属性,会返回页面跳转信息
-
-
-
+### [点击查看详细文档](https://uniapp.dcloud.io/component/uniui/uni-indexed-list)
+#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
@@ -339,8 +43,4 @@ default | 自定义列表右侧内容(包括时间和角标显示)
1. 云端一体列表/宫格视图互切:[https://ext.dcloud.net.cn/plugin?id=2651](https://ext.dcloud.net.cn/plugin?id=2651)
2. 云端一体列表(宫格模式):[https://ext.dcloud.net.cn/plugin?id=2671](https://ext.dcloud.net.cn/plugin?id=2671)
-3. 云端一体列表(列表模式):[https://ext.dcloud.net.cn/plugin?id=2672](https://ext.dcloud.net.cn/plugin?id=2672)
-
-## 组件示例
-
-点击查看:[https://hellouniapp.dcloud.net.cn/pages/extUI/list/list](https://hellouniapp.dcloud.net.cn/pages/extUI/list/list)
\ No newline at end of file
+3. 云端一体列表(列表模式):[https://ext.dcloud.net.cn/plugin?id=2672](https://ext.dcloud.net.cn/plugin?id=2672)
\ No newline at end of file
diff --git a/uni_modules/uni-load-more/changelog.md b/uni_modules/uni-load-more/changelog.md
index 8f03f1d5..667abdb9 100644
--- a/uni_modules/uni-load-more/changelog.md
+++ b/uni_modules/uni-load-more/changelog.md
@@ -1,3 +1,9 @@
+## 1.3.6(2024-10-15)
+- 修复 微信小程序中的getSystemInfo警告
+## 1.3.5(2024-10-12)
+- 修复 微信小程序中的getSystemInfo警告
+## 1.3.4(2024-10-12)
+- 修复 微信小程序中的getSystemInfo警告
## 1.3.3(2022-01-20)
- 新增 showText属性 ,是否显示文本
## 1.3.2(2022-01-19)
diff --git a/uni_modules/uni-load-more/components/uni-load-more/uni-load-more.vue b/uni_modules/uni-load-more/components/uni-load-more/uni-load-more.vue
index ededbc20..aa43c551 100644
--- a/uni_modules/uni-load-more/components/uni-load-more/uni-load-more.vue
+++ b/uni_modules/uni-load-more/components/uni-load-more/uni-load-more.vue
@@ -36,8 +36,13 @@
diff --git a/uni_modules/uni-table/components/uni-tr/uni-tr.vue b/uni_modules/uni-table/components/uni-tr/uni-tr.vue
index a3b20900..56abd4bc 100644
--- a/uni_modules/uni-table/components/uni-tr/uni-tr.vue
+++ b/uni_modules/uni-table/components/uni-tr/uni-tr.vue
@@ -2,16 +2,18 @@
-
+
|
-
+
-
-
+
+
@@ -20,156 +22,163 @@
diff --git a/uni_modules/uni-table/package.json b/uni_modules/uni-table/package.json
index a52821ba..19454c71 100644
--- a/uni_modules/uni-table/package.json
+++ b/uni_modules/uni-table/package.json
@@ -1,7 +1,7 @@
{
"id": "uni-table",
"displayName": "uni-table 表格",
- "version": "1.2.4",
+ "version": "1.2.8",
"description": "表格组件,多用于展示多条结构类似的数据,如",
"keywords": [
"uni-ui",
@@ -42,7 +42,8 @@
"platforms": {
"cloud": {
"tcb": "y",
- "aliyun": "y"
+ "aliyun": "y",
+ "alipay": "n"
},
"client": {
"App": {
@@ -80,4 +81,4 @@
}
}
}
-}
\ No newline at end of file
+}