123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <template>
- <view style="padding: 20px;">
- <uni-forms :modelValue="postForm" ref="form" :rules="rules" :label-width="120">
- <uni-forms-item label="ID">
- <uni-easyinput type="text" v-model="postForm.id" disabled />
- </uni-forms-item>
- <uni-forms-item label="用户名">
- <uni-easyinput type="text" v-model="postForm.userName" disabled />
- </uni-forms-item>
-
- <uni-forms-item label="人脸照片" name="avatar">
- <yf-file-upload v-model="postForm.avatar"></yf-file-upload>
- </uni-forms-item>
-
- <uni-forms-item label="身份证正面照" name="face">
- <yf-file-upload v-model="postForm.face"></yf-file-upload>
- </uni-forms-item>
- <uni-forms-item label="姓名" name="realName">
- <uni-easyinput type="text" v-model="postForm.realName" placeholder="请输入姓名" />
- </uni-forms-item>
-
-
- <uni-forms-item label="身份证号" name="idCard">
- <uni-easyinput type="number" v-model="postForm.idCard" placeholder="请输入身份证号" />
- </uni-forms-item>
- <uni-forms-item label="手机号" name="mobile">
- <uni-easyinput type="text" v-model="postForm.mobile" placeholder="请输入手机号" />
- </uni-forms-item>
- <!-- <uni-forms-item label="邮箱">
- <uni-easyinput type="text" v-model="postForm.email" placeholder="请输入邮箱" />
- </uni-forms-item> -->
- </uni-forms>
- <button type="primary" @click="handleUpdate()">保存并登录</button>
- </view>
- </template>
- <script>
- import { info, update } from '@/api/user'
- export default {
- data() {
- return {
- postForm: {
- avatar: '',
- face: '',
- userName: '',
- realName: '',
- idCard: '',
- mobile: '',
- },
- rules: {
-
- realName: {
- rules: [{
- required: true,
- errorMessage: '姓名不能为空!'
- }]
-
- },
- idCard: {
- rules: [{
- required: true,
- errorMessage: '身份证号不能为空!'
- }, {
- pattern: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
- errorMessage: '请输入正确身份证号!',
- }]
-
- },
- mobile: {
- rules: [{
- required: true,
- errorMessage: '手机号不能为空!'
- },{
- pattern: /^(1)\d{10}$/,
- errorMessage: '请输入正确手机号!'
- }]
-
- },
- avatar: {
- rules: [{
- required: true,
- errorMessage: '请上传人脸照片!'
- }]
- },
- face: {
- rules: [{
- required: true,
- errorMessage: '请上传身份证正面照!'
- }]
- }
-
- },
- }
- },
- mounted() {
- this.handleInfo()
- },
- methods: {
- handleInfo() {
- let token = uni.getStorageSync('token');
- info(token).then(res => {
- this.postForm = res
- })
- },
- handleUpdate() {
- this.$refs.form.validate().then(res => {
- uni.showLoading()
-
- update(this.postForm).then(() => {
-
- uni.showToast({
- title: '资料更新成功!'
- })
- uni.setStorageSync('idCard', this.postForm.idCard);
-
- uni.hideLoading()
-
- setTimeout(()=>{
- uni.switchTab({
- url: '/pages/index/index'
- })
- }, 2000)
-
- })
- }).catch(err => {
-
- })
- },
-
- bindMobile() {
-
- uni.navigateTo({
- url: `/pages/user/info/bind-mobile?type=${this.postForm.mobile?0:1}&mobile=${this.postForm.mobile|| ''}`
- })
- },
- }
- }
- </script>
- <style>
- .user-banner {
- height: 160px;
- display: flex;
- background: url('https://cdn.yfhl.net/static/user-bg.jpg') no-repeat;
- align-items: center;
- background-position: center;
- background-size: 100%;
- justify-content: center;
- width: 100%;
- flex-direction: column;
- }
- .user-banner .avatar {
- width: 80px;
- height: 80px;
- border: #3771CF 2px solid;
- border-radius: 50%;
- }
- .user-banner .points {
- position: absolute;
- top: 15px;
- right: 15px;
- color: #FDBF40;
- font-weight: bold;
- font-weight: 700;
- font-size: 16px;
- }
- .user-banner .name {
- color: #fff;
- font-weight: 700;
- font-size: 18px;
- }
- .user-banner .dept {
- color: #eee;
- font-weight: 700;
- font-size: 14px;
- }
-
- .mv-box{
- font-size: 16px;
- font-weight: 700;
- display: flex;
- align-items: center;
- }
-
- .mv-box .btn{
- margin-left: 10px;
- display: flex;
- align-items: center;
- }
- </style>
|