paylist.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. }
  45. else {
  46. that.setData({
  47. PayList: [],
  48. });
  49. }
  50. });
  51. },
  52. gotoActive: function (e) {
  53. var that = this;
  54. var productid = e.currentTarget.dataset.productid;
  55. var list = server.getProgramList();
  56. for (var i = 0; i < list.length; i++) {
  57. if (productid == list[i].ID) {
  58. var path = list[i].path;
  59. path += "&ProductBuyInfoID=" + e.currentTarget.dataset.id;
  60. path += "&ProductID=" + app.globalData.ProgramID;
  61. path += "&ProductUserID=" + app.globalData.userInfo.UserID;
  62. path += "&BuyType=" + e.currentTarget.dataset.buytype;
  63. wx.navigateToMiniProgram({
  64. appId: list[i].appId,
  65. path: path,
  66. success(res) {
  67. }
  68. });
  69. var data = this.data.PayList;
  70. for (var i = 0; i < data.length; i++) {
  71. for (var j = 0; j < data[i].List.length; j++) {
  72. if (data[i].List[j].ProductID == productid) {
  73. data[i].List[j].isShowActivty = false;
  74. }
  75. }
  76. }
  77. that.setData({
  78. PayList: data,
  79. });
  80. break;
  81. }
  82. }
  83. },
  84. gotoFeedback: function () {
  85. server.gotoFeedback();
  86. },
  87. refresh: function () {
  88. var that = this;
  89. wx.showLoading({
  90. title: '加载中',
  91. });
  92. setTimeout(function () {
  93. wx.hideLoading();
  94. that.init();
  95. }, 1000);
  96. },
  97. onShareAppMessage: function () {
  98. return {
  99. title: app.globalData.ShareTitle,
  100. path: 'pages/index/index?UserID=' + app.globalData.userInfo.UserID,
  101. imageUrl: '../../images/07001.png',
  102. }
  103. },
  104. })