微信小程序
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 3.0 KiB

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