coupon.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. List:[],
  7. },
  8. onLoad: function (options) {
  9. var that = this;
  10. that.setData({
  11. Containnerheight: main.getWindowHeight(),
  12. IsSuccess:0,
  13. });
  14. that.init();
  15. },
  16. init: function (e) {
  17. var that = this;
  18. main.getData("GetMiaoguoCoupon?UserID=" + app.globalData.userInfo.UserID, function (data) {
  19. if (data){
  20. for(var i=0;i<data.length;i++){
  21. if (data[i].Content[1].indexOf("[CouponNumber]")>0){
  22. data[i].Content[1] = data[i].Content[1].replace("[CouponNumber]",data[i].CouponNumber);
  23. }
  24. }
  25. that.setData({
  26. List: data,
  27. });
  28. }
  29. });
  30. },
  31. getCoupon: function (e) {
  32. var that = this;
  33. var coupontype = e.currentTarget.dataset.coupontype;
  34. var couponnumber = e.currentTarget.dataset.couponnumber;
  35. var isloseefficacy = e.currentTarget.dataset.isloseefficacy;
  36. if (!isloseefficacy && couponnumber>0){
  37. wx.setNavigationBarColor({
  38. frontColor: '#ffffff',
  39. backgroundColor: '#0B8457',
  40. });
  41. var ProductServiceTimeNew = common.formatTime(common.addDate("d", couponnumber, new Date(app.globalData.userInfo.ProductServiceTime)));
  42. that.setData({
  43. IsSuccess:1,
  44. ProductServiceTimeOld: common.formatDateCHS(app.globalData.userInfo.ProductServiceTime),
  45. ProductServiceTimeNew: common.formatDateCHS(ProductServiceTimeNew),
  46. });
  47. setTimeout(function(){
  48. main.getData("UseMiaoguoCoupon?UserID=" + app.globalData.userInfo.UserID + "&CouponType=" + coupontype+"&CouponNumber="+couponnumber, function (data) {});
  49. },500);
  50. }
  51. },
  52. gotoIndex:function(){
  53. wx.reLaunch({
  54. url: '../index/index?type=userbook',
  55. });
  56. },
  57. onShareAppMessage: function () {
  58. return {
  59. title: app.globalData.ShareTitle,
  60. path: app.globalData.SharePath + '?LessonID=all&UserID=' + app.globalData.userInfo.UserID,
  61. imageUrl: app.globalData.ShareImage,
  62. }
  63. },
  64. })