index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. // pages/pwdSet/index.js
  2. const util = require('../../utils/util.js');
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. oldPassword:'',
  10. newPassword:'',
  11. confirmPassword:'',
  12. userInfo:{
  13. password:''
  14. },
  15. message:{}
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. },
  22. /**
  23. * 生命周期函数--监听页面初次渲染完成
  24. */
  25. onReady: function () {
  26. },
  27. /**
  28. * 生命周期函数--监听页面显示
  29. */
  30. onShow: function () {
  31. },
  32. /**
  33. * 生命周期函数--监听页面隐藏
  34. */
  35. onHide: function () {
  36. },
  37. /**
  38. * 生命周期函数--监听页面卸载
  39. */
  40. onUnload: function () {
  41. },
  42. /**
  43. * 页面相关事件处理函数--监听用户下拉动作
  44. */
  45. onPullDownRefresh: function () {
  46. },
  47. /**
  48. * 页面上拉触底事件的处理函数
  49. */
  50. onReachBottom: function () {
  51. },
  52. /**
  53. * 用户点击右上角分享
  54. */
  55. onShareAppMessage: function () {
  56. },
  57. changePassword(){
  58. var that = this
  59. console.log("66666")
  60. console.log(that.data)
  61. // that.data.userInfo = app.globalData.userInfo
  62. // console.log("88888")
  63. // console.log(that.data.userInfo)
  64. // if(that.data.userInfo.password != that.data.oldPassword){
  65. // wx.showToast({
  66. // title: "旧密码输入错误!",
  67. // icon: "none"
  68. // });
  69. // return
  70. // }
  71. // if(util.isNullOrEmpty(that.data.newPassword)){
  72. // wx.showToast({
  73. // title: "新密码不允许为空!",
  74. // icon: "none"
  75. // });
  76. // return
  77. // }
  78. // if(that.data.newPassword != that.data.confirmPassword){
  79. // wx.showToast({
  80. // title: "两次输入密码不一致!",
  81. // icon: "none"
  82. // });
  83. // return
  84. // }
  85. util.request(util.api.changePassword, {oldPassword:that.data.oldPassword,newPassword:that.data.newPassword,confirmPassword:that.data.confirmPassword}, "POST", true, true,app.globalData.token).then((res)=>{
  86. console.log("444")
  87. console.log(res)
  88. console.log("333")
  89. that.data.message = res.message
  90. if (res.code == 200) {
  91. if(res.result === "密码重置成功!"){
  92. wx.showToast({
  93. title: "密码重置成功!",
  94. icon: "none"
  95. });
  96. setTimeout(()=>{
  97. wx.navigateBack({
  98. delta: 1,
  99. })
  100. },500)
  101. }
  102. }
  103. if(res.code == 500){
  104. if(that.data.message === "旧密码输入错误!"){
  105. wx.showToast({
  106. title: "旧密码输入错误!",
  107. icon: "none"
  108. });
  109. return
  110. }
  111. if(that.data.message === "新密码不允许为空!"){
  112. wx.showToast({
  113. title: "新密码不允许为空!",
  114. icon: "none"
  115. });
  116. return
  117. }
  118. if(that.data.message === "两次输入密码不一致!"){
  119. wx.showToast({
  120. title: "两次输入密码不一致!",
  121. icon: "none"
  122. });
  123. return
  124. }
  125. }
  126. }).catch((res) => {})
  127. },
  128. inputedit: function (e) {
  129. let _this = this;
  130. let dataset = e.currentTarget.dataset;
  131. let value = e.detail.value;
  132. let name = dataset.name;
  133. _this.data[name] = value;
  134. _this.setData({
  135. [name]: _this.data[name]
  136. });
  137. },
  138. })