paylist.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import common from '../../utils/util';
  2. import server from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. PayList: null,
  7. IsShowActivty: false,
  8. },
  9. onLoad: function (options) {
  10. //测试*****************
  11. // if (!app.globalData.userInfo)
  12. // app.globalData.userInfo = { UserID: 4 };
  13. this.setData({
  14. Height: common.getSystemHeight(),
  15. UnloadType: options.type,
  16. });
  17. this.init();
  18. },
  19. onUnload: function () {
  20. if (this.data.UnloadType == "finished") {
  21. wx.reLaunch({
  22. url: '../main/index'
  23. });
  24. }
  25. },
  26. init: function () {
  27. var that = this;
  28. server.getData('GetWXUsersAllPayInfo?UserID=' + app.globalData.userInfo.UserID + "&ProductID=" + app.globalData.ProgramID, function (data) {
  29. if (data) {
  30. var isShowActivty = false;
  31. for (var i = 0; i < data.length; i++) {
  32. for (var j = 0; j < data[i].List.length; j++) {
  33. data[i].List[j].isShowActivty = false;
  34. if (data[i].List[j].Status == 0) {
  35. data[i].List[j].isShowActivty = true;
  36. isShowActivty = true;
  37. }
  38. }
  39. }
  40. that.setData({
  41. PayList: data,
  42. IsShowActivty: isShowActivty,
  43. });
  44. if (isShowActivty)
  45. wx.setStorageSync("IsShowActivty", isShowActivty);
  46. else
  47. wx.removeStorageSync("IsShowActivty");
  48. }
  49. else {
  50. that.setData({
  51. PayList: [],
  52. });
  53. }
  54. });
  55. },
  56. gotoActive: function (e) {
  57. var that = this;
  58. var productid = e.currentTarget.dataset.productid;
  59. var list = server.getProgramList();
  60. for (var i = 0; i < list.length; i++) {
  61. if (productid == list[i].ID) {
  62. var path = list[i].path;
  63. path += "&ProductBuyInfoID=" + e.currentTarget.dataset.id;
  64. path += "&ProductID=" + app.globalData.ProgramID;
  65. path += "&ProductUserID=" + app.globalData.userInfo.UserID;
  66. path += "&BuyType=" + e.currentTarget.dataset.buytype;
  67. wx.navigateToMiniProgram({
  68. appId: list[i].appId,
  69. path: path,
  70. success(res) {
  71. }
  72. });
  73. var data = this.data.PayList;
  74. for (var i = 0; i < data.length; i++) {
  75. for (var j = 0; j < data[i].List.length; j++) {
  76. if (data[i].List[j].ProductID == productid) {
  77. data[i].List[j].isShowActivty = false;
  78. }
  79. }
  80. }
  81. that.setData({
  82. PayList: data,
  83. });
  84. break;
  85. }
  86. }
  87. },
  88. gotoFeedback: function () {
  89. server.gotoFeedback();
  90. },
  91. refresh: function () {
  92. var that = this;
  93. wx.showLoading({
  94. title: '加载中',
  95. });
  96. setTimeout(function () {
  97. wx.hideLoading();
  98. that.init();
  99. }, 1000);
  100. },
  101. onShareAppMessage: function () {
  102. return {
  103. title: app.globalData.ShareTitle,
  104. path: 'pages/index/index?UserID=' + app.globalData.userInfo.UserID,
  105. imageUrl: '../../images/07001.png',
  106. }
  107. },
  108. })