userpwd.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div>
  3. <cu-custom bgColor="bg-gradual-pink" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content">修改密码</block>
  6. </cu-custom>
  7. <div class="dt">
  8. <ul style="margin-left: -45px;">
  9. <view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.1s'}]">
  10. <li >
  11. <view class="cu-form-group" >
  12. <view class="title" style="margin-top: 10px;"><image src="../../static/eml.png" class="imgs"></image></view>
  13. <input placeholder="请输入邮箱" v-model="name" ></input>
  14. </view>
  15. <div style="width: 100%; height: 1px; border-top: solid #ACC0D8 1px;"></div>
  16. </li>
  17. </view>
  18. <view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.2s'}]">
  19. <li >
  20. <view class="cu-form-group" >
  21. <view class="title" style="margin-top: 10px;"><image src="../../static/yzm.png" class="imgs"></image></view>
  22. <input placeholder="邮箱验证码" v-model="code" ></input>
  23. <span style="float: right;color: #0081FF;font-size: 15px;" @click="getCode" v-if="show">获取验证码</span>
  24. <span v-if="!show" style="color: #D7D9E0;float: right;font-size: 15px;">已发送({{ times }})</span>
  25. </view>
  26. <div style="width: 100%; height: 1px; border-top: solid #ACC0D8 1px;"></div>
  27. </li>
  28. </view>
  29. <view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.3s'}]">
  30. <li >
  31. <view class="cu-form-group" >
  32. <view class="title"><image src="../../static/emlpwd.png" class="img"></image></view>
  33. <input placeholder="填写新密码" v-model="pwd" type="password" style="margin-top: -7px;"></input>
  34. </view>
  35. <div style="width: 100%; height: 1px; border-top: solid #ACC0D8 1px;"></div>
  36. </li>
  37. </view>
  38. <view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.4s'}]">
  39. <li >
  40. <view class="cu-form-group" >
  41. <view class="title"><image src="../../static/emlpwd.png" class="img"></image></view>
  42. <input placeholder="确认新密码" v-model="pwds"type="password" style="margin-top: -7px;"></input>
  43. </view>
  44. </li>
  45. </view>
  46. </ul>
  47. </div>
  48. <br>
  49. <view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.5s'}]">
  50. <button style="background-color: #3C7AD8;color: #FFFFFF; width: 90%;" @click="save()">确定</button>
  51. <br>
  52. <div style="text-align: center;">
  53. <span style="color: #A3A7B1;">本操作将会重置您的登录密码,&nbsp;请牢记您的新密码</span>
  54. </div>
  55. </view>
  56. </div>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. name:null,
  63. code:null,
  64. pwd:null,
  65. pwds:null,
  66. times: 60,
  67. show:true,
  68. userUrl:'/sys/user/sendEamilCode',
  69. userpwdUrl:'/sys/user/userpwd'
  70. }
  71. },
  72. methods:{
  73. getCode() {
  74. let checkEmail = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/;
  75. if(this.name==""||this.name==null){
  76. this.$tip.alert("邮箱不能为空");
  77. return false;
  78. }
  79. if (!checkEmail.test(this.name)) {
  80. this.$tip.alert('请输入正确的邮箱地址');
  81. return false
  82. }
  83. this.$http.get(this.userUrl,{params:{email:this.name,type:1}}).then(res=>{
  84. console.log(res)
  85. if (res.data.msg == "1") {
  86. this.$tip.success('发送成功!')
  87. this.times = 60;
  88. this.show = false
  89. this.timer = setInterval(() => {
  90. this.times--
  91. if (this.times === 0) {
  92. this.show = true
  93. clearInterval(this.timer)
  94. }
  95. }, 1000)
  96. } else {
  97. this.$tip.alert('发送失败!')
  98. }
  99. }).catch(err => {
  100. console.log(err);
  101. });
  102. },
  103. save:function(){
  104. if(this.name==null ||this.name==""){
  105. this.$tip.alert("邮箱不能为空");
  106. return false;
  107. }
  108. if(this.code==null ||this.code==""){
  109. this.$tip.alert("邮箱验证码不能为空");
  110. return false;
  111. }if(this.pwd==null ||this.pwd==""){
  112. this.$tip.alert("新密码不能为空");
  113. return false;
  114. }if(this.pwds==null ||this.pwds==""){
  115. this.$tip.alert("确认密码不能为空");
  116. return false;
  117. }if(this.pwd!=this.pwds){
  118. this.$tip.alert("两次密码不一致");
  119. return false;
  120. }
  121. this.$http.get(this.userpwdUrl,{params:{password:this.pwd,username:this.$store.getters.username,email:this.name,emailCode:this.code,userId:this.$store.getters.userid}}).then(res=>{
  122. console.log(res);
  123. if(res.data.success=="true" ||res.data.success==true){
  124. this.$Router.push({name:'suecss'})
  125. }else{
  126. this.$tip.alert("修改失败");
  127. }
  128. }).catch(err => {
  129. console.log(err);
  130. });
  131. /* this.$Router.push({name:'suecss'}) */
  132. }
  133. }
  134. }
  135. </script>
  136. <style>
  137. .dt{
  138. background-color: #FFFFFF;
  139. width: 90%;
  140. margin: 0 auto;
  141. margin-top: 20px;
  142. }
  143. ul li{
  144. list-style-type:none;
  145. }
  146. .img{
  147. width: 25px;
  148. height: 25px;
  149. background-size:100% 100%;
  150. }
  151. .imgs{
  152. width: 20px;
  153. height: 20px;
  154. background-size:100% 100%;
  155. }
  156. </style>