上传头像

This commit is contained in:
duan
2024-05-16 13:52:38 +08:00
parent 855e165bff
commit bf3df88987
3 changed files with 69 additions and 11 deletions

View File

@@ -126,4 +126,8 @@ export default {
productqueryShopIdByTableCode(data) { //通过桌码获取shopId productqueryShopIdByTableCode(data) { //通过桌码获取shopId
return uni.api.get("/product/queryShopIdByTableCode", data); return uni.api.get("/product/queryShopIdByTableCode", data);
}, },
// 修改头像和昵称
upUserInfo(data) {
return uni.api.post("/login/upUserInfo", data);
},
} }

View File

@@ -5,21 +5,22 @@
<view class="onecontent"> <view class="onecontent">
<view :style="[{'padding-top':HeighT.customBar +44+'px'}]"></view> <view :style="[{'padding-top':HeighT.customBar +44+'px'}]"></view>
<view class="onecontentbox"> <view class="onecontentbox">
<image class="onecontentboximage" src="@/static/avatar.png" mode=""></image> <image class="onecontentboximage" :src="userHeadImg" mode="" @click="uploadImg"></image>
<view class="onecontentboxitem flex-between"> <view class="onecontentboxitem flex-between">
<view class="onecontentboxitemtext"> <view class="onecontentboxitemtext">
昵称 昵称
</view> </view>
<input class="onecontentboxiteminput" type="text" placeholder="请输入昵称"> <input class="onecontentboxiteminput" v-model="userName" type="text" placeholder="请输入昵称">
</view> </view>
<view class="onecontentboxitem flex-between" style="border-top: 1rpx dotted #333333;"> <view class="onecontentboxitem flex-between" style="border-top: 1rpx dotted #333333;">
<view class="onecontentboxitemtext"> <view class="onecontentboxitemtext">
手机号 手机号
</view> </view>
<input class="onecontentboxiteminput" type="text" placeholder="请输入手机号"> <input class="onecontentboxiteminput" disabled v-model="userInfo.telephone" type="text"
placeholder="请输入手机号">
</view> </view>
</view> </view>
<view class="onecontentboxitemnamber"> <view class="onecontentboxitemnamber" @click="sumbit">
保存 保存
</view> </view>
</view> </view>
@@ -33,6 +34,11 @@
components: { components: {
navseat navseat
}, },
onLoad() {
this.userInfo = uni.cache.get('userInfo')
this.userName = this.userInfo.nickName
this.userHeadImg = this.userInfo.headImg
},
data() { data() {
return { return {
titlename: '完善信息', titlename: '完善信息',
@@ -44,8 +50,11 @@
other: '', //附近1KM 1选中 0不选中 other: '', //附近1KM 1选中 0不选中
page: 1, //页数 page: 1, //页数
size: 10, //页容量 size: 10, //页容量
status: 'loadmore' status: 'loadmore',
}, },
userInfo: uni.cache.get('userInfo'),
userHeadImg: "",
userName: ''
}; };
}, },
onPageScroll(e) { onPageScroll(e) {
@@ -55,6 +64,48 @@
this.opacitys = true this.opacitys = true
} }
}, },
methods: {
uploadImg() {
let _this = this
uni.chooseImage({
crop: {
width: 200,
height: 200
},
success: (chooseImageRes) => {
const tempFilePaths = chooseImageRes.tempFilePaths;
uni.uploadFile({
url: uni.conf.baseUrl + '/common/upload',
filePath: tempFilePaths[0],
header: {
environment: 'app',
type: 'android',
version: '1.7.3',
},
name: "file",
formData: {
file: chooseImageRes.tempFiles[0],
},
success: (uploadFileRes) => {
let {
data
} = JSON.parse(uploadFileRes.data)
this.userHeadImg = data
},
});
},
})
},
async sumbit() {
let res = await this.api.upUserInfo({
headImg: this.userHeadImg,
nickName: this.userName
})
if(res.code == 0){
uni.navigateBack()
}
}
},
computed: { computed: {
HeighT() { //手机类型的尺寸 HeighT() { //手机类型的尺寸
return this.$store.getters.is_BarHeight return this.$store.getters.is_BarHeight
@@ -95,13 +146,15 @@
.onecontentboxitem { .onecontentboxitem {
padding: 24rpx 0; padding: 24rpx 0;
.onecontentboxitemtext{
.onecontentboxitemtext {
font-family: PingFang SC, PingFang SC; font-family: PingFang SC, PingFang SC;
font-weight: bold; font-weight: bold;
font-size: 32rpx; font-size: 32rpx;
color: #333333; color: #333333;
} }
.onecontentboxiteminput{
.onecontentboxiteminput {
text-align: right; text-align: right;
flex: auto; flex: auto;
font-family: PingFang SC, PingFang SC; font-family: PingFang SC, PingFang SC;
@@ -112,7 +165,8 @@
} }
} }
} }
.onecontentboxitemnamber{
.onecontentboxitemnamber {
margin-top: 84rpx; margin-top: 84rpx;
text-align: center; text-align: center;
width: 100%; width: 100%;

View File

@@ -2,15 +2,15 @@
<view class="container"> <view class="container">
<view class="user-info-wrap" @click="clickinformation"> <view class="user-info-wrap" @click="clickinformation">
<view style="width: 108rpx; height: 108rpx;border-radius: 50%;"> <view style="width: 108rpx; height: 108rpx;border-radius: 50%;">
<image style="width: 108rpx; height: 108rpx; border-radius: 50%;" v-if="userInfo.avatar" <image style="width: 108rpx; height: 108rpx; border-radius: 50%;" v-if="userInfo.headImg"
:src="userInfo.avatar" mode="aspectFill" > :src="userInfo.headImg" mode="aspectFill" >
</image> </image>
<image style="width: 108rpx; height: 108rpx; border-radius: 50%;" v-else src="@/static/avatar.png" <image style="width: 108rpx; height: 108rpx; border-radius: 50%;" v-else src="@/static/avatar.png"
mode="aspectFill"> mode="aspectFill">
</image> </image>
</view> </view>
<view class="info flex-colum-start"> <view class="info flex-colum-start">
<text class="phone">{{userInfo.telephone || '无'}}</text> <text class="phone">{{userInfo.nickName || '无'}}</text>
</view> </view>
</view> </view>
<view class="userinfoone"> <view class="userinfoone">