default.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. import constant from '../../utils/constant';
  4. const app = getApp();
  5. Page({
  6. data: {
  7. IsIPhoneX:app.globalData.IsIPhoneX,
  8. ImagePath: app.globalData.uploadImageUrl,
  9. ArticleList:[],
  10. District:constant.arrDistrict,
  11. Version:app.globalData.Version,
  12. YearIndex:0,
  13. HideAddProgram:1,
  14. },
  15. onLoad: function (options) {
  16. var that = this;
  17. that.setData({
  18. Containnerheight: main.getWindowHeight(),
  19. IsShow:app.globalData.userInfo.IsShow,
  20. Years:app.globalData.userInfo.ArrYear,
  21. });
  22. if (app.globalData.GotoUrl) {
  23. //console.log(app.globalData.GotoUrl);
  24. wx.navigateTo({
  25. url: app.globalData.GotoUrl,
  26. });
  27. app.globalData.GotoUrl = "";
  28. }
  29. else{
  30. //获得收藏学校数据
  31. main.getCollect();
  32. }
  33. that.getNotice(function(){
  34. that.getPersonNum(function(){
  35. that.getArticle(function(){
  36. that.getWish();
  37. });
  38. });
  39. });
  40. var hideAddProgram=wx.getStorageSync('HideAddProgram');
  41. if (!hideAddProgram){
  42. wx.checkIsAddedToMyMiniProgram({
  43. success:function(e){
  44. console.log(e.added);
  45. that.setData({
  46. HideAddProgram:e.added,
  47. });
  48. }
  49. })
  50. }
  51. var programList=main.getProgramList();
  52. that.setData({
  53. ProgramList:programList,
  54. });
  55. },
  56. onShow:function(){
  57. this.getWish();
  58. },
  59. onHideAddProgram:function(){
  60. wx.setStorageSync('HideAddProgram', 1);
  61. this.setData({
  62. HideAddProgram:1,
  63. });
  64. },
  65. showMore:function(e){
  66. var that = this;
  67. var id=e.currentTarget.dataset.id;
  68. if (id==1){
  69. that.setData({
  70. Page1:0,
  71. });
  72. }
  73. else if (id==2){
  74. that.setData({
  75. Page2:0,
  76. });
  77. }
  78. },
  79. getPersonNum:function(callback){
  80. var that = this;
  81. main.getData("GetMPSCityPersonNum", function (data) {
  82. if (data) {
  83. that.setData({
  84. PersonNum: data,
  85. });
  86. if (callback)
  87. callback();
  88. }
  89. });
  90. },
  91. getWish:function(callback){
  92. var that = this;
  93. main.getData("GetMPSWish?WishType=all", function (data) {
  94. if (data) {
  95. that.setData({
  96. WishList: data,
  97. Page1:1,
  98. Page2:1,
  99. });
  100. if (callback)
  101. callback();
  102. }
  103. });
  104. },
  105. getNotice:function(callback){
  106. var that = this;
  107. main.getData("GetMPSNotice", function (data) {
  108. if (data) {
  109. that.setData({
  110. Notice: data,
  111. });
  112. if (callback)
  113. callback();
  114. }
  115. });
  116. },
  117. getArticle:function(callback){
  118. var that = this;
  119. main.getData("GetMPSArticle", function (data) {
  120. if (data) {
  121. //debugger;
  122. that.setData({
  123. ArticleList: data,
  124. });
  125. app.globalData.ArticleList=data;
  126. if (callback)
  127. callback();
  128. }
  129. });
  130. },
  131. goto: function (e) {
  132. main.goto(e);
  133. },
  134. onShareTimeline: function () {
  135. return this.onShareAppMessage();
  136. },
  137. gotoMiniprogram:function(e){
  138. var appid=e.currentTarget.dataset.appid || "wx80059777521b897c";
  139. var path=e.currentTarget.dataset.path || "pages/index/index?SourceID="+app.globalData.ProgramID;
  140. main.gotoMiniprogram(appid,path);
  141. },
  142. onSelect:function(event){
  143. var that=this;
  144. main.onSelect(that,event,function(obj,e,result){
  145. if (e.currentTarget.dataset.object=="Years"){
  146. that.setData({
  147. YearIndex:e.currentTarget.dataset.index
  148. });
  149. }
  150. });
  151. },
  152. gotoRedirectTo: function (e) {
  153. let that=this;
  154. var url=e.currentTarget.dataset.url;
  155. wx.redirectTo({
  156. url: url,
  157. });
  158. },
  159. onShareAppMessage: function () {
  160. return {
  161. title: "上海中考招生信息查询工具",
  162. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  163. imageUrl: app.globalData.ShareImage,
  164. }
  165. },
  166. })