jp-color-picker.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view>
  3. <view class="action">
  4. <button class="cu-btn shadow round" :disabled="disabled" :style="'color:white;background-color:'+color" @tap="showModal" data-target="DialogModal1">{{color}}</button>
  5. </view>
  6. <view class="cu-modal" :class="modalName=='DialogModal1'?'show':''">
  7. <view class="cu-dialog">
  8. <view class="padding-xl">
  9. <color-picker :show='true' :color="color" @pickerColor="pickerColor"></color-picker>
  10. </view>
  11. <view class="cu-bar bg-white justify-end">
  12. <view class="action">
  13. <button class="cu-btn line-green text-green" @tap="hideModal">取消</button>
  14. <button class="cu-btn bg-green margin-left" @tap="confirm">确定</button>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import colorPicker from "./colorPicker.vue";
  23. export default {
  24. components: { colorPicker },
  25. props: {
  26. value: String,
  27. disabled: {
  28. type: Boolean,
  29. default: false
  30. }
  31. },
  32. data() {
  33. return {
  34. modalName: null,
  35. color: null,
  36. colorRgb: ''
  37. };
  38. },
  39. watch:{
  40. value:{
  41. handler (val) {
  42. this.color = val
  43. },
  44. immediate: true,
  45. deep: false
  46. }
  47. },
  48. methods: {
  49. pickerColor(color) {
  50. this.color = color.rgb
  51. },
  52. showModal(e) {
  53. this.modalName = e.currentTarget.dataset.target
  54. },
  55. hideModal(e) {
  56. this.modalName = null
  57. },
  58. confirm () {
  59. this.$emit('input', this.color)
  60. this.modalName = null
  61. }
  62. }
  63. };
  64. </script>
  65. <style lang="scss" scoped>
  66. #container {
  67. width: 100vw;
  68. height: 100vh;
  69. }
  70. .actions {
  71. margin-top: 20rpx;
  72. display: flex;
  73. justify-content: space-between;
  74. .iconfont {
  75. color: #777;
  76. font-size: 56rpx;
  77. }
  78. .icon-yes {
  79. color: rgb(14, 165, 0)
  80. }
  81. }
  82. </style>