exchange.js 2.0 KB

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