activity.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. const ActivityArr = [
  5. {},
  6. {
  7. ActivityName: "newuserhelp",
  8. ImageArr: [
  9. { src: "salesactivity_a01_manual_01.png", h: 453 },
  10. { src: "salesactivity_a01_manual_02.png", h: 989 },
  11. ]
  12. },
  13. {
  14. ActivityName: "earlybird",
  15. ImageArr: [
  16. { src: "salesactivity_a02_manual_01.png", h: 397 },
  17. { src: "salesactivity_a02_manual_02.png", h: 715 },
  18. ]
  19. },
  20. {
  21. ActivityName: "end",
  22. ImageArr: [
  23. { src: "salesactivity_a03_manual_01.png", h: 397 },
  24. { src: "salesactivity_a03_manual_02.png", h: 715 },
  25. ]
  26. }];
  27. Page({
  28. data: {
  29. ImagePath: app.globalData.uploadImageUrl,
  30. BtnShow: 0,
  31. ShowNone: false,
  32. },
  33. onLoad: function (options) {
  34. var that = this;
  35. var activityID = "1";
  36. if (options && options.ActivityID) {
  37. activityID = options.ActivityID;
  38. }
  39. var EndTime = "";
  40. if (options && options.EndTime) {
  41. EndTime = options.EndTime;
  42. }
  43. var EarlyBirdTimeStart = "", EarlyBirdTimeEnd = "";
  44. if (options && options.EarlyBirdTimeStart) {
  45. EarlyBirdTimeStart = options.EarlyBirdTimeStart;
  46. EarlyBirdTimeEnd = options.EarlyBirdTimeEnd;
  47. }
  48. if (activityID == 2) {
  49. var EarlyBirdTimeEnd1 = common.formatDateENG(EarlyBirdTimeEnd,"/");
  50. EarlyBirdTimeEnd1 = new Date(EarlyBirdTimeEnd1 + " 00:00:00");
  51. console.log("EarlyBirdTimeEnd1:" + EarlyBirdTimeEnd1);
  52. console.log("Today:" +new Date(common.formatTime(new Date(), "/", true) + " 00:00:00"));
  53. var dayNumber = common.diffDate("d", new Date(common.formatTime(new Date(), "/", true) + " 00:00:00"), EarlyBirdTimeEnd1);
  54. console.log(dayNumber);
  55. if (dayNumber < 0 || app.globalData.userInfo.IsPay==1) {
  56. that.setData({
  57. ShowNone: true,
  58. });
  59. }
  60. else {
  61. if (dayNumber == 0)
  62. dayNumber = "今";
  63. that.setData({
  64. DayNumber: dayNumber,
  65. });
  66. }
  67. }
  68. that.setData({
  69. Containnerheight: main.getWindowHeight(),
  70. Activity: ActivityArr[activityID],
  71. ActivityID: activityID,
  72. EndTime: EndTime,
  73. EarlyBirdTimeStart: EarlyBirdTimeStart,
  74. EarlyBirdTimeEnd: EarlyBirdTimeEnd,
  75. });
  76. that.init();
  77. },
  78. init: function () {
  79. var that = this;
  80. var CouponType = 132;
  81. if (that.data.ActivityID == 3)
  82. CouponType = 133;
  83. main.getData("GetMiaoguoCoupon?UserID=" + app.globalData.userInfo.UserID + "&CouponType=" + CouponType, function (data) {
  84. if (data && data.length>0) {
  85. that.setData({
  86. BtnShow: 1,
  87. });
  88. }
  89. });
  90. },
  91. gotoPay: function (e) {
  92. var PayType = e.currentTarget.dataset.paytype;
  93. var EndDate = e.currentTarget.dataset.enddate;
  94. wx.navigateTo({
  95. url: '../other/pay?PayType=' + PayType + '&EndDate=' + EndDate,
  96. });
  97. },
  98. getCoupon: function (e) {
  99. var coupontype = e.currentTarget.dataset.coupontype;
  100. var limittime = e.currentTarget.dataset.limittime;
  101. var that = this;
  102. main.getData("SendMiaoguoCoupon?UserID=" + app.globalData.userInfo.UserID + "&CouponType=" + coupontype + "&LimitTime=" + limittime, function (data) {
  103. wx.showToast({
  104. title: '领券成功!',
  105. });
  106. that.setData({
  107. BtnShow: 1,
  108. });
  109. });
  110. },
  111. onShareAppMessage: function () {
  112. return {
  113. title: app.globalData.ShareTitle,
  114. path: app.globalData.SharePath + '?LessonID=all&UserID=' + app.globalData.userInfo.UserID,
  115. imageUrl: app.globalData.ShareImage,
  116. }
  117. },
  118. })