index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="zs-search" :class="[fixed?'fixed':'']">
  3. <input :class="[showPrefix?'input':'fullwidInput']" :style="{lineHeight:height+'rpx',height:height+'rpx',borderRadius:height / 2+'px',color:color,background:bgColor}" :type="type" v-model="value" :placeholder="placeholder" />
  4. <image v-if="showPrefix" class="icon" src="../../static/search.png" mode=""></image>
  5. <button v-if="showBtn" class="btn" type="default" @click="search">搜索</button>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. props: {
  11. type: {
  12. type: String,
  13. default: 'text'
  14. },
  15. height: {
  16. type: String,
  17. default: '72'
  18. },
  19. color: {
  20. type: String,
  21. default: '#606266'
  22. },
  23. bgColor:{
  24. type: String,
  25. default: '#efefef'
  26. },
  27. fixed:{
  28. type: Boolean,
  29. default: false
  30. },
  31. value:{
  32. },
  33. placeholder:{
  34. type: String,
  35. default: '搜索'
  36. },
  37. showBtn:{
  38. type: Boolean,
  39. default: true
  40. },
  41. showPrefix:{
  42. type: Boolean,
  43. default: true
  44. }
  45. },
  46. data() {
  47. return {
  48. value1:this.value
  49. }
  50. },
  51. onReady(res) {
  52. },
  53. onLoad(){
  54. },
  55. methods: {
  56. input(val){
  57. this.$emit('input',this.value1 )
  58. },
  59. search(){
  60. this.$emit('search',this.value1)
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss">
  66. .zs-search{
  67. box-sizing: border-box;
  68. top: 0%;
  69. left: 0;
  70. position: relative;
  71. margin: 0 30rpx;
  72. .input{
  73. box-sizing: border-box;
  74. padding-left: 100rpx;
  75. padding-right: 130rpx;
  76. }
  77. .fullwidInput{
  78. // width: 100vw;
  79. box-sizing: border-box;
  80. font-size: 22rpx;
  81. padding-left: 20rpx;
  82. padding-right: 130rpx;
  83. }
  84. .icon {
  85. width: 37rpx;
  86. height: 37rpx;
  87. position: absolute;
  88. top: 50%;
  89. left: 36rpx;
  90. transform: translateY(-50%);
  91. }
  92. .btn {
  93. position: absolute;
  94. top: 50%;
  95. transform: translateY(-50%);
  96. right: 10rpx;
  97. width: 128rpx;
  98. height: 56rpx;
  99. line-height: 56rpx;
  100. background: #FF4C3A;
  101. color: #fff;
  102. font-size: 28rpx;
  103. border-radius: 32rpx;
  104. padding: 0;
  105. }
  106. }
  107. .fixed{
  108. position: fixed !important;
  109. }
  110. </style>