pay.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. const WXAPI = require('apifm-wxapi')
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. },
  9. /**
  10. * 生命周期函数--监听页面加载
  11. */
  12. onLoad: function (options) {
  13. },
  14. onShow: function () {
  15. },
  16. bindSave: function (e) {
  17. const that = this;
  18. const amount = e.detail.value.amount;
  19. if (amount == "" || amount * 1 < 0) {
  20. wx.showModal({
  21. title: '错误',
  22. content: '请填写正确的押金金额',
  23. showCancel: false
  24. })
  25. return
  26. }
  27. WXAPI.payDeposit({
  28. token: wx.getStorageSync('token'),
  29. amount: amount
  30. }, 'post').then(res => {
  31. if (res.code == 40000) {
  32. wx.showModal({
  33. title: '请先充值',
  34. content: res.msg,
  35. showCancel: false,
  36. success(res) {
  37. wx.navigateTo({
  38. url: "/pages/recharge/index"
  39. })
  40. }
  41. })
  42. return
  43. }
  44. if (res.code != 0) {
  45. wx.showModal({
  46. title: '错误',
  47. content: res.msg,
  48. showCancel: false
  49. })
  50. return
  51. }
  52. wx.showModal({
  53. title: '成功',
  54. content: '押金支付成功',
  55. showCancel: false,
  56. success(res) {
  57. wx.navigateTo({
  58. url: "/pages/asset/index"
  59. })
  60. }
  61. })
  62. })
  63. }
  64. })