征信小程序
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.
zhengxinApplets/pages/user/personal.vue

282 lines
6.5 KiB

3 months ago
<template>
<view class="site">
<view class="site-bd">
2 months ago
<form @submit="sureSubmit">
3 months ago
<view class="item">
<view class="a">用户头像</view>
<view class="b">
2 months ago
<view class="pic">
<image v-if="userInfo.avatar" class="img" :src="baseUrl + userInfo.avatar"></image>
<image v-else class="img" src="https://www.lijkj.cn/static/default.png"></image>
2 months ago
<button open-type="chooseAvatar" @chooseavatar="chooseavatar"></button>
</view>
<text>编辑</text>
3 months ago
</view>
</view>
<view class="item">
<view class="a">用户昵称</view>
<view class="b">
2 months ago
<input :value="userInfo.nickname" name='nickname' type="nickname" placeholder="请输入用户名" />
<button class="btn" v-if="isShow1 == true" formType="submit">完成</button>
<text @click="openPage(2)" v-else>编辑</text>
3 months ago
</view>
</view>
2 months ago
<!-- <view class="item">
3 months ago
<view class="a">密码</view>
<view class="b" @click="openPage(3)">
<text>设置</text>
</view>
2 months ago
</view> -->
3 months ago
<view class="item">
<view class="a">实名认证</view>
<view class="b" @click="openPage(4)">
1 month ago
<text>{{userInfos.is_shiming == 0?'审核中':userInfos.is_shiming == 1?'已通过':userInfos.is_shiming == -1?'已驳回':'去认证'}}</text>
3 months ago
</view>
</view>
<view class="item">
<view class="a">手机号</view>
<view class="b" @click="openPage(5)">
2 months ago
<input disabled :value="userInfo.mobile" type="number"/>
3 months ago
<text>编辑</text>
</view>
</view>
2 months ago
<view class="item" v-if="systembasicInfoopen.wechat">
3 months ago
<view class="a">微信号</view>
2 months ago
<view class="b">
<input :disabled="isShow2 == false" v-model="userInfo.wechat_num" type="text" placeholder="请输入微信号" />
<text v-if="isShow2 == false" @click="openPage(1)">编辑</text>
<text v-else @click="openPage(7)">完成</text>
3 months ago
</view>
</view>
2 months ago
</form>
3 months ago
</view>
</view>
</template>
<script>
export default {
data() {
return {
2 months ago
systembasicInfoopen: {},
2 months ago
userInfo: {},
isShow1: false,
isShow2: false,
baseUrl: "",
userInfos: {}
3 months ago
};
},
onShow() {
2 months ago
this.systembasicInfoopen = uni.getStorageSync("systembasicInfoopen")
2 months ago
this.getUserInfo();
this.baseUrl=this.$baseUrl
this.getUsershenhe();
3 months ago
},
methods: {
2 months ago
//查询当前实名认证情况
async getUsershenhe() {
const { code, data, msg } = await this.$api.getUsershenhe({token: uni.getStorageSync("token")});
if(code == 1){
this.userInfos = data
}
},
3 months ago
openPage(index){
if(index == 1){
2 months ago
this.isShow2 = !this.isShow2
3 months ago
}else if(index == 2){
2 months ago
this.isShow1 = !this.isShow1
3 months ago
}else if(index == 3){
uni.navigateTo({
url: "/pages/user/password"
})
}else if(index == 4){
uni.navigateTo({
url: "/pages/user/verification"
})
}else if(index == 5){
uni.navigateTo({
url: "/pages/user/phone"
})
}else if(index == 6){
uni.navigateTo({
url: "/pages/user/verification"
})
2 months ago
}else if(index == 7){
if(!this.userInfo.wechat_num){
uni.showToast({
icon: "none",
title: "请输入微信号"
})
return ;
}
this.toSubmit();
3 months ago
}
},
2 months ago
sureSubmit(e) {
this.userInfo.nickname = e.detail.value.nickname
if(!this.userInfo.nickname){
3 months ago
uni.showToast({
2 months ago
icon: "none",
title: "请输入用户昵称"
3 months ago
})
2 months ago
return ;
3 months ago
}
2 months ago
this.toSubmit();
},
async toSubmit() {
const { code, data, msg} = await this.$api.editMember({
avatar: this.userInfo.avatar?this.userInfo.avatar:'',
nickname: this.userInfo.nickname?this.userInfo.nickname:"",
wechat_num: this.userInfo.wechat_num?this.userInfo.wechat_num:"",
token: uni.getStorageSync("token")
})
if(code == 1){
3 months ago
uni.showToast({
2 months ago
title: "修改成功"
3 months ago
})
2 months ago
this.getUserInfo();
}else{
3 months ago
uni.showToast({
2 months ago
icon: "none",
title: msg
3 months ago
})
}
2 months ago
},
//获取用户信息
async getUserInfo() {
const { code, data , msg } = await this.$api.getMemberInfo({token: uni.getStorageSync("token")});
if(code == 1){
uni.setStorageSync('userInfo', data.user);
this.userInfo = data.user;
this.isShow1 = false;
this.isShow2 = false;
}else{
3 months ago
uni.showToast({
2 months ago
title: msg,
icon: "none",
3 months ago
})
}
},
2 months ago
chooseavatar(e){
let tempFiles = e.detail.avatarUrl;
const that = this;
uni.uploadFile({
name: 'file',
url: this.$baseUrl+'/api/Common/upload',
filePath: tempFiles,
formData: {
token: uni.getStorageSync('token')
},
success: (upRes) => {
const {code, data, msg } = JSON.parse(upRes.data);
if(code == 1){
that.userInfo.avatar = data.url
that.toSubmit();
}else{
uni.showToast({
icon: "error",
title: "上传失败"
})
}
3 months ago
},
2 months ago
fail: (err) => {
console.log("toUpload err",err)
console.log(err)
3 months ago
}
2 months ago
});
3 months ago
},
2 months ago
3 months ago
}
}
</script>
<style lang="scss" scoped>
.site{
padding: 25rpx;
overflow: hidden;
&-bd{
width: 700rpx;
background: #FFFFFF;
box-shadow: 0px 3rpx 10rpx 0px rgba(9,44,39,0.05);
border-radius: 20rpx;
margin: 0 auto;
padding: 0 30rpx;
box-sizing: border-box;
position: relative;
.item{
display: flex;
align-items: center;
justify-content: space-between;
border-top: 1px solid #EAEAEA;
padding: 35rpx 0;
overflow: hidden;
position: relative;
&:first-child{
border-color: #FFFFFF;
}
.a{
width: 160rpx;
display: flex;
align-items: center;
font-weight: 500;
font-size: 30rpx;
color: #222222;
}
.b{
flex: 1;
display: flex;
align-items: center;
justify-content: flex-end;
font-weight: 500;
font-size: 24rpx;
color: #999999;
input{
flex: 1;
font-weight: 500;
font-size: 24rpx;
color: #999999;
}
text{
font-weight: 500;
font-size: 28rpx;
color: #00C6A9;
margin-left: 15rpx;
}
2 months ago
button{
font-weight: 500;
font-size: 28rpx;
color: #00C6A9;
background-color: transparent;
display: inline-block;
line-height: 30rpx;
padding: 0;
margin: 0;
&::after{
border-color: transparent;
}
}
.pic{
width: 60rpx;
height: 60rpx;
position: relative;
overflow: hidden;
button{
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
z-index: 2;
opacity: 0;
}
}
3 months ago
image{
width: 60rpx;
height: 60rpx;
2 months ago
border-radius: 50%;
3 months ago
}
}
}
}
}
</style>