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.
147 lines
3.6 KiB
147 lines
3.6 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="name" required>{{form.username}}</u-form-item>
|
|
<u-form-item label="性别" prop="sex" required>{{form.sex}}</u-form-item>
|
|
<u-form-item label="身份证号" prop="idcard" required>{{form.idcard}}</u-form-item>
|
|
<u-form-item label="手机号码" prop="mobile" required>
|
|
{{form.mobile}}
|
|
<u-button style="margin-left:20rpx" size="mini" type="primary" @click="changeMobile">修改</u-button>
|
|
</u-form-item>
|
|
<u-form-item label="公司名称" prop="company_name"><u-input v-model="form.company_name" /></u-form-item>
|
|
<u-form-item label="职务" prop="company_position"><u-input
|
|
v-model="form.company_position" /></u-form-item>
|
|
<u-form-item label="车牌" prop="plate">
|
|
<block v-if="plateList.length>0">
|
|
<text v-for="item in plateList">{{item}},</text>
|
|
</block>
|
|
<u-button size="mini" type="primary" v-if="plateList.length<2" @click="addPlate">新增</u-button>
|
|
</u-form-item>
|
|
|
|
</u-form>
|
|
<view class="form-btn">
|
|
<view @click="saveUser" type="primary">提交</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="modal">
|
|
<u-popup v-model="showPark" mode="bottom">
|
|
<view class="modal-tip">绑定车牌号</view>
|
|
<view class="modal-content">
|
|
<view>
|
|
车牌:<u-input type="text" v-model="plate1" />
|
|
</view>
|
|
</view>
|
|
|
|
<view class="modal-btn">
|
|
<u-button type="primary" @click="saveUser('add')">确定</u-button>
|
|
</view>
|
|
</u-popup>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import tabbar from '@/components/tabbar/tabbar.vue';
|
|
export default {
|
|
components: {
|
|
|
|
},
|
|
data() {
|
|
return {
|
|
form: {},
|
|
plateList: [],
|
|
showPark: false,
|
|
plate1: '',
|
|
}
|
|
},
|
|
onShow() {
|
|
this.getUserInfo()
|
|
},
|
|
onLoad() {
|
|
|
|
},
|
|
methods: {
|
|
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() {
|
|
|
|
},
|
|
saveUser(type) {
|
|
|
|
if (type == 'add') {
|
|
this.plateList.push(this.plate1)
|
|
this.form.plate = this.plateList.join(",")
|
|
}
|
|
console.log("plateList", this.plateList)
|
|
this.$u.api.saveUser(this.form).then(res => {
|
|
this.base.toast("更新用户信息成功")
|
|
this.showPark = false
|
|
this.plate1 = ''
|
|
this.getUserInfo()
|
|
})
|
|
},
|
|
}
|
|
|
|
}
|
|
</script>
|
|
|
|
<style scoped lang="scss">
|
|
.container{
|
|
padding: 30rpx;
|
|
width:100%;
|
|
height:100vh;
|
|
.cbg {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100vh;
|
|
}
|
|
.wrap{
|
|
position: relative;
|
|
}
|
|
.form-btn {
|
|
width: 100%;
|
|
// position: fixed;
|
|
// left: 0;
|
|
// bottom: 0;
|
|
padding: 20rpx 0;
|
|
|
|
&>view{
|
|
width: 70%;
|
|
text-align: center;
|
|
margin: 0 auto;
|
|
color: #fff;
|
|
background-color: #010296;
|
|
border-radius: 10rpx;
|
|
padding: 20rpx;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
</style> |