yangan
2024-04-25 ffc2eddb1c4f534075fdc5787cbca06e847c576c
pages/login/resetPassword/resetPassword.vue
@@ -9,19 +9,31 @@
            label="密码"
            required
            borderBottom>
            <u--input v-model="modelForm.password"
            <u-input v-if='inputType==="password"'
               v-model="modelForm.password"
               border="surround"
               placeholder="请输入密码"
               type='password'></u--input>
               placeholder="请输入密码(仅支持数字字母下划线)"
               :type='inputType' />
            <u-input v-else
               v-model="modelForm.password"
               border="surround"
               placeholder="请输入密码(仅支持数字字母下划线)"
               :type='inputType' />
         </u-form-item>
         <u-form-item prop="secondPassword"
            label="二次确认"
            required
            borderBottom>
            <u--input v-model="modelForm.secondPassword"
            <u-input v-if='inputType==="password"'
               v-model="modelForm.secondPassword"
               border="surround"
               placeholder="请再次输入密码"
               type='password'></u--input>
               placeholder="请再次输入密码(仅支持数字字母下划线)"
               type='password' />
            <u-input v-else
               v-model="modelForm.secondPassword"
               border="surround"
               placeholder="请再次输入密码(仅支持数字字母下划线)"
               type='text' />
         </u-form-item>
         <u-form-item>
            <view class="process-button">
@@ -30,6 +42,18 @@
                  :loading="processLoading"
                  @click.stop="process"></u-button>
            </view>
         </u-form-item>
         <u-form-item prop="checkboxValue">
            <u-checkbox-group v-model="checkboxValue"
               @change="checkChange">
               <u-checkbox label="显示密码"
                  name="显示"
                  iconSize="32"
                  label-size="32"
                  size="40"
                  shape="circle">
               </u-checkbox>
            </u-checkbox-group>
         </u-form-item>
      </u-form>
   </view>
@@ -40,34 +64,81 @@
      data() {
         return {
            userInfo: {},
            checkboxValue: [],
            inputType: 'password',
            isFocus: false,
            modelForm: {
               password: '',
               secondPassword: ''
            },
            processLoading: false,
            rules: {
               password: {
                  type: 'string',
                  required: true,
                  message: '请填写密码',
                  trigger: ['blur', 'change']
               },
               secondPassword: {
                  type: 'string',
                  required: true,
                  message: '请填写二次密码',
                  trigger: ['blur', 'change']
               }
               password: [{
                     type: 'string',
                     required: true,
                     message: '请填写密码',
                     trigger: ['blur', 'change']
                  },
                  {
                     min: 2,
                     max: 10,
                     message: '密码长度应不小于2位,不大于10位  ',
                     trigger: ['blur', 'change']
                  },
                  {
                     pattern: /^[a-zA-Z0-9_]+$/,
                     message: '请输入正确格式的密码',
                     trigger: ['blur', 'change']
                  }
               ],
               secondPassword: [{
                     type: 'string',
                     required: true,
                     message: '请填写二次密码',
                     trigger: ['blur', 'change']
                  },
                  {
                     min: 2,
                     max: 10,
                     message: '密码长度应不小于2,不大于10',
                     trigger: ['blur', 'change']
                  }
               ]
            }
         }
      },
      computed: {
         roleType() {
            return uni.getStorageSync('roleType')
         }
      },
      onLoad(params) {
         this.userInfo = JSON.parse(params.userInfo)
         if (this.roleType === 3) {
            this.userInfo = JSON.parse(params.userInfo)
         } else {
            const query = JSON.parse(params.userInfo)
            this.getUserInfo( query.phone, query.idCard)
         }
      },
      onReady() {
         this.$refs.uForm.setRules(this.rules)
      },
      methods: {
         getUserInfo(phone, idCard) {
            this.$reqGet('phoneAndCard', { phone, idCard }).then(res => {
               if (res.code === 0) {
                  this.userInfo = res.data
               } else {
                  uni.$u.toast('加载失败')
               }
            })
         },
         checkChange(name) {
            this.inputType = name.length === 0 ? 'password' : ''
            this.isFocus = true
         },
         process() {
            if (this.modelForm.password !== this.modelForm.secondPassword) return uni.$u.toast('密码不一致,请检查')
            this.userInfo.password = this.modelForm.secondPassword;