forgotPassword.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <!-- 忘记密码 -->
  2. <template>
  3. <view id="forgotPassword">
  4. <view class="page-title">忘记密码</view>
  5. <view class="input-max-box">
  6. <view>手机号</view>
  7. <input v-model="form.data1" maxlength="11" focus placeholder="请输入手机号码"/>
  8. </view>
  9. <view class="input-max-box">
  10. <view>学/工号</view>
  11. <input v-model="form.data2" maxlength="30" focus placeholder="请输入学/工号"/>
  12. </view>
  13. <view class="input-button-max-box">
  14. <view>手机验证码</view>
  15. <view class="input-button-box">
  16. <input maxlength="6" v-model="form.data3" focus placeholder="请输入手机验证码"/>
  17. <view @click="getCode()"
  18. :class="codeType?'checkButton':'noCheckButton'">
  19. {{codeType?seconds+'秒后重试':'获取验证码'}}
  20. </view>
  21. </view>
  22. </view>
  23. <view class="input-max-box">
  24. <view>新密码</view>
  25. <input type="password" maxlength="16" v-model="form.data4" focus placeholder="请输入新密码"/>
  26. </view>
  27. <view class="input-max-box">
  28. <view>确认新密码</view>
  29. <input type="password" maxlength="16" v-model="form.data5" focus placeholder="请再次输入确认密码"/>
  30. </view>
  31. <view class="bottom-button-box">
  32. <view @click="outButton()">稍后修改</view>
  33. <view @click="submitButton()">确定修改</view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. form:{
  42. phone:"",
  43. },
  44. codeType:false,
  45. seconds:0,
  46. timer:null,
  47. }
  48. },
  49. onLoad(option) {
  50. },
  51. onShow() {
  52. },
  53. methods: {
  54. //返回上级页面
  55. outButton(){
  56. uni.navigateBack();
  57. },
  58. //获取验证码
  59. getCode(){
  60. let self = this;
  61. const reg = /^1[3|4|5|7|8|9][0-9]\d{8}$/
  62. if(this.codeType){
  63. uni.showToast({
  64. title: '请稍后再试',
  65. icon: "none",
  66. duration: 3000
  67. });
  68. return
  69. }else if(!this.form.data1){
  70. uni.showToast({
  71. title: '请输入手机号码',
  72. icon: "none",
  73. duration: 3000
  74. });
  75. return
  76. }else if (!reg.test(this.form.data1)) {
  77. uni.showToast({
  78. title: '请输入正确的手机号码',
  79. icon: "none",
  80. duration: 3000
  81. });
  82. return
  83. }
  84. const TIME_COUNT = 60;
  85. this.$set(this,'codeType',true);
  86. if (!this.timer) {
  87. this.$set(this,'seconds',TIME_COUNT);
  88. this.timer = setInterval(() => {
  89. if (this.seconds > 1 && this.seconds <= TIME_COUNT) {
  90. this.seconds -= 1;
  91. } else {
  92. this.$set(this,'codeType',false);
  93. clearInterval(this.timer);
  94. this.$set(this,'timer',null);
  95. }
  96. }, 1000);
  97. }
  98. },
  99. //提交
  100. submitButton(){
  101. const reg = /^1[3|4|5|7|8|9][0-9]\d{8}$/
  102. const password = /^(?=(?:.*[A-Z]){1})(?=(?:.*[a-z]){1})(?=(?:.*[0-9]){1})(?=(?:.*[!@#*?&]){1})(?!(.)\1)(.{10,16})$/
  103. if(!this.form.data1){
  104. uni.showToast({
  105. title: '请输入手机号码',
  106. icon: "none",
  107. duration: 3000
  108. });
  109. return
  110. }else if (!reg.test(this.form.data1)) {
  111. uni.showToast({
  112. title: '请输入正确的手机号码',
  113. icon: "none",
  114. duration: 3000
  115. });
  116. return
  117. }else if(!this.form.data2){
  118. uni.showToast({
  119. title: '请输入学/工号',
  120. icon: "none",
  121. duration: 3000
  122. });
  123. return
  124. }else if(!this.form.data3){
  125. uni.showToast({
  126. title: '请输入手机验证码',
  127. icon: "none",
  128. duration: 3000
  129. });
  130. return
  131. }else if(!this.form.data4){
  132. uni.showToast({
  133. title: '请输入新密码',
  134. icon: "none",
  135. duration: 3000
  136. });
  137. return
  138. }else if(!this.form.data5){
  139. uni.showToast({
  140. title: '请再次输入确认密码',
  141. icon: "none",
  142. duration: 3000
  143. });
  144. return
  145. }else if(this.form.data4!=this.form.data5){
  146. uni.showToast({
  147. title: '新密码与确认新密码不一致',
  148. icon: "none",
  149. duration: 3000
  150. });
  151. return
  152. }else if(!password.test(this.form.data4)||!password.test(this.form.data5)){
  153. uni.showToast({
  154. title: '密码长度最少10位 最多16位,必须同时包含一个大写字母、一个小写字母、一个数字和一个特殊字符!@#*?&',
  155. icon: "none",
  156. duration: 5000
  157. });
  158. return
  159. }
  160. uni.showModal({
  161. title: '确认提交?',
  162. cancelColor: '#999999',
  163. confirmColor: '#0183FA',
  164. content: '',
  165. success(res) {
  166. if (res.confirm) {
  167. console.log('确定')
  168. } else if (res.cancel) {
  169. console.log('取消')
  170. }
  171. }
  172. })
  173. },
  174. },
  175. }
  176. </script>
  177. <style lang="stylus" scoped>
  178. #forgotPassword {
  179. height:100%;
  180. display: flex;
  181. flex-direction: column;
  182. flex:1;
  183. background-color: #FFFFFF;
  184. overflow-y: scroll;
  185. overflow-x: hidden;
  186. .page-title{
  187. line-height:120rpx;
  188. font-weight: 700;
  189. font-size: 34rpx;
  190. margin-left:30rpx;
  191. }
  192. .input-max-box{
  193. padding:0 30rpx;
  194. view{
  195. line-height: 80rpx;
  196. font-size:30rpx;
  197. font-weight:700;
  198. }
  199. input{
  200. width:630rpx;
  201. height:100rpx;
  202. line-height:100rpx;
  203. border-radius:10rpx;
  204. border:1px solid #D8D8D8;
  205. padding:0 30rpx;
  206. }
  207. }
  208. .input-button-max-box{
  209. padding:0 30rpx;
  210. view:nth-child(1){
  211. line-height: 80rpx;
  212. font-size:30rpx;
  213. font-weight:700;
  214. }
  215. .input-button-box{
  216. display: flex;
  217. input{
  218. width:412rpx;
  219. height:100rpx;
  220. line-height:100rpx;
  221. border-radius:10rpx;
  222. border:1px solid #D8D8D8;
  223. padding:0 30rpx;
  224. margin-right:18rpx;
  225. }
  226. view{
  227. width:200rpx;
  228. line-height:100rpx;
  229. text-align: center;
  230. font-size:30rpx;
  231. border-radius:10rpx;
  232. }
  233. .checkButton{
  234. color:#333;
  235. background-color: #E8E8E8;
  236. }
  237. .noCheckButton{
  238. color:#fff;
  239. background-color: #0183FA;
  240. }
  241. }
  242. }
  243. .bottom-button-box{
  244. display: flex;
  245. margin:43rpx 0;
  246. view{
  247. font-size:30rpx;
  248. line-height:100rpx;
  249. text-align: center;
  250. }
  251. view:nth-child(1){
  252. width:220rpx;
  253. margin:0 33rpx 0 30rpx;
  254. border-radius: 50rpx 50rpx 50rpx 50rpx;
  255. border: 1rpx solid #E0E0E0;
  256. }
  257. view:nth-child(2){
  258. width:437rpx;
  259. color:#fff;
  260. background: #0183FA;
  261. border-radius: 50rpx 50rpx 50rpx 50rpx;
  262. }
  263. }
  264. }
  265. </style>