1
YM
2024-07-26 571e12ca122d12f20689e3040a0f368ef1ae8850
src/pages/changePassword/changePassword.vue
@@ -1,267 +1,318 @@
<template>
   <view class="container flex flex-center" style="align-items: flex-start;">
      <view class="repository relative">
         <view class="Ttop flex flex-center flex-wrap" style="flex-direction: column;">
            <view class=""></view>
            <view class="" ref="Rtop">
               <text class="login"></text>
               <text
                  style="font-size: .36rem;letter-spacing: 4rpx;vertical-align: middle;font-family: cursive;font-weight: bold;">中国医学人物知识库</text>
            </view>
            <view></view>
         </view>
         <!-- 修改密码 -->
         <el-card>
            <view class="LoginTop"
               style="display: flex; justify-content: space-between;margin-bottom: .47rem;align-items: center;">
               <!-- <view class="" style="color: #244A7B;padding-bottom: .47rem;font-size: .3rem;font-weight: bold;">用户注册</view> -->
               <view class="LoginBg"></view>
               <view class="" @click="BacktoLogin"
                  style="cursor: pointer;font-size: .14rem;color: #244A7B;font-weight: normal;">
                  返回
               </view>
            </view>
            <el-form :hide-required-asterisk="true" ref="formLogin2" label-position="right" :rules="rules"
               :model="amendDataPass">
               <el-form-item label="登录账号" prop="loginID">
                  <el-input  v-model="amendDataPass.loginID"></el-input>
               </el-form-item>
               <el-form-item label="原密码" prop="rawPass">
                  <el-input type="password" v-model="amendDataPass.rawPass"></el-input>
               </el-form-item>
               <el-form-item label="新密码" prop="newPass">
                  <el-input type="password" v-model="amendDataPass.newPass"></el-input>
               </el-form-item>
               <el-form-item label="确认新密码" prop="checkPass">
                  <el-input type="password" v-model="amendDataPass.checkPass"></el-input>
               </el-form-item>
               <el-form-item class="btn">
                  <el-button class="font-family"
                     style="margin-top: 30rpx; font-weight:900;font-size: 30rpx; width: 100%;background-color: #244a7b;color: #fff;padding: 30rpx;"
                     size="medium" @click="Login2('formLogin2')">修改</el-button>
               </el-form-item>
            </el-form>
         </el-card>
  <view class="container flex flex-center" style="align-items: flex-start">
    <view class="repository relative">
      <view
        class="Ttop flex flex-center flex-wrap"
        style="flex-direction: column"
      >
        <view ></view>
        <view  ref="Rtop">
          <text class="login"></text>
          <text
            style="
              font-size: 0.36rem;
              letter-spacing: 4rpx;
              vertical-align: middle;
              font-family: cursive;
              font-weight: bold;
            "
            >中国历代医学人物知识库</text
          >
        </view>
        <view></view>
      </view>
      <!-- 修改密码 -->
      <el-card>
        <view
          class="LoginTop"
          style="
            display: flex;
            justify-content: space-between;
            margin-bottom: 0.47rem;
            align-items: center;
            padding-top: 0.6rem;
          "
        >
          <!-- <view  style="color: #244A7B;padding-bottom: .47rem;font-size: .3rem;font-weight: bold;">用户注册</view> -->
          <view class="LoginBg"></view>
          <view
            @click="BacktoLogin"
            style="
              cursor: pointer;
              font-size: 0.14rem;
              color: #244a7b;
              font-weight: normal;
              position: absolute;
              left: 0.1rem;
              top: 0.1rem;
            "
          >
            < 返回
          </view>
        </view>
        <el-form
               :label-width="160"
          :hide-required-asterisk="true"
          ref="formLogin2"
          label-position="right"
          :rules="rules"
          :model="amendDataPass"
        >
          <el-form-item label="登录账号" prop="loginID">
            <el-input v-model="amendDataPass.loginID"></el-input>
          </el-form-item>
          <el-form-item label="原密码" prop="rawPass">
            <el-input
              type="password"
              v-model="amendDataPass.rawPass"
            ></el-input>
          </el-form-item>
          <el-form-item label="新密码" prop="newPass">
            <el-input
              type="password"
              v-model="amendDataPass.newPass"
            ></el-input>
          </el-form-item>
          <el-form-item label="确认新密码" prop="checkPass">
            <el-input
              type="password"
              v-model="amendDataPass.checkPass"
            ></el-input>
          </el-form-item>
          <el-form-item class="btn">
            <el-button
              class="font-family"
              style="
                margin-top: 30rpx;
                font-weight: 900;
                font-size: 30rpx;
                width: 100%;
                background-color: #244a7b;
                color: #fff;
                padding: 30rpx;
              "
              size="medium"
              @click="Login2('formLogin2')"
              >修改</el-button
            >
          </el-form-item>
        </el-form>
      </el-card>
    </view>
    <view class="hua"></view>
    <!-- 底部人物背景图左侧 -->
    <view class="fff"></view>
    <!-- 底部花的背景图右侧 -->
    <view class="rrr"></view>
      </view>
      <view class="hua"></view>
      <!-- 底部人物背景图左侧 -->
      <view class="fff"></view>
      <!-- 底部花的背景图右侧 -->
      <view class="rrr"></view>
      <Footer1 />
   </view>
    <Footer1 />
  </view>
