phone.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view>
  3. <u-navbar title="修改手机号"></u-navbar>
  4. <view class="login-form">
  5. <view class="login-form-item">
  6. <view class="input">
  7. <u-input v-model="form.telephone" type="number" placeholder="请输入手机号" placeholder-style="font-size:16px;color:#ccc;"/>
  8. </view>
  9. </view>
  10. <view class="login-form-item">
  11. <view class="input">
  12. <view class="code" @click="getCode">{{codeTips}}</view>
  13. <u-input v-model="form.verifyCode" type="number" placeholder="请输入验证码" placeholder-style="font-size:16px;color:#ccc;"/>
  14. </view>
  15. </view>
  16. </view>
  17. <u-button class="login-btn" type="success" shape="circle" @click="sure">确定修改</u-button>
  18. <u-verification-code :seconds="sendMsgSecond" ref="uCode" @change="codeChange" @end="end" @start="start" change-text="已发送(XS)">
  19. </u-verification-code>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. checkPhone
  25. } from '@/utils'
  26. export default {
  27. data() {
  28. return {
  29. form: {
  30. telephone: '',
  31. verifyCode: '',
  32. },
  33. isSendMsgIng: false,
  34. sendMsgSecond: 60,
  35. codeTips: '',
  36. }
  37. },
  38. methods: {
  39. codeChange(text) {
  40. this.codeTips = text;
  41. },
  42. start() {
  43. if (!this.isSendMsgIng) {
  44. uni.showLoading({
  45. title: "加载中",
  46. mask: true,
  47. })
  48. loginApi.getVerifyCode(this.form.telephone).then((response) => {
  49. uni.hideLoading();
  50. this.carhelp.set("getvcodetime", new Date().getTime());
  51. if (!"") {
  52. //倒计时
  53. uni.showToast({
  54. title: "发送成功"
  55. })
  56. } else {
  57. uni.showToast({
  58. title: "您的验证码已经发送[5分钟有效],请勿重复点击"
  59. })
  60. }
  61. }).catch(error => {
  62. uni.showToast({
  63. title: error,
  64. icon: "none"
  65. })
  66. })
  67. }
  68. },
  69. //倒计时
  70. end() {
  71. this.sendMsgSecond = 60;
  72. this.isSendMsgIng = false;
  73. },
  74. // 获取验证码
  75. getCode() {
  76. if (this.$refs.uCode.canGetCode) {} else {
  77. uni.showToast({
  78. title: '倒计时结束后再发送',
  79. icon: "none"
  80. })
  81. return
  82. }
  83. var checkPhoneResult = checkPhone(this.form.telephone);
  84. if (checkPhoneResult !== true) {
  85. uni.showToast({
  86. title: checkPhoneResult,
  87. })
  88. return;
  89. }
  90. this.$refs.uCode.start();
  91. },
  92. sure() {
  93. var checkPhoneResult = checkPhone(this.form.telephone);
  94. if(!this.form.telephone || checkPhoneResult != true) {
  95. uni.showToast({
  96. title: checkPhoneResult,
  97. icon: "none"
  98. })
  99. return;
  100. }
  101. if(!this.form.verifyCode) {
  102. uni.showToast({
  103. title: "请输入验证码",
  104. icon: "none"
  105. })
  106. return
  107. }
  108. // uni.showLoading({
  109. // title: "加载中",
  110. // mask: true,
  111. // })
  112. // loginApi.validateCode({
  113. // verifyCode: this.form.verifyCode,
  114. // telephone: this.form.telephone,
  115. // }).then((response) => {
  116. // uni.hideLoading();
  117. uni.redirectTo({
  118. url: '/pages/login/login'
  119. })
  120. // }).catch(error => {
  121. // uni.showToast({
  122. // title: error,
  123. // icon: "none"
  124. // })
  125. // })
  126. }
  127. }
  128. }
  129. </script>
  130. <style>
  131. page{
  132. background-color: #fff;
  133. }
  134. </style>
  135. <style lang="scss" scoped>
  136. .login-form{
  137. background-color: #fff;
  138. padding: 12px 28px;
  139. }
  140. .login-form-item{
  141. .title{
  142. margin-bottom: 8px;
  143. }
  144. .input {
  145. padding: 4px 0;
  146. border-bottom: 1px solid #f7f7f7;
  147. position: relative;
  148. }
  149. .code{
  150. position: absolute;
  151. right: 0;
  152. top:12px;
  153. color:#1677FF;
  154. }
  155. .tips {
  156. color: $u-type-info;
  157. margin-top: 12px;
  158. font-size: 12px;
  159. span{
  160. color:#3fbd70;
  161. }
  162. }
  163. }
  164. .login-btn {
  165. margin: 28px ;
  166. background-color:#00B962!important;
  167. border-color: #00B962!important;
  168. color:#fff!important;
  169. }
  170. </style>