diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index 582561b0c3f6fe39e97853dce405a30cc66748aa..ad7c2a6be83a79900b8cac13428e51381e113455 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -1,16 +1,22 @@ -{ // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/ - // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 - "version": "0.0", - "configurations": [{ - "app-plus" : - { - "launchtype" : "local" - }, - "default" : - { - "launchtype" : "local" - }, - "type" : "uniCloud" - } +{ + // launch.json 配置了启动调试时相关设置,configurations下节点名称可为 app-plus/h5/mp-weixin/mp-baidu/mp-alipay/mp-qq/mp-toutiao/mp-360/ + // launchtype项可配置值为local或remote, local代表前端连本地云函数,remote代表前端连云端云函数 + "version" : "0.0", + "configurations" : [ + { + "app-plus" : { + "launchtype" : "local" + }, + "default" : { + "launchtype" : "local" + }, + "type" : "uniCloud" + }, + { + "bundleId" : "io.dcloud.test123456", + "certificateFile" : "/Users/lizhongyi/Desktop/文件/证书/dev_123.p12", + "certificateProfileFile" : "/Users/lizhongyi/Desktop/文件/证书/io_dcloud_test123456.mobileprovision", + "type" : "uni-app:app-ios" + } ] } diff --git a/manifest.json b/manifest.json index 43e16b568c0943a40fd4dda7403ef233f61ca4be..1932231622c1913f146f5403b48c72a749a88f09 100644 --- a/manifest.json +++ b/manifest.json @@ -1,72 +1,72 @@ -{ - "name" : "uni-api", - "appid" : "__UNI__4F60974", - "description" : "", - "versionName" : "1.0.0", - "versionCode" : "100", - "transformPx" : false, - /* 5+App特有相关 */ - "app-plus" : { - "usingComponents" : true, - "nvueStyleCompiler" : "uni-app", - "compilerVersion" : 3, - "splashscreen" : { - "alwaysShowBeforeRender" : true, - "waiting" : true, - "autoclose" : true, - "delay" : 0 - }, - /* 模块配置 */ - "modules" : {}, - /* 应用发布信息 */ - "distribute" : { - /* android打包配置 */ - "android" : { - "permissions" : [ - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "" - ] - }, - /* ios打包配置 */ - "ios" : {}, - /* SDK配置 */ - "sdkConfigs" : {} - } - }, - /* 快应用特有相关 */ - "quickapp" : {}, - /* 小程序特有相关 */ - "mp-weixin" : { - "appid" : "", - "setting" : { - "urlCheck" : false - }, - "usingComponents" : true - }, - "mp-alipay" : { - "usingComponents" : true - }, - "mp-baidu" : { - "usingComponents" : true - }, - "mp-toutiao" : { - "usingComponents" : true - }, - "uniStatistics" : { - "enable" : false - }, - "vueVersion" : "2" +{ + "name": "uni-api", + "appid": "__UNI__ED9218B", + "description": "", + "versionName": "1.0.0", + "versionCode": "100", + "transformPx": false, + /* 5+App特有相关 */ + "app-plus": { + "usingComponents": true, + "nvueStyleCompiler": "uni-app", + "compilerVersion": 3, + "splashscreen": { + "alwaysShowBeforeRender": true, + "waiting": true, + "autoclose": true, + "delay": 0 + }, + /* 模块配置 */ + "modules": {}, + /* 应用发布信息 */ + "distribute": { + /* android打包配置 */ + "android": { + "permissions": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] + }, + /* ios打包配置 */ + "ios": {}, + /* SDK配置 */ + "sdkConfigs": {} + } + }, + /* 快应用特有相关 */ + "quickapp": {}, + /* 小程序特有相关 */ + "mp-weixin": { + "appid": "", + "setting": { + "urlCheck": false + }, + "usingComponents": true + }, + "mp-alipay": { + "usingComponents": true + }, + "mp-baidu": { + "usingComponents": true + }, + "mp-toutiao": { + "usingComponents": true + }, + "uniStatistics": { + "enable": false + }, + "vueVersion": "2" } diff --git a/pages/index/index.vue b/pages/index/index.vue index 5bac7fa26c03e80a1a6ab1a38d537d4d717a10ab..14d6f84c1d09d8f5423f395782f5d56e9d6610f1 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -1,223 +1,255 @@ - - - - - diff --git a/uni_modules/uni-showmodal/changelog.md b/uni_modules/uni-showmodal/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uni-showmodal/package.json b/uni_modules/uni-showmodal/package.json new file mode 100644 index 0000000000000000000000000000000000000000..a99e98abf8637474ff29fdbbe2c5ea5e1cb7e483 --- /dev/null +++ b/uni_modules/uni-showmodal/package.json @@ -0,0 +1,81 @@ +{ + "id": "uni-showmodal", + "displayName": "uni-showmodal", + "version": "1.0.0", + "description": "uni-showmodal", + "keywords": [ + "uni-showmodal" +], + "repository": "", + "engines": { + "HBuilderX": "^3.6.8" + }, + "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": "u", + "aliyun": "u" + }, + "client": { + "Vue": { + "vue2": "u", + "vue3": "u" + }, + "App": { + "app-android": "u", + "app-ios": "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" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uni-showmodal/readme.md b/uni_modules/uni-showmodal/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..45964a4f5e1a266481c8c28d9f82ad74f8d402cd --- /dev/null +++ b/uni_modules/uni-showmodal/readme.md @@ -0,0 +1,5 @@ +# uni-showmodal +### 开发文档 +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS 原生插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts/-/tree/dev) \ No newline at end of file diff --git a/uni_modules/uni-showmodal/utssdk/app-android/index.uts b/uni_modules/uni-showmodal/utssdk/app-android/index.uts new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uni-showmodal/utssdk/app-ios/index.uts b/uni_modules/uni-showmodal/utssdk/app-ios/index.uts new file mode 100644 index 0000000000000000000000000000000000000000..e90f169c7cb00c55a4c7606e5846cfb159f41bc8 --- /dev/null +++ b/uni_modules/uni-showmodal/utssdk/app-ios/index.uts @@ -0,0 +1,110 @@ +import { UIAlertController, UIAlertAction, UITextField } from "UIKit" +import { UTSiOS } from "DCloudUTSFoundation" +import { DispatchQueue } from 'Dispatch'; + +type ShowModalResult = { + errCode: number, + errSubject: string, + errMsg: string, + confirm: boolean, + cancel: boolean, + content: string +} + +type ShowModalOptions = { + title?: string, + content?: string, + showCancel: boolean, + cancelText?: string, + cancelColor?: string, + confirmText?: string, + confirmColor?: string, + editable: boolean, + placeholderText?: string, + success?: (res: ShowModalResult) => void, + fail?: (res: ShowModalResult) => void, + complete?: (res: ShowModalResult) => void +} + +export default function showModal(options: ShowModalOptions) { + const title = options.title == null ? "" : options.title! + const message = options.content == null ? "" : options.content! + const showCancel = options.showCancel == null ? true : (options.showCancel != false) + const cancelText = options.cancelText == null ? "取消" : options.cancelText! + const confirmText = options.confirmText == null ? "确定" : options.confirmText! + const canEidt = options.editable == true + const placeholderText = options.placeholderText == null ? "" : options.placeholderText! + + // uts方法默认会在子线程中执行,涉及 UI 操作必须在主线程中运行,通过 DispatchQueue.main.async 方法可将代码在主线程中运行 + DispatchQueue.main.async(execute = (): void => { + + // 初始化 UIAlertController 实例对象 alert + let alert = new UIAlertController(title = title, message = message, preferredStyle = UIAlertController.Style.alert) + + if (canEidt == true) { + // 在 alert 上添加输入框 + console.log("需要加上输入框") + alert.addTextField(configurationHandler = (tf: UITextField): void => { + // 添加成功的回调 + // 设置输入框的 placeholder + tf.placeholder = placeholderText + }) + } + + // 创建 UIAlertAction 按钮 + let okAction = new UIAlertAction(title = confirmText, style = UIAlertAction.Style.default, handler = (action: UIAlertAction): void => { + // 获取输入框中的内容 + let inputText = "" + if (canEidt == true) { + let tf = alert.textFields?.[0] + if (tf != null) { + inputText = tf!.text != null ? tf!.text! : "" + } + } + + // 点击按钮的回调方法 + const res = new ShowModalResult() + res.errCode = 0 + res.errSubject = "" + res.errMsg = "" + res.confirm = false + res.cancel = true + res.content = inputText + options.success?.(res) + options.complete?.(res) + + }) + + if (options.confirmColor != null) { + const color = UTSiOS.colorWithString(options.confirmColor!) + okAction.setValue(color, forKey = "titleTextColor") + } + + // 将 UIAlertAction 添加到 alert 上 + alert.addAction(okAction) + + if (showCancel == true) { + // 创建 UIAlertAction 按钮 + let cancelAction = new UIAlertAction(title = cancelText, style = UIAlertAction.Style.cancel, handler = (action: UIAlertAction): void => { + // 点击按钮的回调方法 + const res = new ShowModalResult() + res.errCode = 0 + res.errSubject = "" + res.errMsg = "" + res.confirm = false + res.cancel = true + res.content = "" + options.success?.(res) + options.complete?.(res) + }) + if (options.cancelColor != null) { + const color = UTSiOS.colorWithString(options.cancelColor!) + cancelAction.setValue(color, forKey = "titleTextColor") + } + alert.addAction(cancelAction) + } + // 打开 alert 弹窗 + UTSiOS.getCurrentViewController().present(alert, animated = true) + }) +} +