editPassword.vue 6.0 KB

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