index.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view
  3. @click="onClick"
  4. class="setting_item"
  5. :class="{ setting_item_border: border }">
  6. <text :style="{ color: danger ? '#FF381F' : '$uni-text-color' }">{{
  7. title
  8. }}</text>
  9. <u-switch
  10. :loading="loading"
  11. @change="onChange"
  12. :asyncChange="true"
  13. v-if="is_switch"
  14. size="20"
  15. :value="switchValue"
  16. />
  17. <view v-else class="setting_right">
  18. <slot></slot>
  19. <u-icon v-if="arrow" name="arrow-right" color="#999" size="18" />
  20. </view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. name: "",
  26. components: {},
  27. props: {
  28. title: String,
  29. danger: {
  30. type: Boolean,
  31. default: false,
  32. },
  33. is_switch: {
  34. type: Boolean,
  35. default: false,
  36. },
  37. switchValue: {
  38. type: Boolean,
  39. default: false,
  40. },
  41. loading: {
  42. type: Boolean,
  43. default: false,
  44. },
  45. border: {
  46. type: Boolean,
  47. default: true,
  48. },
  49. arrow: {
  50. type: Boolean,
  51. default: true,
  52. },
  53. },
  54. data() {
  55. return {};
  56. },
  57. methods: {
  58. onClick() {
  59. this.$emit("click");
  60. },
  61. onChange(value) {
  62. this.$emit("switch", value);
  63. },
  64. },
  65. };
  66. </script>
  67. <style lang="scss" scoped>
  68. .setting_item {
  69. @include btwBox();
  70. padding: 24rpx 36rpx;
  71. color: $uni-text-color;
  72. .setting_right {
  73. @include vCenterBox();
  74. }
  75. &_border {
  76. border-bottom: 1px solid rgba(153, 153, 153, 0.2);
  77. }
  78. }
  79. </style>