index.vue 1.5 KB

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