当前位置: 首页 > news >正文

uni-app修改头像和个人信息

效果图

在这里插入图片描述

代码(总)

<script setup lang="ts">
import { reqMember, reqMemberProfile } from '@/services/member/member'
import type { MemberResult, Gender } from '@/services/member/type'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
import { useMemberStore } from '@/stores/modules/member'
let useMemberStores = useMemberStore()
// 获取屏幕边界到安全区域距离
const { safeAreaInsets } = uni.getSystemInfoSync()
let memberList = ref<MemberResult>({} as MemberResult)
// 获取个人信息
let getMember = async () => {let res = await reqMember()memberList.value = res.result
}
// 修改头像
let onAvatatChange = () => {// 调用拍照/选择图片uni.chooseMedia({count: 1,mediaType: ['image'],success: (res) => {// 本地路径let { tempFilePath } = res.tempFiles[0]uni.uploadFile({url: '/member/profile/avatar',name: 'file',filePath: tempFilePath,success: (res) => {if (res.statusCode === 200) {let avatar = JSON.parse(res.data).result.avatarmemberList.value!.avatar = avatar// 同步修改pina仓库的头像信息useMemberStores.profile!.avatar = avataruni.showToast({ icon: 'success', title: '修改成功' })} else {uni.showToast({ icon: 'error', title: '出现错误' })}},})},})
}
// 修改性别
const onGenderChange: UniHelper.RadioGroupOnChange = (e) => {memberList.value.gender = e.detail.value as Gender
}
// 修改生日
const onBirthday: UniHelper.DatePickerOnChange = (ev) => {memberList.value.birthday = ev.detail.value// console.log(ev)
}
// 修改城市
let fullLocationCode: [string, string, string] = ['', '', '']
const onFullLocationChange: UniHelper.RegionPickerOnChange = (ev) => {memberList.value.fullLocation = ev.detail.value.join(' ')fullLocationCode = ev.detail.code!console.log(ev.detail)
}
// 点击保保存
const onSave = async () => {const res = await reqMemberProfile({nickname: memberList.value.nickname,gender: memberList.value.gender,birthday: memberList.value.birthday,provinceCode: fullLocationCode[0] || undefined,cityCode: fullLocationCode[1] || undefined,countyCode: fullLocationCode[2] || undefined,})// 同步更改仓库的用户昵称useMemberStores.profile!.nickname = res.result.nicknameuni.showToast({ icon: 'success', title: '保存成功' })setTimeout(() => {uni.navigateBack()}, 500)
}
onLoad(() => {getMember()
})
</script><template><view class="viewport"><!-- 导航栏 --><view class="navbar" :style="{ paddingTop: safeAreaInsets?.top + 'px' }"><navigator open-type="navigateBack" class="back icon-left" hover-class="none"></navigator><view class="title">个人信息</view></view><!-- 头像 --><view class="avatar"><view class="avatar-content" @tap="onAvatatChange"><image class="image" :src="memberList?.avatar" mode="aspectFill" /><text class="text">点击修改头像</text></view></view><!-- 表单 --><view class="form"><!-- 表单内容 --><view class="form-content"><view class="form-item"><text class="label">账号</text><text class="account">{{ memberList?.account }}</text></view><view class="form-item"><text class="label">昵称</text><input class="input" type="text" placeholder="请填写昵称" v-model="memberList.nickname" /></view><view class="form-item"><text class="label">性别</text><radio-group @change="onGenderChange"><label class="radio"><radio value="男" color="#27ba9b" :checked="memberList?.gender === '男'" /></label><label class="radio"><radio value="女" color="#27ba9b" :checked="memberList?.gender === '女'" /></label></radio-group></view><view class="form-item"><text class="label">生日</text><pickerclass="picker"mode="date"start="1900-01-01":end="new Date()":value="memberList?.birthday"@change="onBirthday"><view v-if="memberList?.birthday">{{ memberList.birthday }}</view><view class="placeholder" v-else>请选择日期</view></picker></view><view class="form-item"><text class="label">城市</text><pickerclass="picker"mode="region":value="memberList.fullLocation?.split(' ')"@change="onFullLocationChange"><view v-if="memberList?.fullLocation">{{ memberList.fullLocation }}</view><view class="placeholder" v-else>请选择城市</view></picker></view><view class="form-item"><text class="label">职业</text><inputclass="input"type="text"placeholder="请填写职业":value="memberList?.profession"/></view></view><!-- 提交按钮 --><button class="form-button" @tap="onSave">保 存</button></view></view>
</template><style lang="scss">
page {background-color: #f4f4f4;
}.viewport {display: flex;flex-direction: column;height: 100%;background-image: url(https://pcapi-xiaotuxian-front-devtest.itheima.net/miniapp/images/order_bg.png);background-size: auto 420rpx;background-repeat: no-repeat;
}// 导航栏
.navbar {position: relative;.title {height: 40px;display: flex;justify-content: center;align-items: center;font-size: 16px;font-weight: 500;color: #fff;}.back {position: absolute;height: 40px;width: 40px;left: 0;font-size: 20px;color: #fff;display: flex;justify-content: center;align-items: center;}
}// 头像
.avatar {text-align: center;width: 100%;height: 260rpx;display: flex;flex-direction: column;justify-content: center;align-items: center;.image {width: 160rpx;height: 160rpx;border-radius: 50%;background-color: #eee;}.text {display: block;padding-top: 20rpx;line-height: 1;font-size: 26rpx;color: #fff;}
}// 表单
.form {background-color: #f4f4f4;&-content {margin: 20rpx 20rpx 0;padding: 0 20rpx;border-radius: 10rpx;background-color: #fff;}&-item {display: flex;height: 96rpx;line-height: 46rpx;padding: 25rpx 10rpx;background-color: #fff;font-size: 28rpx;border-bottom: 1rpx solid #ddd;&:last-child {border: none;}.label {width: 180rpx;color: #333;}.account {color: #666;}.input {flex: 1;display: block;height: 46rpx;}.radio {margin-right: 20rpx;}.picker {flex: 1;}.placeholder {color: #808080;}}&-button {height: 80rpx;text-align: center;line-height: 80rpx;margin: 30rpx 20rpx;color: #fff;border-radius: 80rpx;font-size: 30rpx;background-color: #27ba9b;}
}
</style>

相关文章:

uni-app修改头像和个人信息

效果图 代码&#xff08;总&#xff09; <script setup lang"ts"> import { reqMember, reqMemberProfile } from /services/member/member import type { MemberResult, Gender } from /services/member/type import { onLoad } from dcloudio/uni-app impor…...

IDEA 中搭建 Spring Boot Maven 多模块项目 (父SpringBoot+子Maven)

第1步&#xff1a;新建一个SpringBoot 项目 作为 父工程 [Ref] 新建一个SpringBoot项目 删除无用的 .mvn 目录、 src 目录、 mvnw 及 mvnw.cmd 文件&#xff0c;最终只留 .gitignore 和 pom.xml 第2步&#xff1a;创建 子maven模块 第3步&#xff1a;整理 父 pom 文件 ① …...

竞赛保研 基于计算机视觉的身份证识别系统

0 前言 &#x1f525; 优质竞赛项目系列&#xff0c;今天要分享的是 基于机器视觉的身份证识别系统 该项目较为新颖&#xff0c;适合作为竞赛课题方向&#xff0c;学长非常推荐&#xff01; &#x1f9ff; 更多资料, 项目分享&#xff1a; https://gitee.com/dancheng-sen…...

在visual studio中调试时无法查看std::wstring

1.问题 在调试的时候发现std::wstring类型的变量查看不了&#xff0c;会显示(error)|0&#xff0c;百思不得其解。 2.解决方法 参考的&#xff1a;vs2015调试时无法显示QString变量的值&#xff0c;只显示地址_vs调试qstring的时候如何查看字符串-CSDN博客 在工具/选项/调试…...

2023年全国职业院校技能大赛高职组应用软件系统开发正式赛题—模块三:系统部署测试

模块三&#xff1a;系统部署测试&#xff08;3 小时&#xff09; 一、模块考核点 模块时长&#xff1a;3 小时模块分值&#xff1a;20 分本模块重点考查参赛选手的系统部署、功能测试、Bug 排查修复及文档编写能力&#xff0c;具体包括&#xff1a;系统部署。将给定项目发布到…...

微信小程序上传并显示图片

实现效果&#xff1a; 上传前显示&#xff1a; 点击后可上传&#xff0c;上传后显示&#xff1a; 源代码&#xff1a; .wxml <view class"{{company_logo_src?blank-area:}}" style"position:absolute;top:30rpx;right:30rpx;height:100rpx;width:100rp…...

java基础知识点系列——数据输入(五)

java基础知识点系列——数据输入&#xff08;五&#xff09; 数据输入概述 Scanner使用步骤 &#xff08;1&#xff09;导包 import java.util.Scanner&#xff08;2&#xff09;创建对象 Scanner sc new Scanner(System.in)&#xff08;3&#xff09;接收数据 int i sc…...

MySQL面试题 | 07.精选MySQL面试题

&#x1f90d; 前端开发工程师&#xff08;主业&#xff09;、技术博主&#xff08;副业&#xff09;、已过CET6 &#x1f368; 阿珊和她的猫_CSDN个人主页 &#x1f560; 牛客高级专题作者、在牛客打造高质量专栏《前端面试必备》 &#x1f35a; 蓝桥云课签约作者、已在蓝桥云…...

C语言中关于指针的理解及用法

关于指针意思的参考&#xff1a;https://baike.baidu.com/item/%e6%8c%87%e9%92%88/2878304 指针 指针变量 地址 野指针 野指针就是指针指向的位置是不可知的&#xff08;随机的&#xff0c;不正确的&#xff0c;没有明确限制的&#xff09; 以下是导致野指针的原因 1.指针…...

软件测试|深入理解Python中的re.search()和re.findall()区别

前言 在Python中&#xff0c;正则表达式是一种强大的工具&#xff0c;用于在文本中查找、匹配和处理模式。re 模块提供了许多函数来处理正则表达式&#xff0c;其中 re.search()和 re.findall() 是常用的两个函数&#xff0c;用于在字符串中查找匹配的模式。本文将深入介绍这两…...

❤ Vue3 完整项目太白搭建 Vue3+Pinia+Vant3/ElementPlus+typerscript(一)yarn 版本控制 ltb (太白)

❤ 项目搭建 一、项目信息 Vue3 完整项目搭建 Vue3PiniaVant3/ElementPlustyperscript&#xff08;一&#xff09;yarn 版本控制 项目地址&#xff1a; 二、项目搭建 &#xff08;1&#xff09;创建项目 yarn create vite <ProjectName> --template vueyarn install …...

linux搭建SRS服务器

linux搭建SRS服务器 文章目录 linux搭建SRS服务器SRS说明实验说明搭建步骤推流步骤查看web端服务器拉流步骤final SRS说明 SRS&#xff08;simple Rtmp Server&#xff09;,是一个简单高效的实时视频服务器&#xff0c;支持RTMP/WebRTC/HLS/HTTP-FLV/SRT, 是国人自己开发的一款…...

系列六、Spring Security中的认证 授权 角色继承

一、Spring Security中的认证 & 授权 & 角色继承 1.1、概述 关于Spring Security中的授权&#xff0c;请参考【系列一、认证 & 授权】&#xff0c;这里不再赘述。 1.2、资源类 /*** Author : 一叶浮萍归大海* Date: 2024/1/11 20:58* Description: 测试资源*/ Re…...

云原生周刊:OpenTofu 宣布正式发布 | 2023.1.15

开源项目推荐 kubeaudit kubeaudit 是一个开源项目&#xff0c;旨在帮助用户对其 Kubernetes 集群进行常见安全控制的审计。该项目提供了工具和检查规则&#xff0c;可以帮助用户发现潜在的安全漏洞和配置问题。 Chronos Chronos 是一款综合性开发人员工具&#xff0c;可监…...

【如何在 GitHub上面找项目】【转载】

很多的小伙伴&#xff0c;经常会有这样的困惑&#xff0c;我看了很多技术的学习文档、书籍、甚至视频&#xff0c;我想动手实践&#xff0c;于是我打开了GitHub&#xff0c;想找个开源项目&#xff0c;进行学习&#xff0c;获取项目实战经验。这个时候很多小伙伴就会面临这样的…...

java每日一题——ATM系统编写(答案及编程思路)

前言&#xff1a; 基础语句学完&#xff0c;也可以编写一些像样的程序了&#xff0c;现在要做的是多加练习&#xff0c;巩固下知识点&#xff0c;打好基础&#xff0c;daydayup! 题目&#xff1a;模仿银行ATM系统&#xff0c;可以创建用户&#xff0c;存钱&#xff0c;转账&…...

《TrollStore巨魔商店》TrollStore2安装使用教程支持IOS14.0-16.6.1

TrollStore(巨魔商店) 简单的说就相当于一个永久的免费证书&#xff0c;它可以给你的iPhone和iPad安装任何你想要安装的App软件&#xff0c;而且不需要越狱,不用担心证书签名过期的问题&#xff0c;不需要个人签名和企业签名。 支持的版本&#xff1a; TrollStore安装和使用教…...

鸿鹄电子招投标系统源码实现与立项流程:基于Spring Boot、Mybatis、Redis和Layui的企业电子招采平台

随着企业的快速发展&#xff0c;招采管理逐渐成为企业运营中的重要环节。为了满足公司对内部招采管理提升的要求&#xff0c;建立一个公平、公开、公正的采购环境至关重要。在这个背景下&#xff0c;我们开发了一款电子招标采购软件&#xff0c;以最大限度地控制采购成本&#…...

力扣-三数之和

三数之和 给你一个整数数组 nums &#xff0c;判断是否存在三元组 [nums[i], nums[j], nums[k]] 满足 i ! j、i ! k 且 j ! k &#xff0c;同时还满足 nums[i] nums[j] nums[k] 0 。请你返回所有和为 0 且不重复的三元组。 注意&#xff1a;答案中不可以包含重复的三元组。…...

全罐喂养一个月多少钱?适合全罐喂养的猫罐头推荐

不少铲屎官一直没有办法get到猫罐头对猫咪的好处&#xff0c;或者get到了又觉得给猫咪买猫罐头好贵&#xff0c;看到其他铲屎官都开始全罐喂养了&#xff0c;但是自己却迟迟下不了手&#xff0c;犹犹豫豫的不知道全罐喂养一个月多少钱&#xff1f; 今天&#xff0c;铲龄15年的…...

SEO优化中关键词的作用是什么_关键词布局对SEO有什么影响

SEO优化中关键词的作用是什么 在现代网络营销中&#xff0c;SEO&#xff08;搜索引擎优化&#xff09;是提升网站在搜索引擎结果中排名的重要手段。其中&#xff0c;关键词的作用至关重要。关键词不仅是搜索引擎理解用户意图的重要载体&#xff0c;也是搜索引擎算法评估网站相…...

丰田的“改善”到底牛在哪?-云质QMS为您解读精益生产的核心

提到丰田&#xff0c;大家第一反应大概率是精益生产、JIT 即时制&#xff0c;却很少有人深究&#xff0c;支撑丰田几十年持续领跑制造业的底层逻辑&#xff0c;其实是那个看似简单的日语词 ——改善&#xff08;kaizen&#xff09;。很多企业学丰田学了个皮毛&#xff0c;照搬流…...

极验三代验证码全流程解析:从注册请求到ajax.php验证

1. 极验三代验证码技术架构解析 极验三代验证码作为当前主流的交互式安全验证方案&#xff0c;其技术架构设计体现了多重防御思想。整个验证流程采用分阶段验证机制&#xff0c;每个环节都设置了独立的安全校验点。从技术实现角度看&#xff0c;系统由前端SDK、验证逻辑引擎和风…...

EVA-01效果展示:多场景图文问答案例,看AI如何精准识别与深度分析

EVA-01效果展示&#xff1a;多场景图文问答案例&#xff0c;看AI如何精准识别与深度分析 1. 视觉神经同步系统初体验 当你第一次打开EVA-01视觉神经同步系统&#xff0c;最直观的感受就是它独特的"暴走白昼"界面设计。与传统AI工具常见的深色背景不同&#xff0c;这…...

seo网络推广专员有哪些发展前景

SEO网络推广专员的职业发展前景分析 在当今数字经济时代&#xff0c;网络推广已经成为企业营销的核心手段之一。而在网络推广的诸多角色中&#xff0c;SEO网络推广专员&#xff08;Search Engine Optimization网络推广专员&#xff09;无疑是其中最为关键的一环。作为一个SEO网…...

精选 Skills 推荐:10 个让 Coding Agent 如虎添翼的Skills + 优质来源分享

精选 Skills 推荐&#xff1a;10 个让 Coding Agent 如虎添翼的Skills 优质来源分享 本篇是 Vibecoding 系列教程 的工具导向专题篇。 前篇&#xff1a;进阶教程&#xff08;一&#xff09;&#xff1a;MCP Skills 让 coding agent 有自己的工具系列合集&#xff1a;Vibecodi…...

循环冷却水流量示意图设计 建筑水流量示意图绘制教程

一、引言 在建筑给排水、暖通空调及工业循环水系统设计中&#xff0c;循环冷却水流量示意图与建筑水流量示意图是核心技术图纸之一&#xff0c;其作用是直观呈现水流路径、管径规格、流量分配、设备连接关系及压力节点参数&#xff0c;为系统施工、调试、运维及故障排查提供可…...

3D元器件库在PCB设计中的关键作用与应用

1. 为什么你需要一套完整的3D元器件库作为一名电子工程师&#xff0c;我深知在PCB设计过程中&#xff0c;3D元器件库的重要性。传统的2D设计虽然能满足基本需求&#xff0c;但在实际生产装配时往往会遇到各种意想不到的机械干涉问题。记得我刚开始做硬件设计时&#xff0c;就曾…...

S03TodoWrite - 任务规划:没有计划的 Agent 会迷失方向

核心理念 “没有计划的 Agent 走哪算哪” – 先列步骤再动手&#xff0c;完成率翻倍。 源码&#xff1a;https://github.com/xiayongchao/learn-claude-code-4j/blob/main/src/main/java/org/jc/agents/S03TodoWrite.java原版&#xff1a;https://github.com/shareAI-lab/lea…...

ECharts折线图入门学习:从基础到实战的完整指南

引言 折线图是数据可视化中最常用的图表类型之一&#xff0c;特别适合展示数据随时间变化的趋势。ECharts作为一款功能强大的JavaScript可视化库&#xff0c;提供了丰富的配置选项和交互功能&#xff0c;能够轻松创建出专业、美观的折线图。本文将带领大家从零开始学习ECharts折…...