paylist.js 3.0 KB

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