1.前言
2.按钮
- 支持大小中三种尺寸,支持主题色全局配置,支持常见的状态色
<template>
<view :class="['zll-button-wrap', size, disabled? 'disabled':'',type=='text'?'text-btn':'']" :style="btnStyle" @click="onClick">
<slot></slot>
</view>
</template>
<script>
export default{
mixins: [componentMixins],
props: {
size: {
type: String,
default: "",
},
width: {
type: String,
default: "100%",
},
type: {
type: String,
default: "",
},
disabled: {
type: Boolean,
default: false
},
},
data(){
return {
baseColor: "#33cccc",
}
},
created(){
this.baseColor = uni.getStorageSync("baseColor") || "#33cccc"
},
methods: {
onClick(){
if(!this.disabled){
this.$emit('click')
}
}
},
computed: {
btnStyle(){
if(this.type != "text"){
var bgColor = this.baseColor
if(this.type == "info"){
bgColor = "#909399"
}else if(this.type == "warning"){
bgColor = "#f0ad4e"
}else if(this.type == "error"){
bgColor = "#dd524d"
}
return {
backgroundColor: bgColor,
width: this.width
}
}else{
return {
color: this.baseColor,
width: this.width
}
}
}
}
}
</script>
<style scoped lang="scss">
.zll-button-wrap{
height: 48px;
line-height: 48px;
color: #ffffff;
text-align: center;
border-radius: 10rpx;
font-size: 36rpx;
cursor: pointer;
}
.zll-button-wrap.small{
height: 40px;
line-height: 40px;
border-radius: 8rpx;
font-size: 32rpx;
}
.zll-button-wrap.mini{
height: 36px;
line-height: 36px;
border-radius: 6rpx;
font-size: 28rpx;
}
.zll-button-wrap.disabled{
opacity: 0.65;
cursor: not-allowed;
}
.zll-button-wrap.text-btn{
display: inline-block;
text-decoration: underline;
height: 40rpx;
line-height: 40rpx;
font-size: 28rpx;
}
</style>
3.扫码组件
<template>
<uni-easyinput :placeholder="placeholder" v-model="input_value" :disabled="disabled" suffixIcon="scan" :focus="focus" :clearable="clearable"
@change="onChange" @confirm="onConfirm" @iconClick="onScan" @input="onInput"
@blur="onBlur" @focus="onFocus"></uni-easyinput>
</template>
<script>
export default{
data(){
return {
input_value: ""
}
},
created(){
this.input_value = this.value || ""
},
watch: {
value(newVal){
this.input_value = newVal
}
},
props: {
value: {
type: [Number,String],
default: ""
},
disabled: {
type:Boolean,
default: false
},
placeholder: {
type: String,
default: "请输入"
},
focus: {
type:Boolean,
default: false
},
clearable: {
type:Boolean,
default: true
},
scanEvent: {
type: [String, Function],
default: ""
}
},
model: {
prop: "value",
event: "input"
},
methods: {
onInput(){
this.$nextTick(()=>{
this.$emit('input',this.input_value)
})
},
onChange(){
this.$nextTick(()=>{
this.$emit('change',this.input_value)
})
},
onConfirm(){
if(!getApp().globalData.isPdaScan){
getApp().globalData.isPdaScan = true
setTimeout(()=>{
getApp().globalData.isPdaScan = false
},getApp().globalData.isPdaScanInterval)
this.$nextTick(()=>{
this.$emit('confirm',this.input_value)
})
}else{
}
},
onFocus(){
this.$emit('focus')
},
onBlur(){
this.$emit('blur')
},
onScan(){
if(this.disabled){
return
}
uni.scanCode({
success: (res) => {
if(typeof this.scanEvent == 'function'){
this.scanEvent(res.result)
}else{
this.input_value = res.result
this.$nextTick(()=>{
this.$emit('input',this.input_value)
this.$emit('confirm',this.input_value)
})
}
}
})
}
}
}
</script>
<style scoped lang="scss">
/deep/ .uniui-scan{
font-size: 24px !important;
}
</style>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?