index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view class="zs-search" :class="[fixed?'fixed':'']">
  3. <input class="input" :style="{lineHeight:height+'rpx',height:height+'rpx',borderRadius:height / 2+'px',color:color,background:bgColor}" :type="type" v-model="value" :placeholder="placeholder" />
  4. <image class="icon" src="../../static/search.png" mode=""></image>
  5. <button 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. },
  38. data() {
  39. return {
  40. value1:this.value
  41. }
  42. },
  43. onReady(res) {
  44. },
  45. onLoad(){
  46. },
  47. methods: {
  48. input(val){
  49. this.$emit('input',this.value1 )
  50. },
  51. search(){
  52. this.$emit('search',this.value1)
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="scss">
  58. .zs-search{
  59. box-sizing: border-box;
  60. top: 0%;
  61. left: 0;
  62. position: relative;
  63. margin: 0 30rpx;
  64. .input{
  65. box-sizing: border-box;
  66. padding-left: 100rpx;
  67. padding-right: 130rpx;
  68. }
  69. .icon {
  70. width: 37rpx;
  71. height: 37rpx;
  72. position: absolute;
  73. top: 50%;
  74. left: 36rpx;
  75. transform: translateY(-50%);
  76. }
  77. .btn {
  78. position: absolute;
  79. top: 50%;
  80. transform: translateY(-50%);
  81. right: 10rpx;
  82. width: 128rpx;
  83. height: 56rpx;
  84. line-height: 56rpx;
  85. background: #FF4C3A;
  86. color: #fff;
  87. font-size: 28rpx;
  88. border-radius: 32rpx;
  89. padding: 0;
  90. }
  91. }
  92. .fixed{
  93. position: fixed !important;
  94. }
  95. </style>