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.
255 lines
6.1 KiB
255 lines
6.1 KiB
<template>
|
|
<view class="container">
|
|
<image class="cbg" src="../../static/common_bg.png"></image>
|
|
<view class="wrap">
|
|
<u-form :model="form" :label-width="140" ref="uForm" :label-align="'left'" error-type="toast">
|
|
<u-form-item label="姓名" prop="username">
|
|
{{form.username}}
|
|
</u-form-item>
|
|
<u-form-item label="性别" prop="sex">
|
|
{{form.sex}}
|
|
</u-form-item>
|
|
<u-form-item label="身份证号" prop="idcard">
|
|
{{form.idcard}}
|
|
</u-form-item>
|
|
<u-form-item label="出生日期" prop="birthday">
|
|
{{form.birthday}}
|
|
</u-form-item>
|
|
<u-form-item label="联系方式" prop="mobile">
|
|
<u-input type="number" border placeholder="请输入联系方式" v-model="form.mobile" />
|
|
</u-form-item>
|
|
<u-form-item label="邮箱" prop="email">
|
|
<u-input v-model="form.email" border placeholder="请输入邮箱" /></u-form-item>
|
|
<u-form-item label="公司名称" prop="company_name">
|
|
<u-input v-model="form.company_name" border placeholder="请输入公司名称" />
|
|
</u-form-item>
|
|
<u-form-item label="职务" prop="company_position">
|
|
<u-input border @click="showPosition = true" v-model="form.company_position" type="select"
|
|
placeholder="请选择职务" />
|
|
</u-form-item>
|
|
|
|
<u-form-item label="车牌" prop="plate">
|
|
<view style="display: flex;align-items: center;justify-content: space-between;">
|
|
<view v-if="plateList.length>0">
|
|
<view v-for="item in plateList">
|
|
{{item}}
|
|
</view>
|
|
</view>
|
|
<u-button size="mini" type="primary" v-if="plateList.length<2" @click="addPlate">新增</u-button>
|
|
</view>
|
|
|
|
</u-form-item>
|
|
|
|
</u-form>
|
|
<view class="form-btn">
|
|
<view @click="saveUser" type="primary">提交</view>
|
|
</view>
|
|
</view>
|
|
<u-picker @confirm="selectPosition" v-model="showPosition" :range="positionList" range-key="value"
|
|
mode="selector"></u-picker>
|
|
|
|
<view class="modal">
|
|
<u-popup v-model="showPark" mode="bottom">
|
|
<view class="modal-tip">绑定车牌号</view>
|
|
<view class="modal-content" style="height:400rpx">
|
|
<view>
|
|
<plate @listenPlateChange="plateChange" :defaultPlate="plateNumber" />
|
|
|
|
</view>
|
|
</view>
|
|
<view class="form-btn">
|
|
<view @click="saveUser('add')" type="primary">确定</view>
|
|
</view>
|
|
</u-popup>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import tabbar from '@/components/tabbar/tabbar.vue';
|
|
import {
|
|
plate
|
|
} from '@/components/plate/index.vue'
|
|
export default {
|
|
components: {
|
|
plate
|
|
},
|
|
data() {
|
|
return {
|
|
showPosition: false,
|
|
positionList: [],
|
|
form: {},
|
|
plateList: [],
|
|
showPark: false,
|
|
plate1: '',
|
|
plateNumber: ['苏', 'E', '', '', '', '', ''],
|
|
rules: {
|
|
mobile: [{
|
|
required: true,
|
|
message: '请输入联系方式',
|
|
trigger: ['blur'],
|
|
}, {
|
|
validator: (rule, value, callback) => {
|
|
return this.$u.test.mobile(value);
|
|
},
|
|
message: '手机号码不正确',
|
|
trigger: ['blur'],
|
|
}],
|
|
email: [{
|
|
required: true,
|
|
message: '请输入邮箱',
|
|
trigger: ['blur'],
|
|
}, {
|
|
validator: (rule, value, callback) => {
|
|
return this.$u.test.email(value);
|
|
},
|
|
message: '邮箱不正确',
|
|
trigger: ['blur'],
|
|
}],
|
|
|
|
}
|
|
}
|
|
},
|
|
onReady() {
|
|
this.$refs.uForm.setRules(this.rules);
|
|
},
|
|
onShow() {
|
|
this.getUserInfo()
|
|
},
|
|
onLoad() {
|
|
this.getPosition()
|
|
},
|
|
methods: {
|
|
selectPosition(e) {
|
|
this.form.company_position = this.positionList[e[0]]['value']
|
|
|
|
},
|
|
getPosition() {
|
|
this.$u.api.getparameter({
|
|
number: 'company_position'
|
|
}).then(res => {
|
|
this.positionList = res.detail
|
|
})
|
|
},
|
|
getUserInfo() {
|
|
this.$u.api.user().then(res => {
|
|
console.log("res", res)
|
|
this.form = this.base.requestToForm(res.user, this.form)
|
|
if (res.user.plate) {
|
|
this.plateList = res.user.plate.split(',')
|
|
this.plateList.map((item, index) => {
|
|
if (this.base.isNull(item)) {
|
|
this.plateList.splice(index, 1)
|
|
}
|
|
})
|
|
}
|
|
this.$u.vuex('vuex_user', res.user)
|
|
})
|
|
},
|
|
addPlate() {
|
|
if (this.plateList.length == 2) {
|
|
this.base.toast("每人最多只能添加两个车牌")
|
|
return
|
|
}
|
|
// this.plateList.push('')
|
|
this.showPark = true
|
|
},
|
|
changeMobile() {
|
|
|
|
},
|
|
plateChange(val){
|
|
this.plate1 = val.join('')
|
|
},
|
|
saveUser(type) {
|
|
|
|
if (type == 'add') {
|
|
this.plateList.push(this.plate1)
|
|
this.form.plate = this.plateList.join(",")
|
|
}
|
|
console.log("plateList", this.plateList)
|
|
let that = this
|
|
this.$refs.uForm.validate(valid => {
|
|
if (valid) {
|
|
this.$u.api.saveUser(this.form).then(res => {
|
|
this.showPark = false
|
|
this.plate1 = ''
|
|
this.base.toast("更新用户信息成功", 2000, function() {
|
|
if (type === 'add') {
|
|
that.getUserInfo()
|
|
} else {
|
|
uni.switchTab({
|
|
url: '/pages/me/index'
|
|
})
|
|
}
|
|
})
|
|
|
|
|
|
})
|
|
} else {
|
|
console.log('验证失败');
|
|
// this.base.toast("注册失败")
|
|
}
|
|
});
|
|
|
|
},
|
|
}
|
|
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.container {
|
|
padding: 30rpx;
|
|
height: 100vh;
|
|
overflow: scroll;
|
|
|
|
.cbg {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100vh;
|
|
}
|
|
|
|
.wrap {
|
|
background: #fff;
|
|
position: relative;
|
|
padding: 35rpx;
|
|
border-radius: 30rpx;
|
|
padding-top: 0;
|
|
}
|
|
|
|
.form-btn {
|
|
width: 100%;
|
|
position: relative;
|
|
padding: 60rpx 0;
|
|
|
|
&>view {
|
|
width: 70%;
|
|
text-align: center;
|
|
margin: 0 auto;
|
|
color: #fff;
|
|
background: linear-gradient(to right, #5e5fbc, #0d0398);
|
|
border-radius: 30rpx;
|
|
padding: 20rpx;
|
|
}
|
|
}
|
|
|
|
.modal {
|
|
::v-deep .u-drawer-bottom {
|
|
border-radius: 40rpx;
|
|
}
|
|
|
|
&-tip {
|
|
text-align: center;
|
|
padding: 30rpx;
|
|
font-size: 32rpx;
|
|
}
|
|
|
|
&-content {
|
|
// height: 400rpx;
|
|
padding: 0 30rpx;
|
|
}
|
|
}
|
|
}
|
|
</style> |