From 4ac9d4dd358dcbce99125d2386b97916ebd66889 Mon Sep 17 00:00:00 2001
From: caill <815519168@qq.com>
Date: Mon, 30 Jan 2023 16:48:34 +0800
Subject: [PATCH] =?UTF-8?q?=E6=89=AB=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
App.vue | 2 +-
components/SearchBox.vue | 112 +++++++++++++++++++++++---------------
components/SearchBox1.vue | 110 +++++++++++++++++++++++++++++++++++++
3 files changed, 180 insertions(+), 44 deletions(-)
create mode 100644 components/SearchBox1.vue
diff --git a/App.vue b/App.vue
index 8c2d7c0..3d97b1b 100644
--- a/App.vue
+++ b/App.vue
@@ -2,7 +2,7 @@
export default {
onLaunch: function() {
// #ifdef APP-PLUS
- // plus.screen.lockOrientation('landscape-primary');
+ plus.screen.lockOrientation('portrait-primary');
plus.navigator.setFullscreen(true);
// #endif
},
diff --git a/components/SearchBox.vue b/components/SearchBox.vue
index 63134f7..2c87628 100644
--- a/components/SearchBox.vue
+++ b/components/SearchBox.vue
@@ -4,11 +4,12 @@
type="text"
class="filter_input search_input"
:value="value"
- :focus="focused"
+ :focus="focusState"
+ @blur="handleBlur($event)"
@input="handleChange($event)">
-
+
@@ -19,7 +20,8 @@
export default {
data() {
return {
- cur: ''
+ cur: '',
+ focusState: false
};
},
model: {
@@ -37,60 +39,82 @@
default: false
}
},
+ 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
+ }
+ },
+ handleBlur () {
+ this.focusState = false
},
toSearch () {
this.$emit('toSearch', this.cur)
},
toDel () {
+ this.cur = ''
this.$emit('input', '')
},
- async toScan() {
- // #ifdef APP-PLUS
- let status = await this.checkPermission();
- if (status !== 1) {
- return;
- }
- // #endif
- uni.scanCode({
- success: (res) => {
- this.$emit('input', res.result)
- this.$emit('handleChange', res.result)
- },
- fail: (err) => {
- // uni.showToast({
- // title: '出错',
- // icon: 'none'
- // })
- }
- });
+ toScan () {
+ setTimeout(() => {
+ this.focusState = true
+ },0)
+ setTimeout(() => {
+ uni.hideKeyboard()
+ }, 300)
+ this.cur = ''
+ this.$emit('input', '')
}
- // #ifdef APP-PLUS
- ,
- async checkPermission(code) {
- let status = permision.isIOS ? await permision.requestIOS('camera') :
- await permision.requestAndroid('android.permission.CAMERA');
+ // async toScan() {
+ // // #ifdef APP-PLUS
+ // let status = await this.checkPermission();
+ // if (status !== 1) {
+ // return;
+ // }
+ // // #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
+ // if (status === null || status === 1) {
+ // status = 1;
+ // } else {
+ // uni.showModal({
+ // content: "需要相机权限",
+ // confirmText: "设置",
+ // success: function(res) {
+ // if (res.confirm) {
+ // permision.gotoAppSetting();
+ // }
+ // }
+ // })
+ // }
+ // return status;
+ // }
+ // // #endif
}
}
@@ -107,4 +131,6 @@
top 0
right 0
_wh(auto, 70rpx)
+.icon_scan_active
+ color $red
diff --git a/components/SearchBox1.vue b/components/SearchBox1.vue
new file mode 100644
index 0000000..63134f7
--- /dev/null
+++ b/components/SearchBox1.vue
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+