safe-pass.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <view class="body">
  3. <view class="header-bg">
  4. </view>
  5. <view class="header">
  6. <view class="title">
  7. 设置安全密码
  8. </view>
  9. </view>
  10. <view class="main">
  11. <view class="input-item inline-form">
  12. <label class="label" for="">手机号码</label>
  13. <input class="input" type="text" placeholder="" v-model="form.mobile" disabled="true">
  14. </view>
  15. <view class="input-item inline-form">
  16. <label class="label" for="">验证码</label>
  17. <input class="input" type="text" placeholder="请输入验证码">
  18. <button class="send-vcode" @tap="sendSms()"
  19. :disabled="!sendable">{{sendable?'获取验证码':countdown+'秒'}}</button>
  20. </view>
  21. <view class="input-item inline-form">
  22. <label class="label" for="">新密码</label>
  23. <input class="input" type="password" placeholder="请输入新密码" maxlength="6">
  24. </view>
  25. <view class="input-item inline-form">
  26. <label class="label" for="">确认密码</label>
  27. <input class="input" type="password" placeholder="请输入新密码" maxlength="6">
  28. </view>
  29. </view>
  30. <view style="margin: 10upx 40upx;font-size: 26upx;color: red;">*安全密码必须为6位数字</view>
  31. <view class="submit-btn-wrapper">
  32. <button class="btn submit-btn" type="default">确认修改</button>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. let timeInterval = null;
  38. const time = 120;
  39. export default {
  40. data() {
  41. return {
  42. sendable: true,
  43. countdown: time,
  44. form: {
  45. mobile: ""
  46. }
  47. }
  48. },
  49. onLoad() {
  50. this.form.mobile = this.$store.state.user.mobile
  51. },
  52. methods: {
  53. sendSms() {
  54. if (this.sendable && this.$verified.mobile(this.form.mobile)) {
  55. this.sendable = false;
  56. this.$http.get({
  57. url: '/sms/send',
  58. data: {
  59. mobile: this.form.mobile,
  60. event: "bind-alipay"
  61. },
  62. success: (res) => {
  63. uni.showToast({
  64. title: res.data.msg,
  65. icon: "none"
  66. })
  67. timeInterval = setInterval(() => {
  68. if (this.countdown-- === 0) {
  69. clearInterval(timeInterval)
  70. this.countdown = time;
  71. this.sendable = true;
  72. }
  73. }, 1000)
  74. },
  75. fail: () => {
  76. this.sendable = true;
  77. }
  78. })
  79. }
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .body {
  86. position: relative;
  87. overflow: hidden;
  88. }
  89. .header-bg {
  90. background: $primary-color;
  91. height: 100upx;
  92. position: absolute;
  93. top: 0;
  94. width: 100%;
  95. }
  96. .header {
  97. margin: 20upx;
  98. background: white;
  99. text-align: center;
  100. border-radius: 20upx;
  101. position: relative;
  102. z-index: 1;
  103. .title {
  104. height: 100upx;
  105. font-size: 32upx;
  106. line-height: 100upx;
  107. // font-weight: bold;
  108. }
  109. }
  110. .main {
  111. margin: 20upx;
  112. background: white;
  113. border-radius: 10upx;
  114. }
  115. .input-item.inline-form {
  116. display: flex;
  117. align-items: center;
  118. height: 80upx;
  119. font-size: 28upx;
  120. padding: 0 20upx;
  121. position: relative;
  122. color: #999999;
  123. .label {
  124. width: 160upx;
  125. // flex: 1 1 160upx;
  126. }
  127. .input {
  128. flex-grow: 1;
  129. font-size: 28upx;
  130. }
  131. }
  132. .send-vcode {
  133. background: $primary-color;
  134. color: white;
  135. font-size: 24upx;
  136. position: absolute;
  137. padding: 5upx 0;
  138. width: 160upx;
  139. line-height: normal;
  140. right: 0upx;
  141. top: 20upx;
  142. }
  143. .submit-btn-wrapper {
  144. margin-top: 80upx;
  145. .submit-btn {
  146. font-size: 30upx;
  147. line-height: 60upx;
  148. width: 250upx;
  149. background: $primary-color;
  150. color: white;
  151. }
  152. }
  153. </style>