123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- <template>
- <view style="padding: 20px;">
- <uni-forms :modelValue="postForm" ref="form" :label-width="100">
- <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="用户头像">
- <yf-file-upload v-model="postForm.avatar"></yf-file-upload>
- </uni-forms-item>
-
- <uni-forms-item label="人脸照片">
- <yf-file-upload v-model="postForm.face"></yf-file-upload>
- </uni-forms-item>
- <uni-forms-item label="姓名">
- <uni-easyinput type="text" v-model="postForm.realName" placeholder="请输入姓名" />
- </uni-forms-item>
-
-
- <uni-forms-item label="身份证号">
- <uni-easyinput type="number" v-model="postForm.idCard" placeholder="请输入身份证号" />
- </uni-forms-item>
- <uni-forms-item label="手机号">
-
-
- <view v-if="postForm.mobile" class="mv-box">
- <view>
- {{ postForm.mobile }}
- </view>
-
- <view class="btn">
- <button type="warn" size="mini" @click="bindMobile">解绑</button>
- </view>
- </view>
-
- <view v-else>
- <button type="primary" size="mini" @click="bindMobile">绑定</button>
- </view>
-
- </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: ''
- }
- }
- },
- mounted() {
- this.handleInfo()
- },
- methods: {
- handleInfo() {
- let token = uni.getStorageSync('token');
- info(token).then(res => {
- this.postForm = res
- })
- },
- handleUpdate() {
-
- uni.showLoading()
-
- update(this.postForm).then(() => {
- uni.showToast({
- title: '资料更新成功!'
- })
-
-
- uni.hideLoading()
-
- setTimeout(()=>{
- uni.switchTab({
- url: '/pages/user/index'
- })
- }, 2000)
- })
- },
-
- 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>
|