index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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="+86"
  13. center
  14. label="国家"
  15. readonly
  16. :custom-style='custom_style'
  17. >
  18. </van-field>
  19. <van-field
  20. :value="new_phone"
  21. label="手机号"
  22. placeholder="请输入手机号"
  23. maxlength="11"
  24. error-message="手机号格式错误"
  25. :custom-style="custom_style"
  26. type="number"
  27. />
  28. <van-field
  29. :value="sms"
  30. center
  31. clearable
  32. label="短信验证码"
  33. placeholder="请输入短信验证码"
  34. use-button-slot
  35. :custom-style='custom_style'
  36. >
  37. <van-button slot="button" size="small" type="primary" @click="sand_sms"
  38. >发送验证码
  39. </van-button
  40. >
  41. </van-field>
  42. <div class="padding bottom_button">
  43. <button class="cu-btn lg cu-btn-primary text-white text-center " @click="confirm_modify">确定修改</button>
  44. </div>
  45. </div>
  46. <van-toast id="van-toast"/>
  47. </div>
  48. </template>
  49. <script>
  50. import Toast from '../../../../../static/vant/toast/toast';
  51. import {userChangePhone, userGetCode} from "../../../../requests/user";
  52. var $this
  53. export default {
  54. name: "uc_edit_container",
  55. components: {},
  56. data() {
  57. return {
  58. base_phone: "18802603801",
  59. phone: "18802603801",
  60. sms: "",
  61. custom_style: `width: 330px;
  62. height: 49px;
  63. background: rgba(242, 243, 255, 0.6);
  64. box-shadow: 0px 3px 7px 0px rgba(159, 159, 159, 0.84);
  65. border-radius: 10px;
  66. margin: 20px auto;
  67. `,
  68. new_phone: ""
  69. }
  70. },
  71. methods: {
  72. //假隐藏
  73. cut_phone($val) {
  74. let start = $val.slice(0, 4);
  75. let end = $val.slice(-2);
  76. return start + '******' + end;
  77. },
  78. // 发送验证码
  79. sand_sms() {
  80. if (!$this.new_phone) {
  81. Toast.fail('手机号不为空')
  82. }
  83. let $param = {
  84. phone: $this.new_phone
  85. }
  86. userGetCode($param).then((res) => {
  87. let $data = res.data
  88. if ($data.code != 200) {
  89. Toast.fail($data.errmsg)
  90. }
  91. })
  92. },
  93. //确认修改
  94. confirm_modify() {
  95. // 修改成功跳转个人首页
  96. let $params = {
  97. code: $this.sms,
  98. new_phone: $this.new_phone,
  99. old_phone: $this.phone
  100. }
  101. userChangePhone($params).then((res) => {
  102. let $data = res.data
  103. if ($data.code == 0) {
  104. Toast.success($data.errmsg)
  105. mpvue.navigateBack({
  106. delta: 2
  107. })
  108. }
  109. })
  110. }
  111. }
  112. ,
  113. mounted() {
  114. let $userinfo = wx.getStorageSync('userinfo')
  115. $this.phone = $this.base_phone = $userinfo['phone']
  116. $this.phone = $this.cut_phone($this.phone)
  117. },
  118. created() {
  119. $this = this;
  120. },
  121. onLoad() {
  122. }
  123. }
  124. </script>
  125. <style scoped>
  126. @import "index.css";
  127. </style>