pickerColor.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view v-show="isShow">
  3. <view class="shade" @tap="hide">
  4. <view class="pop">
  5. <view class="list flex_col" v-for="(item,index) in colorArr" :key="index">
  6. <view v-for="(v,i) in item" :key="i" :style="{'backgroundColor':v}" :data-color="v"
  7. :data-index="index" :data-i="i" :class="{'active':(index==pickerArr[0] && i==pickerArr[1])}"
  8. @tap.stop="picker"></view>
  9. </view>
  10. </view>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. name: 'picker-color',
  17. props: {
  18. isShow: {
  19. type: Boolean,
  20. default: false,
  21. },
  22. bottom: {
  23. type: Number,
  24. default: 0,
  25. }
  26. },
  27. data() {
  28. return {
  29. colorArr: [
  30. ['#000000', '#111111', '#222222', '#333333', '#444444', '#666666', '#999999', '#CCCCCC', '#EEEEEE',
  31. '#FFFFFF'
  32. ],
  33. ['#ff0000', '#ff0033', '#ff3399', '#ff33cc', '#cc00ff', '#9900ff', '#cc00cc', '#cc0099', '#cc3399',
  34. '#cc0066'
  35. ],
  36. ['#cc3300', '#cc6600', '#ff9933', '#ff9966', '#ff9999', '#ff99cc', '#ff99ff', '#cc66ff', '#9966ff',
  37. '#cc33ff'
  38. ],
  39. ['#663300', '#996600', '#996633', '#cc9900', '#a58800', '#cccc00', '#ffff66', '#ffff99', '#ffffcc',
  40. '#ffcccc'
  41. ],
  42. ['#336600', '#669900', '#009900', '#009933', '#00cc00', '#66ff66', '#339933', '#339966', '#009999',
  43. '#33cccc'
  44. ],
  45. ['#003366', '#336699', '#3366cc', '#0099ff', '#000099', '#0000cc', '#660066', '#993366', '#993333',
  46. '#800000'
  47. ]
  48. ],
  49. pickerColor: '',
  50. pickerArr: [-1, -1]
  51. };
  52. },
  53. methods: {
  54. picker(e) {
  55. let data = e.currentTarget.dataset;
  56. this.pickerColor = data.color;
  57. this.pickerArr = [data.index, data.i];
  58. this.$emit("callback", this.pickerColor);
  59. },
  60. hide() {
  61. this.$emit("callback", '');
  62. },
  63. },
  64. }
  65. </script>
  66. <style scoped>
  67. .shade {
  68. position: fixed;
  69. top: 0;
  70. right: 0;
  71. bottom: 0;
  72. left: 0;
  73. background-color: rgba(0, 0, 0, 0.5);
  74. z-index: 10080;
  75. display: flex;
  76. justify-content: center;
  77. align-items: center
  78. }
  79. .pop {
  80. border-radius: 8px;
  81. background-color: #fff;
  82. z-index: 100;
  83. padding: 12upx;
  84. font-size: 32upx;
  85. transform: rotate(90deg);
  86. }
  87. .flex_col {
  88. display: flex;
  89. flex-direction: row;
  90. flex-wrap: nowrap;
  91. justify-content: flex-start;
  92. align-items: center;
  93. align-content: center;
  94. }
  95. .list {
  96. justify-content: space-between;
  97. }
  98. .list>view {
  99. width: 60upx;
  100. height: 60upx;
  101. margin: 5upx;
  102. box-sizing: border-box;
  103. border-radius: 3px;
  104. box-shadow: 0 0 2px #ccc;
  105. }
  106. .list .active {
  107. box-shadow: 0 0 2px #09f;
  108. transform: scale(1.05, 1.05);
  109. }
  110. .preview {
  111. width: 180upx;
  112. height: 60upx;
  113. }
  114. .value {
  115. margin: 0 40upx;
  116. flex-grow: 1;
  117. }
  118. .ok {
  119. width: 160upx;
  120. height: 60upx;
  121. line-height: 60upx;
  122. text-align: center;
  123. background-color: #ff9933;
  124. color: #fff;
  125. border-radius: 4px;
  126. letter-spacing: 3px;
  127. font-size: 32upx;
  128. }
  129. .ok:active {
  130. background-color: rgb(255, 107, 34);
  131. }
  132. </style>