123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <template>
- <view class="main">
- <u--form labelPosition="left" labelWidth='180' :model="model1" :rules="rules" ref="form1">
- <u-form-item label="旧登录密码" prop="userInfo.password" borderBottom ref="item1" required>
- <u--input v-model="model1.userInfo.password" border="none" clearable placeholder="请输入"></u--input>
- </u-form-item>
- <u-form-item label="新登录密码" prop="userInfo.newPassword" borderBottom ref="item1" required>
- <u--input v-model="model1.userInfo.newPassword" border="none" clearable placeholder="请输入"></u--input>
- </u-form-item>
- </u-form-item>
- <u-form-item label="请再次输入" prop="userInfo.confirmPassword" borderBottom ref="item1" required>
- <u--input v-model="model1.userInfo.confirmPassword" border="none" clearable
- placeholder="请输入"></u--input>
- </u-form-item>
- </u--form>
- <view class="tijiao">
- <u-button type="primary" @click="submit">确定修改</u-button>
- </view>
- <u-notify ref="uNotify" message=""></u-notify>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- dataForm: {
- password: "",
- newPassword: "",
- confirmPassword: "",
- },
- model1: {
- userInfo: {
- password: '',
- newPassword: '',
- confirmPassword: '',
- },
- },
- rules: {
- 'userInfo.password': {
- type: 'string',
- required: true,
- message: '请填写旧登录密码',
- trigger: ['blur', 'change']
- },
- 'userInfo.newPassword': {
- type: 'string',
- required: true,
- message: '请填写新登录密码',
- trigger: ['blur', 'change']
- },
- 'userInfo.confirmPassword': {
- type: 'string',
- required: true,
- message: '请填写新登录密码',
- trigger: ['blur', 'change']
- },
- },
- };
- },
- onReady() {
- //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
- this.$refs.form1.setRules(this.rules)
- },
- methods: {
- submit() {
- this.$refs.form1.validate().then(res => {
- if (this.model1.userInfo.newPassword != this.model1.userInfo.confirmPassword) {
- uni.$u.toast('您的新密码不一致,请重新输入')
- } else {
- //uni.$u.toast('校验通过')
- // console.log('111111111111111111',this.model1.userInfo)
- let postdata = {
- "newPassword": this.model1.userInfo.newPassword,
- "password": this.model1.userInfo.password
- }
- this.$api.put('/user/password', postdata)
- .then(res => {
- if (res.data.code == 0) {
- uni.navigateTo({
- url: '/pages/login/login'
- })
- } else {
- this.$refs.uNotify.error(res.data.msg)
- }
- })
- }
- }).catch(errors => {
- uni.$u.toast('校验失败')
- })
- }
- }
- }
- </script>
- <style scoped>
- .u-form{
- margin-top:24rpx ;
- padding: 32rpx 32rpx 32rpx 40rpx;
- background-color: #fff;
- }
- </style>
|