info copy 2.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <cwg-page-wrapper>
  3. <uni-tabs v-model="current" :tabs="tabs" @change="changeTab" color="#333" lineHeight="0" field="name">
  4. <template v-slot="{ row, index }">
  5. <view class="tab-title " :class="{ active: current === index }">
  6. <cwg-icon v-if="row.icon" :name="row.icon" :size="16"
  7. :color="current === index ? '#fff' : '#333'" />
  8. <text>{{ row.name }}</text>
  9. </view>
  10. </template>
  11. </uni-tabs>
  12. <view class="info-card">
  13. <view class="content-title">Personal Information</view>
  14. <view class="card-body">
  15. <uni-row class="demo-uni-row">
  16. <uni-col :xs="24" :sm="24" :md="24" :lg="6" :xl="6">
  17. <view class="avatar-section">
  18. <cwg-input v-model:value="formData.idBackUrl" type="upload" fkey="idBackUrl"
  19. rulesKey="idBackUrl" :is-upload-d="true" accept="image/png, image/jpeg, image/jpg"
  20. :readonly="isReadonly" :disabled="isReadonly" @change="handleChange">
  21. <view class="cwg-upload">
  22. </view>
  23. </cwg-input>
  24. <view class="text name">{{ userInfo.firstName }}</view>
  25. <view class="text cid"> CID:{{ userInfo.cId }}</view>
  26. <view class="btn-primary" @click="handleEditProfile">上传头像</view>
  27. </view>
  28. </uni-col>
  29. <uni-col :xs="24" :sm="24" :md="24" :lg="18" :xl="18" class="">
  30. <view class="form">
  31. <uni-row>
  32. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
  33. <cwg-input v-model:value="formData.lastName" fkey="lastName" :required="true"
  34. :label="t('card.Form.f4')" rulesKey="lastName" :readonly="isReadonly"
  35. :disabled="isReadonly" @change="handleChange" />
  36. <cwg-input v-model:value="formData.firstName" fkey="firstName" :required="true"
  37. :label="t('card.Form.f5')" rulesKey="firstName" :readonly="isReadonly"
  38. :disabled="isReadonly" @change="handleChange" />
  39. <cwg-input v-model:value="formData.email" fkey="email" :label="t('card.Form.f3')"
  40. :required="true" rulesKey="email" :readonly="isReadonly" :disabled="isReadonly"
  41. @change="handleChange" />
  42. <view class="f" v-if="phoneCodes.length > 0">
  43. <cwg-input v-model:value="formData.areaCode" class="l" fkey="areaCode"
  44. :required="true" type="select" :show-search="true" :columns="phoneCodes"
  45. :label="t('card.Form.f2')" rulesKey="areaCode" :readonly="isReadonly"
  46. :disabled="isReadonly" @change="handleChange" />
  47. <cwg-input v-model:value="formData.mobile" class="r" fkey="mobile" label=" "
  48. rulesKey="mobile" :readonly="isReadonly" :disabled="isReadonly"
  49. @change="handleChange" />
  50. </view>
  51. <cwg-input v-model:value="formData.gender" fkey="gender" type="select"
  52. :required="true" rulesKey="gender" :columns="sexOptions"
  53. :label="t('card.Form.f8')" :readonly="isReadonly" :disabled="isReadonly"
  54. @change="handleChange" />
  55. <cwg-input v-model:value="formData.birthday" :required="true" type="date"
  56. fkey="birthday" rulesKey="birthday" :label="t('card.Form.f6')"
  57. :readonly="isReadonly" :disabled="isReadonly" @change="handleChange" />
  58. </uni-col>
  59. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
  60. <view class="form-item ">
  61. <view class="left-bg">
  62. <text class="form-label">User CID</text>
  63. <text class="form-value">{{ userInfo.userId }}</text>
  64. </view>
  65. </view>
  66. </uni-col>
  67. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
  68. <view class="form-item ">
  69. <view class="left-bg">
  70. <text class="form-label">User CID</text>
  71. <text class="form-value">{{ userInfo.userId }}</text>
  72. </view>
  73. </view>
  74. </uni-col>
  75. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
  76. <view class="form-item ">
  77. <view class="left-bg">
  78. <text class="form-label">User CID</text>
  79. <text class="form-value">{{ userInfo.userId }}</text>
  80. </view>
  81. </view>
  82. </uni-col>
  83. </uni-row>
  84. </view>
  85. </uni-col>
  86. </uni-row>
  87. <uni-row class="demo-uni-row uni-row1">
  88. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
  89. <cwg-input v-model:value="formData.lastName" fkey="lastName" :required="false"
  90. :label="t('card.Form.f4')" rulesKey="lastName" :readonly="isReadonly" :disabled="isReadonly"
  91. @change="handleChange" />
  92. </uni-col>
  93. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
  94. <cwg-input v-model:value="formData.firstName" fkey="firstName" :required="false"
  95. :label="t('card.Form.f5')" rulesKey="firstName" :readonly="isReadonly"
  96. :disabled="isReadonly" @change="handleChange" />
  97. </uni-col>
  98. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
  99. <cwg-input v-model:value="formData.email" fkey="email" :label="t('card.Form.f3')"
  100. :required="false" rulesKey="email" :readonly="isReadonly" :disabled="isReadonly"
  101. @change="handleChange" />
  102. </uni-col>
  103. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
  104. <cwg-input v-model:value="formData.mobile" class="r" fkey="mobile" :label="t('card.Form.f2')"
  105. rulesKey="mobile" :readonly="isReadonly" :disabled="isReadonly" @change="handleChange" />
  106. </uni-col>
  107. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
  108. <cwg-input v-model:value="formData.birthday" :required="false" type="date" fkey="birthday"
  109. rulesKey="birthday" :label="t('card.Form.f6')" :readonly="isReadonly" :disabled="isReadonly"
  110. @change="handleChange" />
  111. </uni-col>
  112. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
  113. <cwg-input v-if="countryOptions.length > 0" v-model:value="formData.nationality"
  114. fkey="nationality" type="select" :required="false" :show-search="true"
  115. rulesKey="nationality" :columns="countryOptions" :label="t('card.Form.f7')"
  116. :readonly="isReadonly" :disabled="isReadonly" @change="handleChange" />
  117. </uni-col>
  118. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
  119. <cwg-input v-if="cityOptions.length > 0" v-model:value="formData.town" fkey="town"
  120. :required="false" :show-search="true" rulesKey="town" type="select" :columns="cityOptions"
  121. :label="t('card.Form.f9')" :readonly="isReadonly" :disabled="isReadonly"
  122. @change="handleChange" />
  123. </uni-col>
  124. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
  125. <cwg-input v-model:value="formData.address" fkey="address" :label="t('card.Form.f10')"
  126. :required="false" rulesKey="address" :readonly="isReadonly" :disabled="isReadonly"
  127. @change="handleChange" />
  128. </uni-col>
  129. <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="8">
  130. <cwg-input v-model:value="formData.postCode" :required="false" fkey="postCode"
  131. rulesKey="postCode" :label="t('card.Form.f11')" :readonly="isReadonly"
  132. :disabled="isReadonly" @change="handleChange" />
  133. </uni-col>
  134. </uni-row>
  135. </view>
  136. </view>
  137. </cwg-page-wrapper>
  138. </template>
  139. <script setup lang="ts">
  140. import { onLoad } from '@dcloudio/uni-app'
  141. import { ref, onMounted, watch, computed, reactive } from "vue";
  142. import InfoRow from './components/InfoRow.vue';
  143. import VerificationRow from './components/VerificationRow.vue';
  144. import { useI18n } from "vue-i18n";
  145. import useUserStore from "@/stores/use-user-store";
  146. import useRouter from "@/hooks/useRouter";
  147. import useIdTypeOptions from "@/composables/useIdTypeOptions";
  148. const { allIdTypeOptions } = useIdTypeOptions()
  149. const userStore = useUserStore();
  150. const userInfo = computed(() => userStore.userInfo);
  151. const { t } = useI18n();
  152. const router = useRouter();
  153. const idTypeOptions = computed(() => {
  154. return allIdTypeOptions.value?.filter(item => item.value === userInfo.value?.idType);
  155. });
  156. // 获取身份认证状态
  157. function getIdentityStatus() {
  158. // 认证成功就是已认证;否则视为审核中(pending)
  159. if (userInfo.value?.approveStatus == 2 || userInfo.value?.kycStatus == 2) {
  160. return 'verified';
  161. }
  162. return 'pending';
  163. }
  164. const formData = ref({})
  165. const imageStyles = ref({
  166. width: '80px',
  167. height: '80px',
  168. borderRadius: '50%'
  169. });
  170. const current = ref(0);
  171. const tabs = computed(() => [
  172. { id: 1, name: t('card.Info.s1'), icon: 'icon_personal certification' },
  173. { id: 2, name: t('ImproveImmediately.Title.AddressInformation'), icon: 'dw' },
  174. { id: 3, name: t('card.Info.s0'), icon: 'globe' },
  175. { id: 4, name: t('card.Info.s2'), icon: 'checkmark' }
  176. ]);
  177. const changeTab = (index) => {
  178. current.value = index;
  179. }
  180. // 获取身份认证日期
  181. function getIdentityDate() {
  182. // 如果有证件有效期,则使用证件签发日期
  183. if (userInfo.value?.issueDate) {
  184. return new Date(userInfo.value.issueDate).toLocaleDateString();
  185. }
  186. return '';
  187. }
  188. const handleEditProfile = () => {
  189. router.push('/pages/mine/improve');
  190. };
  191. const handleChangePassword = () => {
  192. uni.showToast({
  193. title: t('card.Msg.ComingSoon'),
  194. icon: 'none'
  195. });
  196. };
  197. const isReadonly = computed(() => isAuthInfo.value);
  198. const listStyles = ref({
  199. borderStyle: {
  200. color: '#eee',
  201. width: '1px',
  202. style: 'solid',
  203. radius: '5px'
  204. },
  205. "border": false, // 是否显示边框
  206. "dividline": true // 是否显示分隔线
  207. });
  208. </script>
  209. <style scoped lang="scss">
  210. @import "@/uni.scss";
  211. .tab-title {
  212. display: flex;
  213. align-items: center;
  214. gap: px2rpx(4);
  215. border: 1px solid #f3f4f6;
  216. font-size: 18px;
  217. padding: px2rpx(8) px2rpx(16);
  218. border-radius: px2rpx(8);
  219. background-color: white;
  220. }
  221. .active {
  222. background-color: var(--main-yellow);
  223. color: #fff;
  224. border: none;
  225. }
  226. .info-card {
  227. border-radius: px2rpx(8);
  228. background-color: white;
  229. // padding: px2rpx(16);
  230. }
  231. .card-body {
  232. padding: px2rpx(16);
  233. }
  234. .demo-uni-row {
  235. margin-bottom: px2rpx(16);
  236. }
  237. .avatar-section {
  238. display: flex;
  239. flex-direction: column;
  240. align-items: center;
  241. gap: px2rpx(12);
  242. padding: px2rpx(16);
  243. .cwg-upload {
  244. width: px2rpx(120);
  245. height: px2rpx(120);
  246. border-radius: 50%;
  247. margin: 0 auto;
  248. }
  249. .text {
  250. font-size: 14px;
  251. color: #333;
  252. }
  253. .btn-primary {
  254. margin-top: px2rpx(12);
  255. min-width: px2rpx(120);
  256. background-color: #2563eb;
  257. color: white;
  258. padding: px2rpx(12);
  259. border-radius: px2rpx(8);
  260. border: none;
  261. font-size: px2rpx(14);
  262. text-align: center;
  263. }
  264. .btn-primary:active {
  265. background-color: #1d4ed8;
  266. }
  267. .cid {
  268. color: var(--main-yellow);
  269. font-size: 12px;
  270. margin-top: px2rpx(4);
  271. }
  272. }
  273. .uni-row1 {
  274. display: flex;
  275. gap: px2rpx(16);
  276. flex-shrink: 1;
  277. .uni-col {
  278. margin: px2rpx(12);
  279. border-radius: px2rpx(4);
  280. display: flex;
  281. flex-direction: column;
  282. gap: px2rpx(16);
  283. }
  284. }
  285. .left-bg {
  286. padding: px2rpx(8);
  287. background-color: #f9fafb;
  288. }
  289. .form {
  290. padding: px2rpx(12);
  291. border-radius: px2rpx(4);
  292. display: flex;
  293. flex-direction: column;
  294. gap: px2rpx(16);
  295. }
  296. .form-item {
  297. //
  298. border-radius: px2rpx(8);
  299. padding: px2rpx(8);
  300. }
  301. .form-label {
  302. font-size: px2rpx(12);
  303. color: #6b7280;
  304. font-weight: 500;
  305. }
  306. .form-value {
  307. font-size: px2rpx(14);
  308. color: #1f2937;
  309. font-weight: 500;
  310. }
  311. </style>