myEdit.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import httpRequestApi from '../../../utils/APIClient';
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. sexs: [
  8. { value: '女',checked: true },
  9. { value: '男', checked: false }
  10. ],
  11. occupations: [
  12. { value: '家长', checked: false },
  13. { value: '老师', checked: false },
  14. { value: '学生', checked: true }
  15. ],
  16. date: '2001年12月12日',
  17. msg: '',
  18. nickname: ''
  19. },
  20. saveNickName: function(e){
  21. let nickname = e.detail.value;
  22. this.setData({
  23. nicename: nickname
  24. }, () => {
  25. console.log(nickname);
  26. });
  27. },
  28. saveAddress: function(e){
  29. let msg = e.detail.value;
  30. this.setData({
  31. msg: msg
  32. },() => {
  33. console.log(msg);
  34. });
  35. },
  36. bindDateChange: function(e) {
  37. console.log(e.detail.value)
  38. this.setData({
  39. date: e.detail.value
  40. });
  41. },
  42. optionAction:function(e){
  43. console.log(e.detail.value);
  44. },
  45. optionSetting: function (e) {
  46. console.log(e.detail.value);
  47. },
  48. formSubmit: function(e){
  49. let { nickname, picker, radioGroup1, radioGroup2, address } = e.detail.value;
  50. let uid = 1, wechatName = nickname, mobile = '13994969642', gender = 3, schoolProvince = 11, schoolCity = '运城市', schoolName = '康杰中学', profession = radioGroup2, birthday = picker;
  51. httpRequestApi.settingUserInfo(uid, wechatName, mobile, gender, schoolProvince, schoolCity, schoolName, profession, birthday).success(res => {
  52. console.log(res.data.data.wechatName);//修改资料成功后 调用 getUserInfo
  53. // this.setData({
  54. // nickname: res.data.data.wechatName
  55. // });
  56. wx.redirectTo({
  57. url: '/pages/index/index?index=3'
  58. });
  59. // wx.navigateBack({
  60. //
  61. // });
  62. });
  63. },
  64. /**
  65. * 生命周期函数--监听页面加载
  66. */
  67. onLoad: function (option) {
  68. console.log(option.title);
  69. if (option.title) {
  70. wx.setNavigationBarTitle({
  71. title: option.title//页面标题为路由参数
  72. });
  73. this.setData({
  74. title: option.title
  75. });
  76. }
  77. },
  78. /**
  79. * 生命周期函数--监听页面初次渲染完成
  80. */
  81. onReady: function () {
  82. },
  83. /**
  84. * 生命周期函数--监听页面显示
  85. */
  86. onShow: function () {
  87. },
  88. /**
  89. * 生命周期函数--监听页面隐藏
  90. */
  91. onHide: function () {
  92. },
  93. /**
  94. * 生命周期函数--监听页面卸载
  95. */
  96. onUnload: function () {
  97. },
  98. /**
  99. * 页面相关事件处理函数--监听用户下拉动作
  100. */
  101. onPullDownRefresh: function () {
  102. },
  103. /**
  104. * 页面上拉触底事件的处理函数
  105. */
  106. onReachBottom: function () {
  107. },
  108. /**
  109. * 用户点击右上角分享
  110. */
  111. onShareAppMessage: function () {
  112. }
  113. })