feat: add user profile update issue

This commit is contained in:
Rogee
2025-05-15 10:02:31 +08:00
parent fcca3fef7c
commit 378d3724b3
3 changed files with 33 additions and 21 deletions

View File

@@ -295,6 +295,10 @@ func (m *usersModel) GetUserByOpenIDOrCreate(ctx context.Context, openID string,
} }
} else { } else {
userModel.OpenID = user.OpenID userModel.OpenID = user.OpenID
if !(user.Username == "" || user.Username == "-" || user.Username == "暂未设置昵称") {
userModel.Username = user.Username
userModel.Avatar = user.Avatar
}
user, err = m.Update(ctx, user.ID, userModel) user, err = m.Update(ctx, user.ID, userModel)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "failed to update user") return nil, errors.Wrap(err, "failed to update user")

View File

@@ -1,7 +1,6 @@
<script setup> <script setup>
import { userApi } from "@/api/userApi"; import { userApi } from "@/api/userApi";
import { onMounted, ref } from "vue"; import { onMounted, ref } from "vue";
import { BsBox2Fill, BsGearFill, BsPersonFill, BsPinMapFill } from "vue-icons-plus/bs";
const userInfo = ref({}); const userInfo = ref({});
@@ -16,21 +15,21 @@ onMounted(async () => {
}); });
const menuGroups = [ const menuGroups = [
{ // {
title: "账号与信息", // title: "账号与信息",
items: [{ label: "个人资料", icon: BsPersonFill, link: "/profile/edit" }], // items: [{ label: "个人资料", icon: BsPersonFill, link: "/profile/edit" }],
}, // },
{ // {
title: "订单与服务", // title: "订单与服务",
items: [ // items: [
{ label: "我的订单", icon: BsBox2Fill, link: "/orders" }, // { label: "我的订单", icon: BsBox2Fill, link: "/orders" },
{ label: "我的地址", icon: BsPinMapFill, link: "/address" }, // { label: "我的地址", icon: BsPinMapFill, link: "/address" },
], // ],
}, // },
{ // {
title: "设置", // title: "设置",
items: [{ label: "系统设置", icon: BsGearFill, link: "/settings" }], // items: [{ label: "系统设置", icon: BsGearFill, link: "/settings" }],
}, // },
]; ];
</script> </script>
@@ -51,16 +50,25 @@ const menuGroups = [
<div class="text-gray-500 text-sm"> <div class="text-gray-500 text-sm">
用户编号: {{ userInfo.id }} 用户编号: {{ userInfo.id }}
</div> </div>
<div class="text-primary-600 font-medium"> </div>
账户余额: ¥{{ (userInfo.balance / 100).toFixed(2) }} </div>
</div> </div>
</div>
<!-- 账户余额卡片 -->
<div class="max-w-2xl mx-auto mt-4 px-4">
<div class="bg-white rounded-xl p-4 shadow-sm">
<div class="flex items-center justify-between">
<div class="text-gray-600">账户余额</div>
<div class="text-2xl font-semibold text-primary-600">
¥{{ (userInfo.balance / 100).toFixed(2) }}
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- 菜单列表 --> <!-- 菜单列表 -->
<div class="max-w-2xl mx-auto px-4 py-6 space-y-4 hidden"> <div class="max-w-2xl mx-auto px-4 py-6 space-y-4">
<div v-for="(group, groupIndex) in menuGroups" :key="groupIndex" <div v-for="(group, groupIndex) in menuGroups" :key="groupIndex"
class="bg-white rounded-xl overflow-hidden shadow-sm"> class="bg-white rounded-xl overflow-hidden shadow-sm">
<div class="px-4 py-2 text-sm font-medium text-gray-500 bg-gray-50"> <div class="px-4 py-2 text-sm font-medium text-gray-500 bg-gray-50">

File diff suppressed because one or more lines are too long