You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
226 lines
5.1 KiB
226 lines
5.1 KiB
<template>
|
|
<view class="page-user-modify">
|
|
<view class="top"></view>
|
|
<view class="item-box btPadding">
|
|
<view class="item">
|
|
<view class="left PfScMedium">头像</view>
|
|
<view class="right" @click="upload">
|
|
<img :src="avator" class="avator" v-if="!uinfo.user_avatar">
|
|
<img :src="uinfo.user_avatar" class="avator" v-else>
|
|
<view class="avator_tips">点击上传照片</view>
|
|
</view>
|
|
</view>
|
|
<view class="item">
|
|
<view class="left PfScMedium">昵称</view>
|
|
<view class="right">
|
|
<input type="text" placeholder="请输入用户昵称" v-model="nick">
|
|
</view>
|
|
</view>
|
|
<view class="item">
|
|
<view class="left PfScMedium">用户编号</view>
|
|
<view class="right over copy-box">
|
|
<view>{{uinfo.uid}}</view>
|
|
<img :src="cssUrl+'copy.svg'" class="copy" @click="copyUid(uinfo.uid)">
|
|
</view>
|
|
</view>
|
|
|
|
</view>
|
|
<view class="submit-blank"></view>
|
|
<view class="submit-box btPadding">
|
|
<view class="primary btn btn3" hover-class="hover" @click="save">保存</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
cssUrl:this.cssUrl,
|
|
avator:this.cssUrl+'default_avator.svg',
|
|
uinfo:{
|
|
user_avatar:''
|
|
},
|
|
nick:'',
|
|
tempFilePaths:'',
|
|
tempFiles:''
|
|
}
|
|
},
|
|
onLoad() {
|
|
// this.getUser()
|
|
},
|
|
methods: {
|
|
getUser(){
|
|
this.$http.req('user/get_user_info', {}, 'GET').then(data=>{
|
|
if(data == -1) return
|
|
this.uinfo = data
|
|
this.nick = this.uinfo.nick
|
|
});
|
|
},
|
|
save(){
|
|
var param = new Object()
|
|
var token = uni.getStorageSync('token')
|
|
var that = this;
|
|
param.nick = this.nick;
|
|
uni.uploadFile({
|
|
url: '/api/user/setting_user',
|
|
filePath:that.tempFilePaths,
|
|
name: 'avatar_file',
|
|
header: {
|
|
'AUTH': token
|
|
},
|
|
formData:{
|
|
nick:param.nick,
|
|
},
|
|
success: function(res){
|
|
try{
|
|
var data = JSON.parse(res.data)
|
|
if(data.code != 0){
|
|
that.$pop.modelShow(data.msg)
|
|
return
|
|
}
|
|
uni.showToast({
|
|
title:data.msg
|
|
})
|
|
if(that.tempFilePaths) that.uinfo.user_avatar = that.tempFilePaths
|
|
}catch(e){
|
|
that.$pop.modelShow('保存失败~'+e.message)
|
|
}
|
|
},
|
|
fail: function(res){
|
|
that.$pop.modelShow('保存失败')
|
|
}
|
|
});
|
|
},
|
|
copyUid(uid) {
|
|
var that = this
|
|
uni.setClipboardData({
|
|
data: uid,
|
|
success: function () {
|
|
}
|
|
});
|
|
},
|
|
upload() {
|
|
var that = this
|
|
uni.chooseImage({
|
|
count: 1,
|
|
success: function(res) {
|
|
console.log(res,'res---');
|
|
var tempFilePaths = res.tempFilePaths
|
|
let tempFiles = res.tempFiles;
|
|
that.tempFilePaths = tempFilePaths[0]
|
|
that.tempFiles = tempFiles[0]
|
|
that.uinfo.user_avatar = that.tempFilePaths
|
|
console.log(that.uinfo,'=uinfo');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.page-user-modify{
|
|
.top{
|
|
margin-top: 20rpx;
|
|
}
|
|
background: #F8F8F8;
|
|
width: 100%;
|
|
height: 100vh;
|
|
box-sizing: border-box;
|
|
.item-box{
|
|
margin-top: 20rpx;
|
|
width:710rpx;
|
|
margin: 0 auto;
|
|
background: #F8F8F8;
|
|
box-sizing: border-box;
|
|
.item{
|
|
width: 710rpx;
|
|
background: #FFFFFF;
|
|
margin: 0 auto;
|
|
box-sizing: border-box;
|
|
padding: 40rpx 12rpx;
|
|
border-bottom: 2rpx solid rgba(151,151,151, 0.15);
|
|
display: flex;
|
|
align-items: center;
|
|
line-height: 44rpx;
|
|
justify-content: space-between;
|
|
&:last-of-type{
|
|
border-bottom: none;
|
|
}
|
|
.left{
|
|
height: 44rpx;
|
|
line-height: 44rpx;
|
|
font-size: 32rpx;
|
|
color: #000000;
|
|
letter-spacing: 2rpx;
|
|
padding-left: 12rpx;
|
|
width: 160rpx;
|
|
flex-shrink: 0;
|
|
}
|
|
.right{
|
|
flex-grow: 1;
|
|
position: relative;
|
|
text-align: right;
|
|
line-height: 44rpx;
|
|
.avator{
|
|
width: 160rpx;
|
|
height: 160rpx;
|
|
background: #F8F8F8;
|
|
border-radius: 12rpx;
|
|
}
|
|
.avator_tips{
|
|
position: absolute;
|
|
bottom: 10rpx;
|
|
right: 0;
|
|
width: 100%;
|
|
z-index: 1;
|
|
height: 44rpx;
|
|
line-height: 44rpx;
|
|
background: rgba(0,0,0,0.28);
|
|
border-radius: 12rpx;
|
|
width: 160rpx;
|
|
font-size: 22rpx;
|
|
text-align: center;
|
|
color: #FFFFFF;
|
|
}
|
|
&.copy-box{
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
align-items: center;
|
|
view{
|
|
flex-grow: 1;
|
|
max-width: 272rpx;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
word-break: break-all;
|
|
white-space: nowrap;
|
|
}
|
|
.copy{
|
|
width: 40rpx;
|
|
height: 40rpx;
|
|
flex-shrink: 0;
|
|
margin-left: 16rpx;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
.submit-blank{
|
|
width: 100%;
|
|
height: 134rpx;
|
|
}
|
|
.submit-box{
|
|
width: 750rpx;
|
|
height: 124rpx;
|
|
background: #FFFFFF;
|
|
box-shadow: 0rpx -2rpx 6rpx 0rpx rgba(181,181,181,0.13);
|
|
position: fixed;
|
|
bottom: 0;
|
|
view{
|
|
margin: 0 auto;
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
|