moreInfo.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="more-info-wrapper">
  3. <u-modal :show="show" @confirm="confirmModal" :showCancelButton="showCancelButton" @cancel="closeModal" @close="closeModal">
  4. <view class="modal-content">
  5. <view class="more-info">
  6. <view class="modal-item">
  7. <text>品牌:</text>
  8. <text>{{ moreOptions.dictLabel || '-' }}</text>
  9. </view>
  10. <view class="modal-item">
  11. <text>来源:</text>
  12. <text>{{ moreOptions.origin || '-' }}</text>
  13. </view>
  14. <view class="modal-item">
  15. <text>实价:</text>
  16. <text>¥{{ moreOptions.actualPrice || '-' }}</text>
  17. </view>
  18. <view class="modal-item">
  19. <text>型号:</text>
  20. <text>{{ moreOptions.model || '-' }}</text>
  21. </view>
  22. <view class="modal-item">
  23. <text>编码:</text>
  24. <text>{{ moreOptions.indentifyCode || '-' }}</text>
  25. </view>
  26. <view class="modal-item">
  27. <text>日期:</text>
  28. <text>{{ moreOptions.cardYear || '-' }}</text>
  29. </view>
  30. <view class="modal-item">
  31. <text>备注:</text>
  32. <text>{{ moreOptions.productDesc || '-' }}</text>
  33. </view>
  34. </view>
  35. <view v-if="isCopy">
  36. <u-button type="primary" text="一键复制" size="small" @click="copy"></u-button>
  37. </view>
  38. </view>
  39. </u-modal>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. name: 'MoreInfo',
  45. props: {
  46. moreOptions: {
  47. type: Object,
  48. default: () => { }
  49. },
  50. isCopy: {
  51. type: Boolean,
  52. default: false
  53. },
  54. showCancelButton: {
  55. type: Boolean,
  56. default: false
  57. },
  58. },
  59. emits: ['confirm'],
  60. data() {
  61. return {
  62. show: false,
  63. }
  64. },
  65. methods: {
  66. showMoreInfo() {
  67. this.show = true;
  68. },
  69. confirmModal() {
  70. this.$emit('confirm', this.moreOptions);
  71. },
  72. closeModal(){
  73. this.show = false;
  74. },
  75. copy() {
  76. const { dictLabel, origin, actualPrice, model, indentifyCode, cardYear, productDesc } = this.moreOptions;
  77. const copyText = `品牌:${dictLabel || '-'}\n来源:${origin || '-'}\n实价:¥${actualPrice || '-'}\n型号:${model || '-'}\n编码:${indentifyCode || '-'}\n日期:${cardYear || '-'}\n备注:${productDesc || '-'}`;
  78. uni.setClipboardData({
  79. data: copyText,
  80. success: () => {
  81. uni.showToast({
  82. title: '复制成功',
  83. icon: 'none'
  84. })
  85. },
  86. fail: () => {
  87. uni.showToast({
  88. title: '复制失败',
  89. icon: 'none'
  90. })
  91. }
  92. })
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss" scoped>
  98. .more-info-wrapper {
  99. position: absolute;
  100. width: 0;
  101. height: 0;
  102. overflow: hidden;
  103. }
  104. ::v-deep .modal-content{
  105. width:90%;
  106. }
  107. ::v-deep .u-modal__content{
  108. padding:24rpx 0;
  109. }
  110. .modal-content{
  111. display: flex;
  112. justify-content: space-between;
  113. }
  114. </style>