完成我的信息接口调试
This commit is contained in:
@@ -1,237 +1,284 @@
|
||||
<template>
|
||||
<view class="change-info-container">
|
||||
<image src="/static/ic_back.png" class="back-arrow" @click="goBack" />
|
||||
<view class="title-main">完善你的资料</view>
|
||||
<view class="title-sub">让大家更好地了解你</view>
|
||||
<view class="avatar-section">
|
||||
<image class="avatar-img" src="/static/avatar.png" />
|
||||
<view class="avatar-camera">
|
||||
<image src="/static/ic_camera.png" class="camera-icon" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-section">
|
||||
<view class="form-label">取个昵称</view>
|
||||
<view class="input-row">
|
||||
<input class="form-input" v-model="userInfo.nickName" placeholder="请输入昵称" />
|
||||
<view class="input-suffix">
|
||||
<image src="/static/ic_i_c_01.png" class="random-icon" />
|
||||
<text class="random-text">随机</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-label">你的手机号</view>
|
||||
<view class="input-row">
|
||||
<input class="form-input" v-model="userInfo.phonenumber" placeholder="请输入您的手机号" />
|
||||
<image src="/static/ic_arrow_right.png" class="arrow-icon" />
|
||||
</view>
|
||||
<view class="form-label">你的性别(不可修改)</view>
|
||||
<view class="gender-row">
|
||||
<view v-if="userInfo.sex == 1" class="gender-item selected">
|
||||
<image src="/static/ic_i_c_02.png" class="gender-icon" />
|
||||
</view>
|
||||
<view v-else class="gender-item">
|
||||
<image src="/static/ic_i_c_03.png" class="gender-icon" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="info-row"><text class="info-label">部门</text>{{userInfo.deptName}}</view>
|
||||
<view class="info-row"><text class="info-label">岗位</text>客服</view>
|
||||
<view class="info-row"><text class="info-label">工号</text>A10235</view>
|
||||
</view>
|
||||
<button class="submit-btn">确认修改</button>
|
||||
</view>
|
||||
<view class="change-info-container">
|
||||
<view class="title-main">完善你的资料</view>
|
||||
<view class="title-sub"></view>
|
||||
|
||||
<view class="avatar-section">
|
||||
<view class="avatar-container">
|
||||
<image class="avatar-img" :src="userInfo.img" mode="aspectFill" @click="chooseImage"/>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 表单部分保持不变 -->
|
||||
<view class="form-section">
|
||||
<view class="form-row">
|
||||
<view class="form-label">取个昵称</view>
|
||||
<view class="input-wrapper">
|
||||
<input class="form-input" v-model="userInfo.userName" placeholder="请输入昵称" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-row">
|
||||
<view class="form-label">你的手机号</view>
|
||||
<view class="input-wrapper">
|
||||
<input class="form-input" v-model="userInfo.phone" placeholder="请输入您的手机号" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-row">
|
||||
<view class="form-label">你的性别</view>
|
||||
<view class="input-wrapper">
|
||||
<picker class="form-input gender-select" mode="selector" :range="genderOptions" range-key="label" @change="selectGender" v-model="userInfo.gender">
|
||||
<view class="gender-text">{{userInfo.sexLabel}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-row">
|
||||
<view class="form-label">证件号</view>
|
||||
<view class="input-wrapper">
|
||||
<input class="form-input" v-model="userInfo.idCard" placeholder="请输入您的证件号" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-row">
|
||||
<view class="form-label">所属单位</view>
|
||||
<view class="input-wrapper">
|
||||
<input class="form-input" :value="userInfo.unitName" disabled />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-group">
|
||||
<view class="group-title">联系信息</view>
|
||||
<view class="form-row">
|
||||
<view class="form-label">邮箱</view>
|
||||
<view class="input-wrapper">
|
||||
<input class="form-input" v-model="userInfo.email" placeholder="请输入邮箱" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-row">
|
||||
<view class="form-label">车牌号</view>
|
||||
<view class="input-wrapper">
|
||||
<input class="form-input" v-model="userInfo.carNumber" placeholder="请输入车牌号" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<button class="submit-btn" @click="onsubmit()">确认修改</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
userInfo: {},
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.userInfo = this.vuex_user
|
||||
},
|
||||
methods: {
|
||||
goBack() {
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
import {uploadFiles} from "../../../../common/upload";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
userInfo: {
|
||||
idCard: '',
|
||||
unitName:'',
|
||||
email: '',
|
||||
carNumber: '',
|
||||
img: '',
|
||||
userName:'',
|
||||
phone:'',
|
||||
gender:'',
|
||||
sexLabel:''
|
||||
},
|
||||
genderOptions: [
|
||||
{value: 1, label: '男'},
|
||||
{value: 2, label: '女'}
|
||||
]
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.getUserInfo()
|
||||
console.log(this.userInfo);
|
||||
|
||||
},
|
||||
methods: {
|
||||
getUserInfo() {
|
||||
let params = {
|
||||
id: this.vuex_user.id,
|
||||
unitId: this.vuex_user.unitId,
|
||||
}
|
||||
this.$u.api.unit.queryEmployeeById(params).then(res => {
|
||||
if (res.code == "200") {
|
||||
this.userInfo =res.data;
|
||||
this.userInfo.sexLabel = this.genderOptions[this.userInfo.gender-1].label;
|
||||
}
|
||||
});
|
||||
this.$u.api.unit.queryUnitById(params).then(res => {
|
||||
if (res.code == 200) {
|
||||
this.userInfo.unitName =res.data.name;
|
||||
}
|
||||
});
|
||||
},
|
||||
selectGender(e) {
|
||||
const index = e.detail.value;
|
||||
this.userInfo.gender = this.genderOptions[index].value;
|
||||
this.userInfo.sexLabel = this.genderOptions[index].label;
|
||||
},
|
||||
onsubmit(){
|
||||
this.$u.api.unit.updateEmployee(this.userInfo).then(res => {
|
||||
if (res.code == 200) {
|
||||
uni.reLaunch({
|
||||
url: '/pages/sys/user/mine'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
chooseImage() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: async (res) => {
|
||||
const tempFilePaths = res.tempFilePaths;
|
||||
this.userInfo.img = tempFilePaths[0];
|
||||
const result = await uploadFiles({
|
||||
files: tempFilePaths,
|
||||
url: this.vuex_config.baseUrl + '/resource/oss/upload',
|
||||
name: 'file',
|
||||
vm: this
|
||||
});
|
||||
this.userInfo.img = result[0].data.url;
|
||||
console.log(this.userInfo.img);
|
||||
const allSuccess = result.every(item => item.code == 200);
|
||||
if (!allSuccess) {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.change-info-container {
|
||||
position: relative;
|
||||
padding-bottom: 60rpx;
|
||||
padding-top: 118rpx;
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(180deg, #d2edff 0%, #ffffff 100%);
|
||||
}
|
||||
.change-info-container {
|
||||
position: relative;
|
||||
padding-bottom: 60rpx;
|
||||
padding-top: 24rpx;
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(180deg, #d2edff 0%, #ffffff 100%);
|
||||
}
|
||||
|
||||
.back-arrow {
|
||||
width: 24rpx;
|
||||
height: 42rpx;
|
||||
left: 45rpx;
|
||||
}
|
||||
.back-arrow {
|
||||
width: 24rpx;
|
||||
height: 42rpx;
|
||||
left: 45rpx;
|
||||
}
|
||||
|
||||
.title-main {
|
||||
font-size: 50rpx;
|
||||
font-weight: bold;
|
||||
color: #000;
|
||||
margin-top: 45rpx;
|
||||
margin-left: 65rpx;
|
||||
}
|
||||
.title-main {
|
||||
font-size: 50rpx;
|
||||
font-weight: bold;
|
||||
color: #000;
|
||||
margin-top: 45rpx;
|
||||
margin-left: 65rpx;
|
||||
}
|
||||
|
||||
.title-sub {
|
||||
font-size: 50rpx;
|
||||
color: #000;
|
||||
font-weight: bold;
|
||||
margin-left: 65rpx;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
.title-sub {
|
||||
font-size: 50rpx;
|
||||
color: #000;
|
||||
font-weight: bold;
|
||||
margin-left: 65rpx;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.avatar-section {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
margin-left: 68rpx;
|
||||
margin-bottom: 62rpx;
|
||||
position: relative;
|
||||
}
|
||||
.avatar-section {
|
||||
margin: 0 68rpx 62rpx 68rpx;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.avatar-img {
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
}
|
||||
.avatar-container {
|
||||
position: relative;
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
border-radius: 50%;
|
||||
border: 2rpx solid #e0e0e0;
|
||||
background-color: #fff;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.avatar-camera {
|
||||
position: absolute;
|
||||
left: 100rpx;
|
||||
top: 90rpx;
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
background: #bbb;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.avatar-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.camera-icon {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
margin: 0 68rpx;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
color: #737373;
|
||||
font-size: 28rpx;
|
||||
margin-bottom: 17rpx;
|
||||
margin-top: 32rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
.form-section {
|
||||
margin: 0 68rpx;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.input-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
border-radius: 14rpx;
|
||||
border: 2rpx solid #e0e0e0;
|
||||
margin-bottom: 18rpx;
|
||||
padding: 0 20rpx;
|
||||
height: 98rpx;
|
||||
}
|
||||
.form-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 18rpx;
|
||||
}
|
||||
|
||||
.form-input {
|
||||
flex: 1;
|
||||
border: none;
|
||||
font-weight: bold;
|
||||
font-size: 33rpx;
|
||||
color: #000000;
|
||||
}
|
||||
.form-label {
|
||||
color: #555;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
width: 200rpx;
|
||||
}
|
||||
|
||||
.input-suffix {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
.input-wrapper {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.random-icon {
|
||||
width: 31rpx;
|
||||
height: 27rpx;
|
||||
margin-right: 6rpx;
|
||||
}
|
||||
.form-input {
|
||||
width: 100%;
|
||||
background: #fff;
|
||||
border-radius: 14rpx;
|
||||
border: 2rpx solid #e0e0e0;
|
||||
padding: 0 20rpx;
|
||||
height: 98rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.random-text {
|
||||
color: #636363;
|
||||
font-size: 25rpx;
|
||||
}
|
||||
.gender-select {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.arrow-icon {
|
||||
width: 22rpx;
|
||||
height: 22rpx;
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
.gender-text {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.gender-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 50rpx;
|
||||
padding-top: 15rpx;
|
||||
}
|
||||
.form-group {
|
||||
margin-top: 40rpx;
|
||||
border-top: 1px solid #e0e0e0;
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.gender-item {
|
||||
width: 188rpx;
|
||||
height: 97rpx;
|
||||
border-radius: 10rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 24rpx;
|
||||
background: #fff;
|
||||
}
|
||||
.group-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.gender-item.selected {
|
||||
background: #e0e0e0;
|
||||
border-color: #bbb;
|
||||
}
|
||||
.submit-btn {
|
||||
width: 90vw;
|
||||
height: 80rpx;
|
||||
background: linear-gradient(90deg, #2e6cf6 0%, #4fc3f7 100%);
|
||||
color: #fff;
|
||||
font-size: 32rpx;
|
||||
border: none;
|
||||
border-radius: 40rpx;
|
||||
margin: 80rpx auto 40rpx auto;
|
||||
display: block;
|
||||
box-shadow: 0 8rpx 24rpx rgba(46, 108, 246, 0.12);
|
||||
}
|
||||
|
||||
.gender-icon {
|
||||
width: 38rpx;
|
||||
height: 38rpx;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 28rpx;
|
||||
color: #737373;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
color: #737373;
|
||||
width: 134rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
width: 90vw;
|
||||
height: 80rpx;
|
||||
background: linear-gradient(90deg, #2e6cf6 0%, #4fc3f7 100%);
|
||||
color: #fff;
|
||||
font-size: 32rpx;
|
||||
border: none;
|
||||
border-radius: 40rpx;
|
||||
margin: 80rpx auto 40rpx auto;
|
||||
display: block;
|
||||
box-shadow: 0 8rpx 24rpx rgba(46, 108, 246, 0.12);
|
||||
}
|
||||
</style>
|
||||
.form-input:disabled {
|
||||
background-color: #f5f5f5;
|
||||
color: #666;
|
||||
}
|
||||
</style>
|
||||
|
Reference in New Issue
Block a user