update api
This commit is contained in:
@@ -1,45 +1,106 @@
|
||||
<template>
|
||||
<view class="info">
|
||||
<view class="head" @click="showImage=true">
|
||||
<image></image>
|
||||
<text>更换头像</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="title">用户名</text>
|
||||
<text class="value">兽兽</text>
|
||||
</view>
|
||||
<view class="info">
|
||||
<view class="head" @click="chooseImage">
|
||||
<image :src="fileurl" :key="num"></image>
|
||||
<text>更换头像</text>
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="title">个性签名</text>
|
||||
<text class="value">变瘦变高变有钱</text>
|
||||
</view>
|
||||
<text class="title">用户名</text>
|
||||
<input type="text" :value="info.member_nickname==null?'新用户':info.member_nickname" />
|
||||
</view>
|
||||
<view class="item">
|
||||
<text class="title">个性签名</text>
|
||||
<input type="text" :value="info.signature==''?'该用户很懒没有签名!':info.signature" />
|
||||
</view>
|
||||
<view class="password" @click="updatePwd">
|
||||
<text>修改密码</text>
|
||||
<image src="/static/image/user/1.png"></image>
|
||||
</view>
|
||||
<u-popup v-model="showImage" mode="bottom">
|
||||
<view class="image-popup">
|
||||
<view @click="chooseImage('camera')">拍摄新照片</view>
|
||||
<view @click="chooseImage('album')">从相册选取</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
</view>
|
||||
<u-toast ref="uToast" />
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name:"info",
|
||||
name: 'info',
|
||||
data() {
|
||||
return {
|
||||
showImage: false
|
||||
}
|
||||
fileurl: "",
|
||||
filename:"",
|
||||
info:{},
|
||||
num:0
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
this.getmyinfo()
|
||||
},
|
||||
onNavigationBarButtonTap() {
|
||||
let that = this;
|
||||
this.$u.api.changeinfo({
|
||||
nickname:that.info.member_nickname,
|
||||
avatar:that.filename,
|
||||
signature:that.info.signature
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
if (res.errCode != 0) {
|
||||
this.$refs.uToast.show({
|
||||
title: res.message,
|
||||
type: 'error'
|
||||
});
|
||||
} else {
|
||||
this.$refs.uToast.show({
|
||||
title: res.message,
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
// 获取个人信息
|
||||
getmyinfo(){
|
||||
let that = this;
|
||||
this.$u.api.getshopinfo({
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
if (res.errCode != 0) {
|
||||
this.$refs.uToast.show({
|
||||
title: res.message,
|
||||
type: 'error'
|
||||
});
|
||||
} else {
|
||||
this.info = res.data.memberInfo
|
||||
this.fileurl = res.data.memberInfo.member_avatar
|
||||
}
|
||||
});
|
||||
},
|
||||
// 获取图片,上传图片
|
||||
chooseImage(sourceType) {
|
||||
let that = this
|
||||
const token = uni.getStorageSync('token');
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
||||
sourceType: [sourceType],
|
||||
success: function (res) {
|
||||
success: function(res) {
|
||||
console.log(JSON.stringify(res.tempFilePaths));
|
||||
const tempFilePaths = res.tempFilePaths;
|
||||
that.fileurl = tempFilePaths[0]
|
||||
uni.uploadFile({
|
||||
url: 'https://dmmall.sdbairui.com/storeapi/Upload/uploadFile',
|
||||
filePath: tempFilePaths[0],
|
||||
name: 'avatar',
|
||||
formData:{
|
||||
name:"avatar"
|
||||
},
|
||||
header:{
|
||||
Authorization:'Bearer' + " " + token
|
||||
},
|
||||
success: uploadFileRes => {
|
||||
let obj = JSON.parse(uploadFileRes.data)
|
||||
that.fileurl = obj.data.file_path
|
||||
that.filename = obj.data.file_name
|
||||
that.num++
|
||||
console.log(that.fileurl,that.filename)
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -48,50 +109,49 @@ export default {
|
||||
url: '/pages/user/updatePassword'
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.info{
|
||||
.info {
|
||||
min-height: calc(100vh - var(--window-top));
|
||||
background: #ececec;
|
||||
.head{
|
||||
height: 202rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: #fff;
|
||||
background: #ececec;
|
||||
.head {
|
||||
height: 202rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: #fff;
|
||||
margin-bottom: 2rpx;
|
||||
>image{
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 50%;
|
||||
background-color: #0f0;
|
||||
}
|
||||
>text{
|
||||
font-size: 24rpx;
|
||||
color: #FF780F;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
margin-bottom: 2rpx;
|
||||
}
|
||||
> image {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
> text {
|
||||
font-size: 24rpx;
|
||||
color: #ff780f;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
margin-bottom: 2rpx;
|
||||
}
|
||||
.item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 98rpx;
|
||||
background: rgba(255,255,255,1);
|
||||
background: rgba(255, 255, 255, 1);
|
||||
padding: 0 30rpx;
|
||||
margin-bottom: 2rpx;
|
||||
.title {
|
||||
width: 120rpx;
|
||||
font-size: 30rpx;
|
||||
color: rgba(51,51,51,1);
|
||||
color: rgba(51, 51, 51, 1);
|
||||
margin-right: 120rpx;
|
||||
}
|
||||
.value {
|
||||
font-size: 30rpx;
|
||||
color: rgba(101,101,101,1);
|
||||
color: rgba(101, 101, 101, 1);
|
||||
}
|
||||
}
|
||||
.password {
|
||||
@@ -101,10 +161,10 @@ export default {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: rgba(255,255,255,1);
|
||||
background: rgba(255, 255, 255, 1);
|
||||
> text {
|
||||
font-size: 30rpx;
|
||||
color: rgba(51,51,51,1);
|
||||
color: rgba(51, 51, 51, 1);
|
||||
}
|
||||
> image {
|
||||
width: 11rpx;
|
||||
@@ -114,14 +174,14 @@ export default {
|
||||
.image-popup {
|
||||
padding: 0 30rpx;
|
||||
> view {
|
||||
font-size: 28rpx;
|
||||
color: rgba(51,51,51,1);
|
||||
font-size: 28rpx;
|
||||
color: rgba(51, 51, 51, 1);
|
||||
line-height: 98rpx;
|
||||
text-align: center;
|
||||
&:first-child {
|
||||
border-bottom: 2rpx solid #EBEBEB;
|
||||
border-bottom: 2rpx solid #ebebeb;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user