From 859352ee2e233e8ae80277539af62d982a317c6a Mon Sep 17 00:00:00 2001
From: tj <1378534974@qq.com>
Date: 星期四, 05 六月 2025 09:07:34 +0800
Subject: [PATCH] user edit
---
pages.json | 7 ++
sub-pages/mine/profile-edit.vue | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++
sub-pages/mine/index.vue | 12 +--
3 files changed, 165 insertions(+), 8 deletions(-)
diff --git a/pages.json b/pages.json
index b3ecbda..1ebaad6 100644
--- a/pages.json
+++ b/pages.json
@@ -101,6 +101,13 @@
"enablePullDownRefresh": true
}
}
+ ,{
+ "path": "profile-edit",
+ "style": {
+ "navigationBarTitleText": "编辑资料",
+ "enablePullDownRefresh": true
+ }
+ }
]
}
,{
diff --git a/sub-pages/mine/index.vue b/sub-pages/mine/index.vue
index 977b58d..cb9b46d 100644
--- a/sub-pages/mine/index.vue
+++ b/sub-pages/mine/index.vue
@@ -27,7 +27,7 @@
</view>
</view>
- <view class="edit-profile" @click="goToProfile">点击这里,填写简介</view>
+ <view class="edit-profile" >点击这里,填写简介</view>
<view class="stats">
<view class="stat-row">
@@ -45,9 +45,9 @@
</view>
</view>
<view class="action-buttons">
- <up-button text="编辑资料" size="mini" type="info" plain hairline
+ <up-button text="编辑资料" size="mini" type="info" plain hairline @click="navigateTo('/sub-pages/mine/profile-edit')"
:custom-style="{ backgroundColor: 'transparent', borderColor: '#B1ABA9' }" />
- <up-icon name="setting" size="40rpx" @click="gotoUrl('/sub-pages/mine/settings')" />
+ <up-icon name="setting" size="40rpx" @click="navigateTo('/sub-pages/mine/settings')" />
</view>
</view>
</view>
@@ -99,10 +99,6 @@
const { navigateTo } = useNavigator()
const {getLocation,province } = useLocation()
-
-const gotoUrl = (url: string) => {
- navigateTo(url)
-}
watch(
() => userStore.userInfo, // 监听 userInfo 这个响应式属性
@@ -163,7 +159,7 @@
const goToProfile= ()=> {
- navigateTo('/profile');
+ navigateTo('/sub-pages/mine/edit-profile');
}
</script>
diff --git a/sub-pages/mine/profile-edit.vue b/sub-pages/mine/profile-edit.vue
new file mode 100644
index 0000000..bc49ab5
--- /dev/null
+++ b/sub-pages/mine/profile-edit.vue
@@ -0,0 +1,154 @@
+<template>
+ <view class="edit-profile">
+ <view class="avatar-box">
+ <up-avatar :src="form.avatar" size="80" @click="onChangeAvatar" />
+ </view>
+
+ <up-cell-group :border="false" :customStyle="cellGroupStyle">
+ <up-cell title="名字" isLink @click="editField('nickname')">
+ <template #value>
+ <view class="cell-value">{{ form.nickname }}</view>
+ </template>
+ </up-cell>
+ <up-cell title="小红书号" isLink @click="editField('xhsId')">
+ <template #value>
+ <view class="cell-value">{{ form.xhsId }}</view>
+ </template>
+ </up-cell>
+ <up-cell title="背景图" isLink @click="editField('backgroundImg')">
+ <template #value>
+ <view class="cell-value">
+ <image class="bg-img" :src="form.backgroundImg" mode="aspectFill" @click="onChangeBackground" />
+ </view>
+ </template>
+ </up-cell>
+ </up-cell-group>
+
+ <up-cell-group :border="false" :customStyle="cellGroupStyle">
+ <up-cell title="简介" isLink @click="editField('intro')">
+ <template #value>
+ <view class="cell-value">{{ form.intro }}</view>
+ </template>
+ </up-cell>
+ </up-cell-group>
+
+ <up-cell-group :border="false" :customStyle="cellGroupStyle">
+ <up-cell title="性别" isLink @click="selectGender">
+ <template #value>
+ <view class="cell-value">{{ form.gender }}</view>
+ </template>
+ </up-cell>
+ <up-cell title="生日" isLink @click="selectBirthday">
+ <template #value>
+ <view class="cell-value">{{ form.birthday }}</view>
+ </template>
+ </up-cell>
+ <up-cell title="地区" isLink @click="selectRegion">
+ <template #value>
+ <view class="cell-value">{{ form.region }}</view>
+ </template>
+ </up-cell>
+ <up-cell title="职业" isLink @click="selectJob">
+ <template #value>
+ <view class="cell-value">{{ form.job }}</view>
+ </template>
+ </up-cell>
+ <up-cell title="学校" isLink @click="editField('school')">
+ <template #value>
+ <view class="cell-value">{{ form.school }}</view>
+ </template>
+ </up-cell>
+ </up-cell-group>
+
+ <view class="save-btn">
+ <up-button type="primary" shape="circle" text="保存" @click="onSave" />
+ </view>
+ </view>
+</template>
+
+<script setup lang="ts">
+import { ref } from 'vue';
+import { useGlobal } from '@/composables/useGlobal'
+const { $http, $message, $store } = useGlobal()
+
+const cellGroupStyle = 'background-color: #ffffff; margin-bottom: 20rpx; border-radius: 16rpx;'
+
+const form = ref({
+ avatar: 'https://cdn.uviewui.com/uview/album/1.jpg',
+ nickname: '小红薯6786F040',
+ xhsId: '95619601810',
+ backgroundImg: 'https://smart-manager-new.tos-cn-beijing.volces.com/sms/avatar/avatar.png',
+ intro: '介绍一下自己',
+ gender: '女',
+ birthday: '选择生日',
+ region: '选择所在的地区',
+ job: '选择职业',
+ school: '选择学校'
+});
+
+const onPreview = () => {
+ $message.showToast('预览功能暂未实现');
+};
+
+const onChangeAvatar = () => {
+ $message.showToast('更换头像');
+};
+
+const onChangeBackground = () => {
+ $message.showToast('更换背景图');
+};
+
+const editField = (field: string) => {
+ $message.showToast(`编辑字段: ${field}`);
+};
+
+const selectGender = () => {
+ $message.showToast('选择性别');
+};
+
+const selectBirthday = () => {
+ $message.showToast('选择生日');
+};
+
+const selectRegion = () => {
+ $message.showToast('选择地区');
+};
+
+const selectJob = () => {
+ $message.showToast('选择职业');
+};
+
+const onSave = () => {
+ $message.showToast('资料已保存');
+};
+</script>
+
+<style lang="scss" scoped>
+.cell-value {
+ // text-align: center;
+ text-align: left;
+ width: 60%;
+}
+
+.edit-profile {
+ background-color: #f7f7f7;
+ min-height: 100vh;
+ padding: 20rpx;
+
+ .avatar-box {
+ display: flex;
+ justify-content: center;
+ // margin: 40rpx 0;
+ }
+
+ .bg-img {
+ width: 120rpx;
+ height: 80rpx;
+ border-radius: 12rpx;
+ }
+
+ .save-btn {
+ padding: 40rpx;
+ }
+}
+</style>
\ No newline at end of file
--
Gitblit v1.9.3