linkDetailDialog.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <cwg-popup :title="t('Btn.Detail')" :visible="visible" @singleClick="closeDia" :footerType="'single'"
  3. :singleBtnText="t('Btn.Confirm')" @close="closeDia">
  4. <view class="dialog-content">
  5. <cwg-label-line-value
  6. v-for="(item, index) in items"
  7. :key="index"
  8. :label="item.label"
  9. :value="item.value"
  10. />
  11. <view>
  12. <view>
  13. <view class="label">
  14. {{ t('Ib.Index.Link') }}
  15. </view>
  16. <view class="link-cell">
  17. <uni-easyinput class="read-input" disabled v-model.trim="detail.link"></uni-easyinput>
  18. <view class="qr-code-icon" @click.stop="showQrCodeDialog(detail.link)">
  19. <svg style="width: 18px; height: 18px; fill: #409eff; vertical-align: middle;" viewBox="0 0 24 24"
  20. xmlns="http://www.w3.org/2000/svg">
  21. <path
  22. d="M3 3h8v8H3V3zm2 2v4h4V5H5zm8-2h8v8h-8V3zm2 2v4h4V5h-4zM3 13h8v8H3v-8zm2 2v4h4v-4H5zm13-2h3v2h-3v-2zm0 4h3v2h-3v-2zm-4-4h2v6h-2v-6zm4-8h2v2h-2V3zm0 4h2v2h-2V7zm-4 0h2v2h-2V7z" />
  23. </svg>
  24. </view>
  25. <view class="copy" @click.stop="CopyLink(detail.link)">
  26. {{ t('Ib.Index.Copy') }}
  27. </view>
  28. </view>
  29. </view>
  30. <view>
  31. <view class="label">
  32. {{ t('Ib.Index.LinkValue') }}
  33. </view>
  34. <view class="link-cell">
  35. <uni-easyinput class="read-input" disabled v-model.trim="detail.linkValue"></uni-easyinput>
  36. <view class="copy" @click.stop="CopyLink(detail.linkValue)">
  37. {{ t('Ib.Index.Copy') }}
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </cwg-popup>
  44. </template>
  45. <script setup lang="ts">
  46. import { ref, reactive, computed, onMounted, onUnmounted, watch } from 'vue'
  47. import { onLoad } from '@dcloudio/uni-app'
  48. import { useI18n } from 'vue-i18n' // uni-app 中已集成,但需配置
  49. import { customApi } from '@/service/custom'
  50. import { financialApi } from '@/service/financial'
  51. import Config from '@/config/index'
  52. import PaymentMethodsList from './components/PaymentMethodsList.vue'
  53. import { ibApi } from '@/service/ib'
  54. import useUserStore from '@/stores/use-user-store'
  55. import QrCode from '@/components/QrCode.vue'
  56. const props = defineProps({
  57. // 是否显示弹窗
  58. visible: {
  59. type: Boolean,
  60. default: false,
  61. },
  62. // 详情
  63. detail: { type: Object, default: () => ({}) },
  64. })
  65. const { Code, Host80 } = Config
  66. const { t } = useI18n()
  67. const columns = computed(()=>[
  68. {
  69. prop: 'name',
  70. label: t('Ib.Custom.NameLabel'),
  71. align: 'center',
  72. },
  73. {
  74. prop: 'customNum',
  75. label: t('Ib.Index.CustomNum'),
  76. align: 'center',
  77. },
  78. {
  79. prop: 'comPoint',
  80. label: t('AccountType.StandardAccount'),
  81. align: 'center',
  82. formatter: ({ row }) => getGroupNameByLoginType(row.loginConfig, 7),
  83. },
  84. {
  85. prop: 'hide',
  86. label: 'ECN',
  87. align: 'center',
  88. formatter: ({ row }) => getGroupNameByLoginType(row.loginConfig, 2),
  89. },
  90. {
  91. prop: 'loginTypes',
  92. label: t('AccountType.CentAccount'),
  93. align: 'center',
  94. formatter: ({ row }) => getGroupNameByLoginType(row.loginConfig, 8),
  95. },
  96. ])
  97. const emit = defineEmits(['close','showQrCode'])
  98. const items = computed(() => {
  99. return columns.value.map(item => {
  100. return {
  101. label: item.label,
  102. value: item.formatter ? item.formatter({ row: props.detail }) : props.detail[item.prop],
  103. }
  104. },
  105. )
  106. })
  107. const getGroupNameByLoginType = (loginConfig, loginType) => {
  108. if (!loginConfig) return ''
  109. // 如果 loginConfig 是字符串,尝试解析为数组
  110. let config = loginConfig
  111. if (typeof loginConfig === 'string') {
  112. try {
  113. config = JSON.parse(loginConfig)
  114. } catch (e) {
  115. return ''
  116. }
  117. }
  118. // 确保是数组
  119. if (!Array.isArray(config)) {
  120. return ''
  121. }
  122. // 查找匹配的 loginType
  123. const matchedItem = config.find(item => {
  124. // 支持数字和字符串类型的比较
  125. return item.loginType === loginType ||
  126. item.loginType === String(loginType) ||
  127. String(item.loginType) === String(loginType)
  128. })
  129. return matchedItem ? (matchedItem.groupName || '') : ''
  130. }
  131. const CopyLink = (link) => {
  132. uni.setClipboardData({
  133. data: link,
  134. success: () => {
  135. uni.showToast({
  136. title: t('card.Msg.m8'),
  137. icon: 'success',
  138. })
  139. },
  140. })
  141. }
  142. const showQrCodeDialog = (link) => {
  143. if (!link) return
  144. emit('showQrCode', link)
  145. }
  146. const downloadQrCode = (type = 0) => {
  147. qrCode.value.download()
  148. }
  149. // 下载弹窗中的二维码
  150. const downloadDialogQrCode = (type = 0) => {
  151. dialogQrCode.value.download()
  152. }
  153. const closeDia = () => {
  154. emit('close')
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. @import "@/uni.scss";
  159. @media screen and (max-width: 768px) {
  160. .dialog-content {
  161. padding: 0 px2rpx(10);
  162. }
  163. }
  164. .label {
  165. color: #6c8595;
  166. font-size: px2rpx(14);
  167. line-height: px2rpx(24);
  168. }
  169. .link-cell {
  170. width: 100%;
  171. display: inline-flex;
  172. align-items: center;
  173. justify-content: flex-start;
  174. gap: 10px;
  175. white-space: nowrap;
  176. .read-input {
  177. max-width: px2rpx(400);
  178. white-space: nowrap;
  179. overflow: hidden;
  180. margin-left: px2rpx(40);
  181. text-overflow: ellipsis;
  182. flex: 1;
  183. }
  184. .copy {
  185. cursor: pointer;
  186. line-height: px2rpx(28);
  187. }
  188. }
  189. </style>