</template>
<script>
   import {
      getchangePassword
   } from '@/api/index.js'
   import {
      encryptAES
   } from '@/utils/Crypto.js'
   import {
      nextTick
   } from "vue";
   import Footer1 from '@/components/footer/footer.vue'
   export default {
      components: {
         Footer1
      },
      data() {
         // 新密码
         var validatePass = (rule, value, callback) => {
            if (value === '') {
               callback(new Error('请输入密码'));
            } else {
               if (this.amendDataPass.checkPass !== '') {
                  this.$refs.formLogin2.validateField('checkPass');
               }
               callback();
            }
         };
         // 确认
         var validatePass2 = (rule, value, callback) => {
            if (value === '') {
               callback(new Error('请再次输入密码'));
            } else if (value !== this.amendDataPass.newPass) {
               callback(new Error('两次输入密码不一致!'));
            } else {
               callback();
            }
         };
         return {
            // 用户注册
            isRegister: false,
            // 用户登录
            isLogin: true,
            // 修改密码
            isAmendPass: false,
            // 重置密码
            isResetPass: false,
            // 注册用户账号的校验
            rules: {
               loginID: [{
                  required: true,
                  message: '请输入登录账号',
                  trigger: 'blur'
               }],
               rawPass: [{
                     required: true,
                     message: '请输入原始密码',
                     trigger: 'blur'
                  },
                  {
                     min: 5,
                     max: 12,
                     message: '密码长度在 6 到 12 个字符',
                     trigger: 'blur'
                  }
               ],
               newPass: [{
                     required: true,
                     message: '请输入新密码',
                     trigger: 'blur'
                  },
                  {
                     min: 6,
                     max: 12,
                     message: '密码长度在 6 到 12 个字符',
                     trigger: 'blur'
                  },
                  {
                     validator: validatePass,
                     trigger: 'blur'
                  }
               ],
               checkPass: [{
                  validator: validatePass2,
                  trigger: 'blur'
               }],
               cellphoneORmailbox: [{
                     required: true,
                     message: '请输入邮箱地址',
                     trigger: 'blur'
                  },
                  {
                     type: 'email',
                     message: '请输入正确的邮箱地址',
                     trigger: ['blur', 'change']
                  }
               ],
               verifyCode: [{
                     required: true,
                     message: '请输入验证码',
                     trigger: 'blur'
                  },
                  {
                     validator: (rule, value, callback) => this.validateVerificationCode(rule, value, callback),
                     trigger: 'blur'
                  }
               ]
            },
            // 登录注册框
            loginTrue: true,
            Rtop1: 0,
            value: 'sdfdsf',
            // 修改密码
            amendDataPass: {
               loginID: this.$store.state.username,
               rawPass: "",
               newPass: "",
               checkPass: ""
            },
            // 书籍数据
            listData: [{
                  name: '历代医家传记库',
                  id: 1,
               }, {
                  name: '世医医家库',
                  id: 2,
               }, {
                  name: '医学学术流派',
                  id: 3,
               }, {
                  name: '中国地域医谱',
                  id: 4,
               }, {
                  name: '中国医事制度',
                  id: 5,
               },
            ]
         }
      },
      onLoad() {
         uni.getSystemInfo({
            success: function(info) {
               // console.log('屏幕的宽度:' + info.windowWidth);
               // console.log('屏幕的高度:' + info.windowHeight);
            }
         });
      },
      mounted() {
         this.getElementWidth();
      },
      methods: {
         // 返回登录
         BacktoLogin() {
            // uni.redirectTo({
            //    url: '/pages/Login/Login'
            // })
            uni.navigateBack();
         },
         getElementWidth() {
            this.$nextTick(() => {
               var width = this.$refs.Rtop.$el.clientWidth;
               this.Rtop1 = width + 50;
               console.log('Element width:', width);
            })
         },
         // 忘记密码
         async Login2(formName) {
            let Obj = {
               username: this.amendDataPass.loginID,
               password: encryptAES(this.amendDataPass.rawPass) ,
               newPassword:encryptAES(this.amendDataPass.newPass),
            }
            console.log(Obj);
            this.$refs[formName].validate(async (valid) => {
               if (valid) {
                  // alert('submit!成功');
                  await getchangePassword(Obj).then(res=>{
                     // console.log(res,'修改密码成功');
                     if(res.success==true){
                        uni.showToast({
                           title: res.object,
                           icon: 'none'
                        });
                        uni.navigateBack();
                        console.log('修改成功',res);
                     }else{
                        uni.showToast({
                           title: res.errorText,
                           icon: 'none'
                        });
                     }
                  })
                  // uni.redirectTo({ encryptAES
                  //    url: '/pages/Login/Login'
                  // })
               } else {
                  console.log('error submit!!失败');
                  return false;
               }
            });
         }
      }
   }
