set.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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.login(this)
  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. })