changePassword.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <!-- 修改密码 -->
  2. <template>
  3. <view id="register">
  4. <view class="register_li">
  5. <view class="register_li_min">
  6. <view>原密码:</view>
  7. <input v-model="form.oldPassword" @blur="verifyOldPassword()" type="text" placeholder="请输入原密码">
  8. </view>
  9. <view class="register_li_min">
  10. <view>新密码:</view>
  11. <input v-model="form.newPassword" @blur="verify()" type="text" placeholder="请输入原密码">
  12. </view>
  13. <view class="register_li_min" style="border-bottom:0;">
  14. <view>确认密码:</view>
  15. <input @blur="affirm()" v-model="repassword" type="text" placeholder="请再次确认密码">
  16. </view>
  17. </view>
  18. <view class="sub_btn" @click="submitForm()">提交</view>
  19. </view>
  20. </template>
  21. <script>
  22. import {updatePwd} from '@/api/apiDemo/index.js'
  23. import { config } from '@/api/request/config.js'
  24. export default {
  25. data() {
  26. return {
  27. form:{
  28. oldPassword:'',
  29. newPassword:'',
  30. },
  31. repassword:'',
  32. }
  33. },
  34. onLoad(option) {
  35. },
  36. onShow(){
  37. },
  38. methods: {
  39. //校验特殊字符
  40. verify(){
  41. if(!this.form.oldPassword){
  42. uni.showToast({
  43. title: '请先输入原密码',
  44. icon:"none",
  45. mask:true,
  46. duration: 2000
  47. });
  48. this.form.newPassword='';
  49. return
  50. }
  51. if(this.form.newPassword.length<6 || this.form.newPassword.length>16){
  52. uni.showToast({
  53. title: '原密码不能超出16位、不能低于6位',
  54. icon:"none",
  55. mask:true,
  56. duration: 2000
  57. });
  58. this.form.newPassword='';
  59. return
  60. }
  61. let reg=/[\u4E00-\u9FA5]|[\uFE30-\uFFA0]|[`~!#$%^&*()_\+=<>?:"{}|~!#¥%……&*()={}|《》?:“”【】、;‘’,。、\s+]/;
  62. let aa= reg.test(this.form.newPassword)
  63. if(reg.test(this.form.newPassword)){
  64. uni.showToast({
  65. title: '密码中有中文,空格或特殊字符,请重新输入',
  66. icon:"none",
  67. mask:true,
  68. duration: 2000
  69. });
  70. this.form.newPassword='';
  71. }
  72. },
  73. affirm(){
  74. if(this.form.newPassword===this.repassword){
  75. }else{
  76. uni.showToast({
  77. title: '两次密码不一样,请重新输入',
  78. icon:"none",
  79. mask:true,
  80. duration: 2000
  81. });
  82. this.repassword='';
  83. return
  84. }
  85. },
  86. //校验老的密码
  87. async verifyOldPassword(){
  88. if(!this.form.oldPassword){
  89. uni.showToast({
  90. title: '请输入原密码',
  91. icon:"none",
  92. mask:true,
  93. duration: 2000
  94. });
  95. return
  96. }
  97. },
  98. async submitForm(){
  99. if(!this.form.oldPassword){
  100. uni.showToast({
  101. title: '请输入原密码',
  102. icon:"none",
  103. mask:true,
  104. duration: 2000
  105. });
  106. return
  107. }
  108. if(!this.form.newPassword){
  109. uni.showToast({
  110. title: '请输入新密码',
  111. icon:"none",
  112. mask:true,
  113. duration: 2000
  114. });
  115. return
  116. }
  117. if(!this.repassword){
  118. uni.showToast({
  119. title: '请输入确认密码',
  120. icon:"none",
  121. mask:true,
  122. duration: 2000
  123. });
  124. return
  125. }
  126. const {data} = await updatePwd(this.form);
  127. if(data.code == 200){
  128. uni.showToast({
  129. title: '修改成功!',
  130. icon:"none",
  131. mask:true,
  132. duration: 2000
  133. });
  134. setTimeout(function(){
  135. uni.redirectTo({
  136. url: '/pages/login',
  137. });
  138. },2000);
  139. }
  140. },
  141. }
  142. }
  143. </script>
  144. <style lang="stylus" scoped>
  145. #register{
  146. height:100%;
  147. width:100%;
  148. display flex
  149. flex-direction column;
  150. .register_li{
  151. background #fff;
  152. padding:20rpx 0;
  153. box-sizing: border-box;
  154. .register_li_min{
  155. margin:0 26rpx;
  156. display flex;
  157. align-items center;
  158. border-bottom: 1px solid #F5F5F5;
  159. view{
  160. line-height:100rpx;
  161. font-size: 28rpx;
  162. font-family: PingFang SC;
  163. font-weight: 500;
  164. color: #333333;
  165. }
  166. >input{
  167. flex:1;
  168. text-align: right;
  169. font-size: 24rpx;
  170. font-family: PingFang SC;
  171. font-weight: 500;
  172. color: #CCCCCC;
  173. }
  174. }
  175. }
  176. /* 按钮 */
  177. .sub_btn{
  178. width: 650rpx;
  179. height: 100rpx;
  180. background: #0183FA;
  181. border-radius: 20rpx;
  182. font-size: 28rpx;
  183. font-family: PingFang SC;
  184. font-weight: 500;
  185. color: #FFFFFF;
  186. line-height: 100rpx;
  187. text-align: center;
  188. margin-left: 50rpx;
  189. position: fixed;
  190. bottom:30rpx;
  191. z-index: 1000;
  192. }
  193. }
  194. /deep/.input-value-border{
  195. display :none !important;
  196. }
  197. </style>