editSecurityPass.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <script>
  2. import { mapState } from 'vuex'
  3. import api from '@/api'
  4. export default {
  5. data() {
  6. return {
  7. tips: '',
  8. passVisible: false,
  9. form: {
  10. phone: '',
  11. password: '',
  12. code: ''
  13. }
  14. }
  15. },
  16. computed: {
  17. ...mapState({
  18. user(state) {
  19. this.form.phone = state.user.mobile
  20. return state.user
  21. }
  22. })
  23. },
  24. methods: {
  25. async sendCode() {
  26. if (!this.form.phone) return
  27. await api.sendCode({ type: 'securitypass', mobile: this.form.phone })
  28. this.$refs.uCode.start()
  29. },
  30. async edit() {
  31. await api.editSecurityPass({
  32. ...this.form,
  33. password: this.$common.Encryption(this.form.password)
  34. })
  35. this.$common.toast('设置成功')
  36. setTimeout(() => {
  37. this.$common.back()
  38. }, 1000)
  39. }
  40. }
  41. }
  42. </script>
  43. <template>
  44. <view class="page bg-white">
  45. <view class="main">
  46. <input
  47. type="text"
  48. v-model="form.phone"
  49. :disabled="JSON.stringify(user) !== '{}'"
  50. class="input"
  51. placeholder="请输入手机号"
  52. placeholder-style="color:#a9a9a9"
  53. />
  54. <u-input
  55. v-model="form.code"
  56. placeholder="输入验证码"
  57. placeholderStyle="color:#a9a9a9"
  58. border="none"
  59. customStyle="width: 605rpx;height: 100rpx;background: #f7f7f7;border-radius: 50rpx;padding: 0 60rpx;box-sizing: border-box;"
  60. >
  61. <template slot="suffix">
  62. <u-code
  63. ref="uCode"
  64. seconds="59"
  65. startText="获取验证码"
  66. changeText="已发送(Xs)"
  67. @change="text => (tips = text)"
  68. ></u-code>
  69. <view class="code" :class="tips.includes('s') ? 'wait' : ''" @click="sendCode">
  70. {{ tips }}
  71. </view>
  72. </template>
  73. </u-input>
  74. <view class="tip">
  75. 提示:如若短信验证码发送成功,因运营商运营会稍有延迟,请确
  76. 定手机号码不在欠费状态,以及信号良好状态。如果一直没收到, 请联系客服。
  77. </view>
  78. <view class="flex flex-center">
  79. <view class="title">安全密码</view>
  80. <u-code-input v-model="form.password" mode="box" dot size="60rpx"></u-code-input>
  81. </view>
  82. </view>
  83. <u-button
  84. text="确定"
  85. color="var(--theme)"
  86. shape="circle"
  87. :disabled="!(form.phone && form.password && form.code)"
  88. customStyle="width:650rpx;height:98rpx; position:fixed;bottom:100rpx;left:50%;transform:translate(-50%)"
  89. @click="edit"
  90. ></u-button>
  91. </view>
  92. </template>
  93. <style lang="scss" scoped>
  94. .page {
  95. padding: 57rpx 46rpx 0;
  96. }
  97. .main {
  98. padding: 0 10rpx 0 25rpx;
  99. }
  100. .input {
  101. width: 605rpx;
  102. height: 100rpx;
  103. background: #f7f7f7;
  104. border-radius: 50rpx;
  105. padding: 0 60rpx;
  106. box-sizing: border-box;
  107. margin-bottom: 30rpx;
  108. text-align: left;
  109. &.pass {
  110. margin: 34rpx 0 31rpx;
  111. }
  112. }
  113. .passbox {
  114. position: relative;
  115. width: 605rpx;
  116. .eye {
  117. width: 32rpx;
  118. height: 32rpx;
  119. position: absolute;
  120. right: 63rpx;
  121. top: 50%;
  122. transform: translateY(-30%);
  123. }
  124. }
  125. .code {
  126. color: #637bf7;
  127. font-size: 28rpx;
  128. &.wait {
  129. color: var(--info);
  130. }
  131. }
  132. .tip {
  133. color: #f76363;
  134. font-size: 20rpx;
  135. margin: 26rpx 16rpx;
  136. }
  137. .title {
  138. color: #333333;
  139. font-size: 30rpx;
  140. font-weight: bold;
  141. margin-right: 20rpx;
  142. }
  143. /deep/.u-code-input__item {
  144. border: none !important;
  145. background-color: #f3f3f3;
  146. border-radius: 20rpx;
  147. }
  148. </style>