index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <div class="uc_edit_container">
  3. <div class="main_content text-center">
  4. <img src="https://img.shuimuai.com/sign_phone_shuimu.png" class="main_icon" alt="">
  5. <view class="solid-bottom text-xl padding">
  6. <text class="text-black text-bold">验证当前手机号 {{ phone }}</text>
  7. </view>
  8. <view class=" text-sm">
  9. <text class="text-gray sub-title">为了你的账号安全,请输入验证码</text>
  10. </view>
  11. <van-field
  12. :value="sms"
  13. center
  14. clearable
  15. label="短信验证码"
  16. placeholder="请输入短信验证码"
  17. use-button-slot
  18. :custom-style=custom_style
  19. @change="inputSms"
  20. :maxlength="6"
  21. >
  22. <van-button slot="button" size="small" type="primary" @click="sand_sms"
  23. class="flex"
  24. v-if="time_show==false"
  25. >
  26. <text>发送验证码</text>
  27. </van-button>
  28. <view v-else slot="button" class="flex align-center">
  29. <van-count-down v-if="time_show" :auto-start="time_start" class="control-count-down" @finish="time_finished"
  30. :time="time_count * 1000" format="ss"/>
  31. <text>后发送验证码</text>
  32. </view>
  33. </van-field>
  34. <div class="padding bottom_button">
  35. <button class="cu-btn lg cu-btn-primary text-white text-center " @click="to_finally_confirm">确定修改</button>
  36. </div>
  37. </div>
  38. <van-toast id="van-toast"/>
  39. </div>
  40. </template>
  41. <script>
  42. import Toast from '../../../../../static/vant/toast/toast';
  43. import {userGetCode, userCheckCode} from "@/requests/user";
  44. var $this
  45. export default {
  46. name: "uc_edit_container",
  47. components: {},
  48. data() {
  49. return {
  50. base_phone: "",
  51. phone: "",
  52. sms: "",
  53. custom_style: `width: 330px;
  54. height: 49px;
  55. background: rgba(242, 243, 255, 0.6);
  56. box-shadow: 0px 3px 7px 0px rgba(159, 159, 159, 0.84);
  57. border-radius: 10px;
  58. margin: 30px auto;
  59. `,
  60. time_show: false,
  61. time_start: false,
  62. time_count: 60
  63. }
  64. },
  65. methods: {
  66. //假隐藏
  67. cut_phone($val) {
  68. let start = $val.slice(0, 4);
  69. let end = $val.slice(-2);
  70. return start + '******' + end;
  71. },
  72. inputSms($val) {
  73. $this.sms = $val.mp.detail
  74. },
  75. // 发送验证码
  76. sand_sms() {
  77. Toast.loading({
  78. duration: 0
  79. })
  80. let $param = {
  81. phone: $this.base_phone
  82. }
  83. userGetCode($param).then((res) => {
  84. Toast.clear()
  85. let $data = res.data
  86. $this.start_count_down()
  87. Toast.success($data.errmsg)
  88. })
  89. },
  90. //跳转最终修改手机的页面
  91. to_finally_confirm() {
  92. Toast.loading({
  93. duration: 0
  94. })
  95. let $params = {phone: $this.base_phone, code: $this.sms}
  96. userCheckCode($params).then((res) => {
  97. Toast.clear()
  98. let $data = res.data
  99. if ($data.code == 0) {
  100. Toast.success({
  101. message: $data.errmsg,
  102. onClose() {
  103. mpvue.navigateTo({
  104. url: "/pages/user_center/edit/confirm_phone_finally/main"
  105. })
  106. }
  107. })
  108. } else {
  109. Toast.fail($data.errmsg)
  110. }
  111. })
  112. },
  113. start_count_down() {
  114. $this.time_count = 60
  115. $this.time_start = $this.time_show = true
  116. },
  117. time_finished() {
  118. $this.time_start = $this.time_show = false
  119. }
  120. }
  121. ,
  122. mounted() {
  123. let $userinfo = wx.getStorageSync('userinfo')
  124. $this.phone = $this.base_phone = $userinfo['phone']
  125. $this.phone = $this.cut_phone($this.phone)
  126. },
  127. created() {
  128. $this = this;
  129. },
  130. onLoad() {
  131. }
  132. }
  133. </script>
  134. <style scoped>
  135. @import "index.css";
  136. </style>