info-self.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // pages/edit-info/info-self/info-self.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. min: 0,
  8. max: 500,
  9. selfIntroduction:"",
  10. userId:""
  11. },
  12. // 点击重置
  13. reset(e) {
  14. this.setData({
  15. selfIntroduction: ""
  16. });
  17. },
  18. // 点击提交
  19. submit(e) {
  20. var _this = this
  21. console.log(this.data)
  22. wx.request({
  23. url: getApp().globalData.baseURL + '/resume/modify',
  24. method: 'POST',
  25. data: {
  26. "id": _this.data.userId,
  27. "self": _this.data.selfIntroduction,
  28. "type": 4
  29. },
  30. success(res) {
  31. if (res.statusCode == 200) {
  32. wx.showToast({
  33. title: '提交成功',
  34. icon: 'none',
  35. })
  36. } else {
  37. wx.showToast({
  38. title: '提交失败,请联系管理员',
  39. icon: 'none',
  40. })
  41. }
  42. }
  43. })
  44. },
  45. inputs: function (e) {
  46. var value = e.detail.value;
  47. var len = parseInt(value.length);
  48. if (len > this.data.max) return;
  49. this.setData({
  50. currentWordNumber: len,
  51. selfIntroduction: value
  52. });
  53. },
  54. /**
  55. * 生命周期函数--监听页面加载
  56. */
  57. onLoad: function (options) {
  58. // 获取uid
  59. try {
  60. var value = wx.getStorageSync('uid')
  61. if (value) {
  62. this.setData({
  63. userId: value
  64. });
  65. }
  66. } catch (e) {
  67. console.log(e)
  68. }
  69. },
  70. /**
  71. * 生命周期函数--监听页面初次渲染完成
  72. */
  73. onReady: function () {
  74. },
  75. /**
  76. * 生命周期函数--监听页面显示
  77. */
  78. onShow: function () {
  79. var _this = this
  80. wx.request({
  81. url: getApp().globalData.baseURL + '/resume/id',
  82. method: 'GET',
  83. data: {
  84. "id": _this.data.userId,
  85. "type": 4
  86. },
  87. success(res) {
  88. if (res.data.code == 10001){
  89. _this.setData({
  90. selfIntroduction: '',
  91. });
  92. }else{
  93. _this.setData({
  94. selfIntroduction: res.data.data.selfIntroduction,
  95. });
  96. }
  97. }
  98. })
  99. },
  100. /**
  101. * 生命周期函数--监听页面隐藏
  102. */
  103. onHide: function () {
  104. },
  105. /**
  106. * 生命周期函数--监听页面卸载
  107. */
  108. onUnload: function () {
  109. },
  110. /**
  111. * 页面相关事件处理函数--监听用户下拉动作
  112. */
  113. onPullDownRefresh: function () {
  114. },
  115. /**
  116. * 页面上拉触底事件的处理函数
  117. */
  118. onReachBottom: function () {
  119. },
  120. /**
  121. * 用户点击右上角分享
  122. */
  123. onShareAppMessage: function () {
  124. }
  125. })