th-color.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view class="th-color" v-if="colorShow" @click="checkModel">
  3. <view :class="[colorShow?'open-color':'close-color']" @click.stop="()=>{}">
  4. <view class="color-head">颜色选择器</view>
  5. <view class="color-box">
  6. <view v-for="(item,index) in colorData" :key="item"
  7. @click="checkColor(item)"
  8. :class="{'checkItem':checkItem==item}">
  9. <view>
  10. <view :style="{'background':item}"></view>
  11. </view>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. colorShow:false,
  22. colorData:["red",'black','blue','yellow','green','#d925ff','#00b4ff','#ff00cc','#35ff81','#ff9c00','#ff7e00',
  23. '#b4ff00','#28caa6','#490086','#deb7fe','#acacad','#525252','#a5896f','#bb3a30','#0058b2'
  24. ],
  25. checkItem:""
  26. }
  27. },
  28. methods:{
  29. checkModel() {
  30. this.colorShow = !this.colorShow;
  31. },
  32. //选择颜色
  33. checkColor(item) {
  34. this.checkItem = item;
  35. this.colorShow = false;
  36. this.$emit('setColor',item)
  37. }
  38. }
  39. }
  40. </script>
  41. <style scoped lang="scss">
  42. .checkItem{
  43. border: 1px dashed #4169E1;
  44. box-sizing: border-box;
  45. }
  46. .th-color{
  47. width: 100%;
  48. height: 100%;
  49. background-color: rgba(0,0,0,0.5);
  50. position: fixed;
  51. bottom: 0;
  52. left: 0;
  53. z-index: 100;
  54. display: flex;
  55. align-items: flex-end;
  56. >view{
  57. width: 100%;
  58. height: 470upx;
  59. background: #FFFFFF;
  60. box-shadow: 0 0 10upx #999999;
  61. border-radius: 60upx 60upx 0 0;
  62. box-sizing: border-box;
  63. padding: 0 40upx;
  64. overflow: hidden;
  65. .color-head{
  66. text-align: center;
  67. font-size: 30upx;
  68. height: 100upx;
  69. display: flex;
  70. align-items: center;
  71. justify-content: center;
  72. margin-bottom: 20upx;
  73. }
  74. .color-box{
  75. display: flex;
  76. align-items: center;
  77. flex-wrap: wrap;
  78. >view{
  79. width: 20%;
  80. height: 80upx;
  81. border-radius: 10upx;
  82. display: flex;
  83. align-items: center;
  84. justify-content: center;
  85. // margin-bottom: 30upx;
  86. >view{
  87. width: 50upx;
  88. height: 50upx;
  89. overflow: hidden;
  90. border-radius: 50%;
  91. box-sizing: border-box;
  92. padding: 7upx;
  93. border: 1px solid #C0C0C0;
  94. >view{
  95. width: 100%;
  96. height: 100%;
  97. border-radius: 50%;
  98. background-color: red;
  99. }
  100. }
  101. }
  102. }
  103. }
  104. }
  105. .open-color{
  106. animation:fadeInUp 0.4s ;
  107. }
  108. .close-color{
  109. animation:fadeInDown 0.5s ;
  110. }
  111. @keyframes fadeInUp {
  112. 0% {
  113. opacity: 0;
  114. -webkit-transform: translate3d(0, 100%, 0);
  115. transform: translate3d(0, 100%, 0)
  116. }
  117. to {
  118. opacity: 1;
  119. -webkit-transform: translateZ(0);
  120. transform: translateZ(0)
  121. }
  122. }
  123. @keyframes fadeInDown {
  124. 0% {
  125. opacity: 0;
  126. -webkit-transform: translate3d(0, -100%, 0);
  127. transform: translate3d(0, -100%, 0)
  128. }
  129. to {
  130. opacity: 1;
  131. -webkit-transform: translateZ(0);
  132. transform: translateZ(0)
  133. }
  134. }
  135. </style>