vipCode.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. text: '您发起的团购尚未完成',
  15. type: 'bigOrange'
  16. },
  17. {
  18. text: '拼团成功,才能发起新的团购',
  19. type: 'bigOrange'
  20. }
  21. ],
  22. closeCallBack: false
  23. },
  24. onLoad: function (options) {
  25. if (options.title) {
  26. wx.setNavigationBarTitle({
  27. title: '激活码激活'
  28. });
  29. }
  30. },
  31. activeVIP() {
  32. console.log(11111, this.data.code)
  33. APIClient.postActiveCode(this.data.code).success(res => {
  34. switch (res.data.code) {
  35. case 200:
  36. this.setData({
  37. isModalShow: true,
  38. modalText: [{
  39. text: '激活成功!',
  40. type: 'bigOrange'
  41. },
  42. {
  43. text: '您已获得一年VIP权限',
  44. type: 'bigOrange'
  45. }
  46. ],
  47. closeCallBack: 'index'
  48. })
  49. break;
  50. case 531:
  51. // 激活码已经用过了
  52. this.setData({
  53. isModalShow: true,
  54. modalText: [{
  55. text: '激活失败!',
  56. type: 'bigOrange'
  57. },
  58. {
  59. text: '验证码已经使用过了',
  60. type: 'bigOrange'
  61. }
  62. ]
  63. })
  64. break;
  65. case 404:
  66. //激活码不存在
  67. this.setData({
  68. isModalShow: true,
  69. modalText: [{
  70. text: '激活失败!',
  71. type: 'bigOrange'
  72. },
  73. {
  74. text: '验证码错误',
  75. type: 'bigOrange'
  76. }
  77. ]
  78. })
  79. break;
  80. default:
  81. break;
  82. }
  83. }).fail(err => {
  84. console.log(err);
  85. });
  86. },
  87. saveValue(e) {
  88. console.log(e)
  89. this.setData({
  90. code: e.detail.value
  91. });
  92. },
  93. modalConfirmHandler() {
  94. this.setData({
  95. isModalShow: false
  96. })
  97. if (this.data.closeCallBack === 'index') {
  98. wx.redirectTo({
  99. url: `/pages/index/index`
  100. })
  101. }
  102. },
  103. })