数字艺术
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.
 
 
 
 

304 lines
5.9 KiB

<template>
<view class="container">
<Head @backto="backto" title="个人资料"></Head>
<view class="setlist">
<view>
<view>头像</view>
<view>
<!-- <view>123</view> -->
<image @click="xuanze" class="touxiang" :src="user.avatar" v-if='user.avatar'></image>
<image @click="xuanze" class="touxiang" :src="upload.avaterpath" v-else-if="upload.avaterpath">
</image>
<image @click="xuanze" class="touxiang" src="../../static/usertx.png" v-else></image>
<image class="you" src="../../static/youshou.png"></image>
</view>
</view>
<view>
<view>昵称</view>
<view>
<!-- <view>巴啦啦小魔仙</view> -->
<input placeholder="请输入昵称" v-model="user.username" @blur="setname" />
<!-- <image class="you" src="../../static/youshou.png"></image> -->
</view>
</view>
<view>
<view>手机号</view>
<view>
<view>{{user.userphone}}</view>
<!-- <image class="you" src="../../static/youshou.png"></image> -->
</view>
</view>
<view>
<view>DID</view>
<view>
<input placeholder="请输入did" v-model="user.did" @blur="setdid" />
</view>
</view>
<view>
<view>实名认证</view>
<view>
<view v-if="anth">未实名</view>
<view v-else>已实名</view>
<image class="you" src="../../static/youshou.png"></image>
</view>
</view>
<view class="set" v-if="setstatus.status" @click="setuserinfo">
修改
</view>
</view>
</view>
</template>
<script>
import {
ref,
reactive
} from 'vue'
import {
onLoad,
onUnload,
onShow
} from '@dcloudio/uni-app';
import {
usergetverified,
userinfo,
modifyuserinfo
} from "../../api/api.js";
import Head from "../../components/head.vue"
export default {
components: {
Head
},
setup() {
let texts = ref('巴啦啦小魔仙');
let textdid = ref('')
let anth = ref(true);
let setstatus = reactive({
status: false
})
let user = reactive({
username: "",
userphone: "",
avatar: "",
did: ""
})
let upload = reactive({
path: "",
avaterpath: ""
})
function setname() {
if (user.username != texts.value) {
setstatus.status = true;
}
}
function setdid() {
if (user.did != textdid.value) {
setstatus.status = true;
}
}
function backto() {
uni.navigateTo({
url:"../set/set"
})
}
function setuserinfo() {
let DATA = {}
if (upload.path) {
DATA.avatar = upload.path;
}
if (user.username != texts.value) {
DATA.nickname = user.username;
}
if (user.did != textdid.value) {
DATA.did = user.did;
}
modifyuserinfo(DATA).then((res) => {
console.log(res);
if (res.code == 200) {
uni.showToast({
duration: 1500,
title: "修改成功",
icon: 'success'
})
setstatus.status = false;
// 获取用户信息
userinfo({}).then((res) => {
// console.log(res);
user.username = res.data.nickname;
texts.value = res.data.nickname;
user.userphone = res.data.phone;
user.avatar = res.data.avatar;
textdid = res.data.did;
user.did = res.data.did
})
}
})
}
function xuanze() {
uni.chooseImage({
success: (chooseImageRes) => {
const tempFilePaths = chooseImageRes.tempFilePaths;
uni.uploadFile({
url: 'http://szysweb.x-embers.com/api/upload', //仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
header: {
Authorization: "Bearer " + uni.getStorageSync("token"),
Accept: 'application/json',
},
name: 'file',
success: (uploadFileRes) => {
setstatus.status = true;
let data = JSON.parse(uploadFileRes.data);
upload.path = data.data.path;
upload.avaterpath = data.data.absolute_path;
}
});
}
});
}
onShow(() => {
// 获取认证信息
usergetverified({}).then((res) => {
// console.log(res);
if (res.data.id_card) {
anth.value = !anth.value;
}
});
// 获取用户信息
userinfo({}).then((res) => {
// console.log(res);
user.username = res.data.nickname;
texts.value = res.data.nickname;
user.userphone = res.data.phone;
user.avatar = res.data.avatar;
textdid = res.data.did;
user.did = res.data.did
})
})
onLoad(() => {
})
return {
xuanze,
texts,
anth,
user,
upload,
setstatus,
setname,
setuserinfo,
backto,
textdid,
setdid
}
}
}
</script>
<style lang="scss" scoped>
.container {
display: flex;
}
.setlist {
width: 686upx;
// height: 772upx;
background: #23262F;
border-radius: 12upx;
padding: 32upx;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
// justify-content: space-between;
margin: auto;
margin-top: 150rpx;
>view {
width: 618upx;
display: flex;
align-items: center;
justify-content: space-between;
color: #ffffff;
font-size: 28upx;
font-weight: 400;
color: #FFFFFF;
padding-top: 44upx;
padding-bottom: 44upx;
border-bottom: 1upx solid #373737;
&:nth-of-type(1) {
padding-top: 12upx;
}
&:nth-last-child(1) {
border-bottom: none;
padding-bottom: 24upx;
}
>view {
display: flex;
align-items: center;
box-sizing: border-box;
>input {
font-size: 24upx;
color: #ffffff;
text-align: right;
}
>.touxiang {
width: 56upx;
height: 56upx;
}
>.you {
width: 36upx;
height: 36upx;
margin-left: 8upx;
}
>view {
font-size: 24upx !important;
}
}
}
.set {
width: 618rpx;
height: 60rpx;
background-color: blue;
text-align: center;
justify-content: center;
border-radius: 10rpx;
padding: 0rpx !important;
}
}
page {
// padding-top: 50upx;
}
</style>