th-color.vue 2.7 KB

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