pwd.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view>
  3. <uni-nav-bar id="nav-bar" status-bar="true" @clickLeft="onBack()" :title="bModifyPassword?'修改密码':'设置密码'" color="#000000" fixed="true"
  4. :border="false">
  5. <view slot="left">
  6. <view class=" flex align-center margin-left">
  7. <image class="p-left-arrow" src="../../../static/p-left-arrow.png"></image>
  8. </view>
  9. </view>
  10. <view slot="right">
  11. <view class="make-text-bPurple text-regular margin-right" @click="savePassword">保存</view>
  12. </view>
  13. </uni-nav-bar>
  14. <block v-if="bModifyPassword">
  15. <view class="card-view password-item flex justify-center ">
  16. <m-input style=" margin-left: 46rpx;" type="text" focus clearable v-model="account" placeholder="请输入手机号/邮箱">
  17. </m-input>
  18. </view>
  19. <view class="card-view password-item flex justify-center ">
  20. <m-input style=" margin-left: 46rpx;" type="password" maxlength="16" displayable v-model="oldPassword"
  21. placeholder="请输入旧密码">
  22. </m-input>
  23. </view>
  24. <view class="card-view password-item flex justify-center ">
  25. <m-input style=" margin-left: 46rpx;" type="password" maxlength="16" displayable v-model="newPassword"
  26. placeholder="请输入新密码">
  27. </m-input>
  28. </view>
  29. <view class="card-view password-item flex justify-center ">
  30. <m-input style=" margin-left: 46rpx;" type="password" maxlength="16" displayable v-model="confirmPassword"
  31. placeholder="请再次输入新密码">
  32. </m-input>
  33. </view>
  34. </block>
  35. <block v-else>
  36. <view class="card-view password-item flex justify-center ">
  37. <m-input style=" margin-left: 46rpx;" type="text" focus clearable v-model="account" placeholder="请输入手机号/邮箱">
  38. </m-input>
  39. </view>
  40. <view class="card-view cu-form-group ">
  41. <view style="width: 16rpx;"></view>
  42. <m-input type="number" focus clearable v-model="verificationCode" placeholder="请输入验证码">
  43. </m-input>
  44. <button class='cu-btn make-bg-bPurple shadow text-white'>获取验证码</button>
  45. </view>
  46. <view class="card-view password-item flex justify-center ">
  47. <m-input style=" margin-left: 46rpx;" type="password" maxlength="16" displayable v-model="newPassword"
  48. placeholder="请输入新密码">
  49. </m-input>
  50. </view>
  51. <view class="card-view password-item flex justify-center ">
  52. <m-input style=" margin-left: 46rpx;" type="password" maxlength="16" displayable v-model="confirmPassword"
  53. placeholder="请确认新密码">
  54. </m-input>
  55. </view>
  56. </block>
  57. <view class="text-red margin-xl text-regular">密码必须是6-18位字符,数字、字母、特殊字符 (不能是纯数字、字母的组合)</view>
  58. </view>
  59. </template>
  60. <script>
  61. import service from '../../../util/util-js/service.js';
  62. import mInput from '../../../components/m-input.vue';
  63. import verify from '../../../util/util-js/verify.js'
  64. export default {
  65. components: {
  66. mInput
  67. },
  68. data() {
  69. return {
  70. account: '',
  71. oldPassword: '',
  72. newPassword: '',
  73. confirmPassword: '',
  74. verificationCode: '',
  75. bModifyPassword:true
  76. }
  77. },
  78. onLoad(option) {
  79. //设置页面状态
  80. this.bModifyPassword = option.bModify?true:false;
  81. },
  82. methods: {
  83. onBack() {
  84. uni.navigateBack({
  85. delta: 1
  86. })
  87. },
  88. savePassword() {
  89. /**
  90. * 同时判断两个类型
  91. */
  92. if (!~this.account.indexOf('@') && !verify.checkPhone(this.account)) {
  93. uni.showToast({
  94. icon: 'none',
  95. title: '手机号不合法',
  96. });
  97. return;
  98. }else if(~this.account.indexOf('@') && !verify.checkEMail(this.account))
  99. {
  100. uni.showToast({
  101. icon: 'none',
  102. title: '邮箱地址不合法',
  103. });
  104. return;
  105. }
  106. if(this.verificationCode == ''
  107. || this.verificationCode == undefined
  108. || this.verificationCode == null){
  109. uni.showToast({
  110. icon: 'none',
  111. title: '输入验证码',
  112. });
  113. return;
  114. }
  115. if(!verify.checkPassword(this.newPassword)){
  116. uni.showToast({
  117. icon: 'none',
  118. title: '新的密码格式不合法',
  119. });
  120. return;
  121. }
  122. if(!verify.checkPassword(this.confirmPassword)){
  123. uni.showToast({
  124. icon: 'none',
  125. title: '确认的密码格式不合法',
  126. });
  127. return;
  128. }
  129. if(this.confirmPassword != this.newPassword){
  130. uni.showToast({
  131. icon: 'none',
  132. title: '请输入两个相同的密码',
  133. });
  134. return;
  135. }
  136. uni.showToast({
  137. icon: 'none',
  138. title: '已发送重置邮件至注册邮箱,请注意查收。',
  139. duration: 3000
  140. });
  141. //todo 处理新密码
  142. }
  143. }
  144. }
  145. </script>
  146. <style>
  147. .password-item {
  148. height: 100rpx;
  149. }
  150. .card-view{
  151. border-radius: 10px;
  152. }
  153. </style>