set.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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.pwd) {
  12. wx.showToast({
  13. title: '请输入交易密码',
  14. icon: 'none'
  15. })
  16. return
  17. }
  18. if (!this.data.pwd2) {
  19. wx.showToast({
  20. title: '请再次输入交易密码',
  21. icon: 'none'
  22. })
  23. return
  24. }
  25. if (this.data.pwd != this.data.pwd2) {
  26. wx.showToast({
  27. title: '两次输入不一致',
  28. icon: 'none'
  29. })
  30. return
  31. }
  32. const res = await WXAPI.setPayPassword(wx.getStorageSync('token'), this.data.pwd)
  33. if (res.code == 2000) {
  34. AUTH.openLoginDialog()
  35. return
  36. }
  37. if (res.code != 0) {
  38. wx.showToast({
  39. title: res.msg,
  40. icon: 'none'
  41. })
  42. return
  43. }
  44. wx.showToast({
  45. title: '设置成功'
  46. })
  47. setTimeout(() => {
  48. wx.navigateBack({
  49. delta: 0,
  50. })
  51. }, 1000);
  52. },
  53. processLogin(e) {
  54. if (!e.detail.userInfo) {
  55. wx.showToast({
  56. title: '已取消',
  57. icon: 'none',
  58. })
  59. return;
  60. }
  61. AUTH.register(this);
  62. },
  63. })