VerificationRow.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view>
  3. <view :class="['verification-row', { 'verification-row-last': isLast && !idFrontUrl }]">
  4. <view class="verification-icon">
  5. <cwg-icon :name="icon" :size="20" color="#9ca3af" />
  6. </view>
  7. <view class="verification-content">
  8. <view class="verification-label-wrapper">
  9. <text class="verification-label">{{ label }}</text>
  10. <text v-if="idType" class="verification-id-type">({{ idType }})</text>
  11. </view>
  12. <view class="verification-status-wrapper">
  13. <cwg-icon :name="statusIcon" :size="18" :color="statusColor" />
  14. <text :class="['verification-status-text', statusClass]">
  15. {{ statusText }}
  16. </text>
  17. <text v-if="date" class="verification-date">• {{ date }}</text>
  18. </view>
  19. </view>
  20. <view class="verification-arrow">
  21. <cwg-icon name="right" :size="20" color="#d1d5db" />
  22. </view>
  23. </view>
  24. <!-- ID Card Images -->
  25. <view v-if="idFrontUrl || idBackUrl || idHoldUrl" :class="['id-card-images', { 'id-card-last': isLast }]">
  26. <!-- <view class="id-card-label">
  27. <text class="id-card-label-text">{{ t('card.Form.f21') }}</text>
  28. </view> -->
  29. <view class="id-card-container">
  30. <view v-if="idFrontUrl" class="id-card-item" @click="previewImage(absoluteUrl(idFrontUrl))">
  31. <image :src="absoluteUrl(idFrontUrl)" class="id-card-image" mode="aspectFill" />
  32. <text class="id-card-text">{{ t('card.Form.f21') }}</text>
  33. </view>
  34. <view v-if="idBackUrl" class="id-card-item" @click="previewImage(absoluteUrl(idBackUrl))">
  35. <image :src="absoluteUrl(idBackUrl)" class="id-card-image" mode="aspectFill" />
  36. <text class="id-card-text">{{ t('card.Form.f22') }}</text>
  37. </view>
  38. <view v-if="idHoldUrl" class="id-card-item" @click="previewImage(absoluteUrl(idHoldUrl))">
  39. <image :src="absoluteUrl(idHoldUrl)" class="id-card-image" mode="aspectFill" />
  40. <text class="id-card-text">{{ t('card.Form.f23') }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script setup lang="ts">
  47. import { computed } from 'vue';
  48. import { useI18n } from "vue-i18n";
  49. import config from "@/config";
  50. const { t } = useI18n();
  51. function absoluteUrl(url: string) {
  52. if (!url) {
  53. return "";
  54. }
  55. if (/^https?:\/\//.test(url)) {
  56. return url;
  57. }
  58. const prefix = config.Host85 || "";
  59. if (!prefix) {
  60. return url;
  61. }
  62. return `${prefix}${url.startsWith("/") ? url : `/${url}`}`;
  63. }
  64. // 图片预览功能
  65. function previewImage(url: string) {
  66. if (!url) return;
  67. // 使用 uni.previewImage 进行图片预览
  68. uni.previewImage({
  69. urls: [url],
  70. longPressActions: {
  71. itemList: [t('card.vaildate.v30')], // 保存图片
  72. success: function (data) {
  73. console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  74. },
  75. fail: function (err) {
  76. console.log(err.errMsg);
  77. }
  78. },
  79. showMenu: false
  80. });
  81. }
  82. interface Props {
  83. icon: string;
  84. label: string;
  85. status: 'verified' | 'unverified' | 'pending';
  86. date?: string;
  87. idType?: string;
  88. idFrontUrl?: string;
  89. idBackUrl?: string;
  90. idHoldUrl?: string;
  91. isLast?: boolean;
  92. }
  93. const props = defineProps<Props>();
  94. const statusIcon = computed(() => {
  95. switch (props.status) {
  96. case 'verified':
  97. return 'verified';
  98. case 'pending':
  99. return 'info';
  100. case 'unverified':
  101. return 'closeempty';
  102. default:
  103. return 'closeempty';
  104. }
  105. });
  106. const statusColor = computed(() => {
  107. switch (props.status) {
  108. case 'verified':
  109. return '#22c55e';
  110. case 'pending':
  111. return '#eab308';
  112. case 'unverified':
  113. return '#9ca3af';
  114. default:
  115. return '#9ca3af';
  116. }
  117. });
  118. const statusText = computed(() => {
  119. switch (props.status) {
  120. case 'verified':
  121. return t('card.Status.t1'); // 成功/已认证
  122. case 'pending':
  123. return t('card.Status.t3'); // 处理中/待审核
  124. case 'unverified':
  125. return t('card.Status.t4'); // 待认证
  126. default:
  127. return t('card.Status.t4'); // 待认证
  128. }
  129. });
  130. const statusClass = computed(() => {
  131. switch (props.status) {
  132. case 'verified':
  133. return 'status-verified';
  134. case 'pending':
  135. return 'status-pending';
  136. case 'unverified':
  137. return 'status-unverified';
  138. default:
  139. return 'status-unverified';
  140. }
  141. });
  142. </script>
  143. <style scoped lang="scss">
  144. @import "@/uni.scss";
  145. .verification-row {
  146. display: flex;
  147. align-items: center;
  148. gap: px2rpx(12);
  149. padding: px2rpx(12) 0;
  150. border-bottom: 1px solid #f9fafb;
  151. }
  152. .verification-row-last {
  153. border-bottom: none;
  154. }
  155. .verification-icon {
  156. flex-shrink: 0;
  157. }
  158. .verification-content {
  159. flex: 1;
  160. min-width: 0;
  161. display: flex;
  162. flex-direction: column;
  163. }
  164. .verification-label-wrapper {
  165. display: flex;
  166. align-items: center;
  167. gap: px2rpx(4);
  168. margin-bottom: px2rpx(4);
  169. }
  170. .verification-label {
  171. font-size: px2rpx(12);
  172. color: #6b7280;
  173. }
  174. .verification-id-type {
  175. font-size: px2rpx(10);
  176. color: #9ca3af;
  177. }
  178. .verification-status-wrapper {
  179. display: flex;
  180. align-items: center;
  181. gap: px2rpx(4);
  182. }
  183. .verification-status-text {
  184. font-size: px2rpx(12);
  185. }
  186. .status-verified {
  187. color: #22c55e;
  188. }
  189. .status-pending {
  190. color: #eab308;
  191. }
  192. .status-unverified {
  193. color: #9ca3af;
  194. }
  195. .verification-date {
  196. font-size: px2rpx(10);
  197. color: #9ca3af;
  198. }
  199. .verification-arrow {
  200. flex-shrink: 0;
  201. }
  202. .id-card-images {
  203. padding: px2rpx(12) 0;
  204. border-bottom: 1px solid #f9fafb;
  205. }
  206. .id-card-last {
  207. border-bottom: none;
  208. }
  209. .id-card-label {
  210. margin-bottom: px2rpx(8);
  211. }
  212. .id-card-label-text {
  213. font-size: px2rpx(12);
  214. color: #6b7280;
  215. }
  216. .id-card-container {
  217. display: flex;
  218. gap: px2rpx(12);
  219. }
  220. .id-card-item {
  221. display: flex;
  222. flex-direction: column;
  223. align-items: center;
  224. cursor: pointer;
  225. }
  226. .id-card-item:active {
  227. opacity: 0.8;
  228. }
  229. .id-card-image {
  230. width: px2rpx(100);
  231. height: px2rpx(60);
  232. border-radius: px2rpx(4);
  233. overflow: hidden;
  234. }
  235. .id-card-text {
  236. font-size: px2rpx(10);
  237. color: #9ca3af;
  238. margin-top: px2rpx(4);
  239. }
  240. </style>