convertPopup.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. const util = require('../../../utils/util.js');
  2. Component({
  3. options: {
  4. addGlobalClass: true
  5. }, //使用全局css样式
  6. properties: {
  7. show: {
  8. type: Boolean,
  9. observer: function (newVal) {
  10. this.setData({
  11. show: newVal
  12. });
  13. if (newVal) {
  14. this.stat()
  15. }
  16. }
  17. },
  18. aid: {
  19. type: String,
  20. observer: function (newVal) {
  21. this.setData({
  22. aid: newVal
  23. });
  24. }
  25. },
  26. status: {
  27. type: Number,
  28. observer: function (newVal) {
  29. console.log('status', newVal)
  30. this.setData({
  31. status: newVal
  32. });
  33. }
  34. },
  35. presellOpen: {
  36. type: Number,
  37. observer: function (newVal) {
  38. console.log('presellOpen', newVal)
  39. this.setData({
  40. presellOpen: newVal
  41. });
  42. }
  43. }
  44. },
  45. data: {
  46. disabled: false,
  47. status: 0,
  48. presellOpen: 0,
  49. aid: '',
  50. show: false,
  51. checkedTime: 5,
  52. vip_info: {},
  53. timeList: [{
  54. time: 5,
  55. timeContent: '5分钟'
  56. },
  57. {
  58. time: 10,
  59. timeContent: '10分钟'
  60. },
  61. {
  62. time: 15,
  63. timeContent: '15分钟'
  64. },
  65. {
  66. time: 20,
  67. timeContent: '20分钟'
  68. },
  69. ],
  70. needLevel: [{
  71. time: 5,
  72. level: 2,
  73. levelName: '白银',
  74. consume_coin: '50',
  75. },
  76. {
  77. time: 10,
  78. level: 3,
  79. levelName: '黄金',
  80. consume_coin: '100',
  81. },
  82. {
  83. time: 15,
  84. level: 4,
  85. levelName: '一钻',
  86. consume_coin: '200',
  87. },
  88. {
  89. time: 20,
  90. level: 5,
  91. levelName: '二钻',
  92. consume_coin: '500',
  93. },
  94. ]
  95. },
  96. methods: {
  97. jumpPage() {
  98. wx.navigateTo({
  99. url: '/pages/account/monetaryCenter/ruleInstract',
  100. })
  101. },
  102. // 判断选中时间是否可兑换
  103. getOptionchecked(option) {
  104. let disabled = false,
  105. vip_level = this.data.vip_info;
  106. this.data.needLevel.forEach(el => {
  107. if (option == el.time && ((el.level > vip_level.level) || (el.consume_coin > vip_level.allCoin))) {
  108. disabled = true;
  109. }
  110. });
  111. this.setData({
  112. disabled
  113. })
  114. },
  115. selectTime(e) {
  116. let time = e.currentTarget.dataset.time;
  117. this.setData({
  118. checkedTime: time
  119. })
  120. this.getOptionchecked(time)
  121. },
  122. close() {
  123. this.triggerEvent('close')
  124. },
  125. // 获取宝贝币相关参数
  126. stat() {
  127. let that = this;
  128. util.stat().then(res => {
  129. let checkedTime = 0;
  130. let data = util.getCoinLevel(res.allCoin)
  131. data.allCoin = res.sumCoin;
  132. if (data.level < 2) {
  133. checkedTime = 5;
  134. } else if (data.level > 5) {
  135. checkedTime = 20;
  136. } else {
  137. that.data.needLevel.forEach(el => {
  138. if (el.level == data.level) {
  139. checkedTime = el.time;
  140. }
  141. });
  142. }
  143. that.setData({
  144. vip_info: data,
  145. stat: res,
  146. checkedTime
  147. })
  148. that.getOptionchecked(checkedTime)
  149. })
  150. },
  151. sub() {
  152. let that = this;
  153. if (that.data.presellOpen == 2 || (that.data.presellOpen == 0 && that.data.status == 6)) {
  154. that.triggerEvent('showPrompt', {
  155. checkedTime: that.data.checkedTime
  156. })
  157. } else {
  158. util.showTips('已到达活动开售时间,无法进行兑换');
  159. }
  160. }
  161. }
  162. })