design.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-gradual-blue" :isBack="true"><block slot="backText">返回</block><block slot="content"> 按钮 / 设计</block></cu-custom>
  4. <view class="padding-xl">
  5. <view class="box bg-white text-center radius">
  6. <button class="cu-btn" :class="[border?bordersize?'lines-' + color:'line-' + color:'bg-'+ color,round?'round':'',size,shadow?'shadow':'']">我是一个按钮</button>
  7. </view>
  8. <view class="padding text-center">
  9. class="cu-btn <text v-if="color">{{' '}} {{border?bordersize?'lines-' + color:'line-' + color:'bg-'+ color}} {{round?'round':''}} {{size}} {{shadow?'shadow':''}}</text>"
  10. </view>
  11. </view>
  12. <view class="cu-form-group margin-top" @tap="showModal" data-target="ColorModal">
  13. <view class="title">选择颜色</view>
  14. <view class="padding solid radius shadow-blur" :class="'bg-'+color"></view>
  15. </view>
  16. <view class="cu-form-group">
  17. <view class="title">是否圆角</view>
  18. <switch @change="SetRound" class="blue" :class="round?'checked':''"></switch>
  19. </view>
  20. <view class="cu-form-group">
  21. <view class="title">选择尺寸</view>
  22. <radio-group @change="SetSize">
  23. <label class="margin-left-sm">
  24. <radio class="blue radio" value="sm"></radio>
  25. <text class="margin-left-sm"> 小</text>
  26. </label>
  27. <label class="margin-left-sm">
  28. <radio class="blue radio" value="" checked></radio>
  29. <text class="margin-left-sm"> 中</text>
  30. </label>
  31. <label class="margin-left-sm">
  32. <radio class="blue radio" value="lg"></radio>
  33. <text class="margin-left-sm"> 大</text>
  34. </label>
  35. </radio-group>
  36. </view>
  37. <view class="cu-form-group">
  38. <view class="title">是否添加阴影</view>
  39. <switch @change="SetShadow" :class="shadow?'checked':''"></switch>
  40. </view>
  41. <view class="cu-form-group">
  42. <view class="title">是否镂空</view>
  43. <switch @change="SetBorder" :class="border?'checked':''"></switch>
  44. </view>
  45. <view class="cu-form-group" v-if="border">
  46. <view class="title">边框大小</view>
  47. <radio-group @change="SetBorderSize">
  48. <label class="margin-left-sm">
  49. <radio class="blue radio" value="" checked></radio>
  50. <text class="margin-left-sm"> 小</text>
  51. </label>
  52. <label class="margin-left-sm">
  53. <radio class="blue radio" value="s"></radio>
  54. <text class="margin-left-sm"> 大</text>
  55. </label>
  56. </radio-group>
  57. </view>
  58. <view class="cu-modal" :class="modalName=='ColorModal'?'show':''">
  59. <view class="cu-dialog">
  60. <view class="cu-bar justify-end solid-bottom">
  61. <view class="content">选择颜色</view>
  62. <view class="action" @tap="hideModal">
  63. <text class="cuIcon-close text-red"></text>
  64. </view>
  65. </view>
  66. <view class="grid col-5 padding">
  67. <view class="padding-xs" v-for="(item,index) in ColorList" :key="index" @tap="SetColor" :data-color="item.name" v-if="item.name!='white'">
  68. <view class="padding-tb radius" :class="'bg-' + item.name"> {{item.title}} </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. export default {
  77. data() {
  78. return {
  79. ColorList: this.ColorList,
  80. modalName: '',
  81. round: false,
  82. size: '',
  83. color: 'red',
  84. shadow: false,
  85. border: false,
  86. bordersize: ''
  87. };
  88. },
  89. methods: {
  90. showModal(e) {
  91. this.modalName = e.currentTarget.dataset.target
  92. },
  93. hideModal(e) {
  94. this.modalName = null
  95. },
  96. SetRound(e) {
  97. this.round = e.detail.value
  98. },
  99. SetSize(e) {
  100. this.size = e.detail.value
  101. },
  102. SetColor(e) {
  103. this.color = e.currentTarget.dataset.color;
  104. this.modalName = null
  105. },
  106. SetShadow(e) {
  107. this.shadow = e.detail.value
  108. },
  109. SetBorder(e) {
  110. this.border = e.detail.value
  111. if (!e.detail.value) {
  112. this.bordersize = false
  113. }
  114. },
  115. SetBorderSize(e) {
  116. this.bordersize = e.detail.value
  117. }
  118. }
  119. }
  120. </script>
  121. <style>
  122. .box {
  123. display: flex;
  124. align-items: center;
  125. justify-content: center;
  126. height: 100px;
  127. }
  128. </style>