userpwd.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. <button class='cu-btn bg-blue shadow'@click="getCode" v-if="show">验证码</button>
  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. this.$http.get(this.userUrl,{params:{email:this.name,type:1}}).then(res=>{
  80. console.log(res)
  81. if (res.data != "0"&&res.data != 0) {
  82. this.$tip.success('发送成功!')
  83. this.times = 60;
  84. this.show = false
  85. this.timer = setInterval(() => {
  86. this.times--
  87. if (this.times === 0) {
  88. this.show = true
  89. clearInterval(this.timer)
  90. }
  91. }, 1000)
  92. } else {
  93. this.$tip.alert('发送失败!')
  94. }
  95. }).catch(err => {
  96. console.log(err);
  97. });
  98. },
  99. save:function(){
  100. if(this.name==null ||this.name==""){
  101. this.$tip.alert("邮箱不能为空");
  102. return false;
  103. }
  104. if(this.code==null ||this.code==""){
  105. this.$tip.alert("邮箱验证码不能为空");
  106. return false;
  107. }if(this.pwd==null ||this.pwd==""){
  108. this.$tip.alert("新密码不能为空");
  109. return false;
  110. }if(this.pwds==null ||this.pwds==""){
  111. this.$tip.alert("确认密码不能为空");
  112. return false;
  113. }if(this.pwd!=this.pwds){
  114. this.$tip.alert("两次密码不一致");
  115. return false;
  116. }
  117. 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=>{
  118. console.log(res);
  119. if(res.data.success=="true" ||res.data.success==true){
  120. this.$Router.push({name:'suecss'})
  121. }else{
  122. this.$tip.alert("修改失败");
  123. }
  124. }).catch(err => {
  125. console.log(err);
  126. });
  127. /* this.$Router.push({name:'suecss'}) */
  128. }
  129. }
  130. }
  131. </script>
  132. <style>
  133. .dt{
  134. background-color: #FFFFFF;
  135. width: 90%;
  136. margin: 0 auto;
  137. margin-top: 20px;
  138. }
  139. ul li{
  140. list-style-type:none;
  141. }
  142. .img{
  143. width: 25px;
  144. height: 25px;
  145. background-size:100% 100%;
  146. }
  147. .imgs{
  148. width: 20px;
  149. height: 20px;
  150. background-size:100% 100%;
  151. }
  152. </style>