import { getchangePassword } from "@/api/index.js";
import { encryptAES } from "@/utils/Crypto.js";
import { nextTick } from "vue";
import Footer1 from "@/components/footer/footer.vue";
export default {
  components: {
    Footer1
  },
  data() {
    // 新密码
    var validatePass = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入密码"));
      } else {
        if (this.amendDataPass.checkPass !== "") {
          this.$refs.formLogin2.validateField("checkPass");
        }
        callback();
      }
    };
    // 确认
    var validatePass2 = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请再次输入密码"));
      } else if (value !== this.amendDataPass.newPass) {
        callback(new Error("两次输入密码不一致!"));
      } else {
        callback();
      }
    };
    return {
      // 用户注册
      isRegister: false,
      // 用户登录
      isLogin: true,
      // 修改密码
      isAmendPass: false,
      // 重置密码
      isResetPass: false,
      // 注册用户账号的校验
      rules: {
        loginID: [
          {
            required: true,
            message: "请输入登录账号",
            trigger: "blur"
          }
        ],
        rawPass: [
          {
            required: true,
            message: "请输入原始密码",
            trigger: "blur"
          },
          {
            min: 5,
            max: 12,
            message: "密码长度在 6 到 12 个字符",
            trigger: "blur"
          }
        ],
        newPass: [
          {
            required: true,
            message: "请输入新密码",
            trigger: "blur"
          },
          {
            min: 6,
            max: 12,
            message: "密码长度在 6 到 12 个字符",
            trigger: "blur"
          },
          {
            validator: validatePass,
            trigger: "blur"
          }
        ],
        checkPass: [
          {
            validator: validatePass2,
            trigger: "blur"
          }
        ],
        cellphoneORmailbox: [
          {
            required: true,
            message: "请输入邮箱地址",
            trigger: "blur"
          },
          {
            type: "email",
            message: "请输入正确的邮箱地址",
            trigger: ["blur", "change"]
          }
        ],
        verifyCode: [
          {
            required: true,
            message: "请输入验证码",
            trigger: "blur"
          },
          {
            validator: (rule, value, callback) =>
              this.validateVerificationCode(rule, value, callback),
            trigger: "blur"
          }
        ]
      },
      // 登录注册框
      loginTrue: true,
      Rtop1: 0,
      value: "sdfdsf",
      // 修改密码
      amendDataPass: {
        loginID: this.$store.state.username,
        rawPass: "",
        newPass: "",
        checkPass: ""
      },
      // 书籍数据
      listData: [
        {
          name: "历代人物",
          id: 1
        },
        {
          name: "家学传承",
          id: 2
        },
        {
          name: "学术图谱",
          id: 6
        },
        {
          name: "学术流派",
          id: 3
        },
        {
          name: "地域图谱",
          id: 4
        },
        // {
        //   name: "中医医事制度",
        //   id: 5
        // }
      ]
    };
  },
  onLoad() {
    uni.getSystemInfo({
      success: function (info) {
        // console.log('屏幕的宽度:' + info.windowWidth);
        // console.log('屏幕的高度:' + info.windowHeight);
      }
    });
  },
  mounted() {
    this.getElementWidth();
  },
  methods: {
    BacktoLogin() {
      this.$router.go(-1);
    },
    getElementWidth() {
      this.$nextTick(() => {
        var width = this.$refs.Rtop.$el.clientWidth;
        this.Rtop1 = width + 50;
      });
    },
    // 忘记密码
    Login2(formName) {
      let Obj = {
        username: this.amendDataPass.loginID,
        password: encryptAES(this.amendDataPass.rawPass),
        newPassword: encryptAES(this.amendDataPass.newPass)
      };
      this.$refs[formName].validate((valid) => {
        if (valid) {
          // alert('submit!成功');
          getchangePassword(Obj).then((res) => {
            if (res.success == true) {
              this.$message.success('修改成功');
              uni.navigateTo({
                url: "/pages/Login/Login"
              });
            } else {
              this.$message.error(res.errorText);
            }
          });
        } else {
          console.log("error submit!!失败");
          return false;
        }
      });
    }
  }
};
</script>
<style scoped>
   /*
/*
   在屏幕宽度超过 1440px 时的样式设置 */
   /* @media screen and (min-width: 1441px) {
/* @media screen and (min-width: 1441px) {
      ::v-deep .el-card {
         top: 60% !important;
      }
@@ -289,279 +340,257 @@
      }
   }
    */
   @media screen and (min-width:2560px)and (max-width:3840px) {
      .LoginBg {
         margin: 0 !important;
         height: .3rem !important;
      }
@media screen and (min-width: 2560px) and (max-width: 3840px) {
  .LoginBg {
    margin: 0 !important;
    height: 0.3rem !important;
  }
      ::v-deep .el-card {
         top: 90% !important;
         padding: 0 !important;
      }
  ::v-deep .el-card {
    top: 90% !important;
    padding: 0 !important;
  }
      ::v-deep .el-card__body {
         padding: .25rem .5rem !important;
      }
  ::v-deep .el-card__body {
    padding: 0.25rem 0.5rem !important;
  }
      ::v-deep .el-form {
         padding-left: .1rem !important;
      }
  ::v-deep .el-form {
    padding-left: 0.1rem !important;
  }
      ::v-deep .el-form-item__error {
         font-size: .13rem !important;
      }
  ::v-deep .el-form-item__error {
    font-size: 0.13rem !important;
  }
      ::v-deep .el-input__inner {
         height: .35rem !important;
         font-size: .14rem;
      }
  ::v-deep .el-input__inner {
    height: 0.35rem !important;
    font-size: 0.14rem;
  }
      ::v-deep .el-form-item__label {
         display: flex;
         align-items: center;
         justify-content: flex-end;
         margin-right: .2rem !important;
         width: .7rem;
      }
  .hua {
    height: 4rem !important;
  }
      .hua {
         height: 4rem !important;
      }
  .LoginTop {
    margin-bottom: 0.4rem !important;
  }
      .LoginTop {
         margin-bottom: .4rem !important;
      }
  .yzm {
    top: 15% !important;
  }
      .yzm {
         top: 15% !important;
      }
  .fff {
    width: 2.4rem !important;
    height: 4rem !important;
  }
      .fff {
         width: 2.4rem !important;
         height: 4rem !important;
      }
  .rrr {
    width: 2rem !important;
  }
      .rrr {
         width: 2rem !important;
      }
  .btn {
    margin-bottom: 0.1rem !important;
  }
      .btn {
         margin-bottom: .1rem !important;
      }
  .btn ::v-deep .el-button {
    margin-top: 0.2rem !important;
    font-size: 0.2rem !important;
    width: 100%;
    padding: 0.12rem !important;
      .btn ::v-deep .el-button {
         margin-top: 0.2rem !important;
         font-size: 0.2rem !important;
         width: 100%;
         padding: 0.12rem !important;
    span {
      font-weight: bold !important;
    }
  }
         span {
            font-weight: bold !important;
         }
      }
  .asdf {
    margin-bottom: 0.1rem !important;
  }
}
      .asdf {
         margin-bottom: .1rem !important;
      }
.LoginBg {
  width: 1.2rem;
  height: 0.37rem;
  background: url(@/static/image/修改密码.png) no-repeat 0 0;
  background-size: 100%;
}
   }
