contact.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // import Notify from '../../dist/notify/notify';
  2. const { fetchGraphql } = require('../../../utils/util.js');
  3. const { userbyid } = require('../../../config/gql.js');
  4. const app = getApp();
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. },
  11. lifetimes: {
  12. attached() {
  13. fetchGraphql(userbyid, { id: app.globalData.userID }, 'user', 'userbyid', this).then(user => {
  14. this.setData({
  15. phone: user.telephone,
  16. name: user.nickname,
  17. loading: false
  18. })
  19. });
  20. }
  21. },
  22. /**
  23. * 组件的初始数据
  24. */
  25. data: {
  26. loading: true,
  27. phone: '',
  28. name: ''
  29. },
  30. /**
  31. * 组件的方法列表
  32. */
  33. methods: {
  34. phoneInput: function (e) {
  35. this.setData({
  36. phone: e.detail
  37. })
  38. },
  39. nameInput: function (e) {
  40. this.setData({
  41. name: e.detail
  42. })
  43. },
  44. submit: function() {
  45. if(this.data.name && this.data.phone) {
  46. wx.showToast({
  47. title: '修改成功',
  48. icon: 'success'
  49. });
  50. console.log('仅做展示,无操作');
  51. } else {
  52. wx.showToast({
  53. title: '修改成功',
  54. icon: 'success'
  55. });
  56. }
  57. },
  58. reset: function() {
  59. this.setData({
  60. name: '',
  61. phone: ''
  62. })
  63. }
  64. }
  65. });