cog.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <cwg-page-wrapper>
  3. <view class="page">
  4. <view class="group">
  5. <view class="group-item" @click="router.push('/pages/mine/pay-password')">
  6. <cwg-icon color="#000" icon="xgmm" />
  7. <text class="item-text">{{ t("language.i2") }}</text>
  8. <text class="version item-text"></text>
  9. <cwg-icon color="#817f7f" icon="chevron-right" />
  10. </view>
  11. <view class="group-item" @click="router.push('/pages/mine/language')">
  12. <cwg-icon color="#000" icon="web" />
  13. <text class="item-text">{{ t("language.i1") }}</text>
  14. <text class="version item-text">{{ t(`language.${lang}`) }}</text>
  15. <cwg-icon color="#817f7f" icon="chevron-right" />
  16. </view>
  17. </view>
  18. <!-- <view class="group">
  19. <view class="group-item" @click="router.push('/pages/mine/pay-password')">
  20. <cwg-icon color="#000" icon="xxtz" />
  21. <text class="item-text">消息通知设置</text>
  22. <text class="version item-text"></text>
  23. <cwg-icon color="#817f7f" icon="chevron-right" />
  24. </view>
  25. </view> -->
  26. <view class="group">
  27. <view class="group-item" @click="router.push('/pages/mine/permission')">
  28. <cwg-icon color="#000" icon="yszc" />
  29. <text class="item-text">{{ t('pages.mine.permission') }}</text>
  30. <text class="version item-text"></text>
  31. <cwg-icon color="#817f7f" icon="chevron-right" />
  32. </view>
  33. </view>
  34. <view class="group">
  35. <view class="group-item" @click="router.push('/pages/mine/privacy')">
  36. <cwg-icon color="#000" icon="ys" />
  37. <text class="item-text">{{ t('pages.mine.privacy') }}</text>
  38. <text class="version item-text"></text>
  39. <cwg-icon color="#817f7f" icon="chevron-right" />
  40. </view>
  41. </view>
  42. <view class="group">
  43. <view class="group-item">
  44. <cwg-icon color="#000" icon="qchc" />
  45. <text class="item-text">{{ t('pages.mine.clearCache') }}</text>
  46. <text class="version item-text" @click="clearCache">{{ b || a }}</text>
  47. <cwg-icon color="#817f7f" icon="chevron-right" />
  48. </view>
  49. </view>
  50. <view class="group" v-if="appVersion?.currentVersion">
  51. <view class="group-item">
  52. <cwg-icon color="#000" icon="dqbb" />
  53. <text class="item-text">{{ t('pages.mine.currentVersion') }} v{{ appVersion.currentVersion }}</text>
  54. <text class="version item-text" @click="checkUpdate">{{ isUploadD }}</text>
  55. <cwg-icon color="#817f7f" icon="chevron-right" />
  56. </view>
  57. </view>
  58. <view class="group">
  59. <view class="group-item">
  60. <cwg-icon color="#000" icon="gy" />
  61. <text class="item-text">{{ t('pages.mine.about') }}</text>
  62. <text class="version item-text"></text>
  63. <cwg-icon color="#817f7f" icon="chevron-right" />
  64. </view>
  65. </view>
  66. <view class="fixed-btn">
  67. <view class="cwg-button">
  68. <u-button type="primary" block :loading="loading" @click="showLogoutPopup = true">{{
  69. t("language.i6") }}</u-button>
  70. </view>
  71. </view>
  72. <u-modal class="code-dialog" :show="showLogoutPopup" title="" :show-confirm-button="false"
  73. :show-cancel-button="false" :close-on-click-overlay="false">
  74. <view class="modal-class">
  75. <view class="p1 title">{{ t('mine.logout') }}</view>
  76. <view class="p1">{{ t('mine.p') }}</view>
  77. <view class="cwg-button ok-button">
  78. <u-button type="primary" block @click="handleLogout('confirm')">{{
  79. t("mine.b1")
  80. }}</u-button>
  81. </view>
  82. <view class="cwg-button no-button">
  83. <u-button type="primary" block @click="handleLogout">{{
  84. t("mine.b2")
  85. }}</u-button>
  86. </view>
  87. </view>
  88. </u-modal>
  89. </view>
  90. </cwg-page-wrapper>
  91. </template>
  92. <script setup lang="ts">
  93. import { onLoad } from '@dcloudio/uni-app'
  94. import { ref, computed } from "vue";
  95. import { useI18n } from "vue-i18n";
  96. import useRouter from "@/hooks/useRouter";
  97. import { userApi } from "@/api/user";
  98. import { lang } from "@/composables/config";
  99. import useUserStore from "@/stores/use-user-store";
  100. import { showToast } from "@/utils/toast";
  101. import { useAppUpdate } from '@/hooks/useAppUpdate'
  102. const { checkUpdate } = useAppUpdate()
  103. const { t } = useI18n();
  104. const userStore = useUserStore();
  105. const router = useRouter();
  106. const b = ref('')
  107. const a = computed(() => {
  108. try {
  109. const res = uni.getStorageInfoSync();
  110. const currentSizeMB = (res.currentSize / 1024).toFixed(2);
  111. return `${currentSizeMB} MB`;
  112. } catch (e) {
  113. return 0
  114. }
  115. });
  116. const appVersion = computed(() => userStore.appVersion);
  117. const isUploadD = computed(() => appVersion.value?.isUpdate ? t('pages.mine.newVersion') : t('pages.mine.hasNewVersion'));
  118. const showLogoutPopup = ref(false);
  119. async function handleLogout(action: string) {
  120. if (action === "confirm") {
  121. try {
  122. const res = await userApi.logout();
  123. if (res.code === 200) {
  124. userStore.clearUserInfo();
  125. router.push("/pages/login/index");
  126. }
  127. } catch (error) {
  128. showToast(error.message || "退出登录失败");
  129. }
  130. }
  131. showLogoutPopup.value = false;
  132. }
  133. const clearCache = () => {
  134. uni.showModal({
  135. title: t('pages.mine.clearCache'),
  136. cancelText: t('common.cancel'),
  137. confirmText: t('common.confirm'),
  138. content: t('mine.p19') + a.value,
  139. success: async (e) => {
  140. if (e.confirm) {
  141. b.value = '0 MB';
  142. } else {
  143. b.value = '';
  144. }
  145. }
  146. });
  147. };
  148. </script>
  149. <style scoped lang="scss">
  150. @import "@/uni.scss";
  151. :deep(.u-modal__content) {
  152. padding: px2rpx(24) px2rpx(40);
  153. .p1 {
  154. color: #363130;
  155. font-family: "League Spartan";
  156. font-size: px2rpx(17);
  157. font-style: normal;
  158. font-weight: 400;
  159. line-height: normal;
  160. margin-bottom: px2rpx(32);
  161. }
  162. .modal-class {
  163. width: px2rpx(300);
  164. }
  165. .title {
  166. color: #1a1a1a;
  167. text-align: center;
  168. font-family: Roboto;
  169. font-size: px2rpx(22);
  170. font-style: normal;
  171. font-weight: 600;
  172. line-height: px2rpx(22);
  173. }
  174. .no-button {
  175. width: 100%;
  176. margin: px2rpx(12) 0;
  177. .u-button {
  178. background-color: #ffbdc8 !important;
  179. }
  180. }
  181. .ok-button {
  182. margin: px2rpx(4) 0;
  183. /* background-color: #EA002A; */
  184. }
  185. }
  186. .user-card {
  187. width: 100%;
  188. display: inline-flex;
  189. flex-direction: column;
  190. justify-content: center;
  191. align-items: center;
  192. gap: px2rpx(24);
  193. padding-bottom: px2rpx(48);
  194. .avatar {
  195. width: px2rpx(64);
  196. height: px2rpx(64);
  197. border-radius: 50%;
  198. background: #d8d8d8 url("/static/images/avatars.png") center/cover no-repeat;
  199. border: 4rpx solid #fff;
  200. }
  201. .phone {
  202. color: #1a1a1a;
  203. font-family: Roboto;
  204. font-size: px2rpx(22);
  205. font-style: normal;
  206. font-weight: 600;
  207. line-height: px2rpx(4);
  208. }
  209. }
  210. .user-info .group {
  211. background: var(--action-bg);
  212. border-radius: px2rpx(16);
  213. margin-top: px2rpx(24);
  214. overflow: hidden;
  215. }
  216. .group-item {
  217. display: flex;
  218. align-items: center;
  219. padding: px2rpx(16) 0;
  220. color: #000;
  221. font-size: px2rpx(16);
  222. /* border-bottom: 2rpx solid var(--action-bg); */
  223. position: relative;
  224. }
  225. .group-item:last-child {
  226. border-bottom: none;
  227. }
  228. svg {
  229. width: px2rpx(24);
  230. height: px2rpx(24);
  231. color: #000;
  232. font-size: px2rpx(24);
  233. }
  234. .group-item .version {
  235. margin-left: auto;
  236. color: #817f7f;
  237. font-size: px2rpx(16);
  238. }
  239. .item-text {
  240. margin-left: px2rpx(12);
  241. }
  242. .code-dialog {
  243. display: flex;
  244. justify-content: center;
  245. gap: px2rpx(12);
  246. padding: px2rpx(16);
  247. :deep(.u-popup__content) {
  248. width: 90% !important;
  249. }
  250. :deep(.u-modal) {
  251. width: 100% !important;
  252. }
  253. }
  254. </style>