::v-deep .el-card {
  border-radius: 0;
  width: 5.42rem;
  /* height: 5.65rem; */
  position: absolute;
  top: 80%;
}
   .LoginBg {
      width: 1.2rem;
      height: .37rem;
      background: url(@/static/image/修改密码.png) no-repeat 0 0;
      background-size: 100% 100%;
   }
::v-deep .el-card__body {
  padding: 0.26rem 0.58rem;
}
.btn >>> .el-form-item__content {
  margin-left: 0 !important;
}
   ::v-deep .el-card {
      border-radius: 0;
      width: 5.42rem;
      /* height: 5.65rem; */
      position: absolute;
      top: 80%;
   }
::v-deep .el-form-item__content {
  margin-left: 0 !important;
  flex: 1;
  overflow: hidden;
}
   ::v-deep .el-card__body {
      padding: .26rem .58rem;
   }
::v-deep .el-input__inner {
  border: none;
  border-bottom: 1px solid #2d476a;
  border-radius: 0;
  padding: 0;
  height: 0.4rem;
  line-height: 0.4rem;
}
   .btn>>>.el-form-item__content {
      margin-left: 0 !important;
::v-deep .el-form-item__error {
  /* display: none; */
}
   }
::v-deep .input.invalid:focus {
  border-color: #2d476a !important;
}
   ::v-deep .el-form-item__content {
      margin-left: 0 !important;
      flex: 1;
   }
