Commit 2bcd5e1e by 张立顺

去掉无用组件

1 parent a30e88e3
// components/SearchBox/SearchBox.js
Component({
/**
* 组件的属性列表
*/
properties: {
placeholder: {
type: String,
value: '请输入搜索内容'
},
value: {
type: String,
value: '',
observer(n) {
this.setData({
inputValue: n
})
}
},
searchType: {
type: Number,
value: 1
},
couponDetails: Boolean
},
/**
* 组件的初始数据
*/
data: {
inputValue: ''
},
/**
* 组件的方法列表
*/
methods: {
input(e) {
let { value } = e.detail
this.setData({
inputValue: value
})
},
blur(e) {
let { inputValue } = this.data
this.setData({
inputValue
})
},
clear() {
this.setData({
inputValue: ''
})
},
confirm(e) {
let { value } = e.detail
this.triggerEvent('search', value)
},
search(e) {
let { value } = e.currentTarget.dataset
this.triggerEvent('search', value)
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view class="search-box box-center">
<view class="search type-{{searchType}}">
<view class="input-box" style="{{couponDetails?'width: 528rpx;':''}}">
<view class="icon box-center">
<icon type="search" size="20"></icon>
</view>
<input type="text" bindinput="input" bindblur="blur" value="{{inputValue}}" placeholder-class="input-placeholder" placeholder="{{placeholder}}" confirm-type="search" class="input" bindconfirm="confirm" />
<block wx:if="{{inputValue}}">
<view class="clear-box" bindtap="clear">
<view class="sprite-icon icon-clear"></view>
</view>
</block>
</view>
<view class="button box-center" bindtap="search" data-value="{{inputValue}}">搜索</view>
</view>
</view>
\ No newline at end of file
/* components/SearchBox/SearchBox.wxss */
@import '/sprite.wxss';
.search-box {
height: 104rpx;
box-sizing: border-box;
padding: 0 var(--margin);
background-color: #fff;
}
.box-center {
display: flex;
align-items: center;
justify-content: center;
}
.search {
width: 100%;
height: 72rpx;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: space-between;
}
.type-1 {
padding: 0 6rpx;
border-radius: 38px;
border: 3rpx solid var(--btnColor);
}
.type-1 .button {
width: 104rpx;
height: 60rpx;
border-radius: 38rpx;
background-color: var(--btnColor);
color: #fff;
font-size: var(--margin);
}
.type-1 .input-box {
width: calc(100% - 110rpx);
display: flex;
align-items: center;
}
.input-box .icon {
width: 58rpx;
}
.type-1 .input-box .input,
.type-2 .input-box .input {
width: calc(100% - 130rpx);
font-size: 28rpx;
}
.input-box .clear-box{
width: 58rpx;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.input-box .clear-box .icon-clear{
opacity: .7;
}
.type-2 .input-box {
display: flex;
align-items: center;
width: 592rpx;
height: 100%;
background: #F8F8F8;
border-radius: 38rpx;
}
.type-2 .button {
color: #656566;
font-size: var(--margin);
}
.input-placeholder {
color: #CFCFCF;
font-size: 28rpx;
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!