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.
268 lines
5.7 KiB
268 lines
5.7 KiB
10 months ago
|
<template>
|
||
|
<view class="setting">
|
||
|
<view class="box">
|
||
|
<view class="box-avter">
|
||
|
<view class="name-text">
|
||
|
头像
|
||
|
</view>
|
||
|
<image @click="chooseImage()" :src="info.avatar_url?info.avatar_url:'/static/default-logo.png'"
|
||
|
class="image_logo"></image>
|
||
|
</view>
|
||
|
<view class="box-avter conten-height">
|
||
|
<view class="name-text">
|
||
|
昵称
|
||
|
</view>
|
||
|
<input type="text" v-model="info.nick_name" placeholder="请输入用户昵称">
|
||
|
</view>
|
||
|
<view class="box-avter conten-height">
|
||
|
<view class="name-text">
|
||
|
性别
|
||
|
</view>
|
||
|
<picker style="width: 400rpx;text-align: right;" :value="genderIndex" :range="gender"
|
||
|
:range-key="'name'" @change="bindPickerChange">
|
||
|
<view class="lx" :style="genderIndex==-1?'color:#999':'color:#333'">
|
||
|
{{genderIndex==-1?'请选择':gender[genderIndex].name}}
|
||
|
<image class="more" src="/static/news/icon-arrow.png" mode=""></image>
|
||
|
</view>
|
||
|
</picker>
|
||
|
</view>
|
||
|
<view class="box-avter conten-height" style="border: none;">
|
||
|
<view class="name-text">
|
||
|
手机号
|
||
|
</view>
|
||
|
<text>{{info.mobile}}</text>
|
||
|
</view>
|
||
|
</view>
|
||
|
<view class="box">
|
||
|
<view class="box-avter conten-height" @click="bindPickerInvoice">
|
||
|
<view class="name-text">
|
||
|
发票助手
|
||
|
</view>
|
||
|
<image class="more" src="/static/news/icon-arrow.png" mode=""></image>
|
||
|
</view>
|
||
|
<view class="box-avter conten-height">
|
||
|
<view class="name-text">
|
||
|
清除缓存
|
||
|
</view>
|
||
|
<image class="more" src="/static/news/icon-arrow.png" mode=""></image>
|
||
|
</view>
|
||
|
<view class="box-avter conten-height">
|
||
|
<view class="name-text">
|
||
|
隐私
|
||
|
</view>
|
||
|
<image class="more" src="/static/news/icon-arrow.png" mode=""></image>
|
||
|
</view>
|
||
|
<view class="box-avter conten-height" style="border: none;">
|
||
|
<view class="name-text">
|
||
|
关于
|
||
|
</view>
|
||
|
<image class="more" src="/static/news/icon-arrow.png" mode=""></image>
|
||
|
</view>
|
||
|
</view>
|
||
|
<view class="box" style="padding: 0 40rpx;" @click="onOut">
|
||
|
<view class="box-avter conten-height" style="border: none;">
|
||
|
<view class="name-text">
|
||
|
注销账号
|
||
|
</view>
|
||
|
</view>
|
||
|
</view>
|
||
|
<button class="submitBtn" @click="sureSubmit">确认修改</button>
|
||
|
</view>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import * as UploadApi from '@/api/upload'
|
||
|
import * as userApi from '@/api/user'
|
||
|
export default {
|
||
|
data() {
|
||
|
return {
|
||
|
genderIndex: -1,
|
||
|
gender: [{
|
||
|
name: '男',
|
||
|
id: 0
|
||
|
}, {
|
||
|
name: '女',
|
||
|
id: 1
|
||
|
}, ],
|
||
|
info: '',
|
||
|
imageList: [],
|
||
|
avatar_id: [],
|
||
|
nick_name: ''
|
||
|
};
|
||
|
},
|
||
|
onShow() {},
|
||
|
onLoad(params) {
|
||
|
console.log(uni.getStorageSync("userInfo"))
|
||
|
this.info = uni.getStorageSync("userInfo")
|
||
|
this.genderIndex = this.info.gender == '男' ? 0 : 1
|
||
|
},
|
||
|
methods: {
|
||
|
sureSubmit() {
|
||
|
let params = {
|
||
|
nick_name: this.info.nick_name,
|
||
|
avatar_id: this.avatar_id[0],
|
||
|
gender: this.genderIndex==0?1:2
|
||
|
}
|
||
|
userApi.editUser(params)
|
||
|
.then(res => {
|
||
|
if (res.status==200) {
|
||
|
uni.showToast({
|
||
|
title: '修改成功',
|
||
|
icon: 'none',
|
||
|
duration: 2000
|
||
|
})
|
||
|
uni.setStorageSync('userInfo', this.info)
|
||
|
} else {
|
||
|
uni.showToast({
|
||
|
title: '修改失败',
|
||
|
icon: 'none',
|
||
|
duration: 2000
|
||
|
})
|
||
|
}
|
||
|
})
|
||
|
.finally()
|
||
|
},
|
||
|
// 选择图片
|
||
|
chooseImage() {
|
||
|
const app = this
|
||
|
app.imageList = []
|
||
|
const oldImageList = app.imageList
|
||
|
// 选择图片
|
||
|
uni.chooseImage({
|
||
|
count: 1,
|
||
|
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
|
||
|
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
|
||
|
success({
|
||
|
tempFiles
|
||
|
}) {
|
||
|
app.info.avatar_url = tempFiles[0].path
|
||
|
app.imageList = oldImageList.concat(tempFiles)
|
||
|
app.uploadFile()
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
|
||
|
// 上传图片
|
||
|
uploadFile() {
|
||
|
const app = this
|
||
|
const {
|
||
|
imageList
|
||
|
} = app
|
||
|
// 批量上传
|
||
|
return new Promise((resolve, reject) => {
|
||
|
if (imageList.length > 0) {
|
||
|
UploadApi.image(imageList)
|
||
|
.then(fileIds => {
|
||
|
app.avatar_id = fileIds;
|
||
|
resolve(fileIds)
|
||
|
})
|
||
|
.catch(reject)
|
||
|
} else {
|
||
|
resolve()
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
onOut() {
|
||
|
uni.showModal({
|
||
|
title: '友情提示',
|
||
|
content: '确认要注销吗?',
|
||
|
success(o) {
|
||
|
if (o.confirm) {
|
||
|
uni.removeStorage('token');
|
||
|
uni.removeStorage('userInfo');
|
||
|
uni.reLaunch({
|
||
|
url: '/pages/login/index'
|
||
|
})
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
bindPickerInvoice() {
|
||
|
uni.navigateTo({
|
||
|
url: "/pages/invoice/index"
|
||
|
})
|
||
|
},
|
||
|
bindPickerChange(e) {
|
||
|
this.genderIndex = e.detail.value
|
||
|
},
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style>
|
||
|
page {
|
||
|
width: 100%;
|
||
|
}
|
||
|
|
||
|
.setting {
|
||
|
height: 100%;
|
||
|
margin-top: 20rpx;
|
||
|
padding-bottom: 50rpx;
|
||
|
}
|
||
|
|
||
|
.box {
|
||
|
background: #FFF;
|
||
|
padding: 24rpx 40rpx;
|
||
|
margin-top: 20rpx;
|
||
|
}
|
||
|
|
||
|
.more {
|
||
|
width: 28rpx;
|
||
|
height: 28rpx;
|
||
|
}
|
||
|
|
||
|
.box-avter {
|
||
|
height: 120rpx;
|
||
|
width: 100%;
|
||
|
display: flex;
|
||
|
justify-content: space-between;
|
||
|
align-items: center;
|
||
|
border-bottom: 1rpx solid #f2f2f2;
|
||
|
}
|
||
|
|
||
|
.conten-height {
|
||
|
height: 100rpx;
|
||
|
}
|
||
|
|
||
|
.conten-height text {
|
||
|
font-size: 35rpx;
|
||
|
color: #333;
|
||
|
}
|
||
|
|
||
|
.box-avter input {
|
||
|
height: 100%;
|
||
|
color: #333;
|
||
|
width: 400rpx;
|
||
|
text-align: right;
|
||
|
font-size: 28rpx;
|
||
|
}
|
||
|
|
||
|
.name-text {
|
||
|
font-size: 28rpx;
|
||
|
color: #999;
|
||
|
}
|
||
|
|
||
|
.image_logo {
|
||
|
width: 90rpx;
|
||
|
height: 90rpx;
|
||
|
border-radius: 50%;
|
||
|
}
|
||
|
|
||
|
.submitBtn {
|
||
|
height: 88upx;
|
||
|
margin: 64upx 0;
|
||
|
margin-bottom: 0;
|
||
|
line-height: 88upx;
|
||
|
background: #FFAAA4;
|
||
|
background: #FE483B;
|
||
|
border-radius: 36px 36px 36px 36px;
|
||
|
opacity: 1;
|
||
|
font-size: 28upx;
|
||
|
font-family: PingFang SC, PingFang SC;
|
||
|
font-weight: 500;
|
||
|
color: #FFFFFF;
|
||
|
text-align: center;
|
||
|
margin: 50rpx 30rpx;
|
||
|
}
|
||
|
</style>
|