::v-deep .el-input__inner:invalid {
  border-color: #2d476a !important;
}
   ::v-deep .el-input__inner {
      border: none;
      border-bottom: 1px solid #2d476a;
      border-radius: 0;
      padding: 0;
      height: .4rem;
      line-height: .4rem;
   }
::v-deep .el-form-item__label {
  width: 88px;
  color: #244a7b;
  font-size: 0.14rem;
}
   ::v-deep .el-form-item__error {
      /* display: none; */
   }
::v-deep .el-form-item {
  margin-bottom: 0.22rem;
  display: flex;
}
   ::v-deep .input.invalid:focus {
      border-color: #2d476a !important;
   }
.ss1 {
  background-repeat: no-repeat;
  background-size: 100% 100%;
  width: 40rpx;
  height: 40rpx;
  background-size: 100% 100%;
}
   ::v-deep .el-input__inner:invalid {
      border-color: #2d476a !important;
   }
.s1 {
  background-image: url(@/static/image/search.png);
}
.s2 {
  background-image: url(@/static/image/question.png);
}
   ::v-deep .el-form-item__label {
      min-width: .6rem;
      padding: 0;
      color: #244A7B;
      font-size: .14rem;
      font-weight: 500;
      margin-right: .29rem;
   }
.s3 {
  background-image: url(@/static/image/question.png);
}
   ::v-deep .el-form-item {
      margin-bottom: .22rem;
      display: flex;
   }
.container {
  background: url(@/static/image/bg1.png);
  width: 100vw;
  height: 100vh;
   .ss1 {
      background-repeat: no-repeat;
      background-size: 100% 100%;
      width: 40rpx;
      height: 40rpx;
      background-size: 100% 100%;
   }
  color: #fff;
   .s1 {
      background-image: url(@/static/image/search.png);
  .repository {
    width: 100% !important;
    /* margin-top: 19px; */
    /* height: 68%; */
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
   }
    .Ttop {
      margin-top: 0.38rem;
      margin-bottom: 1.22rem;
    }
   .s2 {
      background-image: url(@/static/image/question.png);
   }
    .r-top {
      font-size: 40rpx !important;
      margin: 10rpx 0;
    }
  }
}
   .s3 {
      background-image: url(@/static/image/question.png);
   }
