exchange.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // pages/exchange/exchange.js
  2. import { userEntityRecharge } from '../../api/charge'
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. cardNo: '',
  9. cardSecret: ''
  10. },
  11. /**
  12. * 确认提交充值
  13. */
  14. handleComfirm() {
  15. var cardNo = this.data.cardNo
  16. var cardSecret = this.data.cardSecret
  17. console.log(cardNo, cardSecret);
  18. if (cardNo == '') {
  19. wx.showToast({
  20. title: '请输入卡号',
  21. icon: 'error'
  22. })
  23. return
  24. } else if (cardSecret == '') {
  25. wx.showToast({
  26. title: '请输入卡密',
  27. icon: 'error'
  28. })
  29. return
  30. } else {
  31. var data = {
  32. cardNo: cardNo,
  33. cardSecret: cardSecret
  34. }
  35. wx.showLoading({
  36. title: '充值中...',
  37. mask: true
  38. })
  39. userEntityRecharge(data).then(res => {
  40. console.log(res, 'userEntityRecharge');
  41. wx.hideLoading()
  42. w.showToast({
  43. title: '充值成功',
  44. icon: 'success'
  45. })
  46. }).catch(e => {
  47. wx.hideLoading()
  48. wx.showModal({
  49. content: e,
  50. confirmColor: '#333',
  51. showCancel: false
  52. })
  53. })
  54. }
  55. },
  56. bindCardNo(e) {
  57. this.setData({
  58. cardNo: e.detail.value
  59. })
  60. },
  61. bindCardPwd(e) {
  62. this.setData({
  63. cardSecret: e.detail.value
  64. })
  65. },
  66. /**
  67. * 生命周期函数--监听页面卸载
  68. */
  69. handleCancle() {
  70. wx.navigateBack()
  71. },
  72. /**
  73. * 页面相关事件处理函数--监听用户下拉动作
  74. */
  75. onPullDownRefresh() {
  76. },
  77. /**
  78. * 页面上拉触底事件的处理函数
  79. */
  80. onReachBottom() {
  81. },
  82. /**
  83. * 用户点击右上角分享
  84. */
  85. onShareAppMessage() {
  86. }
  87. })