modify.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. const app = getApp();
  2. Page({
  3. data: {
  4. past_password:'', //旧密码
  5. password:'', //新密码
  6. qpassword:'', //确认密码
  7. used_value:'',
  8. password_value:'',
  9. qpassword_value:'',
  10. },
  11. onLoad: function (options) {
  12. },
  13. //获取旧密码
  14. used_password: function (e) {
  15. var _used_password = e.detail.value;
  16. // console.log(_used_password);
  17. this.setData({
  18. past_password: _used_password
  19. });
  20. },
  21. //获取新密码
  22. password: function (e) {
  23. var _password = e.detail.value;
  24. // console.log(_password);
  25. this.setData({
  26. password: _password
  27. });
  28. },
  29. //获取确认密码
  30. qpassword: function (e) {
  31. var _qpassword = e.detail.value;
  32. // console.log(_qpassword);
  33. this.setData({
  34. qpassword: _qpassword
  35. });
  36. },
  37. //完成事件
  38. complete: function (e) {
  39. var _this = this;
  40. var _past_password = _this.data.past_password;
  41. var _password = _this.data.password;
  42. var _qpassword = _this.data.qpassword;
  43. // console.log(_past_password);
  44. // console.log(_password);
  45. // console.log(_qpassword);
  46. if (_past_password == ''){
  47. var _qrcode = '原始密码不能为空'
  48. getApp().Tips(_qrcode);
  49. } else if (_password == ''){
  50. var _qrcode = '新密码不能为空'
  51. getApp().Tips(_qrcode);
  52. } else if (_qpassword == '') {
  53. var _qrcode = '确认新密码不能为空'
  54. getApp().Tips(_qrcode);
  55. } else if (_password != _qpassword) {
  56. var _qrcode = '两次新密码输入不一致'
  57. getApp().Tips(_qrcode);
  58. }else{
  59. let income_url = 'my/accountsecurity/resetpassword';
  60. let income_data = {
  61. past_password: _past_password, //旧密码
  62. password: _password, //新密码
  63. qpassword: _qpassword, //确认密码
  64. };
  65. app.postRequest(income_url, income_data, function (res) {
  66. // console.log(income_data.photo);
  67. if (res.code == 201) {
  68. wx.showToast({
  69. title: '修改成功',
  70. duration: 1500,
  71. })
  72. setTimeout(function () {
  73. wx.clearStorageSync();
  74. wx.reLaunch({
  75. url: '/pages/Landpage/Land/Land'
  76. });
  77. }, 800)
  78. return;
  79. }
  80. // console.log(res.data.past_password);
  81. if (res.data.past_password){
  82. getApp().Tips(res.data.past_password[0]);
  83. _this.setData({
  84. used_value: '',
  85. });
  86. } else if (res.data.password){
  87. getApp().Tips(res.data.password[0]);
  88. _this.setData({
  89. password_value: '',
  90. qpassword_value: '',
  91. });
  92. }
  93. })
  94. }
  95. },
  96. })