获取微信头像和昵称.

This commit is contained in:
18631081161 2025-03-08 22:59:53 +08:00
parent eb09c65c83
commit becbc8a3e5

View File

@ -4,13 +4,18 @@
:statusBar="true" :border="false" @clickLeft="back"></uni-nav-bar>
<view class="user_logo relative">
<view class="avatar-wrapper" @click="chooseAvatar">
<!-- <button class="avatar-wrapper" open-type="chooseAvatar" @click="chooseAvatar">
<image class="avatar" :src="avatarUrl"></image>
</view>
</button> -->
<button class="avatar-wrapper" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
<image class="avatar" :src="avatarUrl"></image>
</button>
<text class="user_logo-title">修改头像</text>
<image class="camera" :src="$img1('my/camera.png')" mode="aspectFill"></image>
</view>
<view class="row">
<view class="row-title">昵称:</view>
@ -65,43 +70,44 @@
},
onChooseAvatar(e) {
console.log(e)
console.log("6666666666", e.detail.avatarUrl)
this.avatarUrl = e.detail.avatarUrl
this.headimg_status = true
},
chooseAvatar() {
let that = this
uni.chooseImage({
count: 1,
success: (res) => {
console.log(res);
uni.showLoading({
title:'上传中...',
mask:true
})
uni.uploadFile({
url: that.siteBaseUrl + 'picture1',
filePath: res.tempFilePaths[0],
name: 'file',
success: (e) => {
let re = JSON.parse(e.data)
that.avatarUrl = re.data.path
that.headimg_status = true
},
fail: (err) => {
uni.showToast({
title: '上传失败',
icon: 'none'
})
},
complete: () => {
uni.hideLoading()
}
})
}
})
},
// chooseAvatar() {
// let that = this
// uni.chooseImage({
// count: 1,
// success: (res) => {
// console.log(res);
// uni.showLoading({
// title: '...',
// mask: true
// })
// uni.uploadFile({
// url: that.siteBaseUrl + 'picture1',
// filePath: res.tempFilePaths[0],
// name: 'file',
// success: (e) => {
// let re = JSON.parse(e.data)
// that.avatarUrl = re.data.path
// that.headimg_status = true
// },
// fail: (err) => {
// uni.showToast({
// title: '',
// icon: 'none'
// })
// },
// complete: () => {
// uni.hideLoading()
// }
// })
// }
// })
// },
setdata() {
let that = this
if (this.headimg_status) {
@ -200,7 +206,8 @@
/* background-color: #000000; */
padding: 80rpx 0 60rpx 0;
text-align: center;
&-title{
&-title {
font-weight: 400;
font-size: 36rpx;
color: #FFFFFF;