123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <template>
- <view class="acea-row search-contain" :style="{'margin-top':searchTop+'px'}">
- <text class='iconfont icon-fanhui2' @click="toBack" v-if="toBackShow"></text>
- <view class='search-box acea-row row-between-wrapper' :style="[searchBoxStyle]">
- <text class='iconfont icon-sousuo2'></text>
- <input :value="searchVal" @confirm="inputSearch" type='text' confirm-type='search' name="search" placeholder='点击搜索商品' placeholder-class='placeholder' maxlength="20"></input>
- </view>
- </view>
- </template>
- <script>
- export default {
- props: {
- //是否展示返回按钮
- toBackShow: {
- type: Boolean,
- default: true
- },
- searchValue:{
- type: String,
- default: ''
- }
- },
- data(){
- return{
- searchVal:'',
- searchTop:0,
- searchRight:0,
- searchHeight:0,
- statusWidth:0,
- }
- },
- watch:{
- searchValue(val){
- this.searchVal=val
- }
- },
- computed:{
- searchBoxStyle(){
- return {
- height:this.searchHeight + 'px',
- flex:1,
- marginRight:this.statusWidth + this.searchRight+'px',
- }
- }
- },
- created() {
- const res = uni.getMenuButtonBoundingClientRect()
- this.searchTop=uni.getMenuButtonBoundingClientRect().top
- const statusRight = res.right //胶囊右边界坐标
- const jnHeight = res.height //胶囊高度
- this.statusWidth= res.width
- this.searchHeight=jnHeight
- //搜索框宽度计算
- uni.getSystemInfo({
- success:res=>{
- this.searchRight=res.windowWidth-statusRight
- }
- })
- },
- methods:{
- inputSearch(e){
- this.$emit('searchChange',e)
- },
- toBack(){
- uni.navigateBack()
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .search-contain{
- padding: 0 20rpx 10rpx 0;
- }
- .search-box {
- margin-left: 16rpx;
- background-color: #f7f7f7;
- border-radius: 33rpx;
- padding: 0 35rpx;
- box-sizing: border-box;
- height: 66rpx;
- }
- .icon-fanhui2{
- line-height: 66rpx;
- }
- .search-box input {
- width: 90%;
- font-size: 26rpx;
- }
- .search-box .placeholder {
- color: #bbb;
- }
- .search-box .iconfont {
- color: #000;
- font-size: 35rpx;
- }
- </style>
|