updatepassword.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. const app = require('../../utils/util.js');
  2. var util = require('../../utils/md5.js')
  3. Page({
  4. data: {
  5. defaultType1: true,
  6. passwordType1: true,
  7. defaultType2: true,
  8. passwordType2: true,
  9. defaultType3: true,
  10. passwordType3: true,
  11. info: {},
  12. },
  13. eyeStatus1() {
  14. if (this.data.defaultType1) {
  15. this.setData({
  16. passwordType1: false,
  17. defaultType1: false,
  18. })
  19. } else {
  20. this.setData({
  21. passwordType1: true,
  22. defaultType1: true,
  23. })
  24. }
  25. },
  26. eyeStatus2() {
  27. if (this.data.defaultType2) {
  28. this.setData({
  29. passwordType2: false,
  30. defaultType2: false,
  31. })
  32. } else {
  33. this.setData({
  34. passwordType2: true,
  35. defaultType2: true,
  36. })
  37. }
  38. },
  39. eyeStatus3() {
  40. if (this.data.defaultType3) {
  41. this.setData({
  42. passwordType3: false,
  43. defaultType3: false,
  44. })
  45. } else {
  46. this.setData({
  47. passwordType3: true,
  48. defaultType3: true,
  49. })
  50. }
  51. },
  52. formSubmit(e) {
  53. console.log(e.detail, "daying");
  54. if (e.detail.value.oldPwd) {
  55. if (e.detail.value.pwd) {
  56. if (e.detail.value.newPwd) {
  57. if (e.detail.value.pwd.toString().length > 6) {
  58. if (e.detail.value.pwd == e.detail.value.newPwd) {
  59. wx.request({
  60. url: app.globalData.publicUrl + '/applet/updatePwd',
  61. method: "GET",
  62. header: {
  63. appletsId: wx.getStorageSync('openId')
  64. },
  65. data: e.detail.value,
  66. success: (res) => {
  67. console.log(res);
  68. // if (res.data.code == 0) {
  69. // wx.switchTab({
  70. // url: '/pages/updatepassword/updatepassword',
  71. // })
  72. // }
  73. }
  74. })
  75. wx.switchTab({
  76. url: '/pages/index/index',
  77. })
  78. } else {
  79. wx.showToast({
  80. title: "两次输入密码不一致",
  81. icon: 'none',
  82. duration: 2000,
  83. })
  84. }
  85. } else {
  86. wx.showToast({
  87. title: "密码长度最少为7位",
  88. icon: 'none',
  89. duration: 2000,
  90. })
  91. }
  92. } else {
  93. wx.showToast({
  94. title: "在输入新密码不能为空",
  95. icon: 'none',
  96. duration: 2000,
  97. })
  98. }
  99. } else {
  100. wx.showToast({
  101. title: "新密码不能为空",
  102. icon: 'none',
  103. duration: 2000,
  104. })
  105. }
  106. } else {
  107. wx.showToast({
  108. title: "原密码不能为空",
  109. icon: 'none',
  110. duration: 2000,
  111. })
  112. }
  113. },
  114. onLoad: function () {
  115. wx.request({
  116. url: app.globalData.publicUrl + '/sys/login/session',
  117. method: "GET",
  118. header: {
  119. appletsId: wx.getStorageSync('openId')
  120. },
  121. success: (res) => {
  122. console.log(res, "000");
  123. this.setData({
  124. info: res.data.data
  125. })
  126. }
  127. })
  128. },
  129. })