shadow-card.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="shadow-card">
  3. <slot></slot>
  4. <view
  5. v-for="(item, index) in list"
  6. :key="index"
  7. :style="{
  8. marginTop: index === 0 ? '0rpx' : '40rpx',
  9. }">
  10. <view class="label">{{ item.label }}</view>
  11. <view
  12. class="value"
  13. :style="{
  14. color: item.color ? item.color : '#000',
  15. }">
  16. {{ item.value }}
  17. <text class="copy-btn" v-if="item.copy" @click="copyText(item.value)">复制</text>
  18. <text class="copy-btn" v-if="item.discount" @click="handleClickOrderDiscountDesc">明细</text>
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script lang="ts">
  24. export default {
  25. props: {
  26. list: {
  27. type: Array<any>,
  28. defalut: [],
  29. },
  30. },
  31. methods: {
  32. copyText(text: string) {
  33. if (!text) return;
  34. uni.setClipboardData({
  35. data: text,
  36. success: function () {
  37. uni.showToast({
  38. title: '复制成功',
  39. icon: 'success',
  40. })
  41. }
  42. })
  43. },
  44. handleClickOrderDiscountDesc(){
  45. this.$emit('on-discount')
  46. }
  47. }
  48. };
  49. </script>
  50. <style lang="scss">
  51. .shadow-card {
  52. background: #ffffff;
  53. border: 1rpx solid rgba(0, 0, 0, 0.1);
  54. box-shadow: 0px 4rpx 20rpx rgba(0, 0, 0, 0.1);
  55. border-radius: 20rpx;
  56. padding: 40rpx;
  57. & > view {
  58. display: flex;
  59. .label {
  60. width: 156rpx;
  61. flex-shrink: 0;
  62. color: rgba(0, 0, 0, 0.4);
  63. font-size: 26rpx;
  64. }
  65. .value {
  66. flex-grow: 1;
  67. font-size: 26rpx;
  68. overflow-wrap: anywhere;
  69. }
  70. }
  71. }
  72. .copy-btn {
  73. margin-left: 10rpx;
  74. color: #1aa4f2;
  75. /* padding: 6rpx;
  76. background: #1aa4f2;*/
  77. font-size: 20rpx;
  78. }
  79. </style>