index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <cwg-page-wrapper>
  3. <view class="page">
  4. <view class="user-card">
  5. <view class="avatar"></view>
  6. <view class="user-info">
  7. <view class="phone">{{ userInfo?.customInfo?.email }}</view>
  8. </view>
  9. </view>
  10. <view class="group">
  11. <view class="group-item" @click="openProfile()">
  12. <cwg-icon color="#000" icon="shield-lock-open-outline" />
  13. <text class="item-text">{{ t("language.i3") }}</text>
  14. <text class="item-text version" v-if="!isPersonalInfoCompleted">{{ t("language.i0") }}</text>
  15. <text class="item-text version" v-if="isPersonalInfoCompleted">{{ t("State.ToCertified") }}</text>
  16. <cwg-icon color="#000" icon="chevron-right" />
  17. </view>
  18. <view class="group-item" @click="router.push('/pages/mine/language')">
  19. <cwg-icon color="#000" icon="web" />
  20. <text class="item-text">{{ t("language.i1") }}</text>
  21. <text class="version item-text">{{ t(`language.${lang}`) }}</text>
  22. <cwg-icon color="#000" icon="chevron-right" />
  23. </view>
  24. <view class="group-item" @click="router.push('/pages/apply-record/list')">
  25. <cwg-icon color="#000" icon="history" />
  26. <text class="item-text">{{ t("card.tab15") }}</text>
  27. <text class="version item-text"></text>
  28. <cwg-icon color="#000" icon="chevron-right" />
  29. </view>
  30. <view class="group-item" @click="router.push('/pages/wallet/balance')">
  31. <cwg-icon color="#000" icon="history" />
  32. <text class="item-text">{{ t("card.tab17") }}</text>
  33. <text class="version item-text"></text>
  34. <cwg-icon color="#000" icon="chevron-right" />
  35. </view>
  36. </view>
  37. <view class="group">
  38. <view class="group-item" @click="router.push('/pages/mine/pay-password')">
  39. <cwg-icon color="#000" icon="lock-reset" />
  40. <text class="item-text">{{ t("language.i2") }}</text>
  41. <text class="version item-text"></text>
  42. <cwg-icon color="#000" icon="chevron-right" />
  43. </view>
  44. </view>
  45. <!-- <view class="group">
  46. <view class="group-item">
  47. <cwg-icon color="#000" icon="information-outline"/>
  48. <text class="item-text">{{ t('language.i5') }}</text>
  49. <text class="version item-text"></text>
  50. <cwg-icon color="#000" icon="chevron-right" />
  51. </view>
  52. </view> -->
  53. <view class="group">
  54. <view class="group-item" @click="showLogoutPopup = true">
  55. <cwg-icon color="#000" icon="logout" />
  56. <text class="item-text">{{ t("language.i6") }}</text>
  57. <text class="version item-text"></text>
  58. <cwg-icon color="#000" icon="chevron-right" />
  59. </view>
  60. </view>
  61. <u-modal class="code-dialog" :show="showLogoutPopup" title="" :show-confirm-button="false"
  62. :show-cancel-button="false" :close-on-click-overlay="false">
  63. <view class="modal-class">
  64. <view class="p1 title">{{ t('mine.logout') }}</view>
  65. <view class="p1">{{ t('mine.p') }}</view>
  66. <view class="cwg-button ok-button">
  67. <u-button type="primary" block @click="handleLogout('confirm')">{{
  68. t("mine.b1")
  69. }}</u-button>
  70. </view>
  71. <view class="cwg-button no-button">
  72. <u-button type="primary" block @click="handleLogout">{{
  73. t("mine.b2")
  74. }}</u-button>
  75. </view>
  76. </view>
  77. </u-modal>
  78. </view>
  79. </cwg-page-wrapper>
  80. </template>
  81. <script setup lang="ts">
  82. import { ref, onMounted, watch, computed } from "vue";
  83. import { useI18n } from "vue-i18n";
  84. import useRouter from "@/hooks/useRouter";
  85. import { userApi } from "@/api/user";
  86. import { lang } from "@/composables/config";
  87. import useUserStore from "@/stores/use-user-store";
  88. import { showToast } from "@/utils/toast";
  89. const { t } = useI18n();
  90. const userStore = useUserStore();
  91. const router = useRouter();
  92. const userInfo = computed(() => userStore.userInfo);
  93. // 判断是否已完成个人信息认证
  94. const isPersonalInfoCompleted = computed(() => {
  95. if (userInfo?.approveStatus == 2) {
  96. return true;
  97. } else {
  98. return false;
  99. }
  100. });
  101. function openProfile() {
  102. if (!isPersonalInfoCompleted.value) {
  103. router.push('/pages/mine/info');
  104. } else {
  105. router.push('/pages/mine/improve');
  106. }
  107. }
  108. const showLogoutPopup = ref(false);
  109. async function handleLogout(action: string) {
  110. if (action === "confirm") {
  111. try {
  112. const res = await userApi.logout();
  113. if (res.code === 200) {
  114. userStore.clearUserInfo();
  115. router.push("/pages/login/index");
  116. }
  117. } catch (error) {
  118. showToast(error.message || "退出登录失败");
  119. }
  120. }
  121. showLogoutPopup.value = false;
  122. }
  123. </script>
  124. <style scoped lang="scss">
  125. @import "@/uni.scss";
  126. :deep(.u-modal__content) {
  127. padding: px2rpx(24) px2rpx(40);
  128. .p1 {
  129. color: #363130;
  130. font-family: "League Spartan";
  131. font-size: px2rpx(17);
  132. font-style: normal;
  133. font-weight: 400;
  134. line-height: normal;
  135. margin-bottom: px2rpx(32);
  136. }
  137. .modal-class {
  138. width: px2rpx(300);
  139. }
  140. .title {
  141. color: #1a1a1a;
  142. text-align: center;
  143. font-family: Roboto;
  144. font-size: px2rpx(22);
  145. font-style: normal;
  146. font-weight: 600;
  147. line-height: px2rpx(22);
  148. }
  149. .no-button {
  150. width: 100%;
  151. margin: px2rpx(12) 0;
  152. .u-button {
  153. background-color: #ffbdc8 !important;
  154. }
  155. }
  156. .ok-button {
  157. margin: px2rpx(4) 0;
  158. /* background-color: #EA002A; */
  159. }
  160. }
  161. .user-card {
  162. width: 100%;
  163. display: inline-flex;
  164. flex-direction: column;
  165. justify-content: center;
  166. align-items: center;
  167. gap: px2rpx(24);
  168. padding-bottom: px2rpx(48);
  169. .avatar {
  170. width: px2rpx(64);
  171. height: px2rpx(64);
  172. border-radius: 50%;
  173. background: #d8d8d8 url("/static/images/avatars.png") center/cover no-repeat;
  174. border: 4rpx solid #fff;
  175. }
  176. .phone {
  177. color: #1a1a1a;
  178. font-family: Roboto;
  179. font-size: px2rpx(22);
  180. font-style: normal;
  181. font-weight: 600;
  182. line-height: px2rpx(4);
  183. }
  184. }
  185. .user-info .group {
  186. background: var(--action-bg);
  187. border-radius: px2rpx(16);
  188. margin-top: px2rpx(24);
  189. overflow: hidden;
  190. }
  191. .group-item {
  192. display: flex;
  193. align-items: center;
  194. padding: px2rpx(16) 0;
  195. color: #000;
  196. font-size: px2rpx(16);
  197. /* border-bottom: 2rpx solid var(--action-bg); */
  198. position: relative;
  199. }
  200. .group-item:last-child {
  201. border-bottom: none;
  202. }
  203. svg {
  204. width: px2rpx(24);
  205. height: px2rpx(24);
  206. color: #000;
  207. font-size: px2rpx(24);
  208. }
  209. .group-item .version {
  210. margin-left: auto;
  211. color: #000;
  212. font-size: px2rpx(16);
  213. }
  214. .item-text {
  215. margin-left: px2rpx(12);
  216. }
  217. .code-dialog {
  218. display: flex;
  219. justify-content: center;
  220. gap: px2rpx(12);
  221. padding: px2rpx(16);
  222. :deep(.u-popup__content) {
  223. width: 90% !important;
  224. }
  225. :deep(.u-modal) {
  226. width: 100% !important;
  227. }
  228. }
  229. </style>