|
@@ -16,6 +16,7 @@ import FormMessageBox from '@/components/form-message-box.vue'
|
|
|
import { useMessage } from 'wot-design-uni'
|
|
|
import { requestToast } from '../../../core/utils/common'
|
|
|
import { DataFormSchema } from '../../../components/data-form'
|
|
|
+import dayjs from 'dayjs'
|
|
|
|
|
|
const userStore = useUserStore()
|
|
|
const { userInfo, isDesigner } = storeToRefs(userStore)
|
|
@@ -23,7 +24,8 @@ const { setUserInfo } = userStore
|
|
|
const { confirm } = useMessage('nickname')
|
|
|
const formData = ref<any>({})
|
|
|
const schema = ref<DataFormSchema>()
|
|
|
-const birthday = ref<string>('')
|
|
|
+const birthday = ref()
|
|
|
+const birthdayShow = ref(false)
|
|
|
const { data: userAuthInfo, run: setUserAuthInfo } = useRequest(() => getUserAuthInfo(), {})
|
|
|
const { data: userBasicInfo, run: setUserBasicInfo } = useRequest(() => getUserBasicInfo(), {})
|
|
|
const handleChooseAvatar = async ({ detail: { avatarUrl } }) => {
|
|
@@ -124,11 +126,33 @@ const handleSetSex = async () => {
|
|
|
},
|
|
|
})
|
|
|
}
|
|
|
+const handeleSetBirthday = async () => {
|
|
|
+ const { code, data } = await requestToast(
|
|
|
+ () =>
|
|
|
+ updateMemberUserInfo({
|
|
|
+ birthday: dayjs(birthday.value).format('YYYY-MM-DD'),
|
|
|
+ }),
|
|
|
+ {
|
|
|
+ success: true,
|
|
|
+ successTitle: '修改成功',
|
|
|
+ },
|
|
|
+ )
|
|
|
+ if (code === 0) {
|
|
|
+ // await setUserBasicInfo()
|
|
|
+ setUserInfo({
|
|
|
+ ...userInfo.value,
|
|
|
+ birthday: dayjs(birthday.value).format('YYYY-MM-DD'),
|
|
|
+ })
|
|
|
+ birthdayShow.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
onMounted(async () => {
|
|
|
await setUserAuthInfo()
|
|
|
if (isDesigner.value) {
|
|
|
await Promise.all([setUserBasicInfo()])
|
|
|
+ console.log(userBasicInfo.value)
|
|
|
}
|
|
|
+ birthday.value = userInfo.value.birthday || dayjs().toDate().getTime()
|
|
|
})
|
|
|
</script>
|
|
|
<template>
|
|
@@ -170,10 +194,9 @@ onMounted(async () => {
|
|
|
end-arrow
|
|
|
@click="handleSetSex"
|
|
|
></SectionHeading>
|
|
|
- <!-- <div class="relative">
|
|
|
+ <div class="relative" @click="birthdayShow = true">
|
|
|
<SectionHeading title="生日" size="sm" end-text="设置" end-arrow></SectionHeading>
|
|
|
- </div> -->
|
|
|
- <!-- <wd-datetime-picker-view type="date" v-model="formData" label="年月日" /> -->
|
|
|
+ </div>
|
|
|
<!-- <div class="absolute left-0 top-0 w-full h-full opacity-" style="visibility: hidden">
|
|
|
<wd-datetime-picker type="date" v-model="birthday" custom-class=""></wd-datetime-picker>
|
|
|
</div> -->
|
|
@@ -197,6 +220,20 @@ onMounted(async () => {
|
|
|
<div class="flex-1"></div>
|
|
|
<div><wd-button block :round="false" @click="handleLogout">退出登录</wd-button></div>
|
|
|
<FormMessageBox v-model="formData" selector="nickname" :schema="schema"></FormMessageBox>
|
|
|
+ <wd-action-sheet v-model="birthdayShow" title="设置生日" @close="close">
|
|
|
+ <!-- <view style="padding: 15px 15px 150px 15px"> -->
|
|
|
+ <wd-datetime-picker-view
|
|
|
+ type="date"
|
|
|
+ v-model="birthday"
|
|
|
+ :minDate="dayjs().subtract(80, 'y').toDate().getTime()"
|
|
|
+ :maxDate="dayjs().toDate().getTime()"
|
|
|
+ label="年月日"
|
|
|
+ />
|
|
|
+ <!-- </view> -->
|
|
|
+ <div class="px-4 pb-4">
|
|
|
+ <wd-button block :round="false" @click="handeleSetBirthday">确定</wd-button>
|
|
|
+ </div>
|
|
|
+ </wd-action-sheet>
|
|
|
</div>
|
|
|
</template>
|
|
|
<style lang="scss">
|