Browse Source

feat: 添加生日设置功能,优化手机号修改逻辑,修复分享按钮样式

EvilDragon 3 months ago
parent
commit
e3dd8c272e

+ 11 - 1
packages/app/src/pages/mine/homepage/index.vue

@@ -162,6 +162,8 @@ onUnload(async () => {
 onShareAppMessage(async ({ from, target }) => {
   const res: Page.CustomShareContent = {}
   if (from === 'button') {
+    console.log(target)
+
     if (target.dataset.type === 'homepage') {
       res.title = `${userInfo.value.nickname}: “${designerInfo.value.designDesc}”`
       res.imageUrl = designerInfo.value?.sharePageUrl
@@ -386,7 +388,15 @@ defineExpose({
           </wd-button>
         </div>
         <div class="flex-1" v-if="userInfo.userId === Number(id)">
-          <wd-button block :round="false" open-type="share" data-type="homepage">分享</wd-button>
+          <button
+            class="p-0 after:b-none"
+            block
+            :round="false"
+            open-type="share"
+            :data-type="'homepage'"
+          >
+            <wd-button block :round="false">分享</wd-button>
+          </button>
         </div>
         <div class="flex-1" v-if="userInfo.userId !== Number(id)">
           <wd-button

+ 41 - 4
packages/app/src/pages/mine/setting/index.vue

@@ -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">

+ 10 - 2
packages/app/src/pages/mine/setting/mobile/modify/index.vue

@@ -11,7 +11,13 @@ const userStore = useUserStore()
 const { reset } = userStore
 const router = useRouter()
 const formData = ref<{ mobile?: string; code?: string }>({})
-const disabled = computed(() => !formData.value.mobile || !formData.value.code)
+const disabled = computed(
+  () =>
+    !formData.value.mobile ||
+    !formData.value.code ||
+    formData.value.code.length !== 6 ||
+    formData.value.mobile.length !== 11,
+)
 const sendCodeDisabled = computed(() => !formData.value.mobile && timer.value === 0)
 const timer = ref(0)
 const interval = ref()
@@ -45,7 +51,9 @@ const handleSubmit = async () => {
   )
   if (code === 0) {
     reset()
-    router.replace('/pages/login/index')
+    uni.switchTab({
+      url: '/pages/home/index',
+    })
   }
 }
 </script>

+ 1 - 0
packages/app/src/typings.ts

@@ -32,6 +32,7 @@ type IUserInfo = {
   level?: { cardCode: string; icon: string; level: number; name: string; point: number }
   userAuthStatus?: 0 | 1 | 2
   mobile?: string
+  birthday?: string
 }
 
 enum TestEnum {