2024-02-27 17:40:30 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<view class="zd-row search_wraper" :class="{'input_focus': focusState}">
|
|
|
|
|
|
<input
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
class="search_input"
|
2024-05-28 17:28:28 +08:00
|
|
|
|
confirm-type="go"
|
2024-02-27 17:40:30 +08:00
|
|
|
|
:value="value"
|
|
|
|
|
|
:focus="focusState"
|
2024-05-28 17:28:28 +08:00
|
|
|
|
@focus="handleFocus"
|
|
|
|
|
|
@blur="handleBlur"
|
|
|
|
|
|
@confirm="handleSend">
|
|
|
|
|
|
<view class="iconfont icon-del" @tap="toDel"></view>
|
2024-03-04 15:48:06 +08:00
|
|
|
|
<view class="iconfont icon_scan" @tap="toScan"></view>
|
2024-02-27 17:40:30 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import permision from "@/utils/permission.js"
|
|
|
|
|
|
export default {
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
focusState: false
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
model: {
|
|
|
|
|
|
prop: 'value',
|
|
|
|
|
|
event: 'input'
|
|
|
|
|
|
},
|
|
|
|
|
|
props: {
|
2024-05-28 17:28:28 +08:00
|
|
|
|
value: String
|
2024-02-27 17:40:30 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2024-05-28 17:28:28 +08:00
|
|
|
|
handleFocus () {
|
|
|
|
|
|
this.focusState = true
|
2024-02-27 17:40:30 +08:00
|
|
|
|
},
|
2024-05-28 17:28:28 +08:00
|
|
|
|
handleBlur (e) {
|
|
|
|
|
|
this.$emit('input', e.target.value)
|
|
|
|
|
|
if (e.target.value.length) {
|
|
|
|
|
|
this.$emit('handleChange', e.target.value)
|
|
|
|
|
|
}
|
|
|
|
|
|
this.focusState = false
|
|
|
|
|
|
},
|
|
|
|
|
|
handleSend (e) {
|
|
|
|
|
|
this.$emit('input', e.target.value)
|
|
|
|
|
|
if (e.target.value.length) {
|
|
|
|
|
|
this.$emit('handleChange', e.target.value)
|
|
|
|
|
|
}
|
2024-02-27 17:40:30 +08:00
|
|
|
|
},
|
|
|
|
|
|
toDel () {
|
|
|
|
|
|
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'
|
|
|
|
|
|
// })
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
// #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: "设置",
|
2025-04-17 15:46:32 +08:00
|
|
|
|
confirmColor: '#fff',
|
2024-02-27 17:40:30 +08:00
|
|
|
|
success: function(res) {
|
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
|
permision.gotoAppSetting();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
return status;
|
|
|
|
|
|
}
|
|
|
|
|
|
// #endif
|
|
|
|
|
|
// #ifdef APP-PLUS
|
|
|
|
|
|
,
|
|
|
|
|
|
async checkMpaasScan () {
|
|
|
|
|
|
var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
|
|
|
|
|
|
mpaasScanModule.mpaasScan({
|
|
|
|
|
|
// 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
|
|
|
|
|
|
'scanType': ['qrCode','barCode'],
|
|
|
|
|
|
// 是否隐藏相册,默认false不隐藏
|
|
|
|
|
|
'hideAlbum': false
|
|
|
|
|
|
},
|
|
|
|
|
|
(ret) => {
|
|
|
|
|
|
// uni.showModal({
|
|
|
|
|
|
// title: "弹窗标题",
|
|
|
|
|
|
// // 返回值中,resp_code 表示返回结果值,10:用户取消,11:其他错误,1000:成功
|
|
|
|
|
|
// // 返回值中,resp_message 表示返回结果信息
|
|
|
|
|
|
// // 返回值中,resp_result 表示扫码结果,只有成功才会有返回
|
|
|
|
|
|
// content: JSON.stringify(ret),
|
|
|
|
|
|
// showCancel: false,
|
|
|
|
|
|
// confirmText: "确定"
|
|
|
|
|
|
// })
|
|
|
|
|
|
this.$emit('input', ret.resp_result)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
// #endif
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="stylus">
|
|
|
|
|
|
@import '../common/style/mixin.styl';
|
|
|
|
|
|
.search_wraper
|
2024-03-04 15:15:15 +08:00
|
|
|
|
_wh(100%, 28px)
|
2024-05-28 17:28:28 +08:00
|
|
|
|
padding 0 2px 0 10px
|
2024-03-04 15:15:15 +08:00
|
|
|
|
border 1px solid #4980BD
|
2024-02-27 17:40:30 +08:00
|
|
|
|
background-color rgba(45,88,184,0.1)
|
2024-03-04 15:15:15 +08:00
|
|
|
|
border-radius 6px
|
2024-02-27 17:40:30 +08:00
|
|
|
|
.search_input
|
|
|
|
|
|
width 100%
|
2024-03-04 15:15:15 +08:00
|
|
|
|
height: 28px;
|
|
|
|
|
|
line-height: 28px;
|
|
|
|
|
|
font-size: 12px;
|
2024-02-27 17:40:30 +08:00
|
|
|
|
color: #fff
|
|
|
|
|
|
.icon_scan
|
2024-12-02 15:47:46 +08:00
|
|
|
|
_wh(50px, 24px)
|
2024-05-28 17:28:28 +08:00
|
|
|
|
_font(20px,24px,#fff,,center)
|
|
|
|
|
|
background-color #137ABD
|
|
|
|
|
|
border-radius 6px
|
|
|
|
|
|
.icon-del
|
2024-12-02 15:47:46 +08:00
|
|
|
|
_wh(30px, 28px)
|
2024-05-28 17:28:28 +08:00
|
|
|
|
_font(20px,28px,#fff,,center)
|
|
|
|
|
|
.input_focus
|
|
|
|
|
|
border: 1px solid #889dc7;
|
|
|
|
|
|
box-shadow: 0 0 0 1px rgba(136, 157, 199,.2);
|
2024-02-27 17:40:30 +08:00
|
|
|
|
</style>
|