From f4f2d2ac8cdcc85460db88855665cfd500acc76e Mon Sep 17 00:00:00 2001
From: zhenyuWang <13641039885@163.com>
Date: Fri, 11 Oct 2024 15:06:07 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=88=86=E6=94=AF?=
=?UTF-8?q?=E5=90=88=E5=B9=B6=E9=94=99=E8=AF=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages.json | 7 --
.../component/native-view/native-view.test.js | 17 ++++
pages/component/native-view/native-view.uvue | 50 +++++++++++
uni_modules/native-button/package.json | 87 +++++++++++++++++++
uni_modules/native-button/readme.md | 3 +
.../utssdk/app-android/config.json | 3 +
.../utssdk/app-android/index.uts | 37 ++++++++
.../native-button/utssdk/app-ios/config.json | 3 +
8 files changed, 200 insertions(+), 7 deletions(-)
create mode 100644 pages/component/native-view/native-view.test.js
create mode 100644 pages/component/native-view/native-view.uvue
create mode 100644 uni_modules/native-button/package.json
create mode 100644 uni_modules/native-button/readme.md
create mode 100644 uni_modules/native-button/utssdk/app-android/config.json
create mode 100644 uni_modules/native-button/utssdk/app-android/index.uts
create mode 100644 uni_modules/native-button/utssdk/app-ios/config.json
diff --git a/pages.json b/pages.json
index 0c9f07fd..3ec5d2ab 100644
--- a/pages.json
+++ b/pages.json
@@ -1052,13 +1052,6 @@
"enablePullDownRefresh": false
}
},
- {
- "path": "pages/API/virtual-payment/virtual-payment-uni-pay",
- "style": {
- "navigationBarTitleText": "苹果虚拟支付(uni-pay)",
- "enablePullDownRefresh": false
- }
- },
// #endif
// #ifdef APP-IOS
{
diff --git a/pages/component/native-view/native-view.test.js b/pages/component/native-view/native-view.test.js
new file mode 100644
index 00000000..d0578f05
--- /dev/null
+++ b/pages/component/native-view/native-view.test.js
@@ -0,0 +1,17 @@
+describe('native-view.uvue', () => {
+ if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
+ it('object', () => {
+ expect(1).toBe(1)
+ })
+ return
+ }
+ beforeAll(async () => {
+ page = await program.reLaunch('/pages/component/native-view/native-view')
+ });
+
+ it('native-view检测init函数是否响应', async () => {
+ await page.waitFor(600)
+ const value = await page.data('isLoad')
+ expect(value).toBe(true)
+ })
+})
diff --git a/pages/component/native-view/native-view.uvue b/pages/component/native-view/native-view.uvue
new file mode 100644
index 00000000..4207eb83
--- /dev/null
+++ b/pages/component/native-view/native-view.uvue
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/uni_modules/native-button/package.json b/uni_modules/native-button/package.json
new file mode 100644
index 00000000..dff99bce
--- /dev/null
+++ b/uni_modules/native-button/package.json
@@ -0,0 +1,87 @@
+{
+ "id": "uni-native-button",
+ "displayName": "uni-native-button",
+ "version": "0.0.1",
+ "description": "vue开发button原生组件",
+ "keywords": [
+ "tencent",
+ "map",
+ "tmap"
+ ],
+ "repository": "",
+ "engines": {
+ "HBuilderX": "^4.25"
+ },
+ "dcloudext": {
+ "type": "uts",
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "无",
+ "data": "插件不采集任何数据",
+ "permissions": "无"
+ },
+ "npmurl": ""
+ },
+ "uni_modules": {
+ "dependencies": [],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "y",
+ "aliyun": "y"
+ },
+ "client": {
+ "Vue": {
+ "vue2": "n",
+ "vue3": "y"
+ },
+ "App": {
+ "app-android": {
+ "minVersion": "21"
+ },
+ "app-ios": {
+ "minVersion": "9"
+ }
+ },
+ "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",
+ "字节跳动": "u",
+ "QQ": "y",
+ "钉钉": "u",
+ "快手": "u",
+ "飞书": "u",
+ "京东": "u"
+ },
+ "快应用": {
+ "华为": "u",
+ "联盟": "u"
+ }
+ }
+ }
+ }
+}
diff --git a/uni_modules/native-button/readme.md b/uni_modules/native-button/readme.md
new file mode 100644
index 00000000..ee8a09e0
--- /dev/null
+++ b/uni_modules/native-button/readme.md
@@ -0,0 +1,3 @@
+## native-button
+
+通过 object 封装原生平台Button按钮
diff --git a/uni_modules/native-button/utssdk/app-android/config.json b/uni_modules/native-button/utssdk/app-android/config.json
new file mode 100644
index 00000000..5defc8f1
--- /dev/null
+++ b/uni_modules/native-button/utssdk/app-android/config.json
@@ -0,0 +1,3 @@
+{
+ "minSdkVersion": "21"
+}
diff --git a/uni_modules/native-button/utssdk/app-android/index.uts b/uni_modules/native-button/utssdk/app-android/index.uts
new file mode 100644
index 00000000..5118215f
--- /dev/null
+++ b/uni_modules/native-button/utssdk/app-android/index.uts
@@ -0,0 +1,37 @@
+import { Button } from "android.widget"
+
+export class NativeButton {
+ $element: UniNativeViewElement;
+
+ constructor(element: UniNativeViewElement) {
+ this.$element = element;
+ this.bindView();
+ }
+
+ button: Button | null = null;
+ bindView() {
+ //通过UniElement.getAndroidActivity()获取android平台activity 用于创建view的上下文
+ this.button = new Button(this.$element.getAndroidActivity()!); //构建原生view
+ //限制原生Button 文案描述不自动大写
+ this.button?.setAllCaps(false)
+ //监听原生Button点击事件
+ this.button?.setOnClickListener(_ => {
+ const detail = {}
+ //构建自定义UniNativeViewEvent返回对象
+ const event = new UniNativeViewEvent("customClick", detail)
+ //响应分发原生Button的点击事件
+ this.$element.dispatchEvent(event)
+ })
+ //UniNativeViewEvent 绑定 安卓原生view
+ this.$element.bindAndroidView(this.button!);
+ }
+
+ updateText(text: string) {
+ //更新原生Button 文案描述
+ this.button?.setText(text)
+ }
+
+ destroy() {
+ //数据回收
+ }
+}
diff --git a/uni_modules/native-button/utssdk/app-ios/config.json b/uni_modules/native-button/utssdk/app-ios/config.json
new file mode 100644
index 00000000..33128280
--- /dev/null
+++ b/uni_modules/native-button/utssdk/app-ios/config.json
@@ -0,0 +1,3 @@
+{
+ "deploymentTarget": "12"
+}
--
GitLab