微信小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

153 wiersze
2.8 KiB

  1. // pages/apply/index.js
  2. import * as UTIL from '../../../../utils/util.js';
  3. import * as API from '../../../../utils/API.js';
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. isIPX: app.globalData.isIPX,
  11. show:false,
  12. baseItem:"",
  13. item:{},
  14. oldPwd:"",
  15. newPwd:"",
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. this.getUserInfo()
  22. },
  23. /* 获取用户信息*/
  24. getUserInfo(){
  25. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  26. success: (res) => {
  27. if (res.code == API.SUCCESS_CODE) {
  28. this.setData({item:res.user})
  29. }
  30. }
  31. })
  32. },
  33. bindOldInput: function (e) {
  34. console.log(e);
  35. this.setData({
  36. oldPwd: e.detail.value
  37. })
  38. },
  39. bindNewInput: function (e) {
  40. console.log(e);
  41. this.setData({
  42. newPwd: e.detail.value
  43. })
  44. },
  45. updatePassword(){
  46. let newPassword = this.data.newPwd;
  47. let oldPassword = this.data.oldPwd;
  48. const d = {oldPassword, newPassword}
  49. if(newPassword==""||oldPassword==""){
  50. wx.showToast({
  51. title: '新旧密码不能为空!',
  52. duration: 2000,
  53. icon:"none"
  54. })
  55. }else if(newPassword==oldPassword){
  56. wx.showToast({
  57. title: '新旧密码不能相同!',
  58. duration: 2000,
  59. icon:"none"
  60. })
  61. }else{
  62. wx.request({
  63. url:API.URL_POST_UPDATEPWD,
  64. data: d,
  65. method: 'POST',
  66. timeout: 60000,
  67. header: {
  68. 'Content-Type': 'application/x-www-form-urlencoded',
  69. 'Authorization':'Bearer '+getApp().globalData.userInfo.token,
  70. },
  71. success: function (response) {
  72. if(response.data.code==200){
  73. wx.showToast({
  74. title: response.data.msg,
  75. duration: 2000,
  76. icon:"success"
  77. })
  78. }else{
  79. wx.showToast({
  80. title: response.data.msg,
  81. duration: 2000,
  82. icon:"none"
  83. })
  84. }
  85. },
  86. fail: function (response) {
  87. console.log(response);
  88. },
  89. complete: function (response) {
  90. console.log(response);
  91. }
  92. })
  93. }
  94. },
  95. back:function(){
  96. wx.navigateBack({
  97. delta: 1
  98. })
  99. },
  100. /**
  101. * 生命周期函数--监听页面初次渲染完成
  102. */
  103. onReady: function () {
  104. },
  105. /**
  106. * 生命周期函数--监听页面显示
  107. */
  108. onShow: function () {
  109. },
  110. /**
  111. * 生命周期函数--监听页面隐藏
  112. */
  113. onHide: function () {
  114. },
  115. /**
  116. * 生命周期函数--监听页面卸载
  117. */
  118. onUnload: function () {
  119. },
  120. /**
  121. * 页面相关事件处理函数--监听用户下拉动作
  122. */
  123. onPullDownRefresh: function () {
  124. },
  125. /**
  126. * 页面上拉触底事件的处理函数
  127. */
  128. onReachBottom: function () {
  129. },
  130. /**
  131. * 用户点击右上角分享
  132. */
  133. onShareAppMessage: function () {
  134. }
  135. })