search-tabs.vue
3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<template>
<view class="search-tabs">
<view class="search-box">
<view class="search-input">
<u-input placeholder="搜索" placeholderStyle="font-size:13px;" v-model="keyword" prefixIcon="search"
border="none" prefixIconStyle="font-size: 22px;color: #909399">
<template slot="suffix">
<view class="sou-suo" @click="search">搜索</view>
</template>
</u-input>
</view>
<view class="scan-box" v-if="itScan">
<u-icon name="scan" color="#106FFF" size="24" class="uni-icon" @click="scan"></u-icon>
</view>
</view>
<view class="header-tabs" v-if="isShow" :class="{isflex: itflex}">
<u-tabs :list="navTabs" :activeStyle="activeStyle" :inactiveStyle="inactiveStyle" @click="clickTab">
</u-tabs>
</view>
</view>
</template>
<script>
import qrcode from '@/utils/reqrcode.js'
export default {
props: {
list: {
type: Array,
default () {
return []
}
},
show: {
type: Boolean,
default: true
},
isScan: {
type: Boolean,
default: false
},
isflex: {
type: Boolean,
default: false
}
},
data() {
return {
activeStyle: {
color: '#106FFF',
fontSize: '14px',
fontWeight: 500
},
inactiveStyle: {
color: '#606266',
fontSize: '14px',
fontWeight: 400
},
navTabs: this.list,
isShow: this.show,
itScan: this.isScan,
itflex: this.isflex,
keyword: ''
};
},
created() {
// 打印qrcode 查看是否引入成功
console.log(qrcode)
},
mounted() {},
watch: {
list(val, oval) {
this.navTabs = val
},
show(val, old) {
this.isShow = val
},
itScan(val, old) {
this.itScan = val
},
isflex(val, old) {
this.itflex = val
}
},
computed: {
},
methods: {
scan() {
let that = this
// 调用uni提供的调用相机api
uni.chooseImage({
sizeType: ['original'],
count: 1,
success: function(res) {
const tempFilePaths = res.tempFilePaths[0] // 获取到二维码图片的链接
qrcode.decode(tempFilePaths); // 解析二维码图片
qrcode.callback = function(res1) {
// 解析失败返回 error decoding QR Code
if (res1 == "error decoding QR Code") {
uni.showToast({
title: "识别二维码失败,请重新上传!",
duration: 2000,
icon: 'none'
})
} else {
// 解析成功返回二维码链接
console.log(res1)
}
this.$emit('onScan')
}
}
});
// uni.navigateTo({
// url: '/pages/bind-company/index'
// })
},
clickTab(ms) {
// console.log(ms, "ms");
this.$emit('changeTabs', ms)
},
search() {
let word = this.keyword
this.$emit('onSearch', word)
}
}
};
</script>
<style lang="scss" scoped>
.search-tabs {
width: 100%;
background-color: #fff;
margin-bottom: 10px;
.search-box {
width: 100%;
padding: 8px 16px;
box-sizing: border-box;
display: flex;
align-items: center;
.search-input {
width: 100%;
border-radius: 19px;
opacity: 1;
background: rgba(236, 242, 254, 1);
.sou-suo {
width: 48px;
height: 24px;
border-radius: 48px;
opacity: 1;
border: 0 solid rgba(0, 0.4588235318660736, 0.9764705896377563, 1);
background: linear-gradient(180deg, rgba(83, 151, 255, 1) 0%, rgba(16, 111, 255, 1) 100%);
opacity: 1;
color: rgba(245, 246, 250, 1);
font-size: 12px;
font-weight: 400;
font-family: "PingFang SC";
text-align: center;
line-height: 24px;
}
}
.scan-box {
width: 40px;
padding-left: 10px;
box-sizing: border-box;
}
}
.search-box {
width: 100%;
height: 48px;
}
}
</style>