updatepassword.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 > 5) {
  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. if (res.data.code == 0) {
  68. wx.showModal({
  69. showCancel: false,
  70. content: '密码已修改',
  71. success: () => {
  72. wx.switchTab({
  73. url: '/pages/index/index',
  74. })
  75. }
  76. })
  77. } else if(res.data.code == 1) {
  78. wx.showToast({
  79. title: "修改失败,原密码不正确",
  80. icon: 'none',
  81. duration: 2000,
  82. })
  83. }else{
  84. wx.showToast({
  85. title: "修改失败,请联系管理员",
  86. icon: 'none',
  87. duration: 2000,
  88. })
  89. }
  90. }
  91. })
  92. } else {
  93. wx.showToast({
  94. title: "两次输入密码不一致",
  95. icon: 'none',
  96. duration: 2000,
  97. })
  98. }
  99. } else {
  100. wx.showToast({
  101. title: "密码长度最少为6位",
  102. icon: 'none',
  103. duration: 2000,
  104. })
  105. }
  106. } else {
  107. wx.showToast({
  108. title: "在输入新密码不能为空",
  109. icon: 'none',
  110. duration: 2000,
  111. })
  112. }
  113. } else {
  114. wx.showToast({
  115. title: "新密码不能为空",
  116. icon: 'none',
  117. duration: 2000,
  118. })
  119. }
  120. } else {
  121. wx.showToast({
  122. title: "原密码不能为空",
  123. icon: 'none',
  124. duration: 2000,
  125. })
  126. }
  127. },
  128. onLoad: function () {
  129. wx.request({
  130. url: app.globalData.publicUrl + '/applet/findUserInfo',
  131. method: "GET",
  132. header: {
  133. appletsId: wx.getStorageSync('openId')
  134. },
  135. success: (res) => {
  136. console.log(res, "000");
  137. this.setData({
  138. info: res.data.data
  139. })
  140. }
  141. })
  142. },
  143. })