vipCode.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // pages/user/walletDetails/walletDetails.js
  2. import Date from '../../../utils/util.js'
  3. import APIClient from '../../../utils/APIClient.js'
  4. Page({
  5. data: {
  6. buyBtnText: '立即激活',
  7. price: '29',
  8. originPrice: '99',
  9. productId: 0,
  10. modalType: 'image',
  11. isModalShow: false,
  12. isCloseShow: false,
  13. modalText: [],
  14. closeCallBack: false
  15. },
  16. onLoad: function (options) {
  17. if (options.title) {
  18. wx.setNavigationBarTitle({
  19. title: '激活码激活'
  20. });
  21. }
  22. },
  23. activeVIP() {
  24. console.log(11111, this.data.code)
  25. APIClient.postActiveCode(this.data.code).success(res => {
  26. switch (res.data.code) {
  27. case 200:
  28. this.setData({
  29. isModalShow: true,
  30. modalText: [{
  31. text: '激活成功!',
  32. type: 'bigOrange'
  33. },
  34. {
  35. text: '您已获得一年VIP权限',
  36. type: 'bigOrange'
  37. }
  38. ],
  39. closeCallBack: 'index'
  40. })
  41. break;
  42. case 531:
  43. // 激活码已经用过了
  44. this.setData({
  45. isModalShow: true,
  46. modalText: [{
  47. text: '激活失败!',
  48. type: 'bigOrange'
  49. },
  50. {
  51. text: '验证码已经使用过了',
  52. type: 'bigOrange'
  53. }
  54. ]
  55. })
  56. break;
  57. case 404:
  58. //激活码不存在
  59. this.setData({
  60. isModalShow: true,
  61. modalText: [{
  62. text: '激活失败!',
  63. type: 'bigOrange'
  64. },
  65. {
  66. text: '验证码错误',
  67. type: 'bigOrange'
  68. }
  69. ]
  70. })
  71. break;
  72. default:
  73. break;
  74. }
  75. }).fail(err => {
  76. console.log(err);
  77. });
  78. },
  79. saveValue(e) {
  80. console.log(e)
  81. this.setData({
  82. code: e.detail.value
  83. });
  84. },
  85. modalConfirmHandler() {
  86. this.setData({
  87. isModalShow: false
  88. })
  89. if (this.data.closeCallBack === 'index') {
  90. wx.redirectTo({
  91. url: `/pages/index/index`
  92. })
  93. }
  94. },
  95. })