<template>
    <view class="page">
	<NavBar :title="$t('用户设置')"></NavBar>
	<view class="infoedit">
		<u-form ref="form" :modelValue="form" class="login-form" :labelWidth="160">
			<u-form-item prop="ti003" :label="$t('用户名：')" class="disabled">
				<input
					v-model="form.mv001"
					type="text"
					disabled
				>
				</input>
			</u-form-item>
			<u-form-item prop="ti004" :label="$t('姓名：')" class="disabled">
				<input
					v-model="form.mv002"
					disabled
					type="text"
					@confirm="submit"
				>
				</input>
			</u-form-item>
			<u-form-item prop="oldPassWord" :label="$t('旧密码：')">
				<input
					v-model="form.oldPassWord"
					type="text"
					@confirm="submit"
				>
				</input>
			</u-form-item>
			<u-form-item prop="newPassword" :label="$t('新密码：')">
				<input
					v-model="form.newPassword"
					type="text"
					@confirm="submit"
				>
				</input>
			</u-form-item>
			<u-form-item style="width:100%;">
			<button
				size="medium"
				type="primary"
				style="width:95%;margin-top: 50rpx"
				@click="submit()"
			>
				<span>{{$t('确定')}}</span>
			</button>
			</u-form-item>
		</u-form>
	</view>
    </view>
  </template>
  
  <script>
import i18n from '../../../lang/index'

  import StickyNavBar from "@/components/StickyNavBar/index.vue";
  import ContentLoadingMore from "@/components/ContentLoadingMore/index.vue";
  export default {
    components: {
      StickyNavBar,
      ContentLoadingMore,
    },
    data() {
      return {
		info: null,
		index: 0,
		form: {
			newPassword: null,
			mv001: null,
			mv002: null,
			oldPassWord: null
		}
      };
    },
    created() {
		this.form.mv001 = this.vuex_user.mv001
		this.form.mv002 = this.vuex_user.mv002
    },
    methods: {
		submit(row) {
			if (!this.form['oldPassWord']) {
				return this.$u.toast(i18n.t('旧密码不能为空'))
			}
			if (!this.form['newPassword']) {
				return this.$u.toast(i18n.t('新密码不能为空'))
			}
			this.$u.api.changepassword({
				newPassword: this.form.newPassword,
				oldPassWord: this.form.oldPassWord
			}).then(res => {
				if(res.success) {
					uni.reLaunch({
						url: '/pages/sys/login/login'
					});
				}
			})
		}
    },
  };
  </script>
  
  <style lang="scss" scoped>
  ::v-deep .u-sticky {
    top: 0 !important;
    background: #fff;
  }
  .infoedit {
	padding: 20rpx 20rpx;
	.underline {
		border-bottom: 1px solid #d5d5d5;
		padding-bottom: 0px;
    	line-height: 40px;
		font-weight: 500;
		margin-left: 20rpx;
		font-size: 19px;
	}
	.u-border-bottom:after {
		display: none;
	}
	
  }
  </style>
  