1.上传后显示头像,没有上传就是默认头像把avatarurl改为定义为一个对象,页面用if和else判断是否存在显示,上传完头像,然后把头像地址保存到数据库然后一开始加载就会显示上传了的头像在上传之前就会把临时头像地址先给avatarurl,这样先显示,使得页面更加友好<image v-if="avatarurl" :src="avatarurl" mode="aspectFill"></image> <image v-else src="../../static/images/defAvatar.png" mode="aspectFill"></image> jsconst avatarurl =ref(userStore.userInfo.avatar); function onChooseAvatar(e){ avatarurl.value=e.detail.av
1.上传头像功能完成,这里面cloudPathAsRealPath:true只能阿里云空间可以使用,就是绝对路径,我们上传的会也创建好路径,不会把路径也当成文件名字let avatarurl =e.detail.avatarUrl; uniCloud.uploadFile({ filePath:avatarurl, cloudPath:`userAvatar/${formatTimestampToYearMonthDay(Date.now())}/${Date.now()}.jpg`, cloudPathAsRealPath:true })
1.引入pinia里面的数据userinfo,为把/soup/edit里面的数据补充上import { useUserStore, useUserStore } from "../../stores/user"; const userStore=useUserStore(); const userInfo = userStore.userInfo; 2.补充内容绑定<view class="list"> <uni-list> <uni-list-item showArrow title="用户ID" clickable :rightText="userInfo._id" @click="clickID(userInfo._id)"/> <uni-list-item showArrow title
1.创建page_self/user/edit.vue,作为个人中心资料编辑页面(记得注册路由)<template> <view class="userLayout"> <view class="avatar"> <view class="box"> <view class="inner"> <image src="../../static/images/defAvatar.png" mode="aspectFill"></image> <button open-type="chooseAvatar" @chooseavatar="onChooseAva
1.在app.vue中引入user.js,其中这里给里面的函数传值,pinia存储,userStore.loginSuccess({...res,showToast:false});这里面的...是指展开res对象内容,然后后面又传了一个值,刚好就能代替掉了,这个showtoast就变成false了,然后组成了一个新的对象import{onLaunch,onShow,onHide} from "@dcloudio/uni-app" import { useUserStore } from "./stores/user"; const uniIdco =uniCloud.importObject('uni-id-co') const userStore =useUserStore() onLaunch(()=>{ console.log('APP Lanch') uni.login({ success:login=>{
ikrins