editPass.vue 3.5 KB

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