index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="search_box_all">
  3. <view class="zw"></view>
  4. <view class="search_box">
  5. <template v-for="(item,index) in list">
  6. <view class="input_style box_style" v-if="!item.scope">
  7. <img class="search_icon" src="@/static/images/icon_search@2x.png" alt="">
  8. <input type="text" v-model="formData[item.prop]" :placeholder="item.placeholder">
  9. </view>
  10. <view class="select_style box_style" v-if="item.scope === 'select'">
  11. <text> {{textOverflow(item)}}</text>
  12. <img class="zk_icon" src="@/static/images/icon_zk@2x.png" alt="">
  13. </view>
  14. </template>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. list: [{
  23. placeholder: "输入手机号码/会员卡号",
  24. prop: "searchKey"
  25. },
  26. {
  27. placeholder: "所属店铺",
  28. prop: "cid",
  29. scope: "select"
  30. },
  31. {
  32. placeholder: "日期",
  33. prop: "time",
  34. scope: "select"
  35. }
  36. ],
  37. formData: {}
  38. };
  39. },
  40. computed: {
  41. textOverflow: function() {
  42. return function(item) {
  43. if (this.formData[item.prop]) {
  44. return this.formData[item.prop].slice(0, 5) + '...'
  45. } else {
  46. return item.placeholder || ''
  47. }
  48. }
  49. }
  50. },
  51. }
  52. </script>
  53. <style lang="scss" scoped>
  54. .search_box_all {
  55. background-color: #fff;
  56. flex-shrink: 0;
  57. border-bottom: 1rpx solid #eee;
  58. &>.zw {
  59. height: 99rpx;
  60. }
  61. &>.search_box {
  62. position: fixed;
  63. top: 0rpx;
  64. left: 0rpx;
  65. right: 0rpx;
  66. height: 99rpx;
  67. padding: 0rpx 20rpx;
  68. display: flex;
  69. align-items: center;
  70. .input_style {
  71. flex: 1;
  72. &>input {
  73. padding: 0rpx 14rpx;
  74. }
  75. }
  76. .box_style {
  77. flex-shrink: 0;
  78. margin: 0rpx 12rpx;
  79. height: 72rpx;
  80. padding: 0rpx 24rpx;
  81. border-radius: 100rpx;
  82. background-color: #f7f7f7;
  83. display: flex;
  84. align-items: center;
  85. font-size: 28rpx;
  86. color: #828282;
  87. &>text {
  88. flex: 1;
  89. // width: 100rpx;
  90. // white-space: nowrap;text-overflow:ellipsis;overflow:hidden;
  91. margin-right: 12rpx;
  92. }
  93. &>.search_icon {
  94. width: 30rpx;
  95. height: 30rpx;
  96. flex-shrink: 0;
  97. }
  98. &>.zk_icon {
  99. flex-shrink: 0;
  100. width: 24rpx;
  101. height: 24rpx;
  102. }
  103. }
  104. }
  105. }
  106. </style>