recharge.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // pages/joinFee/joinFee.js
  2. import userApi from '../../api/user'
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. },
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad: async function (options) {
  14. },
  15. /**
  16. * 生命周期函数--监听页面初次渲染完成
  17. */
  18. onReady: function () {
  19. },
  20. /**
  21. * 生命周期函数--监听页面显示
  22. */
  23. onShow: async function () {
  24. },
  25. /**
  26. * 生命周期函数--监听页面隐藏
  27. */
  28. onHide: function () {
  29. },
  30. /**
  31. * 生命周期函数--监听页面卸载
  32. */
  33. onUnload: function () {
  34. },
  35. /**
  36. * 页面相关事件处理函数--监听用户下拉动作
  37. */
  38. onPullDownRefresh: function () {
  39. },
  40. /**
  41. * 页面上拉触底事件的处理函数
  42. */
  43. onReachBottom: function () {
  44. },
  45. bindMoney(e) {
  46. let money = e.detail.value
  47. this.setData({
  48. money
  49. })
  50. },
  51. async rechargeMoney(e) {
  52. const self = this
  53. let money = e.currentTarget.dataset.money
  54. console.log()
  55. if (!money) {
  56. money = self.data.money
  57. } else {
  58. self.setData({
  59. money
  60. })
  61. money = self.data.money
  62. }
  63. if (!money) {
  64. wx.showModal({
  65. content: '请选择充值的金额',
  66. title:'提示'
  67. })
  68. return
  69. }
  70. const confimObj = await wx.showModal({
  71. content: `您确定要充值${money}元?`,
  72. title:'提示'
  73. })
  74. //没同意
  75. if (!confimObj.confirm) {
  76. return
  77. }
  78. let data = {
  79. recharge: money
  80. }
  81. const rs = await userApi.recharge(data)
  82. let orderId = rs.orderId;
  83. wx.requestPayment({
  84. timeStamp: rs.timeStamp,
  85. nonceStr: rs.nonceStr,
  86. package: rs.package,
  87. signType: rs.signType,
  88. paySign: rs.paySign,
  89. success (res) {
  90. wx.showModal({
  91. content: `充值成功`,
  92. title:'提示'
  93. }).then(() => {
  94. wx.switchTab({
  95. url: '/pages/person/person',
  96. })
  97. })
  98. },
  99. fail (res) {
  100. }
  101. })
  102. }
  103. })