first commit
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
<script setup lang="ts">
|
||||
import {debounce} from "throttle-debounce";
|
||||
import Config from "@/config";
|
||||
import {useConfigStore} from "@/store";
|
||||
import {setDayjsLocale, setWotDesignLocale} from "@/plugin";
|
||||
|
||||
const {locale} = useI18n();
|
||||
const configStore = useConfigStore();
|
||||
|
||||
const show = ref(false);
|
||||
|
||||
const languages = reactive([
|
||||
{
|
||||
name: "中文",
|
||||
systemValue: "zh-Hans",
|
||||
},
|
||||
{
|
||||
name: "English",
|
||||
systemValue: "en",
|
||||
},
|
||||
]);
|
||||
|
||||
function init() {
|
||||
show.value = true;
|
||||
}
|
||||
|
||||
function close() {
|
||||
show.value = false;
|
||||
}
|
||||
|
||||
function submit(item: { name: string; systemValue: string; }) {
|
||||
close();
|
||||
const localeLanguages = uni.getLocale()
|
||||
console.log(localeLanguages)
|
||||
if (item.systemValue === uni.getLocale()) {
|
||||
return;
|
||||
}
|
||||
uni.setLocale(item.systemValue);
|
||||
locale.value = item.systemValue;
|
||||
setWotDesignLocale()
|
||||
setDayjsLocale()
|
||||
// #ifdef APP-PLUS
|
||||
if (configStore.isIos) {
|
||||
setTimeout(() => {
|
||||
plus.runtime.restart();
|
||||
}, 1000)
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
|
||||
const handleSubmit = debounce(Config.debounceShortTime, submit, {
|
||||
atBegin: true,
|
||||
});
|
||||
|
||||
defineOptions({
|
||||
name: "ChooseLanguage",
|
||||
});
|
||||
|
||||
defineExpose({
|
||||
show,
|
||||
init,
|
||||
close,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<wd-popup
|
||||
custom-class="!bg-transparent"
|
||||
|
||||
position="bottom"
|
||||
safe-area-inset-bottom
|
||||
v-model="show"
|
||||
@close="close"
|
||||
>
|
||||
<view class="p-[28rpx+20rpx]">
|
||||
<view class="bg-#ffff rounded-16rpx shadow-[0rpx_3rpx_6rpx_rgba(0,0,0,0.16)]">
|
||||
<view
|
||||
class="relative"
|
||||
v-for="(item, index) in languages"
|
||||
:key="item.systemValue"
|
||||
@click="handleSubmit(item)"
|
||||
>
|
||||
<view class="h-108rpx center text-28rpx lh-42rpx text-primary font-bold">
|
||||
<text>{{ item.name }}</text>
|
||||
</view>
|
||||
<view
|
||||
class="absolute bottom-0 w-340rpx left-205rpx border-bottom"
|
||||
v-if="index === 0"
|
||||
></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -0,0 +1,73 @@
|
||||
<script setup lang="ts">
|
||||
import {appUserLogOffPost} from "@/service";
|
||||
import {useUserStore} from "@/store";
|
||||
import {debounce} from "throttle-debounce";
|
||||
import Config from "@/config";
|
||||
|
||||
const {t} = useI18n();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const show = ref(false);
|
||||
|
||||
function init() {
|
||||
show.value = true;
|
||||
}
|
||||
|
||||
function close() {
|
||||
show.value = false;
|
||||
}
|
||||
|
||||
async function confirmLogout() {
|
||||
try {
|
||||
close();
|
||||
// await appUserLogOffPost({
|
||||
// body: {}
|
||||
// });
|
||||
await uni.showToast({title: t("pages.mine.log-out-successfully"), icon: "none"});
|
||||
userStore.clear();
|
||||
uni.switchTab({
|
||||
url: Config.indexPath
|
||||
})
|
||||
} catch (error) {
|
||||
}
|
||||
}
|
||||
|
||||
const handleConfirmLogout = debounce(Config.debounceLongTime, confirmLogout, {
|
||||
atBegin: true
|
||||
});
|
||||
|
||||
defineOptions({
|
||||
name: "LogOut",
|
||||
});
|
||||
|
||||
defineExpose({
|
||||
show,
|
||||
init,
|
||||
close,
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<wd-popup
|
||||
custom-class="!bg-transparent"
|
||||
position="bottom"
|
||||
safe-area-inset-bottom
|
||||
v-model="show"
|
||||
@close="close"
|
||||
>
|
||||
<view class="p-[40rpx+20rpx]">
|
||||
<view
|
||||
class="mb-20rpx py-46rpx px-102rpx flex items-center justify-center text-center text-28rpx text-primary font-bold bg-white shadow-[0rpx_3rpx_6rpx_rgba(0,0,0,0.16)] rounded-12rpx"
|
||||
>
|
||||
{{ t("pages.mine.login-out-tip") }}
|
||||
</view>
|
||||
<view
|
||||
class="h-100rpx flex items-center justify-center text-28rpx text-primary font-bold shadow-[0rpx_3rpx_6rpx_rgba(0,0,0,0.16)] bg-white rounded-12rpx"
|
||||
@click="handleConfirmLogout"
|
||||
>
|
||||
{{ t("common.confirm") }}
|
||||
</view>
|
||||
</view>
|
||||
</wd-popup>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -0,0 +1,149 @@
|
||||
<script setup lang="ts">
|
||||
import {useMessage} from "wot-design-uni";
|
||||
import {useConfigStore, useUserStore} from "@/store";
|
||||
import {conversionMobile} from "@/utils";
|
||||
import {Agreement} from "@/constant/enums";
|
||||
import ChooseLanguage from "./components/choose-language/choose-language.vue";
|
||||
import Logout from "./components/log-out/log-out.vue";
|
||||
import Config from "@/config";
|
||||
import {appUserLogOffPost} from "@/service";
|
||||
|
||||
const {t} = useI18n();
|
||||
const {locale} = useI18n();
|
||||
const userStore = useUserStore();
|
||||
const configStore = useConfigStore()
|
||||
const message = useMessage();
|
||||
const currentVersion = ref(configStore.appVersion)
|
||||
const chooseLanguageRef = ref<InstanceType<typeof ChooseLanguage>>()
|
||||
const logoutRef = ref<InstanceType<typeof Logout>>()
|
||||
|
||||
function handleChooseLanguage() {
|
||||
if (chooseLanguageRef.value) {
|
||||
chooseLanguageRef.value.init()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function navigateTo(url: string) {
|
||||
uni.navigateTo({url});
|
||||
}
|
||||
|
||||
|
||||
function handleSetOrUpdatePassword() {
|
||||
if (userStore.userInfo?.payPwd) {
|
||||
return navigateTo(`/pages-user/pages/pay-password/change/index`)
|
||||
}
|
||||
navigateTo(`/pages-user/pages/pay-password/set/index`)
|
||||
}
|
||||
|
||||
function handleLogout() {
|
||||
if (logoutRef.value) {
|
||||
logoutRef.value.init()
|
||||
}
|
||||
}
|
||||
|
||||
function handleLogoutAccount() {
|
||||
message
|
||||
.confirm({
|
||||
msg: t('pages-user.setting.cancelAccountConfirm'),
|
||||
title: t('common.prompt.system-prompt'),
|
||||
cancelButtonText: t('common.close'),
|
||||
confirmButtonText: t('common.confirm'),
|
||||
confirmButtonProps: {
|
||||
customClass: '!bg-#000'
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
appUserLogOffPost({
|
||||
body: {
|
||||
userPort: 1,
|
||||
}
|
||||
}).then(res=> {
|
||||
uni.showToast({
|
||||
title: t('pages-user.setting.cancelAccountSuccess'),
|
||||
icon: 'none',
|
||||
})
|
||||
userStore.clear()
|
||||
uni.switchTab({
|
||||
url: Config.indexPath,
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<navbar :title="t('navbar-settings')"/>
|
||||
<view class="pt-20rpx">
|
||||
<view class="text-30-bold bg-#fff">
|
||||
<view
|
||||
class="flex justify-between items-center border-bottom font-bold p-[40rpx+20rpx]"
|
||||
@click="navigateTo('/pages-user/pages/password/change/index')"
|
||||
>
|
||||
<view>{{ t("pages-user.setting.modification") }}</view>
|
||||
<image
|
||||
src="@img/chef/100202.png"
|
||||
class="shrink-0 ml-16rpx w-22rpx h-30rpx"
|
||||
></image>
|
||||
</view>
|
||||
|
||||
<view
|
||||
@click="
|
||||
handleSetOrUpdatePassword
|
||||
"
|
||||
class="flex justify-between items-center p-[40rpx+20rpx] border-bottom"
|
||||
>
|
||||
<view>{{ t("pages-user.setting.payPwd") }}</view>
|
||||
<view class="flex items-center">
|
||||
<text>{{ t('navbar-settings') }}</text>
|
||||
<image
|
||||
src="@img/chef/100202.png"
|
||||
class="shrink-0 ml-16rpx w-22rpx h-30rpx"
|
||||
></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view
|
||||
class="flex justify-between items-center p-[40rpx+20rpx] border-bottom before:!bg-common"
|
||||
@click="handleChooseLanguage"
|
||||
>
|
||||
<view>{{ t("pages-user.setting.language") }}</view>
|
||||
<view class="flex items-center">
|
||||
<text>{{ locale === 'en' ? 'English' : '中文'}}</text>
|
||||
<image
|
||||
src="@img/chef/100202.png"
|
||||
class="shrink-0 ml-16rpx w-22rpx h-30rpx"
|
||||
></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view
|
||||
class="flex justify-between items-center font-bold p-[40rpx+20rpx]"
|
||||
@click="handleLogoutAccount"
|
||||
>
|
||||
<view>{{ t('pages-user.setting.cancelAccount') }}</view>
|
||||
<image
|
||||
src="@img/chef/100202.png"
|
||||
class="shrink-0 ml-16rpx w-22rpx h-30rpx"
|
||||
></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="px-30rpx mt-180rpx">
|
||||
<wd-button
|
||||
custom-class="!h-108rpx !text-36rpx !text-white !bg-#14181B !rounded-16rpx"
|
||||
block
|
||||
@click="handleLogout"
|
||||
>
|
||||
{{ t('pages-user.setting.logout') }}
|
||||
</wd-button>
|
||||
|
||||
</view>
|
||||
|
||||
<choose-language ref="chooseLanguageRef"/>
|
||||
<logout ref="logoutRef"/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
Reference in New Issue
Block a user