mobileModify.js 806 B

12345678910111213141516171819202122232425262728293031323334
  1. const api = require('../../config/api')
  2. const util = require('../../utils/util')
  3. const check = require('../../utils/check')
  4. Page({
  5. data: {
  6. id: 0,
  7. mobile: ''
  8. },
  9. onLoad() {
  10. const { id, mobile } = wx.getStorageSync('userInfo')
  11. this.setData({ id, mobile: mobile && mobile.length == 11 ? mobile : '' })
  12. },
  13. nameInput({ detail }) {
  14. this.setData({ mobile: detail })
  15. },
  16. submit() {
  17. const { id, mobile } = this.data
  18. if (!check.validPhone(mobile)) return util.showToast('请输入正确手机号')
  19. util.showLoad('加载中')
  20. util.request(api.UserUpdate, { id, mobile }, 'POST').then(res => {
  21. util.hideLoad()
  22. if (res.errno === 0) wx.navigateBack()
  23. else util.showErrorToast(res.errmsg)
  24. }).catch(() => {
  25. util.hideLoad()
  26. util.showErrorToast('网络连接失败')
  27. })
  28. }
  29. })