activate.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. init: function (e, isRemind) {
  16. var that = this;
  17. wx.showLoading({
  18. title: '装载中',
  19. });
  20. server.getData('GetUserActivateListByUserID500?UserID=' + app.globalData.userInfo.UserID + "&ProductID=" + app.globalData.ProgramID, function (data) {
  21. if (data && data.length > 0) {
  22. var programList = server.getProgramList();
  23. for (var i = 0; i < programList.length; i++) {
  24. for (var j = 0; j < data.length; j++) {
  25. if (programList[i].ID == data[j].ProductID) {
  26. data[j].Name = programList[i].Name;
  27. data[j].ImageUrl = programList[i].ImageUrl;
  28. data[j].appId = programList[i].appId;
  29. data[j].path = programList[i].path;
  30. }
  31. }
  32. }
  33. if (productList.length>0){
  34. for(var i=0;i<productList.length;i++){
  35. var b=false;
  36. for(var j=0;j<data.length;j++){
  37. if (productList[i].ProductID == data[j].ProductID){
  38. b=true;
  39. break;
  40. }
  41. }
  42. if (!b){
  43. productList[i].IsActivate=1;
  44. data.push(productList[i]);
  45. }
  46. }
  47. }
  48. that.setData({
  49. List: data,
  50. });
  51. productList=data;
  52. wx.hideLoading();
  53. if (isRemind) {
  54. wx.showModal({
  55. title: '产品未激活',
  56. content: '您有产品未激活,请立即点击红色“去激活”按钮。',
  57. showCancel: false,
  58. confirmText: "知道了",
  59. });
  60. }
  61. wx.setStorageSync("HasActivate", 1);
  62. }
  63. else {
  64. wx.redirectTo({
  65. url: "./activateFinish",
  66. });
  67. wx.removeStorageSync("HasActivate");
  68. }
  69. });
  70. },
  71. gotoFeedback: function () {
  72. server.gotoFeedback();
  73. },
  74. gotoActive: function (e) {
  75. var that = this;
  76. var productid = e.currentTarget.dataset.id;
  77. if (productid == app.globalData.ProgramID) {
  78. server.getData('UpdateWXUsersAll500?ProductID=' + productid
  79. + "&ProductUserID=" + app.globalData.userInfo.UserID
  80. + "&CurrentProductID=" + productid
  81. + "&CurrentUserID=" + app.globalData.userInfo.UserID, function (data) {
  82. if (data) {
  83. }
  84. });
  85. }
  86. else {
  87. var appId = e.currentTarget.dataset.appid;
  88. var path = e.currentTarget.dataset.path;
  89. path += "&ProductID=" + app.globalData.ProgramID;
  90. path += "&ProductUserID=" + app.globalData.userInfo.UserID;
  91. wx.navigateToMiniProgram({
  92. appId: appId,
  93. path: path,
  94. success(res) {
  95. }
  96. });
  97. }
  98. var data = this.data.List;
  99. for (var i = 0; i < data.length; i++) {
  100. if (data[i].ProductID == productid) {
  101. data[i].IsActivate = 0;
  102. }
  103. }
  104. that.setData({
  105. List: data,
  106. });
  107. },
  108. gotoFinish: function () {
  109. this.init(null, true);
  110. },
  111. onShareAppMessage: function () {
  112. return {
  113. title: app.globalData.ShareTitle,
  114. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  115. imageUrl: app.globalData.ShareImage,
  116. }
  117. },
  118. })