From fea523a122b892abfdf0dda12b72e3307206a053 Mon Sep 17 00:00:00 2001 From: aihe <961836564@qq.com> Date: Mon, 5 Aug 2024 00:49:59 +0800 Subject: [PATCH] uu --- .hbuilderx/launch.json | 39 +++++++++++++++++++++------------------ common/untool.js | 31 +++++++++++++++++++++++++++++++ manifest.json | 16 ++++++++++++++++ 3 files changed, 68 insertions(+), 18 deletions(-) diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index ee5be77..179fe2d 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -1,20 +1,23 @@ -{ // 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" - }, - "mp-weixin" : - { - "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" + }, + "mp-weixin" : { + "launchtype" : "local" + }, + "type" : "uniCloud" + }, + { + "playground" : "custom", + "type" : "uni-app:app-android" + } ] } diff --git a/common/untool.js b/common/untool.js index c974ee2..b5be76e 100644 --- a/common/untool.js +++ b/common/untool.js @@ -3,6 +3,10 @@ import qs from "@/common/libs/qs" import { saveAs } from "file-saver" // #endif +// #ifdef APP-PLUS +const appCloudScanner = uni.requireNativePlugin('Ba-Scanner'); +// #endif + const tabBarUrls = [ '/pages/tabBar/deal/deal', @@ -78,8 +82,34 @@ const hideLoading = ()=> { uni.hideLoading(); } +const customAppScanCode = ({resolve, reject})=> { + appCloudScanner.onScan( + { + // isContinuous: true, + barcodeFormats: [ + // "QR Code" + ], + // scanTimeSpace: 2000, + // isShowVibrate: true, + // isShowBeep: false, + hintText: '扫码', + }, + (res) => { + console.log("scanCode res========", res) + if (res.result) { + resolve(res.result) + } + } + ); +} + const scanCode = ()=> { return new Promise((resolve, reject)=> { + // #ifdef APP-PLUS + customAppScanCode({resolve, reject}) + // #endif + + // #ifndef APP-PLUS uni.scanCode({ onlyFromCamera: false, success: (res) =>{ @@ -88,6 +118,7 @@ const scanCode = ()=> { }, fail: reject }) + // #endif0 }) } diff --git a/manifest.json b/manifest.json index a6aca14..8491e2e 100644 --- a/manifest.json +++ b/manifest.json @@ -180,6 +180,22 @@ }, "uniStatistics" : { "enable" : true + }, + "nativePlugins" : { + "Ba-Scanner" : { + "__plugin_info__" : { + "name" : "扫码原生插件 - 新(连续扫码、设置格式、任意自定义界面)Ba-Scanner", + "description" : "Ba-Scanner 是一款毫秒级扫码插件,采用Google MLKit。支持连续扫码,持续万次不卡顿;支持自定义任意界面、任意点击事件、权限说明;支持多码、相册、闪光灯、焦距缩放、提示音、震动等等。", + "platforms" : "Android", + "url" : "https://ext.dcloud.net.cn/plugin?id=9669", + "android_package_name" : "uni.UNIBCB0FB5", + "ios_bundle_id" : "uni.UNIBCB0FB5", + "isCloud" : true, + "bought" : 1, + "pid" : "9669", + "parameters" : {} + } + } } }, /* 快应用特有相关 */