个人信息页面的头像修改暂定方案实行
This commit is contained in:
parent
fbce1a4103
commit
eeccef63fc
@ -4,7 +4,33 @@
|
|||||||
<view class="container">
|
<view class="container">
|
||||||
<view class="card">
|
<view class="card">
|
||||||
<view class="list">
|
<view class="list">
|
||||||
<view class="list-item" @click="setAvator">
|
<view class="list-item" @click="imageShow=true">
|
||||||
|
<view>
|
||||||
|
头像
|
||||||
|
</view>
|
||||||
|
<view class="right">
|
||||||
|
<u-image :src="avatar" shape="circle" width="100rpx" height="100rpx"></u-image>
|
||||||
|
<view style="margin-left: 10px;">
|
||||||
|
<u-icon name="arrow-right"></u-icon>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<u-popup :show="imageShow" mode="center" closeable closeOnClickOverlay @close="imageShow=false">
|
||||||
|
<view class="popup_box">
|
||||||
|
<view class="popup_title">更换图片</view>
|
||||||
|
<button class="popup_button" type="default" plain="true" open-type="chooseAvatar"
|
||||||
|
@chooseavatar="chooseavatar">
|
||||||
|
<u-image shape="circle" width="140rpx" height="140rpx" :src="upAvatar" mode="aspectFill"></u-image>
|
||||||
|
</button>
|
||||||
|
<view style="width: 80% !important;margin-top: 20px;">
|
||||||
|
<u-button shape="circle" @click="confirmImage" :customStyle="avatarShowStyle">
|
||||||
|
完成
|
||||||
|
</u-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</u-popup>
|
||||||
|
|
||||||
|
<!-- <view class="list-item" @click="setAvator">
|
||||||
<view class="left">
|
<view class="left">
|
||||||
头像设置
|
头像设置
|
||||||
</view>
|
</view>
|
||||||
@ -16,7 +42,7 @@
|
|||||||
<u-icon name="arrow-right"></u-icon>
|
<u-icon name="arrow-right"></u-icon>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view> -->
|
||||||
<view class="list-item" @click="toName('nc')">
|
<view class="list-item" @click="toName('nc')">
|
||||||
<view class="left">
|
<view class="left">
|
||||||
昵称设置
|
昵称设置
|
||||||
@ -142,6 +168,7 @@
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
baseUrl: 'https://naweigetetest2.hschool.com.cn/',
|
||||||
typeop: '',
|
typeop: '',
|
||||||
avatarStyle: {
|
avatarStyle: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@ -185,6 +212,17 @@
|
|||||||
border: 'none',
|
border: 'none',
|
||||||
fontFamily: "YouSheBiaoTiHei"
|
fontFamily: "YouSheBiaoTiHei"
|
||||||
},
|
},
|
||||||
|
avatarShowStyle: {
|
||||||
|
width: '400rpx',
|
||||||
|
height: '90rpx',
|
||||||
|
borderRadius: '148rpx',
|
||||||
|
background: '#323232',
|
||||||
|
fontSize: '36rpx',
|
||||||
|
color: '#BBFC5B',
|
||||||
|
lineHeight: '90rpx',
|
||||||
|
border: 'none',
|
||||||
|
fontFamily: "YouSheBiaoTiHei"
|
||||||
|
},
|
||||||
//昵称
|
//昵称
|
||||||
niName: '',
|
niName: '',
|
||||||
//签名
|
//签名
|
||||||
@ -253,7 +291,9 @@
|
|||||||
}]
|
}]
|
||||||
],
|
],
|
||||||
sfInfo: {},
|
sfInfo: {},
|
||||||
bankInfo: {}
|
bankInfo: {},
|
||||||
|
imageShow: false,
|
||||||
|
profile:'',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
@ -277,6 +317,117 @@
|
|||||||
this.getDetail();
|
this.getDetail();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
confirmImage() {
|
||||||
|
console.log('confirmImage11',this.profile);
|
||||||
|
if(!this.profile){
|
||||||
|
uni.showToast({
|
||||||
|
title: "请选择图片",
|
||||||
|
icon: "none"
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('confirmImage22');
|
||||||
|
// this.userInfo.profile = this.profile
|
||||||
|
// this.userInfo.avatar = this.profile
|
||||||
|
|
||||||
|
this.upAvatar = this.profile;
|
||||||
|
this.avatar = this.avatar;
|
||||||
|
console.log(this.upAvatar);
|
||||||
|
console.log(this.avatar);
|
||||||
|
this.imageShow = false
|
||||||
|
this.submit();
|
||||||
|
|
||||||
|
},
|
||||||
|
async chooseavatar(e) {
|
||||||
|
console.log('chooseavatar',e,e.detail);
|
||||||
|
// this.profile = this.uploadFilePromise(e.detail.avatarUrl, 'user');
|
||||||
|
let result = await this.uploadFilePromise(e.detail.avatarUrl, 'user');
|
||||||
|
console.log('chooseavatar2222',result,);
|
||||||
|
this.profile = result
|
||||||
|
this.upAvatar = this.baseUrl + this.profile
|
||||||
|
this.avatar = this.profile;
|
||||||
|
console.log('chooseavatar3333',this.profile,this.avatar,this.upAvatar);
|
||||||
|
|
||||||
|
},
|
||||||
|
uploadFilePromise(url) {
|
||||||
|
console.log('uploadFilePromise',url);
|
||||||
|
// console.log('接口地址', `${baseUrl}/common/upload`);
|
||||||
|
console.log('上传-uploadFilePromise');
|
||||||
|
// console.log('category', category)
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let a = uni.uploadFile({
|
||||||
|
url: 'https://naweigetetest2.hschool.com.cn/api/common/upload', // 仅为示例,非真实的接口地址
|
||||||
|
filePath: url,
|
||||||
|
name: 'file',
|
||||||
|
formData: {
|
||||||
|
user: 'test',
|
||||||
|
category: 'category'
|
||||||
|
},
|
||||||
|
header: {
|
||||||
|
"token": uni.getStorageSync("token")
|
||||||
|
},
|
||||||
|
success: (res) => {
|
||||||
|
console.log('uploadFilePromise成功',res.data);
|
||||||
|
// setTimeout(() => {
|
||||||
|
// resolve(JSON.parse(res.data).url);
|
||||||
|
// }, 1000);
|
||||||
|
var js = JSON.parse(res.data);
|
||||||
|
console.log(js.data.errcode);
|
||||||
|
if (js.data.errcode == '30002') {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请登录...',
|
||||||
|
icon: 'none',
|
||||||
|
duration: 1000
|
||||||
|
});
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.switchTab({
|
||||||
|
url: '/pages/my/index',
|
||||||
|
})
|
||||||
|
}, 1000)
|
||||||
|
resolve('');
|
||||||
|
}
|
||||||
|
resolve(js.data.url);
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// console.log('');
|
||||||
|
});
|
||||||
|
// return new Promise((resolve, reject) => {
|
||||||
|
// let a = uni.uploadFile({
|
||||||
|
// url: 'https://naweigetetest2.hschool.com.cn/api/common/upload', // 接口地址
|
||||||
|
// filePath: url,
|
||||||
|
// name: 'file',
|
||||||
|
// header: {
|
||||||
|
// "token": uni.getStorageSync("token")
|
||||||
|
// },
|
||||||
|
// formData: {
|
||||||
|
// 'user': 'test'
|
||||||
|
// },
|
||||||
|
// success: (res) => {
|
||||||
|
// console.log('res', JSON.parse(res.data), JSON.parse(res.data).url);
|
||||||
|
// setTimeout(() => {
|
||||||
|
// resolve(JSON.parse(res.data).url);
|
||||||
|
// }, 1000);
|
||||||
|
// },
|
||||||
|
// fail: (res) => {
|
||||||
|
// setTimeout(() => {
|
||||||
|
// console.log("上传失败", res)
|
||||||
|
// reject(res)
|
||||||
|
// }, 1000);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
},
|
||||||
|
|
||||||
|
closeImagePopup() {
|
||||||
|
this.imageShow = false
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
getBankList() {
|
getBankList() {
|
||||||
uni.$u.http
|
uni.$u.http
|
||||||
.get("/api/school.newactivity.settle_log/detail")
|
.get("/api/school.newactivity.settle_log/detail")
|
||||||
@ -372,6 +523,8 @@
|
|||||||
// }
|
// }
|
||||||
if (userinfo.avatar !== null) {
|
if (userinfo.avatar !== null) {
|
||||||
this.avatar = userinfo.avatar
|
this.avatar = userinfo.avatar
|
||||||
|
this.upAvatar = userinfo.avatar
|
||||||
|
this.profile = userinfo.avatar
|
||||||
uni.setStorageSync('avatar', this.avatar)
|
uni.setStorageSync('avatar', this.avatar)
|
||||||
}
|
}
|
||||||
if (userinfo.nickname !== null) {
|
if (userinfo.nickname !== null) {
|
||||||
@ -731,5 +884,37 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.popup_box {
|
||||||
|
background-color: #fff;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-around;
|
||||||
|
padding: 20px;
|
||||||
|
|
||||||
|
.popup_title {
|
||||||
|
width: 500rpx;
|
||||||
|
text-align: center;
|
||||||
|
margin: 10px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
box-shadow: 0 5px 7px 0 rgba(86, 119, 252, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
::v-deep button[type=default][plain] {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nickname {
|
||||||
|
border: none;
|
||||||
|
font-size: 32rpx;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
Loading…
x
Reference in New Issue
Block a user