modify.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. const WXAPI = require('apifm-wxapi')
  2. const AUTH = require('../../utils/auth')
  3. Page({
  4. data: {
  5. },
  6. onLoad: function (options) {
  7. },
  8. onShow: function () {
  9. },
  10. async submit() {
  11. if (!this.data.pwdOld) {
  12. wx.showToast({
  13. title: '请输入原来的交易密码',
  14. icon: 'none'
  15. })
  16. return
  17. }
  18. if (!this.data.pwd) {
  19. wx.showToast({
  20. title: '请输入新的交易密码',
  21. icon: 'none'
  22. })
  23. return
  24. }
  25. if (!this.data.pwd2) {
  26. wx.showToast({
  27. title: '请再次输入新的交易密码',
  28. icon: 'none'
  29. })
  30. return
  31. }
  32. if (this.data.pwd != this.data.pwd2) {
  33. wx.showToast({
  34. title: '两次输入不一致',
  35. icon: 'none'
  36. })
  37. return
  38. }
  39. const res = await WXAPI.modifyPayPassword(wx.getStorageSync('token'), this.data.pwdOld, this.data.pwd)
  40. if (res.code == 2000) {
  41. AUTH.openLoginDialog()
  42. return
  43. }
  44. if (res.code != 0) {
  45. wx.showToast({
  46. title: res.msg,
  47. icon: 'none'
  48. })
  49. return
  50. }
  51. wx.showToast({
  52. title: '修改成功'
  53. })
  54. setTimeout(() => {
  55. wx.navigateBack({
  56. delta: 0,
  57. })
  58. }, 1000);
  59. },
  60. processLogin(e) {
  61. if (!e.detail.userInfo) {
  62. wx.showToast({
  63. title: '已取消',
  64. icon: 'none',
  65. })
  66. return;
  67. }
  68. AUTH.register(this);
  69. },
  70. })