diff --git a/components/SearchBox.vue b/components/SearchBox.vue index 183aac9..1d118e5 100644 --- a/components/SearchBox.vue +++ b/components/SearchBox.vue @@ -13,6 +13,7 @@ + @@ -53,7 +54,49 @@ if (e.target.value.length) { this.$emit('handleChange', e.target.value) } + }, + async toPhone() { + // #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 } }