search-drawer.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view>
  3. <view v-show="showSearch" class="search" @click="showDrawer"></view>
  4. <uni-drawer ref="showRight" mode="right" :width="300">
  5. <scroll-view class="drawer" style="height: 100%" scroll-y="true">
  6. <div class="title">{{ title }}</div>
  7. <slot></slot>
  8. <view class="btn-group">
  9. <view class="btn" @click="onOk">确定</view>
  10. <view class="btn btn-white" @click="closeDrawer">取消</view>
  11. </view>
  12. </scroll-view>
  13. </uni-drawer>
  14. </view>
  15. </template>
  16. <script>
  17. import { mapState } from "vuex";
  18. export default {
  19. name: "search-drawer",
  20. props: ["title", "visible"],
  21. watch: {
  22. visible(val) {
  23. if (val) {
  24. this.$refs.showRight.open();
  25. } else {
  26. this.$refs.showRight.close();
  27. }
  28. },
  29. },
  30. computed: {
  31. ...mapState(["showSearch"]),
  32. },
  33. methods: {
  34. onOk() {
  35. this.$emit("onOk");
  36. },
  37. closeDrawer() {
  38. this.$emit("update:visible", false);
  39. this.$refs.showRight.close();
  40. },
  41. showDrawer() {
  42. this.$emit("update:visible", true);
  43. this.$refs.showRight.open();
  44. },
  45. },
  46. };
  47. </script>
  48. <style lang="less" scoped>
  49. .search {
  50. position: fixed;
  51. right: 0;
  52. top: 300rpx;
  53. width: 100rpx;
  54. height: 100rpx;
  55. z-index: 999;
  56. background: url("@/static/drawer-bar.png") no-repeat center;
  57. background-size: cover;
  58. background-attachment: fixed;
  59. }
  60. .drawer {
  61. .title {
  62. font-size: 34rpx;
  63. font-family: Microsoft YaHei UI;
  64. font-weight: bold;
  65. color: #666666;
  66. line-height: 1;
  67. border-bottom: 1px solid #666666;
  68. margin: 44rpx 30rpx 20rpx;
  69. padding-bottom: 34rpx;
  70. }
  71. .btn-group {
  72. display: flex;
  73. justify-content: space-between;
  74. padding: 20rpx 30rpx;
  75. margin-top: 20rpx;
  76. }
  77. .btn {
  78. height: 70rpx;
  79. width: 210rpx;
  80. line-height: 70rpx;
  81. text-align: center;
  82. background: #5b78bf;
  83. color: #fff;
  84. font-size: 30rpx;
  85. &.btn-white {
  86. background: #fff;
  87. color: #333;
  88. border: 1px solid #666;
  89. }
  90. }
  91. ::v-deep {
  92. .select {
  93. width: 100%;
  94. height: 72rpx;
  95. line-height: 70rpx;
  96. border: 1px solid #666;
  97. padding-left: 20rpx;
  98. }
  99. .input {
  100. border: 1px solid #666;
  101. }
  102. .uni-forms-item__label {
  103. font-size: 34rpx;
  104. color: #666;
  105. width: 100% !important;
  106. }
  107. }
  108. }
  109. </style>