activate.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import common from '../../utils/util';
  2. import server from '../../utils/main';
  3. const app = getApp();
  4. var productList = [];
  5. Page({
  6. data: {
  7. },
  8. onLoad: function (options) {
  9. this.setData({
  10. Containnerheight: common.getSystemHeight(),
  11. ProgramList: server.getProgramList(),
  12. });
  13. this.init();
  14. },
  15. onUnload:function(){
  16. productList=[];
  17. },
  18. init: function (e, isRemind) {
  19. var that = this;
  20. wx.showLoading({
  21. title: '装载中',
  22. });
  23. server.getData('GetUserActivateListByUserID500?UserID=' + app.globalData.userInfo.UserID + "&ProductID=" + app.globalData.ProgramID, function (data) {
  24. if (data && data.length > 0) {
  25. var programList = server.getProgramList();
  26. for (var i = 0; i < programList.length; i++) {
  27. for (var j = 0; j < data.length; j++) {
  28. if (programList[i].ID == data[j].ProductID) {
  29. data[j].Name = programList[i].Name;
  30. data[j].ImageUrl = programList[i].ImageUrl;
  31. data[j].appId = programList[i].appId;
  32. data[j].path = programList[i].path;
  33. //不是当前小程序不解锁
  34. if (app.globalData.ProgramID == data[j].ProductID)
  35. app.globalData.userInfo.IsMember = 1;
  36. }
  37. }
  38. }
  39. if (productList.length > 0) {
  40. for (var i = 0; i < productList.length; i++) {
  41. var b = false;
  42. for (var j = 0; j < data.length; j++) {
  43. if (productList[i].ProductID == data[j].ProductID) {
  44. b = true;
  45. break;
  46. }
  47. }
  48. if (!b) {
  49. productList[i].IsActivate = 1;
  50. data.push(productList[i]);
  51. }
  52. }
  53. }
  54. that.setData({
  55. List: data,
  56. });
  57. productList = data;
  58. if (isRemind) {
  59. wx.showModal({
  60. title: '产品未激活',
  61. content: '您有产品未激活,请立即点击红色“去激活”按钮。',
  62. showCancel: false,
  63. confirmText: "知道了",
  64. });
  65. }
  66. wx.setStorageSync("HasActivate", 1);
  67. wx.hideLoading();
  68. }
  69. else {
  70. if (isRemind) {
  71. var arr = [];
  72. for (var i = 0; i < productList.length; i++) {
  73. arr.push(productList[i].ProductID);
  74. }
  75. wx.redirectTo({
  76. url: "./activateFinish?idarr="+arr.join(","),
  77. });
  78. productList = [];
  79. wx.removeStorageSync("HasActivate");
  80. }
  81. else{
  82. for (var i = 0; i < productList.length; i++) {
  83. productList[i].IsActivate = 1;
  84. }
  85. that.setData({
  86. List: productList,
  87. });
  88. }
  89. }
  90. wx.hideLoading();
  91. });
  92. },
  93. gotoFeedback: function () {
  94. server.gotoFeedback();
  95. },
  96. gotoActive: function (e) {
  97. var that = this;
  98. var productid = e.currentTarget.dataset.id;
  99. if (productid == app.globalData.ProgramID) {
  100. server.getData('UpdateWXUsersAll500?ProductID=' + productid
  101. + "&ProductUserID=" + app.globalData.userInfo.UserID
  102. + "&CurrentProductID=" + productid
  103. + "&CurrentUserID=" + app.globalData.userInfo.UserID, function (data) {
  104. if (data) {
  105. }
  106. });
  107. }
  108. else {
  109. var appId = e.currentTarget.dataset.appid;
  110. var path = e.currentTarget.dataset.path;
  111. path += "&ProductID=" + app.globalData.ProgramID;
  112. path += "&ProductUserID=" + app.globalData.userInfo.UserID;
  113. wx.navigateToMiniProgram({
  114. appId: appId,
  115. path: path,
  116. success(res) {
  117. }
  118. });
  119. }
  120. var data = this.data.List;
  121. for (var i = 0; i < data.length; i++) {
  122. if (data[i].ProductID == productid) {
  123. data[i].IsActivate = 0;
  124. }
  125. }
  126. that.setData({
  127. List: data,
  128. });
  129. },
  130. gotoFinish: function () {
  131. this.init(null, true);
  132. },
  133. onShareAppMessage: function () {
  134. return {
  135. title: app.globalData.ShareTitle,
  136. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  137. imageUrl: app.globalData.ShareImage,
  138. }
  139. },
  140. })