拷贝xinfengtianneng
This commit is contained in:
62
components/NavBar.vue
Normal file
62
components/NavBar.vue
Normal file
@@ -0,0 +1,62 @@
|
||||
<template>
|
||||
<view class="header">
|
||||
<span @tap="goBack" class="iconfont icon_back"></span>
|
||||
<span class="page_name">{{title}}</span>
|
||||
<span @tap="backHome" class="iconfont icon_home" :class="{'vhide': show1 === false}"></span>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
};
|
||||
},
|
||||
props: {
|
||||
title: String,
|
||||
inner: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
inner2: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
show1: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
goBack () {
|
||||
if (this.inner) {
|
||||
uni.navigateBack()
|
||||
} else if (this.inner2) {
|
||||
this.$emit('goIn')
|
||||
} else {
|
||||
uni.redirectTo({
|
||||
url: '/pages/home/home'
|
||||
})
|
||||
}
|
||||
},
|
||||
backHome () {
|
||||
uni.redirectTo({
|
||||
url: '/pages/home/home'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="stylus">
|
||||
@import '@/common/style/mixin.styl';
|
||||
.header
|
||||
_fj()
|
||||
position fixed
|
||||
_wh(100%, 72rpx)
|
||||
background-color $red
|
||||
z-index 200
|
||||
padding 0 20rpx
|
||||
.page_name
|
||||
_font(32rpx, 32rpx, #fff,700,center)
|
||||
</style>
|
||||
138
components/SearchBox.vue
Normal file
138
components/SearchBox.vue
Normal file
@@ -0,0 +1,138 @@
|
||||
<template>
|
||||
<view class="search_wraper">
|
||||
<input
|
||||
type="text"
|
||||
class="filter_input search_input"
|
||||
:value="value"
|
||||
:focus="focusState"
|
||||
@blur="handleBlur($event)"
|
||||
@input="handleChange($event)">
|
||||
<view class="buttons_wraper">
|
||||
<view class="iconfont icon_del" @tap="toDel"></view>
|
||||
<view class="iconfont icon_scan" :class="{'icon_scan_active': focusState === true}" @tap="toScan"></view>
|
||||
<view class="iconfont icon_phone" @tap="toPhone"></view>
|
||||
<view v-show="seaShow" class="iconfont icon_search" @tap="toSearch"></view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import permision from "@/utils/permission.js"
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
cur: '',
|
||||
focusState: false
|
||||
};
|
||||
},
|
||||
model: {
|
||||
prop: 'value',
|
||||
event: 'input'
|
||||
},
|
||||
props: {
|
||||
value: String,
|
||||
seaShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
focused: {
|
||||
type: Boolean,
|
||||
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', '')
|
||||
},
|
||||
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;
|
||||
}
|
||||
// #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
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="stylus">
|
||||
@import '../common/style/mixin.styl';
|
||||
.search_wraper
|
||||
position relative
|
||||
_wh(100%, 70rpx)
|
||||
.search_input
|
||||
padding-right: 160rpx;
|
||||
.buttons_wraper
|
||||
position absolute
|
||||
top 0
|
||||
right 10rpx
|
||||
_wh(auto, 70rpx)
|
||||
_fj(flex-end)
|
||||
.icon_scan_active
|
||||
color $red
|
||||
</style>
|
||||
110
components/SearchBox1.vue
Normal file
110
components/SearchBox1.vue
Normal file
@@ -0,0 +1,110 @@
|
||||
<template>
|
||||
<view class="search_wraper">
|
||||
<input
|
||||
type="text"
|
||||
class="filter_input search_input"
|
||||
:value="value"
|
||||
:focus="focused"
|
||||
@input="handleChange($event)">
|
||||
<view class="buttons_wraper">
|
||||
<span class="iconfont icon-del" @tap="toDel"></span>
|
||||
<span class="iconfont icon_scan" @tap="toScan"></span>
|
||||
<span v-show="seaShow" class="iconfont icon_search" @tap="toSearch"></span>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import permision from "@/utils/permission.js"
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
cur: ''
|
||||
};
|
||||
},
|
||||
model: {
|
||||
prop: 'value',
|
||||
event: 'input'
|
||||
},
|
||||
props: {
|
||||
value: String,
|
||||
seaShow: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
focused: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleChange ($event) {
|
||||
this.cur = $event.target.value
|
||||
this.$emit('input', this.cur)
|
||||
this.$emit('handleChange', this.cur)
|
||||
},
|
||||
toSearch () {
|
||||
this.$emit('toSearch', this.cur)
|
||||
},
|
||||
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: "设置",
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
permision.gotoAppSetting();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return status;
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="stylus">
|
||||
@import '../common/style/mixin.styl';
|
||||
.search_wraper
|
||||
position relative
|
||||
_wh(100%, 70rpx)
|
||||
.search_input
|
||||
padding-right: 160rpx;
|
||||
.buttons_wraper
|
||||
position absolute
|
||||
top 0
|
||||
right 0
|
||||
_wh(auto, 70rpx)
|
||||
</style>
|
||||
Reference in New Issue
Block a user