app-search-for.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="app-view" :style="{backgroundColor: newData.background}">
  3. <view class="jump dir-left-nowrap main-center cross-center" @click="jump_route()">
  4. <view class="input main-center" :style="{backgroundColor: newData.color, borderRadius: `${newData.radius}rpx`,color: `${newData.textColor}`}">
  5. <view class="app-text-search dir-left-nowrap cross-center" :style="{color: `${newData.textColor}`}" :class="[`${newData.textPosition === 'center' ? 'main-center' : 'main-left'}`]">
  6. <view class="app-icon"></view>
  7. <text>{{newData.placeholder}}</text>
  8. </view>
  9. </view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'app-search-for',
  16. props: {
  17. value: {
  18. type: Object,
  19. default: function() {
  20. return {
  21. background: `#efeff4`,
  22. color: '#ffffff',
  23. placeholder: '搜索',
  24. radius: 28,
  25. textColor: '#999999',
  26. textPosition: `center`,
  27. }
  28. }
  29. }
  30. },
  31. data() {
  32. return {
  33. newData: this.value
  34. };
  35. },
  36. watch: {
  37. value: {
  38. handler(newData) {
  39. this.newData = newData;
  40. },
  41. deep: true
  42. }
  43. },
  44. methods: {
  45. jump_route() {
  46. uni.navigateTo({
  47. url: '/pages/search/search'
  48. });
  49. }
  50. }
  51. }
  52. </script>
  53. <style scoped lang="scss">
  54. .jump {
  55. width: 100%;
  56. height: 100%;
  57. }
  58. .app-view {
  59. height: #{88rpx};
  60. width: #{750rpx};
  61. position: relative;
  62. border-radius: 0;
  63. border: none;
  64. }
  65. .app-text-search {
  66. z-index: 1000;
  67. width: #{704rpx};
  68. height: #{58rpx};
  69. line-height: #{58rpx};
  70. }
  71. .app-text-search text {
  72. font-size: #{26rpx};
  73. }
  74. .app-icon {
  75. margin-right: #{12rpx};
  76. margin-left: #{12rpx};
  77. width: #{25rpx};
  78. height: #{25rpx};
  79. background-size: 100% 100%;
  80. background-image: url("../../../static/image/icon/search.png");
  81. }
  82. .input {
  83. height: #{58rpx};
  84. width: #{704rpx};
  85. border: #{1rpx} solid #dcdfe6;
  86. }
  87. </style>