EquityLinkDialog.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible.sync="dialogVisible"
  5. width="680px"
  6. @open="resetForm"
  7. >
  8. <el-form label-width="100px" inline>
  9. <el-form-item label="Campaign ID">
  10. <el-select v-model="form.campaignId" clearable placeholder="请选择 (无)">
  11. <el-option
  12. v-for="opt in campaignOptions"
  13. :key="opt.value"
  14. :label="opt.label"
  15. :value="opt.value"
  16. />
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="Channel ID">
  20. <el-select v-model="form.channelId" clearable placeholder="请选择 (无)">
  21. <el-option
  22. v-for="opt in channelOptions"
  23. :key="opt.value"
  24. :label="opt.label"
  25. :value="opt.value"
  26. />
  27. </el-select>
  28. </el-form-item>
  29. </el-form>
  30. <div class="link-section">
  31. <div class="link-label"><span class="dot"></span> 权益链接</div>
  32. <div class="link-row">
  33. <span class="link-type">H5 链接</span>
  34. <el-input :value="h5Url" readonly size="small" />
  35. <el-button size="small" type="primary" plain @click="copyLink(h5Url)">复制</el-button>
  36. </div>
  37. <div class="link-row">
  38. <span class="link-type">小程序/APP</span>
  39. <el-input :value="appUrl" readonly size="small" />
  40. <el-button size="small" type="primary" plain @click="copyLink(appUrl)">复制</el-button>
  41. </div>
  42. </div>
  43. </el-dialog>
  44. </template>
  45. <script>
  46. export default {
  47. name: 'EquityLinkDialog',
  48. props: {
  49. visible: { type: Boolean, default: false },
  50. id: { type: [String, Number], default: '' },
  51. pathName: { type: String, default: 'equity' },
  52. title: { type: String, default: '生成链接' }
  53. },
  54. data() {
  55. return {
  56. form: { campaignId: '', channelId: '' },
  57. campaignOptions: [
  58. { label: 'CAMP202511', value: 'CAMP202511' },
  59. { label: 'CAMP_WINTER', value: 'CAMP_WINTER' }
  60. ],
  61. channelOptions: [
  62. { label: 'APP推送', value: 'CH_APP' },
  63. { label: '微信公众号', value: 'CH_WECHAT' }
  64. ]
  65. }
  66. },
  67. computed: {
  68. dialogVisible: {
  69. get() { return this.visible },
  70. set(v) { this.$emit('update:visible', v) }
  71. },
  72. queryStr() {
  73. const params = []
  74. if (this.form.campaignId) params.push(`CampaignId=${this.form.campaignId}`)
  75. if (this.form.channelId) params.push(`Channelid=${this.form.channelId}`)
  76. return params.length ? '&' + params.join('&') : ''
  77. },
  78. h5Url() {
  79. return `https://hsbc.com/${this.pathName}?id=${this.id}${this.queryStr}`
  80. },
  81. appUrl() {
  82. return `hsbc-app://${this.pathName}?id=${this.id}${this.queryStr}`
  83. }
  84. },
  85. methods: {
  86. resetForm() {
  87. this.form = { campaignId: '', channelId: '' }
  88. },
  89. copyLink(text) {
  90. if (!text) return
  91. navigator.clipboard.writeText(text).then(() => {
  92. this.$message.success('链接已复制到剪贴板')
  93. }).catch(() => {
  94. this.$message.error('复制失败,请手动选取')
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style scoped>
  101. .link-section {
  102. margin-top: 8px;
  103. padding: 12px;
  104. background: #fafafa;
  105. border-radius: 6px;
  106. border: 1px solid #ebeef5;
  107. }
  108. .link-label {
  109. font-weight: 600;
  110. margin-bottom: 10px;
  111. display: flex;
  112. align-items: center;
  113. gap: 6px;
  114. color: #303133;
  115. }
  116. .link-row {
  117. display: flex;
  118. align-items: center;
  119. gap: 8px;
  120. margin-bottom: 8px;
  121. }
  122. .link-row:last-child { margin-bottom: 0; }
  123. .link-type {
  124. font-size: 12px;
  125. color: #909399;
  126. width: 70px;
  127. flex-shrink: 0;
  128. }
  129. .dot {
  130. width: 8px;
  131. height: 8px;
  132. border-radius: 50%;
  133. display: inline-block;
  134. background: #67C23A;
  135. }
  136. </style>