From 791a52ef94165d8e095b85379d9eefa1435695e8 Mon Sep 17 00:00:00 2001 From: caill <815519168@qq.com> Date: Thu, 1 Aug 2024 14:10:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/SearchBox.vue | 108 +++++--------------------- components/SearchBox_back.vue | 142 ++++++++++++++++++++++++++++++++++ manifest.json | 8 +- 3 files changed, 167 insertions(+), 91 deletions(-) create mode 100644 components/SearchBox_back.vue diff --git a/components/SearchBox.vue b/components/SearchBox.vue index 239028a..24deec5 100644 --- a/components/SearchBox.vue +++ b/components/SearchBox.vue @@ -3,15 +3,15 @@ + @focus="handleFocus" + @blur="handleBlur" + @confirm="handleSend"> - - - - + + @@ -21,7 +21,6 @@ export default { data() { return { - cur: '', focusState: false }; }, @@ -30,97 +29,28 @@ event: 'input' }, props: { - value: String, - seaShow: { - type: Boolean, - default: false - }, - focused: { - type: Boolean, - default: false - } + value: String }, - watch: { - focused() { - this.focusState = this.focused - }, - }, - mounted () { - if (this.focused) { - this.focusState = true - } - }, methods: { - handleChange ($event) { - this.cur = $event.target.value - this.$emit('input', this.cur) - this.$emit('handleChange', this.cur) - if (this.focusState) { - this.focusState = false - } + handleFocus () { + this.focusState = true }, - handleBlur () { - this.focusState = false - }, - toSearch () { - this.$emit('toSearch', this.cur) + handleBlur (e) { + this.$emit('input', e.target.value) + // if (e.target.value.length) { + // this.$emit('handleChange', e.target.value) + // } + this.focusState = false }, toDel () { - this.cur = '' this.$emit('input', '') }, - toScan () { - setTimeout(() => { - this.focusState = true - },0) - setTimeout(() => { - uni.hideKeyboard() - }, 300) - this.cur = '' - this.$emit('input', '') - }, - async toPhone() { - // #ifdef APP-PLUS - let status = await this.checkPermission(); - if (status !== 1) { - return; + handleSend (e) { + this.$emit('input', e.target.value) + if (e.target.value.length) { + this.$emit('handleChange', e.target.value) } - // #endif - uni.scanCode({ - success: (res) => { - this.$emit('input', res.result) - this.$emit('handleChange', res.result) - }, - fail: (err) => { - // uni.showToast({ - // title: '出错', - // icon: 'none' - // }) - } - }); } - // #ifdef APP-PLUS - , - async checkPermission(code) { - let status = permision.isIOS ? await permision.requestIOS('camera') : - await permision.requestAndroid('android.permission.CAMERA'); - - if (status === null || status === 1) { - status = 1; - } else { - uni.showModal({ - content: "需要相机权限", - confirmText: "设置", - success: function(res) { - if (res.confirm) { - permision.gotoAppSetting(); - } - } - }) - } - return status; - } - // #endif } } diff --git a/components/SearchBox_back.vue b/components/SearchBox_back.vue new file mode 100644 index 0000000..239028a --- /dev/null +++ b/components/SearchBox_back.vue @@ -0,0 +1,142 @@ + + + + + diff --git a/manifest.json b/manifest.json index 3559192..8410ab2 100644 --- a/manifest.json +++ b/manifest.json @@ -20,7 +20,10 @@ "ignoreVersion" : true }, /* 模块配置 */ - "modules" : {}, + "modules" : { + "Barcode" : {}, + "Camera" : {} + }, /* 应用发布信息 */ "distribute" : { /* android打包配置 */ @@ -41,7 +44,8 @@ "", "", "" - ] + ], + "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ] }, /* ios打包配置 */ "ios" : {