You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

142 lines
3.3 KiB

  1. <template>
  2. <view class="page">
  3. <l-title>修改密码</l-title>
  4. <l-input
  5. @input="setValue('password.oldPwd', $event)"
  6. :value="getValue('password.oldPwd')"
  7. password
  8. title="旧密码"
  9. />
  10. <l-input
  11. @input="setValue('password.newPwd', $event)"
  12. :value="getValue('password.newPwd')"
  13. password
  14. title="新密码"
  15. />
  16. <l-input
  17. @input="setValue('password.confirmPwd', $event)"
  18. :value="getValue('password.confirmPwd')"
  19. password
  20. title="确认输入"
  21. placeholder="请再次输入新密码"
  22. />
  23. <view class="margin-sm">新密码必须8-20位同时包含1.[大小写字母]、2[数字]、3[特殊符号!@@#$%^&*]</view>
  24. <view class="margin-sm text-red" v-if="strongFlag">您的密码不满足强度要求,请您先修改密码后再执行系统其他操作!</view>
  25. <view class="padding">
  26. <l-button @click="submit" size="lg" color="blue" class="block" block>确认修改</l-button>
  27. </view>
  28. <view class="padding" v-if="strongFlag">
  29. <l-button @click="logout" size="lg" color="red" class="block" block>退出</l-button>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import get from 'lodash/get'
  35. import set from 'lodash/set'
  36. import customPageMixins from '@/common/custompage.js'
  37. export default {
  38. mixins: [customPageMixins],
  39. data() {
  40. return {
  41. strongFlag:false,
  42. // 表单数据
  43. current: {},
  44. origin: {},
  45. // 表单项数据结构
  46. scheme: {
  47. password:{
  48. oldPwd: { type: 'text',title:'旧密码',verify:'NotNull' },
  49. newPwd: { type: 'text',title:'新密码',verify:'NotNull' },
  50. confirmPwd: { type: 'text',title:'确认密码',verify:'NotNull' },
  51. }
  52. },
  53. }
  54. },
  55. async onLoad({}){
  56. await this.init();
  57. },
  58. methods: {
  59. async init(){
  60. //判断是否是验证强密码打开的页面
  61. console.log(this.GET_STORAGE('pwd'))
  62. if(this.GET_STORAGE('pwd') == true){
  63. this.strongFlag=true
  64. }
  65. this.origin = await this.getDefaultForm()
  66. this.current=this.COPY(this.origin)
  67. },
  68. // 提交修改
  69. async submit() {
  70. const verifyResult = this.verifyForm()
  71. if (verifyResult.length > 0) {
  72. this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  73. return
  74. }
  75. const postData = await this.getPostData()
  76. const postVal = JSON.parse(postData.strEntity)
  77. var reg = /^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%^&*,\.])[0-9a-zA-Z!@#$%^&*,\.]{8,20}$/;
  78. if(!reg.test(postVal.newPwd)){
  79. this.TOAST('新密码不满足强度要求');
  80. return ;
  81. }
  82. if(postVal.newPwd != postVal.confirmPwd){
  83. this.TOAST('新密码和确认密码输入不一致');
  84. return ;
  85. }
  86. const success = await this.HTTP_POST(
  87. 'learun/adms/user/modifypw',
  88. {
  89. newpassword: this.MD5(postVal.newPwd),
  90. oldpassword: this.MD5(postVal.oldPwd)
  91. },
  92. '未能成功修改密码'
  93. )
  94. if (!success) {
  95. return
  96. }
  97. // this.NAV_BACK()
  98. this.TOAST('密码修改成功')
  99. this.CLEAR_GLOBAL()
  100. this.RELAUNCH_TO('/pages/login')
  101. },
  102. // 点击「注销登录」按钮
  103. async logout() {
  104. if (!(await this.CONFIRM('注销确认', '确定要注销登录吗?', true))) {
  105. return
  106. }
  107. this.CLEAR_GLOBAL()
  108. this.RELAUNCH_TO('/pages/login')
  109. },
  110. // 获取表单值
  111. getValue(path) {
  112. return get(this.current, path)
  113. },
  114. // 设置表单值
  115. setValue(path, val) {
  116. set(this.current, path, val)
  117. } ,
  118. }
  119. }
  120. </script>