index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <SsConfirm
  3. v-model:visible="isVisible"
  4. :title="loginType.title || '扫码登录'"
  5. :width="600"
  6. height="430rpx"
  7. :bottom-buttons="buttons"
  8. @button-click="handleButtonClick"
  9. >
  10. <view class="login-confirm-body">
  11. <!-- 图标区域 -->
  12. <!-- <view class="icon-wrapper" v-if="loginType.icon">
  13. <image :src="loginType.icon" mode="aspectFit" class="system-icon"></image>
  14. </view> -->
  15. <!-- 系统名称 -->
  16. <view class="system-name">{{ loginType.systemName }}</view>
  17. <!-- 提示信息 -->
  18. <view class="login-tip">{{ loginType.tip || '确认登录该系统吗?' }}</view>
  19. <!-- 额外信息 -->
  20. <view class="extra-info" v-if="loginType.address">
  21. <view class="info-row">
  22. <text class="label">登录地址:</text>
  23. <text class="value">{{ loginType.address }}</text>
  24. </view>
  25. </view>
  26. </view>
  27. </SsConfirm>
  28. </template>
  29. <script setup>
  30. import { ref, watch } from 'vue'
  31. import SsConfirm from '@/components/SsConfirm/index.vue'
  32. const props = defineProps({
  33. // 显示状态
  34. visible: {
  35. type: Boolean,
  36. default: false
  37. },
  38. // 登录类型配置
  39. loginType: {
  40. type: Object,
  41. default: () => ({
  42. systemName: '系统',
  43. title: '扫码登录',
  44. tip: '确认登录该系统吗?',
  45. icon: '',
  46. address: ''
  47. })
  48. }
  49. })
  50. const emit = defineEmits(['update:visible', 'confirm', 'cancel'])
  51. const isVisible = ref(false)
  52. // 底部按钮配置
  53. const buttons = [
  54. { text: '取消', action: 'cancel' },
  55. { text: '确认登录', action: 'confirm' }
  56. ]
  57. // 监听外部 visible 变化
  58. watch(() => props.visible, (val) => {
  59. isVisible.value = val
  60. })
  61. // 监听内部 isVisible 变化
  62. watch(isVisible, (val) => {
  63. emit('update:visible', val)
  64. })
  65. // 处理按钮点击
  66. const handleButtonClick = (button, index) => {
  67. if (button.action === 'confirm') {
  68. emit('confirm')
  69. isVisible.value = false
  70. } else if (button.action === 'cancel') {
  71. emit('cancel')
  72. isVisible.value = false
  73. }
  74. }
  75. // 暴露方法供父组件调用
  76. const show = () => {
  77. isVisible.value = true
  78. }
  79. const hide = () => {
  80. isVisible.value = false
  81. }
  82. defineExpose({
  83. show,
  84. hide
  85. })
  86. </script>
  87. <style lang="scss" scoped>
  88. .login-confirm-body {
  89. padding: 40rpx;
  90. display: flex;
  91. flex-direction: column;
  92. align-items: center;
  93. }
  94. .icon-wrapper {
  95. width: 120rpx;
  96. height: 120rpx;
  97. margin-bottom: 30rpx;
  98. .system-icon {
  99. width: 100%;
  100. height: 100%;
  101. }
  102. }
  103. .system-name {
  104. font-size: 36rpx;
  105. font-weight: bold;
  106. color: #333;
  107. margin-bottom: 20rpx;
  108. text-align: center;
  109. }
  110. .login-tip {
  111. font-size: 28rpx;
  112. color: #666;
  113. text-align: center;
  114. margin-bottom: 30rpx;
  115. line-height: 1.6;
  116. }
  117. .extra-info {
  118. width: 100%;
  119. padding: 20rpx;
  120. background: #fafafb;
  121. border-radius: 8rpx;
  122. border: 1rpx solid #e6e6e6;
  123. .info-row {
  124. display: flex;
  125. align-items: center;
  126. font-size: 26rpx;
  127. .label {
  128. color: #666;
  129. margin-right: 10rpx;
  130. white-space: nowrap;
  131. }
  132. .value {
  133. color: #999;
  134. word-break: break-all;
  135. flex: 1;
  136. }
  137. }
  138. }
  139. </style>