.login {
  width: 0.52rem;
  height: 0.52rem;
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.19rem;
  background: url(@/static/image/logo.png) no-repeat 0 0;
  background-size: 100% 100%;
}
   .container {
      background: url(@/static/image/bg1.png);
      width: 100vw;
      height: 100vh;
.rrr {
  position: absolute;
  right: 0.53rem;
  bottom: 0.36rem;
  width: 2.5rem;
  height: 3.07rem;
  opacity: 1;
  background: url(@/static/image/bg4.png);
  background-size: 100% 100%;
}
      color: #fff;
.hua {
  width: 13.81rem;
  height: 5.965rem;
  position: absolute;
  background: url(@/static/image/bg3.png) no-repeat 0 0;
  background-size: 100% 100%;
}
      .repository {
         width: 100% !important;
         /* margin-top: 19px; */
         /* height: 68%; */
         display: flex;
         flex-direction: column;
         justify-content: space-around;
         align-items: center;
/* 底部人物背景图  */
.fff {
  background: url(@/static/image/bg2.png) no-repeat 0 0;
  background-size: 100% 100%;
  width: 2.74rem;
  height: 4.52rem;
  position: fixed;
  bottom: 0;
  z-index: 9999999999999;
  left: 0;
}
         .Ttop {
            margin-top: .38rem;
            margin-bottom: 1.22rem;
         }
::v-deep .uni-easyinput__content {
  border-radius: 30rpx !important;
  /* height: 52rpx; */
}
         .r-top {
            font-size: 40rpx !important;
            margin: 10rpx 0;
         }
      }
.secretary {
  width: 1300rpx !important;
  height: 50rpx;
  /* height: 80%; */
  /* flex-wrap: wrap; */
  padding: 0 20px;
  text-align: center;
   }
  li {
    background-color: #fff;
    color: black;
    height: 600rpx;
    display: flex;
    justify-content: space-between;
    flex-direction: column;
    align-items: center;
    border: 1rpx solid #fff;
    padding: 50rpx 65rpx;
    /*          padding: 58rpx 128rpx 88rpx; */
    text-align: center;
    background: #ebf4ff;
  }
}
   .login {
      width: .52rem;
      height: .52rem;
      display: inline-block;
      vertical-align: middle;
      margin-right: .19rem;
      background: url(@/static/image/logo.png) no-repeat 0 0;
      background-size: 100% 100%;
   }
   .rrr {
      position: absolute;
      right: .53rem;
      bottom: .36rem;
      width: 2.5rem;
      height: 3.07rem;
      opacity: 1;
      background: url(@/static/image/bg4.png);
      background-size: 100% 100%;
   }
   .hua {
      width: 13.81rem;
      height: 5.965rem;
      position: absolute;
      background: url(@/static/image/bg3.png) no-repeat 0 0;
      background-size: 100% 100%;
   }
   /* 底部人物背景图  */
   .fff {
      background: url(@/static/image/bg2.png) no-repeat 0 0;
      background-size: 100% 100%;
      width: 2.74rem;
      height: 4.52rem;
      position: fixed;
      bottom: 0;
      z-index: 9999999999999;
      left: 0;
   }
   ::v-deep .uni-easyinput__content {
      border-radius: 30rpx !important;
      /* height: 52rpx; */
   }
   .secretary {
      width: 1300rpx !important;
      height: 50rpx;
      /* height: 80%; */
      /* flex-wrap: wrap; */
      padding: 0 20px;
      text-align: center;
      li {
         background-color: #fff;
         color: black;
         height: 600rpx;
         display: flex;
         justify-content: space-between;
         flex-direction: column;
         align-items: center;
         border: 1rpx solid #fff;
         padding: 50rpx 65rpx;
         /*          padding: 58rpx 128rpx 88rpx; */
         text-align: center;
         background: #EBF4FF;
      }
   }
   .Bbottom {
      display: flex;
      justify-content: center;
   }
</style>
.Bbottom {
  display: flex;
  justify-content: center;
}
</style>